Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dist/include/mozilla/dom/CSSPageRule.h
Line
Count
Source (jump to first uncovered line)
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_CSSPageRule_h
8
#define mozilla_dom_CSSPageRule_h
9
10
#include "mozilla/css/Rule.h"
11
#include "mozilla/ServoBindingTypes.h"
12
13
#include "nsDOMCSSDeclaration.h"
14
#include "nsICSSDeclaration.h"
15
16
namespace mozilla {
17
class DeclarationBlock;
18
19
namespace dom {
20
class DocGroup;
21
class CSSPageRule;
22
23
class CSSPageRuleDeclaration final : public nsDOMCSSDeclaration
24
{
25
public:
26
  NS_DECL_ISUPPORTS_INHERITED
27
28
  css::Rule* GetParentRule() final;
29
  nsINode* GetParentObject() final;
30
31
protected:
32
  mozilla::DeclarationBlock* GetOrCreateCSSDeclaration(
33
    Operation aOperation, mozilla::DeclarationBlock** aCreated) final;
34
  nsresult SetCSSDeclaration(DeclarationBlock* aDecl,
35
                             MutationClosureData* aClosureData) final;
36
  nsIDocument* DocToUpdate() final;
37
  nsDOMCSSDeclaration::ParsingEnvironment
38
  GetParsingEnvironment(nsIPrincipal* aSubjectPrincipal) const final;
39
40
private:
41
  // For accessing the constructor.
42
  friend class CSSPageRule;
43
44
  explicit CSSPageRuleDeclaration(
45
    already_AddRefed<RawServoDeclarationBlock> aDecls);
46
  ~CSSPageRuleDeclaration();
47
48
  inline CSSPageRule* Rule();
49
  inline const CSSPageRule* Rule() const;
50
51
  RefPtr<DeclarationBlock> mDecls;
52
};
53
54
class CSSPageRule final : public css::Rule
55
{
56
public:
57
  CSSPageRule(RefPtr<RawServoPageRule> aRawRule,
58
              StyleSheet* aSheet,
59
              css::Rule* aParentRule,
60
              uint32_t aLine,
61
              uint32_t aColumn);
62
63
  NS_DECL_ISUPPORTS_INHERITED
64
  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(
65
    CSSPageRule, css::Rule
66
  )
67
68
  bool IsCCLeaf() const final;
69
70
0
  RawServoPageRule* Raw() const { return mRawRule; }
71
72
  // WebIDL interfaces
73
0
  uint16_t Type() const final { return CSSRule_Binding::PAGE_RULE; }
74
  void GetCssText(nsAString& aCssText) const final;
75
  nsICSSDeclaration* Style();
76
77
  size_t
78
  SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const final;
79
80
#ifdef DEBUG
81
  void List(FILE* out = stdout, int32_t aIndent = 0) const final;
82
#endif
83
84
  JSObject*
85
  WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) final;
86
87
private:
88
0
  ~CSSPageRule() = default;
89
90
  // For computing the offset of mDecls.
91
  friend class CSSPageRuleDeclaration;
92
93
  RefPtr<RawServoPageRule> mRawRule;
94
  CSSPageRuleDeclaration mDecls;
95
};
96
97
CSSPageRule*
98
CSSPageRuleDeclaration::Rule()
99
0
{
100
0
  return reinterpret_cast<CSSPageRule*>(
101
0
    reinterpret_cast<uint8_t*>(this) - offsetof(CSSPageRule, mDecls));
102
0
}
103
104
const CSSPageRule*
105
CSSPageRuleDeclaration::Rule() const
106
0
{
107
0
  return reinterpret_cast<const CSSPageRule*>(
108
0
    reinterpret_cast<const uint8_t*>(this) - offsetof(CSSPageRule, mDecls));
109
0
}
110
111
} // namespace dom
112
} // namespace mozilla
113
114
#endif // mozilla_dom_CSSPageRule_h