CSSScopeRule.cpp (2173B)
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/CSSScopeRule.h" 8 9 #include "mozilla/ServoBindings.h" 10 #include "mozilla/dom/CSSScopeRuleBinding.h" 11 12 namespace mozilla::dom { 13 14 CSSScopeRule::CSSScopeRule(RefPtr<StyleScopeRule> aRawRule, StyleSheet* aSheet, 15 css::Rule* aParentRule, uint32_t aLine, 16 uint32_t aColumn) 17 : css::GroupRule(aSheet, aParentRule, aLine, aColumn), 18 mRawRule(std::move(aRawRule)) {} 19 20 NS_IMPL_ISUPPORTS_CYCLE_COLLECTION_INHERITED_0(CSSScopeRule, css::GroupRule) 21 22 // QueryInterface implementation for SupportsRule 23 24 #ifdef DEBUG 25 void CSSScopeRule::List(FILE* out, int32_t aIndent) const { 26 nsAutoCString str; 27 for (int32_t i = 0; i < aIndent; i++) { 28 str.AppendLiteral(" "); 29 } 30 Servo_ScopeRule_Debug(mRawRule, &str); 31 fprintf_stderr(out, "%s\n", str.get()); 32 } 33 #endif 34 35 StyleCssRuleType CSSScopeRule::Type() const { return StyleCssRuleType::Scope; } 36 37 already_AddRefed<StyleLockedCssRules> CSSScopeRule::GetOrCreateRawRules() { 38 return Servo_ScopeRule_GetRules(mRawRule).Consume(); 39 } 40 41 void CSSScopeRule::SetRawAfterClone(RefPtr<StyleScopeRule> aRaw) { 42 mRawRule = std::move(aRaw); 43 css::GroupRule::DidSetRawAfterClone(); 44 } 45 46 void CSSScopeRule::GetCssText(nsACString& aCssText) const { 47 Servo_ScopeRule_GetCssText(mRawRule.get(), &aCssText); 48 } 49 50 void CSSScopeRule::GetStart(nsACString& aStart) const { 51 Servo_ScopeRule_GetStart(mRawRule.get(), &aStart); 52 } 53 54 void CSSScopeRule::GetEnd(nsACString& aEnd) const { 55 Servo_ScopeRule_GetEnd(mRawRule.get(), &aEnd); 56 } 57 58 size_t CSSScopeRule::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const { 59 return aMallocSizeOf(this); 60 } 61 62 JSObject* CSSScopeRule::WrapObject(JSContext* aCx, 63 JS::Handle<JSObject*> aGivenProto) { 64 return CSSScopeRule_Binding::Wrap(aCx, this, aGivenProto); 65 } 66 67 } // namespace mozilla::dom