tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

CSSContainerRule.cpp (2976B)


      1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
      3 /* This Source Code Form is subject to the terms of the Mozilla Public
      4 * License, v. 2.0. If a copy of the MPL was not distributed with this
      5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      6 
      7 #include "mozilla/dom/CSSContainerRule.h"
      8 
      9 #include "mozilla/ServoBindings.h"
     10 #include "mozilla/css/GroupRule.h"
     11 #include "mozilla/dom/CSSContainerRuleBinding.h"
     12 
     13 using namespace mozilla::css;
     14 
     15 namespace mozilla::dom {
     16 
     17 CSSContainerRule::CSSContainerRule(RefPtr<StyleContainerRule> aRawRule,
     18                                   StyleSheet* aSheet, css::Rule* aParentRule,
     19                                   uint32_t aLine, uint32_t aColumn)
     20    : css::ConditionRule(aSheet, aParentRule, aLine, aColumn),
     21      mRawRule(std::move(aRawRule)) {}
     22 
     23 CSSContainerRule::~CSSContainerRule() = default;
     24 
     25 NS_IMPL_ADDREF_INHERITED(CSSContainerRule, ConditionRule)
     26 NS_IMPL_RELEASE_INHERITED(CSSContainerRule, ConditionRule)
     27 
     28 // QueryInterface implementation for ContainerRule
     29 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(CSSContainerRule)
     30 NS_INTERFACE_MAP_END_INHERITING(ConditionRule)
     31 
     32 #ifdef DEBUG
     33 /* virtual */
     34 void CSSContainerRule::List(FILE* out, int32_t aIndent) const {
     35  nsAutoCString str;
     36  for (int32_t i = 0; i < aIndent; i++) {
     37    str.AppendLiteral("  ");
     38  }
     39  Servo_ContainerRule_Debug(mRawRule, &str);
     40  fprintf_stderr(out, "%s\n", str.get());
     41 }
     42 #endif
     43 
     44 already_AddRefed<StyleLockedCssRules> CSSContainerRule::GetOrCreateRawRules() {
     45  return Servo_ContainerRule_GetRules(mRawRule).Consume();
     46 }
     47 
     48 StyleCssRuleType CSSContainerRule::Type() const {
     49  return StyleCssRuleType::Container;
     50 }
     51 
     52 void CSSContainerRule::GetConditionText(nsACString& aConditionText) {
     53  Servo_ContainerRule_GetConditionText(mRawRule, &aConditionText);
     54 }
     55 
     56 /* virtual */
     57 void CSSContainerRule::GetCssText(nsACString& aCssText) const {
     58  Servo_ContainerRule_GetCssText(mRawRule, &aCssText);
     59 }
     60 
     61 void CSSContainerRule::GetContainerName(nsACString& aName) const {
     62  Servo_ContainerRule_GetContainerName(mRawRule, &aName);
     63 }
     64 
     65 void CSSContainerRule::GetContainerQuery(nsACString& aQuery) const {
     66  Servo_ContainerRule_GetContainerQuery(mRawRule, &aQuery);
     67 }
     68 
     69 Element* CSSContainerRule::QueryContainerFor(const Element& aElement) const {
     70  return const_cast<Element*>(
     71      Servo_ContainerRule_QueryContainerFor(mRawRule, &aElement));
     72 }
     73 
     74 void CSSContainerRule::SetRawAfterClone(RefPtr<StyleContainerRule> aRaw) {
     75  mRawRule = std::move(aRaw);
     76  css::ConditionRule::DidSetRawAfterClone();
     77 }
     78 
     79 /* virtual */
     80 size_t CSSContainerRule::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const {
     81  // TODO Implement this!
     82  return aMallocSizeOf(this);
     83 }
     84 
     85 /* virtual */
     86 JSObject* CSSContainerRule::WrapObject(JSContext* aCx,
     87                                       JS::Handle<JSObject*> aGivenProto) {
     88  return CSSContainerRule_Binding::Wrap(aCx, this, aGivenProto);
     89 }
     90 
     91 }  // namespace mozilla::dom