CSSLayerStatementRule.cpp (2340B)
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/CSSLayerStatementRule.h" 8 9 #include "mozilla/ServoBindings.h" 10 #include "mozilla/dom/CSSLayerStatementRuleBinding.h" 11 12 namespace mozilla::dom { 13 14 CSSLayerStatementRule::CSSLayerStatementRule( 15 RefPtr<StyleLayerStatementRule> aRawRule, StyleSheet* aSheet, 16 css::Rule* aParentRule, uint32_t aLine, uint32_t aColumn) 17 : Rule(aSheet, aParentRule, aLine, aColumn), 18 mRawRule(std::move(aRawRule)) {} 19 20 NS_IMPL_ADDREF_INHERITED(CSSLayerStatementRule, Rule) 21 NS_IMPL_RELEASE_INHERITED(CSSLayerStatementRule, Rule) 22 23 // QueryInterface implementation for SupportsRule 24 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(CSSLayerStatementRule) 25 NS_INTERFACE_MAP_END_INHERITING(Rule) 26 27 #ifdef DEBUG 28 void CSSLayerStatementRule::List(FILE* out, int32_t aIndent) const { 29 nsAutoCString str; 30 for (int32_t i = 0; i < aIndent; i++) { 31 str.AppendLiteral(" "); 32 } 33 Servo_LayerStatementRule_Debug(mRawRule, &str); 34 fprintf_stderr(out, "%s\n", str.get()); 35 } 36 #endif 37 38 StyleCssRuleType CSSLayerStatementRule::Type() const { 39 return StyleCssRuleType::LayerStatement; 40 } 41 42 void CSSLayerStatementRule::SetRawAfterClone( 43 RefPtr<StyleLayerStatementRule> aRaw) { 44 mRawRule = std::move(aRaw); 45 } 46 47 void CSSLayerStatementRule::GetCssText(nsACString& aCssText) const { 48 Servo_LayerStatementRule_GetCssText(mRawRule.get(), &aCssText); 49 } 50 51 void CSSLayerStatementRule::GetNameList(nsTArray<nsCString>& aNames) const { 52 size_t size = Servo_LayerStatementRule_GetNameCount(mRawRule.get()); 53 for (size_t i = 0; i < size; ++i) { 54 Servo_LayerStatementRule_GetNameAt(mRawRule.get(), i, 55 aNames.AppendElement()); 56 } 57 } 58 59 size_t CSSLayerStatementRule::SizeOfIncludingThis( 60 MallocSizeOf aMallocSizeOf) const { 61 return aMallocSizeOf(this); 62 } 63 64 JSObject* CSSLayerStatementRule::WrapObject(JSContext* aCx, 65 JS::Handle<JSObject*> aGivenProto) { 66 return CSSLayerStatementRule_Binding::Wrap(aCx, this, aGivenProto); 67 } 68 69 } // namespace mozilla::dom