Bug 1700051: part 48) Slightly simplify `mozInlineSpellWordUtil::FindRealWordContaini...
[gecko.git] / layout / style / CSSPageRule.h
blob59f1df667796fe4c072ab34aa18053990f73db17
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<RawServoDeclarationBlock> aDecls);
46 ~CSSPageRuleDeclaration();
48 inline CSSPageRule* Rule();
49 inline const CSSPageRule* Rule() const;
51 RefPtr<DeclarationBlock> mDecls;
54 class CSSPageRule final : public css::Rule {
55 public:
56 CSSPageRule(RefPtr<RawServoPageRule> aRawRule, StyleSheet* aSheet,
57 css::Rule* aParentRule, uint32_t aLine, uint32_t aColumn);
59 NS_DECL_ISUPPORTS_INHERITED
60 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(CSSPageRule, css::Rule)
62 bool IsCCLeaf() const final;
64 RawServoPageRule* Raw() const { return mRawRule; }
66 // WebIDL interfaces
67 uint16_t Type() const final { return CSSRule_Binding::PAGE_RULE; }
68 void GetCssText(nsACString& aCssText) const final;
69 nsICSSDeclaration* Style();
71 size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const final;
73 #ifdef DEBUG
74 void List(FILE* out = stdout, int32_t aIndent = 0) const final;
75 #endif
77 JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) final;
79 private:
80 ~CSSPageRule() = default;
82 // For computing the offset of mDecls.
83 friend class CSSPageRuleDeclaration;
85 RefPtr<RawServoPageRule> mRawRule;
86 CSSPageRuleDeclaration mDecls;
89 CSSPageRule* CSSPageRuleDeclaration::Rule() {
90 return reinterpret_cast<CSSPageRule*>(reinterpret_cast<uint8_t*>(this) -
91 offsetof(CSSPageRule, mDecls));
94 const CSSPageRule* CSSPageRuleDeclaration::Rule() const {
95 return reinterpret_cast<const CSSPageRule*>(
96 reinterpret_cast<const uint8_t*>(this) - offsetof(CSSPageRule, mDecls));
99 } // namespace dom
100 } // namespace mozilla
102 #endif // mozilla_dom_CSSPageRule_h