CSSNamespaceRule.h (1951B)
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 #ifndef mozilla_dom_CSSNamespaceRule_h 8 #define mozilla_dom_CSSNamespaceRule_h 9 10 #include "mozilla/ServoBindingTypes.h" 11 #include "mozilla/css/Rule.h" 12 #include "mozilla/dom/CSSNamespaceRuleBinding.h" 13 14 class nsAtom; 15 16 namespace mozilla::dom { 17 18 class CSSNamespaceRule final : public css::Rule { 19 public: 20 CSSNamespaceRule(already_AddRefed<StyleNamespaceRule> aRule, 21 StyleSheet* aSheet, css::Rule* aParentRule, uint32_t aLine, 22 uint32_t aColumn) 23 : css::Rule(aSheet, aParentRule, aLine, aColumn), 24 mRawRule(std::move(aRule)) {} 25 26 bool IsCCLeaf() const final { return Rule::IsCCLeaf(); } 27 28 #ifdef DEBUG 29 void List(FILE* out = stdout, int32_t aIndent = 0) const final; 30 #endif 31 32 nsAtom* GetPrefix() const; 33 void GetURLSpec(nsString& aURLSpec) const; 34 35 // WebIDL interface 36 void GetCssText(nsACString& aCssText) const final; 37 38 StyleCssRuleType Type() const final; 39 40 const StyleNamespaceRule* Raw() const { return mRawRule.get(); } 41 void SetRawAfterClone(RefPtr<StyleNamespaceRule>); 42 43 void GetNamespaceURI(nsString& aNamespaceURI) { GetURLSpec(aNamespaceURI); } 44 45 void GetPrefix(DOMString& aPrefix) { 46 aPrefix.SetKnownLiveAtom(GetPrefix(), DOMString::eTreatNullAsEmpty); 47 } 48 49 size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const final; 50 51 JSObject* WrapObject(JSContext* aCx, 52 JS::Handle<JSObject*> aGivenProto) final { 53 return CSSNamespaceRule_Binding::Wrap(aCx, this, aGivenProto); 54 } 55 56 private: 57 ~CSSNamespaceRule(); 58 RefPtr<StyleNamespaceRule> mRawRule; 59 }; 60 61 } // namespace mozilla::dom 62 63 #endif // mozilla_dom_CSSNamespaceRule_h