Bug 1839315: part 4) Link from `SheetLoadData::mWasAlternate` to spec. r=emilio DONTBUILD
[gecko.git] / layout / style / CSSPageRule.h
blob705d526bdf1c67462cd039594c9e9e728f76993c
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/. */
7 #ifndef mozilla_dom_CSSPageRule_h
8 #define mozilla_dom_CSSPageRule_h
10 #include "mozilla/css/Rule.h"
11 #include "mozilla/ServoBindingTypes.h"
13 #include "nsDOMCSSDeclaration.h"
14 #include "nsICSSDeclaration.h"
16 namespace mozilla {
17 class DeclarationBlock;
19 namespace dom {
20 class DocGroup;
21 class CSSPageRule;
23 class CSSPageRuleDeclaration final : public nsDOMCSSDeclaration {
24 public:
25 NS_DECL_ISUPPORTS_INHERITED
27 css::Rule* GetParentRule() final;
28 nsINode* GetAssociatedNode() const final;
29 nsISupports* GetParentObject() const final;
31 protected:
32 DeclarationBlock* GetOrCreateCSSDeclaration(
33 Operation aOperation, DeclarationBlock** aCreated) final;
34 nsresult SetCSSDeclaration(DeclarationBlock* aDecl,
35 MutationClosureData* aClosureData) final;
36 Document* DocToUpdate() final { return nullptr; }
37 nsDOMCSSDeclaration::ParsingEnvironment GetParsingEnvironment(
38 nsIPrincipal* aSubjectPrincipal) const final;
40 private:
41 // For accessing the constructor.
42 friend class CSSPageRule;
44 explicit CSSPageRuleDeclaration(
45 already_AddRefed<StyleLockedDeclarationBlock> aDecls);
46 void SetRawAfterClone(RefPtr<StyleLockedDeclarationBlock>);
48 ~CSSPageRuleDeclaration();
50 inline CSSPageRule* Rule();
51 inline const CSSPageRule* Rule() const;
53 RefPtr<DeclarationBlock> mDecls;
56 class CSSPageRule final : public css::Rule {
57 public:
58 CSSPageRule(RefPtr<StyleLockedPageRule> aRawRule, StyleSheet* aSheet,
59 css::Rule* aParentRule, uint32_t aLine, uint32_t aColumn);
61 NS_DECL_ISUPPORTS_INHERITED
62 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(CSSPageRule, css::Rule)
64 bool IsCCLeaf() const final;
66 StyleLockedPageRule* Raw() const { return mRawRule; }
67 void SetRawAfterClone(RefPtr<StyleLockedPageRule>);
69 // WebIDL interfaces
70 StyleCssRuleType Type() const final;
71 void GetCssText(nsACString& aCssText) const final;
72 nsICSSDeclaration* Style();
74 void GetSelectorText(nsACString& aSelectorText) const;
75 void SetSelectorText(const nsACString& aSelectorText);
77 size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const final;
79 #ifdef DEBUG
80 void List(FILE* out = stdout, int32_t aIndent = 0) const final;
81 #endif
83 JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) final;
85 private:
86 ~CSSPageRule() = default;
88 // For computing the offset of mDecls.
89 friend class CSSPageRuleDeclaration;
91 RefPtr<StyleLockedPageRule> mRawRule;
92 CSSPageRuleDeclaration mDecls;
95 CSSPageRule* CSSPageRuleDeclaration::Rule() {
96 return reinterpret_cast<CSSPageRule*>(reinterpret_cast<uint8_t*>(this) -
97 offsetof(CSSPageRule, mDecls));
100 const CSSPageRule* CSSPageRuleDeclaration::Rule() const {
101 return reinterpret_cast<const CSSPageRule*>(
102 reinterpret_cast<const uint8_t*>(this) - offsetof(CSSPageRule, mDecls));
105 } // namespace dom
106 } // namespace mozilla
108 #endif // mozilla_dom_CSSPageRule_h