Bug 1451289 - Part 1: Merge ServoNamespaceRule and css::CSSNamespaceRule r=emilio
authorNazım Can Altınova <canaltinova@gmail.com>
Fri, 01 Jun 2018 12:35:39 +0200
changeset 422449 6299a6e593f80fcb93f66c3dcd399b4cd4149229
parent 422448 2bfcf8b5ae77bb0948b904154547910ad05da12f
child 422450 369dae118647f4c5f61b08e611a224a42f71f2e3
push id34135
push userncsoregi@mozilla.com
push dateThu, 14 Jun 2018 09:43:50 +0000
treeherdermozilla-central@1b80f6d8ea65 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemilio
bugs1451289
milestone62.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1451289 - Part 1: Merge ServoNamespaceRule and css::CSSNamespaceRule r=emilio MozReview-Commit-ID: D5kU7f0hluL
layout/style/CSSNamespaceRule.cpp
layout/style/CSSNamespaceRule.h
layout/style/ServoBindingList.h
layout/style/ServoCSSRuleList.cpp
layout/style/ServoNamespaceRule.cpp
layout/style/ServoNamespaceRule.h
layout/style/moz.build
rename from layout/style/ServoNamespaceRule.cpp
rename to layout/style/CSSNamespaceRule.cpp
--- a/layout/style/ServoNamespaceRule.cpp
+++ b/layout/style/CSSNamespaceRule.cpp
@@ -1,57 +1,57 @@
 /* -*- 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/ServoNamespaceRule.h"
+#include "mozilla/dom/CSSNamespaceRule.h"
 
 #include "mozilla/ServoBindings.h"
 
 using namespace mozilla::dom;
 
 namespace mozilla {
 
-ServoNamespaceRule::~ServoNamespaceRule()
+CSSNamespaceRule::~CSSNamespaceRule()
 {
 }
 
 #ifdef DEBUG
 void
-ServoNamespaceRule::List(FILE* out, int32_t aIndent) const
+CSSNamespaceRule::List(FILE* out, int32_t aIndent) const
 {
   nsAutoCString str;
   for (int32_t i = 0; i < aIndent; i++) {
     str.AppendLiteral("  ");
   }
   Servo_NamespaceRule_Debug(mRawRule, &str);
   fprintf_stderr(out, "%s\n", str.get());
 }
 #endif
 
 nsAtom*
-ServoNamespaceRule::GetPrefix() const
+CSSNamespaceRule::GetPrefix() const
 {
   return Servo_NamespaceRule_GetPrefix(mRawRule);
 }
 
 void
-ServoNamespaceRule::GetURLSpec(nsString& aURLSpec) const
+CSSNamespaceRule::GetURLSpec(nsString& aURLSpec) const
 {
   nsAtom* atom = Servo_NamespaceRule_GetURI(mRawRule);
   atom->ToString(aURLSpec);
 }
 
 void
-ServoNamespaceRule::GetCssText(nsAString& aCssText) const
+CSSNamespaceRule::GetCssText(nsAString& aCssText) const
 {
   Servo_NamespaceRule_GetCssText(mRawRule, &aCssText);
 }
 
 size_t
-ServoNamespaceRule::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const
+CSSNamespaceRule::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const
 {
   return aMallocSizeOf(this);
 }
 
 } // namespace mozilla
--- a/layout/style/CSSNamespaceRule.h
+++ b/layout/style/CSSNamespaceRule.h
@@ -4,48 +4,66 @@
  * 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_CSSNamespaceRule_h
 #define mozilla_dom_CSSNamespaceRule_h
 
 #include "mozilla/css/Rule.h"
 #include "mozilla/dom/CSSNamespaceRuleBinding.h"
+#include "mozilla/ServoBindingTypes.h"
 
 class nsAtom;
 
 namespace mozilla {
 namespace dom {
 
-class CSSNamespaceRule : public css::Rule
+class CSSNamespaceRule final : public css::Rule
 {
-protected:
-  using Rule::Rule;
+public:
+  CSSNamespaceRule(already_AddRefed<RawServoNamespaceRule> aRule,
+                   uint32_t aLine, uint32_t aColumn)
+    : css::Rule(aLine, aColumn)
+    , mRawRule(std::move(aRule))
+  {
+  }
 
-public:
   bool IsCCLeaf() const final {
     return Rule::IsCCLeaf();
   }
 
-  virtual nsAtom* GetPrefix() const = 0;
-  virtual void GetURLSpec(nsString& aURLSpec) const = 0;
+#ifdef DEBUG
+  void List(FILE* out = stdout, int32_t aIndent = 0) const final;
+#endif
+
+  nsAtom* GetPrefix() const;
+  void GetURLSpec(nsString& aURLSpec) const;
+
+  // WebIDL interface
+  void GetCssText(nsAString& aCssText) const final;
 
   // WebIDL interfaces
   uint16_t Type() const final { return CSSRuleBinding::NAMESPACE_RULE; }
+
   void GetNamespaceURI(nsString& aNamespaceURI) {
     GetURLSpec(aNamespaceURI);
   }
+
   void GetPrefix(DOMString& aPrefix) {
     aPrefix.SetKnownLiveAtom(GetPrefix(), DOMString::eTreatNullAsEmpty);
   }
 
-  size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const override = 0;
+  size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const final;
 
   JSObject* WrapObject(JSContext* aCx,
                        JS::Handle<JSObject*> aGivenProto) final {
     return CSSNamespaceRuleBinding::Wrap(aCx, this, aGivenProto);
   }
+
+private:
+  ~CSSNamespaceRule();
+  RefPtr<RawServoNamespaceRule> mRawRule;
 };
 
 } // namespace dom
 } // namespace mozilla
 
 #endif // mozilla_dom_CSSNamespaceRule_h
--- a/layout/style/ServoBindingList.h
+++ b/layout/style/ServoBindingList.h
@@ -259,16 +259,17 @@ SERVO_BINDING_FUNC(Servo_CssRules_Delete
                      RawServo##type_##RuleStrong, \
                      ServoCssRulesBorrowed rules, uint32_t index, \
                      uint32_t* line, uint32_t* column) \
   BASIC_RULE_FUNCS_WITHOUT_GETTER(type_##Rule)
 #define GROUP_RULE_FUNCS(type_) \
   BASIC_RULE_FUNCS(type_) \
   SERVO_BINDING_FUNC(Servo_##type_##Rule_GetRules, ServoCssRulesStrong, \
                      RawServo##type_##RuleBorrowed rule)
+
 BASIC_RULE_FUNCS(Style)
 BASIC_RULE_FUNCS(Import)
 BASIC_RULE_FUNCS_WITHOUT_GETTER(Keyframe)
 BASIC_RULE_FUNCS(Keyframes)
 GROUP_RULE_FUNCS(Media)
 BASIC_RULE_FUNCS(Namespace)
 BASIC_RULE_FUNCS(Page)
 GROUP_RULE_FUNCS(Supports)
--- a/layout/style/ServoCSSRuleList.cpp
+++ b/layout/style/ServoCSSRuleList.cpp
@@ -3,26 +3,26 @@
 /* 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 CSSRuleList for stylo */
 
 #include "mozilla/ServoCSSRuleList.h"
 
+#include "mozilla/dom/CSSNamespaceRule.h"
 #include "mozilla/IntegerRange.h"
 #include "mozilla/ServoBindings.h"
 #include "mozilla/ServoCounterStyleRule.h"
 #include "mozilla/ServoDocumentRule.h"
 #include "mozilla/ServoImportRule.h"
 #include "mozilla/ServoFontFaceRule.h"
 #include "mozilla/ServoFontFeatureValuesRule.h"
 #include "mozilla/ServoKeyframesRule.h"
 #include "mozilla/ServoMediaRule.h"
-#include "mozilla/ServoNamespaceRule.h"
 #include "mozilla/ServoPageRule.h"
 #include "mozilla/ServoStyleRule.h"
 #include "mozilla/ServoSupportsRule.h"
 #include "mozilla/StyleSheet.h"
 
 using namespace mozilla::dom;
 
 namespace mozilla {
@@ -88,20 +88,31 @@ ServoCSSRuleList::GetRule(uint32_t aInde
         RefPtr<RawServo##name_##Rule> rule =                                \
           Servo_CssRules_Get##name_##RuleAt(                                \
               mRawRules, aIndex, &line, &column                             \
           ).Consume();                                                      \
         MOZ_ASSERT(rule);                                                   \
         ruleObj = new Servo##name_##Rule(rule.forget(), line, column);      \
         break;                                                              \
       }
+#define CASE_RULE_CSS(const_, name_)                                        \
+      case CSSRuleBinding::const_##_RULE: {                                 \
+        uint32_t line = 0, column = 0;                                      \
+        RefPtr<RawServo##name_##Rule> rule =                                \
+          Servo_CssRules_Get##name_##RuleAt(                                \
+              mRawRules, aIndex, &line, &column                             \
+          ).Consume();                                                      \
+        MOZ_ASSERT(rule);                                                   \
+        ruleObj = new CSS##name_##Rule(rule.forget(), line, column);        \
+        break;                                                              \
+      }
       CASE_RULE(STYLE, Style)
       CASE_RULE(KEYFRAMES, Keyframes)
       CASE_RULE(MEDIA, Media)
-      CASE_RULE(NAMESPACE, Namespace)
+      CASE_RULE_CSS(NAMESPACE, Namespace)
       CASE_RULE(PAGE, Page)
       CASE_RULE(SUPPORTS, Supports)
       CASE_RULE(DOCUMENT, Document)
       CASE_RULE(IMPORT, Import)
       CASE_RULE(FONT_FEATURE_VALUES, FontFeatureValues)
       CASE_RULE(FONT_FACE, FontFace)
       CASE_RULE(COUNTER_STYLE, CounterStyle)
 #undef CASE_RULE
deleted file mode 100644
--- a/layout/style/ServoNamespaceRule.h
+++ /dev/null
@@ -1,48 +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/. */
-
-#ifndef mozilla_ServoNamespaceRule_h
-#define mozilla_ServoNamespaceRule_h
-
-#include "mozilla/ServoBindingTypes.h"
-#include "mozilla/dom/CSSNamespaceRule.h"
-
-namespace mozilla {
-
-class ServoNamespaceRule : public dom::CSSNamespaceRule
-{
-public:
-  ServoNamespaceRule(already_AddRefed<RawServoNamespaceRule> aRule,
-                     uint32_t aLine, uint32_t aColumn)
-    : CSSNamespaceRule(aLine, aColumn)
-    , mRawRule(std::move(aRule))
-  {
-  }
-
-  NS_INLINE_DECL_REFCOUNTING_INHERITED(ServoNamespaceRule,
-                                       dom::CSSNamespaceRule)
-
-#ifdef DEBUG
-  void List(FILE* out = stdout, int32_t aIndent = 0) const final;
-#endif
-
-  nsAtom* GetPrefix() const final;
-  void GetURLSpec(nsString& aURLSpec) const final;
-
-  // WebIDL interface
-  void GetCssText(nsAString& aCssText) const final;
-
-  size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const final;
-
-private:
-  ~ServoNamespaceRule();
-
-  RefPtr<RawServoNamespaceRule> mRawRule;
-};
-
-} // namespace mozilla
-
-#endif // mozilla_ServoNamespaceRule_h
--- a/layout/style/moz.build
+++ b/layout/style/moz.build
@@ -89,17 +89,16 @@ EXPORTS.mozilla += [
     'ServoElementSnapshot.h',
     'ServoElementSnapshotTable.h',
     'ServoFontFaceRule.h',
     'ServoFontFeatureValuesRule.h',
     'ServoImportRule.h',
     'ServoKeyframeRule.h',
     'ServoKeyframesRule.h',
     'ServoMediaRule.h',
-    'ServoNamespaceRule.h',
     'ServoPageRule.h',
     'ServoSpecifiedValues.h',
     'ServoStyleRule.h',
     'ServoStyleSet.h',
     'ServoStyleSetInlines.h',
     'ServoSupportsRule.h',
     'ServoTraversalStatistics.h',
     'ServoTypes.h',
@@ -155,16 +154,17 @@ UNIFIED_SOURCES += [
     'CSS.cpp',
     'CSSFontFeatureValuesRule.cpp',
     'CSSImportRule.cpp',
     'CSSKeyframeRule.cpp',
     'CSSKeyframesRule.cpp',
     'CSSLexer.cpp',
     'CSSMediaRule.cpp',
     'CSSMozDocumentRule.cpp',
+    'CSSNamespaceRule.cpp',
     'CSSPageRule.cpp',
     'CSSRuleList.cpp',
     'CSSSupportsRule.cpp',
     'DeclarationBlock.cpp',
     'DocumentStyleRootIterator.cpp',
     'ErrorReporter.cpp',
     'FontFace.cpp',
     'FontFaceSet.cpp',
@@ -208,17 +208,16 @@ UNIFIED_SOURCES += [
     'ServoDocumentRule.cpp',
     'ServoElementSnapshot.cpp',
     'ServoFontFaceRule.cpp',
     'ServoFontFeatureValuesRule.cpp',
     'ServoImportRule.cpp',
     'ServoKeyframeRule.cpp',
     'ServoKeyframesRule.cpp',
     'ServoMediaRule.cpp',
-    'ServoNamespaceRule.cpp',
     'ServoPageRule.cpp',
     'ServoSpecifiedValues.cpp',
     'ServoStyleRule.cpp',
     'ServoStyleSet.cpp',
     'ServoSupportsRule.cpp',
     'StreamLoader.cpp',
     'StyleAnimationValue.cpp',
     'StyleComplexColor.cpp',