Bug 1890793: Assert CallArgs::newTarget is not gray. r=spidermonkey-reviewers,sfink...
[gecko.git] / layout / style / CSSPageRule.h
blob904f94d2c076b7fd3321d0686c636b2298dbb177
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/GroupRule.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::GroupRule {
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,
63 css::GroupRule)
65 bool IsCCLeaf() const final;
67 StyleLockedPageRule* Raw() const { return mRawRule; }
68 void SetRawAfterClone(RefPtr<StyleLockedPageRule>);
70 // WebIDL interfaces
71 StyleCssRuleType Type() const final;
72 void GetCssText(nsACString& aCssText) const final;
73 nsICSSDeclaration* Style();
75 void GetSelectorText(nsACString& aSelectorText) const;
76 void SetSelectorText(const nsACString& aSelectorText);
78 size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const final;
80 already_AddRefed<StyleLockedCssRules> GetOrCreateRawRules() final;
82 #ifdef DEBUG
83 void List(FILE* out = stdout, int32_t aIndent = 0) const final;
84 #endif
86 JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) final;
88 private:
89 ~CSSPageRule() = default;
91 // For computing the offset of mDecls.
92 friend class CSSPageRuleDeclaration;
94 RefPtr<StyleLockedPageRule> mRawRule;
95 CSSPageRuleDeclaration mDecls;
98 CSSPageRule* CSSPageRuleDeclaration::Rule() {
99 return reinterpret_cast<CSSPageRule*>(reinterpret_cast<uint8_t*>(this) -
100 offsetof(CSSPageRule, mDecls));
103 const CSSPageRule* CSSPageRuleDeclaration::Rule() const {
104 return reinterpret_cast<const CSSPageRule*>(
105 reinterpret_cast<const uint8_t*>(this) - offsetof(CSSPageRule, mDecls));
108 } // namespace dom
109 } // namespace mozilla
111 #endif // mozilla_dom_CSSPageRule_h