Bug 1451289 - Part 7: Merge ServoPageRule and CSSPageRule r?emilio draft
authorNazım Can Altınova <canaltinova@gmail.com>
Tue, 05 Jun 2018 13:39:42 +0200
changeset 805175 bb49d63ab197da39f727b2e939679dfd30305f0f
parent 805174 060209c11577f6bebbe5fdc4ce24dd3a6e22b477
child 805176 33f9529131c9b9e292f00d1eb27dc75fc9853dc2
push id112583
push userbmo:canaltinova@gmail.com
push dateThu, 07 Jun 2018 11:56:39 +0000
reviewersemilio
bugs1451289
milestone62.0a1
Bug 1451289 - Part 7: Merge ServoPageRule and CSSPageRule r?emilio MozReview-Commit-ID: 5kqMLZWXFN5
layout/style/CSSPageRule.cpp
layout/style/CSSPageRule.h
layout/style/ServoCSSRuleList.cpp
layout/style/ServoPageRule.cpp
layout/style/ServoPageRule.h
layout/style/moz.build
layout/style/nsHTMLStyleSheet.cpp
--- a/layout/style/CSSPageRule.cpp
+++ b/layout/style/CSSPageRule.cpp
@@ -1,21 +1,189 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/dom/CSSPageRule.h"
+#include "mozilla/dom/CSSPageRuleBinding.h"
 
-#include "mozilla/dom/CSSPageRuleBinding.h"
+#include "mozilla/DeclarationBlock.h"
+#include "mozilla/ServoBindings.h"
 
 namespace mozilla {
 namespace dom {
 
+// -- CSSPageRuleDeclaration ---------------------------------------
+
+CSSPageRuleDeclaration::CSSPageRuleDeclaration(
+  already_AddRefed<RawServoDeclarationBlock> aDecls)
+  : mDecls(new DeclarationBlock(std::move(aDecls)))
+{
+}
+
+CSSPageRuleDeclaration::~CSSPageRuleDeclaration()
+{
+  mDecls->SetOwningRule(nullptr);
+}
+
+// QueryInterface implementation for CSSPageRuleDeclaration
+NS_INTERFACE_MAP_BEGIN(CSSPageRuleDeclaration)
+  NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
+  // We forward the cycle collection interfaces to Rule(), which is
+  // never null (in fact, we're part of that object!)
+  if (aIID.Equals(NS_GET_IID(nsCycleCollectionISupports)) ||
+      aIID.Equals(NS_GET_IID(nsXPCOMCycleCollectionParticipant))) {
+    return Rule()->QueryInterface(aIID, aInstancePtr);
+  }
+  else
+NS_IMPL_QUERY_TAIL_INHERITING(nsDOMCSSDeclaration)
+
+NS_IMPL_ADDREF_USING_AGGREGATOR(CSSPageRuleDeclaration, Rule())
+NS_IMPL_RELEASE_USING_AGGREGATOR(CSSPageRuleDeclaration, Rule())
+
+/* nsDOMCSSDeclaration implementation */
+
+css::Rule*
+CSSPageRuleDeclaration::GetParentRule()
+{
+  return Rule();
+}
+
+nsINode*
+CSSPageRuleDeclaration::GetParentObject()
+{
+  return Rule()->GetParentObject();
+}
+
+DeclarationBlock*
+CSSPageRuleDeclaration::GetCSSDeclaration(Operation aOperation)
+{
+  return mDecls;
+}
+
+nsresult
+CSSPageRuleDeclaration::SetCSSDeclaration(DeclarationBlock* aDecl)
+{
+  MOZ_ASSERT(aDecl, "must be non-null");
+  CSSPageRule* rule = Rule();
+
+  if (aDecl != mDecls) {
+    mDecls->SetOwningRule(nullptr);
+    RefPtr<DeclarationBlock> decls = aDecl;
+    Servo_PageRule_SetStyle(rule->Raw(), decls->Raw());
+    mDecls = decls.forget();
+    mDecls->SetOwningRule(rule);
+  }
+
+  return NS_OK;
+}
+
+nsIDocument*
+CSSPageRuleDeclaration::DocToUpdate()
+{
+  return nullptr;
+}
+
+nsDOMCSSDeclaration::ParsingEnvironment
+CSSPageRuleDeclaration::GetParsingEnvironment(
+  nsIPrincipal* aSubjectPrincipal) const
+{
+  return GetParsingEnvironmentForRule(Rule());
+}
+
+// -- CSSPageRule --------------------------------------------------
+
+CSSPageRule::CSSPageRule(RefPtr<RawServoPageRule> aRawRule,
+                         uint32_t aLine, uint32_t aColumn)
+  : Rule(aLine, aColumn)
+  , mRawRule(std::move(aRawRule))
+  , mDecls(Servo_PageRule_GetStyle(mRawRule).Consume())
+{
+}
+
+NS_IMPL_ADDREF_INHERITED(CSSPageRule, css::Rule)
+NS_IMPL_RELEASE_INHERITED(CSSPageRule, css::Rule)
+
+// QueryInterface implementation for PageRule
+NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(CSSPageRule)
+NS_INTERFACE_MAP_END_INHERITING(css::Rule)
+
+NS_IMPL_CYCLE_COLLECTION_CLASS(CSSPageRule)
+
+NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(CSSPageRule, css::Rule)
+  // Keep this in sync with IsCCLeaf.
+
+  // Trace the wrapper for our declaration.  This just expands out
+  // NS_IMPL_CYCLE_COLLECTION_TRACE_PRESERVED_WRAPPER which we can't use
+  // directly because the wrapper is on the declaration, not on us.
+  tmp->mDecls.TraceWrapper(aCallbacks, aClosure);
+NS_IMPL_CYCLE_COLLECTION_TRACE_END
+
+NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(CSSPageRule, css::Rule)
+  // Keep this in sync with IsCCLeaf.
+
+  // Unlink the wrapper for our declaraton.  This just expands out
+  // NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER which we can't use
+  // directly because the wrapper is on the declaration, not on us.
+  tmp->mDecls.ReleaseWrapper(static_cast<nsISupports*>(p));
+  tmp->mDecls.mDecls->SetOwningRule(nullptr);
+NS_IMPL_CYCLE_COLLECTION_UNLINK_END
+
+NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(CSSPageRule, css::Rule)
+  // Keep this in sync with IsCCLeaf.
+NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
+
+bool
+CSSPageRule::IsCCLeaf() const
+{
+  if (!Rule::IsCCLeaf()) {
+    return false;
+  }
+
+  return !mDecls.PreservingWrapper();
+}
+
+size_t
+CSSPageRule::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const
+{
+  // TODO Implement this!
+  return aMallocSizeOf(this);
+}
+
+#ifdef DEBUG
+void
+CSSPageRule::List(FILE* out, int32_t aIndent) const
+{
+  nsAutoCString str;
+  for (int32_t i = 0; i < aIndent; i++) {
+    str.AppendLiteral("  ");
+  }
+  Servo_PageRule_Debug(mRawRule, &str);
+  fprintf_stderr(out, "%s\n", str.get());
+}
+#endif
+
+/* CSSRule implementation */
+
+void
+CSSPageRule::GetCssText(nsAString& aCssText) const
+{
+  Servo_PageRule_GetCssText(mRawRule, &aCssText);
+}
+
+/* CSSPageRule implementation */
+
+nsICSSDeclaration*
+CSSPageRule::Style()
+{
+  return &mDecls;
+}
+
 JSObject*
 CSSPageRule::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
 {
   return CSSPageRuleBinding::Wrap(aCx, this, aGivenProto);
 }
 
 } // namespace dom
 } // namespace mozilla
--- a/layout/style/CSSPageRule.h
+++ b/layout/style/CSSPageRule.h
@@ -3,39 +3,107 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_dom_CSSPageRule_h
 #define mozilla_dom_CSSPageRule_h
 
 #include "mozilla/css/Rule.h"
+#include "mozilla/ServoBindingTypes.h"
 
+#include "nsDOMCSSDeclaration.h"
 #include "nsICSSDeclaration.h"
 
 namespace mozilla {
+class DeclarationBlock;
+
 namespace dom {
+class DocGroup;
+class CSSPageRule;
 
-class CSSPageRule : public css::Rule
+class CSSPageRuleDeclaration final : public nsDOMCSSDeclaration
 {
+public:
+  NS_DECL_ISUPPORTS_INHERITED
+
+  css::Rule* GetParentRule() final;
+  nsINode* GetParentObject() final;
+
 protected:
-  using Rule::Rule;
-  virtual ~CSSPageRule() {};
+  DeclarationBlock* GetCSSDeclaration(Operation aOperation) final;
+  nsresult SetCSSDeclaration(DeclarationBlock* aDecl) final;
+  nsIDocument* DocToUpdate() final;
+  nsDOMCSSDeclaration::ParsingEnvironment
+  GetParsingEnvironment(nsIPrincipal* aSubjectPrincipal) const final;
+
+private:
+  // For accessing the constructor.
+  friend class CSSPageRule;
+
+  explicit CSSPageRuleDeclaration(
+    already_AddRefed<RawServoDeclarationBlock> aDecls);
+  ~CSSPageRuleDeclaration();
+
+  inline CSSPageRule* Rule();
+  inline const CSSPageRule* Rule() const;
 
+  RefPtr<DeclarationBlock> mDecls;
+};
+
+class CSSPageRule final : public css::Rule
+{
 public:
-  virtual bool IsCCLeaf() const override = 0;
+  CSSPageRule(RefPtr<RawServoPageRule> aRawRule,
+                uint32_t aLine, uint32_t aColumn);
+
+  NS_DECL_ISUPPORTS_INHERITED
+  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(
+    CSSPageRule, css::Rule
+  )
+
+  bool IsCCLeaf() const final;
+
+  RawServoPageRule* Raw() const { return mRawRule; }
 
   // WebIDL interfaces
   uint16_t Type() const final { return CSSRuleBinding::PAGE_RULE; }
-  virtual void GetCssText(nsAString& aCssText) const override = 0;
-  virtual nsICSSDeclaration* Style() = 0;
+  void GetCssText(nsAString& aCssText) const final;
+  nsICSSDeclaration* Style();
 
-  virtual size_t
-  SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const override = 0;
+  size_t
+  SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const final;
+
+#ifdef DEBUG
+  void List(FILE* out = stdout, int32_t aIndent = 0) const final;
+#endif
 
   JSObject*
-  WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
+  WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) final;
+
+private:
+  ~CSSPageRule() = default;
+
+  // For computing the offset of mDecls.
+  friend class CSSPageRuleDeclaration;
+
+  RefPtr<RawServoPageRule> mRawRule;
+  CSSPageRuleDeclaration mDecls;
 };
 
+CSSPageRule*
+CSSPageRuleDeclaration::Rule()
+{
+  return reinterpret_cast<CSSPageRule*>(
+    reinterpret_cast<uint8_t*>(this) - offsetof(CSSPageRule, mDecls));
+}
+
+const CSSPageRule*
+CSSPageRuleDeclaration::Rule() const
+{
+  return reinterpret_cast<const CSSPageRule*>(
+    reinterpret_cast<const uint8_t*>(this) - offsetof(CSSPageRule, mDecls));
+}
+
 } // namespace dom
 } // namespace mozilla
 
 #endif // mozilla_dom_CSSPageRule_h
--- a/layout/style/ServoCSSRuleList.cpp
+++ b/layout/style/ServoCSSRuleList.cpp
@@ -8,23 +8,23 @@
 
 #include "mozilla/ServoCSSRuleList.h"
 
 #include "mozilla/dom/CSSCounterStyleRule.h"
 #include "mozilla/dom/CSSFontFaceRule.h"
 #include "mozilla/dom/CSSKeyframesRule.h"
 #include "mozilla/dom/CSSMediaRule.h"
 #include "mozilla/dom/CSSNamespaceRule.h"
+#include "mozilla/dom/CSSPageRule.h"
 #include "mozilla/dom/CSSStyleRule.h"
 #include "mozilla/IntegerRange.h"
 #include "mozilla/ServoBindings.h"
 #include "mozilla/ServoDocumentRule.h"
 #include "mozilla/ServoImportRule.h"
 #include "mozilla/ServoFontFeatureValuesRule.h"
-#include "mozilla/ServoPageRule.h"
 #include "mozilla/ServoSupportsRule.h"
 #include "mozilla/StyleSheet.h"
 
 using namespace mozilla::dom;
 
 namespace mozilla {
 
 ServoCSSRuleList::ServoCSSRuleList(already_AddRefed<ServoCssRules> aRawRules,
@@ -103,17 +103,17 @@ ServoCSSRuleList::GetRule(uint32_t aInde
         MOZ_ASSERT(rule);                                                   \
         ruleObj = new CSS##name_##Rule(rule.forget(), line, column);        \
         break;                                                              \
       }
       CASE_RULE_CSS(STYLE, Style)
       CASE_RULE_CSS(KEYFRAMES, Keyframes)
       CASE_RULE_CSS(MEDIA, Media)
       CASE_RULE_CSS(NAMESPACE, Namespace)
-      CASE_RULE(PAGE, Page)
+      CASE_RULE_CSS(PAGE, Page)
       CASE_RULE(SUPPORTS, Supports)
       CASE_RULE(DOCUMENT, Document)
       CASE_RULE(IMPORT, Import)
       CASE_RULE(FONT_FEATURE_VALUES, FontFeatureValues)
       CASE_RULE_CSS(FONT_FACE, FontFace)
       CASE_RULE_CSS(COUNTER_STYLE, CounterStyle)
 #undef CASE_RULE
       case CSSRuleBinding::KEYFRAME_RULE:
deleted file mode 100644
--- a/layout/style/ServoPageRule.cpp
+++ /dev/null
@@ -1,188 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/* representation of CSSPageRule for stylo */
-
-#include "mozilla/ServoPageRule.h"
-
-#include "mozilla/DeclarationBlock.h"
-#include "mozilla/ServoBindings.h"
-
-using namespace mozilla::dom;
-
-namespace mozilla {
-
-// -- ServoPageRuleDeclaration ---------------------------------------
-
-ServoPageRuleDeclaration::ServoPageRuleDeclaration(
-  already_AddRefed<RawServoDeclarationBlock> aDecls)
-  : mDecls(new DeclarationBlock(std::move(aDecls)))
-{
-}
-
-ServoPageRuleDeclaration::~ServoPageRuleDeclaration()
-{
-  mDecls->SetOwningRule(nullptr);
-}
-
-// QueryInterface implementation for ServoPageRuleDeclaration
-NS_INTERFACE_MAP_BEGIN(ServoPageRuleDeclaration)
-  NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
-  // We forward the cycle collection interfaces to Rule(), which is
-  // never null (in fact, we're part of that object!)
-  if (aIID.Equals(NS_GET_IID(nsCycleCollectionISupports)) ||
-      aIID.Equals(NS_GET_IID(nsXPCOMCycleCollectionParticipant))) {
-    return Rule()->QueryInterface(aIID, aInstancePtr);
-  }
-  else
-NS_IMPL_QUERY_TAIL_INHERITING(nsDOMCSSDeclaration)
-
-NS_IMPL_ADDREF_USING_AGGREGATOR(ServoPageRuleDeclaration, Rule())
-NS_IMPL_RELEASE_USING_AGGREGATOR(ServoPageRuleDeclaration, Rule())
-
-/* nsDOMCSSDeclaration implementation */
-
-css::Rule*
-ServoPageRuleDeclaration::GetParentRule()
-{
-  return Rule();
-}
-
-nsINode*
-ServoPageRuleDeclaration::GetParentObject()
-{
-  return Rule()->GetParentObject();
-}
-
-DeclarationBlock*
-ServoPageRuleDeclaration::GetCSSDeclaration(Operation aOperation)
-{
-  return mDecls;
-}
-
-nsresult
-ServoPageRuleDeclaration::SetCSSDeclaration(DeclarationBlock* aDecl)
-{
-  MOZ_ASSERT(aDecl, "must be non-null");
-  ServoPageRule* rule = Rule();
-
-  if (aDecl != mDecls) {
-    mDecls->SetOwningRule(nullptr);
-    RefPtr<DeclarationBlock> decls = aDecl;
-    Servo_PageRule_SetStyle(rule->Raw(), decls->Raw());
-    mDecls = decls.forget();
-    mDecls->SetOwningRule(rule);
-  }
-
-  return NS_OK;
-}
-
-nsIDocument*
-ServoPageRuleDeclaration::DocToUpdate()
-{
-  return nullptr;
-}
-
-nsDOMCSSDeclaration::ParsingEnvironment
-ServoPageRuleDeclaration::GetParsingEnvironment(
-  nsIPrincipal* aSubjectPrincipal) const
-{
-  return GetParsingEnvironmentForRule(Rule());
-}
-
-// -- ServoPageRule --------------------------------------------------
-
-ServoPageRule::ServoPageRule(RefPtr<RawServoPageRule> aRawRule,
-                             uint32_t aLine, uint32_t aColumn)
-  : CSSPageRule(aLine, aColumn)
-  , mRawRule(std::move(aRawRule))
-  , mDecls(Servo_PageRule_GetStyle(mRawRule).Consume())
-{
-}
-
-ServoPageRule::~ServoPageRule()
-{
-}
-
-NS_IMPL_ADDREF_INHERITED(ServoPageRule, CSSPageRule)
-NS_IMPL_RELEASE_INHERITED(ServoPageRule, CSSPageRule)
-
-// QueryInterface implementation for PageRule
-NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(ServoPageRule)
-NS_INTERFACE_MAP_END_INHERITING(CSSPageRule)
-
-NS_IMPL_CYCLE_COLLECTION_CLASS(ServoPageRule)
-
-NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(ServoPageRule, CSSPageRule)
-  // Keep this in sync with IsCCLeaf.
-
-  // Trace the wrapper for our declaration.  This just expands out
-  // NS_IMPL_CYCLE_COLLECTION_TRACE_PRESERVED_WRAPPER which we can't use
-  // directly because the wrapper is on the declaration, not on us.
-  tmp->mDecls.TraceWrapper(aCallbacks, aClosure);
-NS_IMPL_CYCLE_COLLECTION_TRACE_END
-
-NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(ServoPageRule, CSSPageRule)
-  // Keep this in sync with IsCCLeaf.
-
-  // Unlink the wrapper for our declaraton.  This just expands out
-  // NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER which we can't use
-  // directly because the wrapper is on the declaration, not on us.
-  tmp->mDecls.ReleaseWrapper(static_cast<nsISupports*>(p));
-  tmp->mDecls.mDecls->SetOwningRule(nullptr);
-NS_IMPL_CYCLE_COLLECTION_UNLINK_END
-
-NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(ServoPageRule, CSSPageRule)
-  // Keep this in sync with IsCCLeaf.
-NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
-
-bool
-ServoPageRule::IsCCLeaf() const
-{
-  if (!Rule::IsCCLeaf()) {
-    return false;
-  }
-
-  return !mDecls.PreservingWrapper();
-}
-
-size_t
-ServoPageRule::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const
-{
-  // TODO Implement this!
-  return aMallocSizeOf(this);
-}
-
-#ifdef DEBUG
-void
-ServoPageRule::List(FILE* out, int32_t aIndent) const
-{
-  nsAutoCString str;
-  for (int32_t i = 0; i < aIndent; i++) {
-    str.AppendLiteral("  ");
-  }
-  Servo_PageRule_Debug(mRawRule, &str);
-  fprintf_stderr(out, "%s\n", str.get());
-}
-#endif
-
-/* CSSRule implementation */
-
-void
-ServoPageRule::GetCssText(nsAString& aCssText) const
-{
-  Servo_PageRule_GetCssText(mRawRule, &aCssText);
-}
-
-/* CSSPageRule implementation */
-
-nsICSSDeclaration*
-ServoPageRule::Style()
-{
-  return &mDecls;
-}
-
-} // namespace mozilla
deleted file mode 100644
--- a/layout/style/ServoPageRule.h
+++ /dev/null
@@ -1,107 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/* representation of CSSPageRule for stylo */
-
-#ifndef mozilla_ServoPageRule_h
-#define mozilla_ServoPageRule_h
-
-#include "mozilla/dom/CSSPageRule.h"
-#include "mozilla/ServoBindingTypes.h"
-
-#include "nsDOMCSSDeclaration.h"
-
-namespace mozilla {
-
-namespace dom {
-class DocGroup;
-} // namespace dom
-
-class DeclarationBlock;
-class ServoPageRule;
-
-class ServoPageRuleDeclaration final : public nsDOMCSSDeclaration
-{
-public:
-  NS_DECL_ISUPPORTS_INHERITED
-
-  css::Rule* GetParentRule() final;
-  nsINode* GetParentObject() final;
-
-protected:
-  DeclarationBlock* GetCSSDeclaration(Operation aOperation) final;
-  nsresult SetCSSDeclaration(DeclarationBlock* aDecl) final;
-  nsIDocument* DocToUpdate() final;
-  nsDOMCSSDeclaration::ParsingEnvironment
-  GetParsingEnvironment(nsIPrincipal* aSubjectPrincipal) const final;
-
-private:
-  // For accessing the constructor.
-  friend class ServoPageRule;
-
-  explicit ServoPageRuleDeclaration(
-    already_AddRefed<RawServoDeclarationBlock> aDecls);
-  ~ServoPageRuleDeclaration();
-
-  inline ServoPageRule* Rule();
-  inline const ServoPageRule* Rule() const;
-
-  RefPtr<DeclarationBlock> mDecls;
-};
-
-class ServoPageRule final : public dom::CSSPageRule
-{
-public:
-  ServoPageRule(RefPtr<RawServoPageRule> aRawRule,
-                uint32_t aLine, uint32_t aColumn);
-
-  NS_DECL_ISUPPORTS_INHERITED
-  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(
-    ServoPageRule, dom::CSSPageRule
-  )
-  bool IsCCLeaf() const final;
-
-  RawServoPageRule* Raw() const { return mRawRule; }
-
-  // WebIDL interface
-  void GetCssText(nsAString& aCssText) const final;
-  nsICSSDeclaration* Style() final;
-
-  // Methods of mozilla::css::Rule
-  size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf)
-    const final;
-
-#ifdef DEBUG
-  void List(FILE* out = stdout, int32_t aIndent = 0) const final;
-#endif
-
-private:
-  virtual ~ServoPageRule();
-
-  // For computing the offset of mDecls.
-  friend class ServoPageRuleDeclaration;
-
-  RefPtr<RawServoPageRule> mRawRule;
-  ServoPageRuleDeclaration mDecls;
-};
-
-ServoPageRule*
-ServoPageRuleDeclaration::Rule()
-{
-  return reinterpret_cast<ServoPageRule*>(
-    reinterpret_cast<uint8_t*>(this) - offsetof(ServoPageRule, mDecls));
-}
-
-const ServoPageRule*
-ServoPageRuleDeclaration::Rule() const
-{
-  return reinterpret_cast<const ServoPageRule*>(
-    reinterpret_cast<const uint8_t*>(this) - offsetof(ServoPageRule, mDecls));
-}
-
-} // namespace mozilla
-
-#endif // mozilla_ServoPageRule_h
--- a/layout/style/moz.build
+++ b/layout/style/moz.build
@@ -84,17 +84,16 @@ EXPORTS.mozilla += [
     'ServoComputedDataInlines.h',
     'ServoCSSParser.h',
     'ServoCSSRuleList.h',
     'ServoDocumentRule.h',
     'ServoElementSnapshot.h',
     'ServoElementSnapshotTable.h',
     'ServoFontFeatureValuesRule.h',
     'ServoImportRule.h',
-    'ServoPageRule.h',
     'ServoSpecifiedValues.h',
     'ServoStyleSet.h',
     'ServoStyleSetInlines.h',
     'ServoSupportsRule.h',
     'ServoTraversalStatistics.h',
     'ServoTypes.h',
     'ServoUtils.h',
     'SheetType.h',
@@ -203,17 +202,16 @@ UNIFIED_SOURCES += [
     'Rule.cpp',
     'ServoBindings.cpp',
     'ServoCSSParser.cpp',
     'ServoCSSRuleList.cpp',
     'ServoDocumentRule.cpp',
     'ServoElementSnapshot.cpp',
     'ServoFontFeatureValuesRule.cpp',
     'ServoImportRule.cpp',
-    'ServoPageRule.cpp',
     'ServoSpecifiedValues.cpp',
     'ServoStyleSet.cpp',
     'ServoSupportsRule.cpp',
     'StreamLoader.cpp',
     'StyleAnimationValue.cpp',
     'StyleComplexColor.cpp',
     'StyleSheet.cpp',
     'URLExtraData.cpp',
--- a/layout/style/nsHTMLStyleSheet.cpp
+++ b/layout/style/nsHTMLStyleSheet.cpp
@@ -18,16 +18,17 @@
 #include "nsIPresShell.h"
 #include "nsStyleConsts.h"
 #include "nsError.h"
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/dom/Element.h"
 #include "nsHashKeys.h"
 #include "mozilla/OperatorNewExtensions.h"
 #include "mozilla/RestyleManager.h"
+#include "mozilla/ServoBindings.h"
 #include "mozilla/ServoStyleSet.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
 
 
 // -----------------------------------------------------------