Bug 1449390 - Remove Rule::GetType() and its corresponding constants. r=emilio
authorXidorn Quan <me@upsuper.org>
Wed, 28 Mar 2018 14:22:01 +1100
changeset 466471 77f75377b821850c4c501cb3ca19d9ea8db5011c
parent 466470 d9f8d12c6d6e4b2eeaf86aec198f33bb579ecfcf
child 466472 f2079554d7531f3f5e9deee6e0f0c41e3b9fafba
push id1728
push userjlund@mozilla.com
push dateMon, 18 Jun 2018 21:12:27 +0000
treeherdermozilla-release@c296fde26f5f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemilio
bugs1449390
milestone61.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 1449390 - Remove Rule::GetType() and its corresponding constants. r=emilio MozReview-Commit-ID: 5r64ATHUAux
dom/base/nsTreeSanitizer.cpp
layout/style/CSSFontFeatureValuesRule.h
layout/style/CSSImportRule.h
layout/style/CSSKeyframeRule.h
layout/style/CSSKeyframesRule.h
layout/style/CSSMediaRule.h
layout/style/CSSMozDocumentRule.h
layout/style/CSSNamespaceRule.h
layout/style/CSSPageRule.h
layout/style/CSSSupportsRule.h
layout/style/Rule.h
layout/style/ServoStyleRule.cpp
layout/style/ServoStyleRule.h
layout/style/ServoStyleSheet.cpp
layout/style/StyleSheet.cpp
layout/style/nsCSSCounterStyleRule.cpp
layout/style/nsCSSCounterStyleRule.h
layout/style/nsCSSFontFaceRule.cpp
layout/style/nsCSSFontFaceRule.h
--- a/dom/base/nsTreeSanitizer.cpp
+++ b/dom/base/nsTreeSanitizer.cpp
@@ -1113,30 +1113,30 @@ nsTreeSanitizer::SanitizeStyleSheet(cons
   if (!rules) {
     return true;
   }
   uint32_t ruleCount = rules->Length();
   for (uint32_t i = 0; i < ruleCount; ++i) {
     mozilla::css::Rule* rule = rules->Item(i);
     if (!rule)
       continue;
-    switch (rule->GetType()) {
+    switch (rule->Type()) {
       default:
         didSanitize = true;
         // Ignore these rule types.
         break;
-      case mozilla::css::Rule::NAMESPACE_RULE:
-      case mozilla::css::Rule::FONT_FACE_RULE: {
+      case CSSRuleBinding::NAMESPACE_RULE:
+      case CSSRuleBinding::FONT_FACE_RULE: {
         // Append @namespace and @font-face rules verbatim.
         nsAutoString cssText;
         rule->GetCssText(cssText);
         aSanitized.Append(cssText);
         break;
       }
-      case mozilla::css::Rule::STYLE_RULE: {
+      case CSSRuleBinding::STYLE_RULE: {
         // For style rules, we will just look for and remove the
         // -moz-binding properties.
         auto styleRule = static_cast<BindingStyleRule*>(rule);
         DeclarationBlock* styleDecl = styleRule->GetDeclarationBlock();
         MOZ_ASSERT(styleDecl);
         if (SanitizeStyleDeclaration(styleDecl)) {
           didSanitize = true;
         }
--- a/layout/style/CSSFontFeatureValuesRule.h
+++ b/layout/style/CSSFontFeatureValuesRule.h
@@ -14,17 +14,16 @@
 namespace mozilla {
 namespace dom {
 
 class CSSFontFeatureValuesRule : public css::Rule
 {
 public:
   virtual bool IsCCLeaf() const override;
 
-  int32_t GetType() const final { return Rule::FONT_FEATURE_VALUES_RULE; }
   virtual already_AddRefed<mozilla::css::Rule> Clone() const override = 0;
 
   // WebIDL interfaces
   uint16_t Type() const final { return CSSRuleBinding::FONT_FEATURE_VALUES_RULE; }
   virtual void GetCssText(nsAString& aCssText) const override = 0;
   virtual void GetFontFamily(nsAString& aFamily) = 0;
   virtual void SetFontFamily(const nsAString& aFamily, mozilla::ErrorResult& aRv) = 0;
   virtual void GetValueText(nsAString& aValueText) = 0;
--- a/layout/style/CSSImportRule.h
+++ b/layout/style/CSSImportRule.h
@@ -16,18 +16,16 @@ class CSSImportRule : public css::Rule
 {
 protected:
   using Rule::Rule;
   virtual ~CSSImportRule() {}
 
 public:
   bool IsCCLeaf() const final;
 
-  int32_t GetType() const final { return css::Rule::IMPORT_RULE; }
-
   size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf)
     const override = 0;
 
   // WebIDL interface
   uint16_t Type() const final { return CSSRuleBinding::IMPORT_RULE; }
   virtual void GetHref(nsAString& aHref) const = 0;
   virtual dom::MediaList* GetMedia() const = 0;
   virtual StyleSheet* GetStyleSheet() const = 0;
--- a/layout/style/CSSKeyframeRule.h
+++ b/layout/style/CSSKeyframeRule.h
@@ -16,17 +16,16 @@ namespace dom {
 
 class CSSKeyframeRule : public css::Rule
 {
 protected:
   using css::Rule::Rule;
   virtual ~CSSKeyframeRule() {}
 
 public:
-  int32_t GetType() const final { return Rule::KEYFRAME_RULE; }
   bool IsCCLeaf() const override { return Rule::IsCCLeaf(); }
 
   // WebIDL interface
   uint16_t Type() const final { return CSSRuleBinding::KEYFRAME_RULE; }
   virtual void GetKeyText(nsAString& aKey) = 0;
   virtual void SetKeyText(const nsAString& aKey) = 0;
   virtual nsICSSDeclaration* Style() = 0;
 
--- a/layout/style/CSSKeyframesRule.h
+++ b/layout/style/CSSKeyframesRule.h
@@ -15,17 +15,16 @@ namespace dom {
 
 class CSSKeyframesRule : public css::Rule
 {
 protected:
   using css::Rule::Rule;
   virtual ~CSSKeyframesRule() {}
 
 public:
-  int32_t GetType() const final { return Rule::KEYFRAMES_RULE; }
   // Let's not worry for now about sorting out whether we're a leaf or not.
   bool IsCCLeaf() const override { return false; }
 
   // WebIDL interface
   uint16_t Type() const final { return CSSRuleBinding::KEYFRAMES_RULE; }
   virtual void GetName(nsAString& aName) const = 0;
   virtual void SetName(const nsAString& aName) = 0;
   virtual CSSRuleList* CssRules() = 0;
--- a/layout/style/CSSMediaRule.h
+++ b/layout/style/CSSMediaRule.h
@@ -14,18 +14,16 @@ namespace dom {
 
 class CSSMediaRule : public css::ConditionRule
 {
 protected:
   using ConditionRule::ConditionRule;
   virtual ~CSSMediaRule() {}
 
 public:
-  int32_t GetType() const override { return css::Rule::MEDIA_RULE; }
-
   // WebIDL interface
   uint16_t Type() const override { return CSSRuleBinding::MEDIA_RULE; }
   virtual MediaList* Media() = 0;
 
   JSObject* WrapObject(JSContext* aCx,
                        JS::Handle<JSObject*> aGivenProto) override;
 };
 
--- a/layout/style/CSSMozDocumentRule.h
+++ b/layout/style/CSSMozDocumentRule.h
@@ -15,18 +15,16 @@ namespace dom {
 
 class CSSMozDocumentRule : public css::ConditionRule
 {
 protected:
   using ConditionRule::ConditionRule;
   virtual ~CSSMozDocumentRule() {}
 
 public:
-  int32_t GetType() const final { return css::Rule::DOCUMENT_RULE; }
-
   static bool Match(nsIDocument* aDoc,
                     nsIURI* aDocURI,
                     const nsACString& aDocURISpec,
                     const nsACString& aPattern,
                     css::URLMatchingFunction aUrlMatchingFunction);
 
   // WebIDL interface
   uint16_t Type() const final { return CSSRuleBinding::DOCUMENT_RULE; }
--- a/layout/style/CSSNamespaceRule.h
+++ b/layout/style/CSSNamespaceRule.h
@@ -19,19 +19,16 @@ class CSSNamespaceRule : public css::Rul
 {
 protected:
   using Rule::Rule;
 
 public:
   bool IsCCLeaf() const final {
     return Rule::IsCCLeaf();
   }
-  int32_t GetType() const final {
-    return Rule::NAMESPACE_RULE;
-  }
 
   virtual nsAtom* GetPrefix() const = 0;
   virtual void GetURLSpec(nsString& aURLSpec) const = 0;
 
   // WebIDL interfaces
   uint16_t Type() const final { return CSSRuleBinding::NAMESPACE_RULE; }
   void GetNamespaceURI(nsString& aNamespaceURI) {
     GetURLSpec(aNamespaceURI);
--- a/layout/style/CSSPageRule.h
+++ b/layout/style/CSSPageRule.h
@@ -18,18 +18,16 @@ class CSSPageRule : public css::Rule
 {
 protected:
   using Rule::Rule;
   virtual ~CSSPageRule() {};
 
 public:
   virtual bool IsCCLeaf() const override = 0;
 
-  int32_t GetType() const final { return Rule::PAGE_RULE; }
-
   // WebIDL interfaces
   uint16_t Type() const final { return CSSRuleBinding::PAGE_RULE; }
   virtual void GetCssText(nsAString& aCssText) const override = 0;
   virtual nsICSSDeclaration* Style() = 0;
 
   virtual size_t
   SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const override = 0;
 
--- a/layout/style/CSSSupportsRule.h
+++ b/layout/style/CSSSupportsRule.h
@@ -14,18 +14,16 @@ namespace dom {
 
 class CSSSupportsRule : public css::ConditionRule
 {
 protected:
   using ConditionRule::ConditionRule;
   virtual ~CSSSupportsRule() {}
 
 public:
-  int32_t GetType() const override { return css::Rule::SUPPORTS_RULE; }
-
   // WebIDL interface
   uint16_t Type() const override { return CSSRuleBinding::SUPPORTS_RULE; }
 
   JSObject* WrapObject(JSContext* aCx,
                        JS::Handle<JSObject*> aGivenProto) override;
 };
 
 } // namespace dom
--- a/layout/style/Rule.h
+++ b/layout/style/Rule.h
@@ -53,40 +53,16 @@ public:
   // Return true if this rule is known to be a cycle collection leaf, in the
   // sense that it doesn't have any outgoing owning edges.
   virtual bool IsCCLeaf() const MOZ_MUST_OVERRIDE;
 
 #ifdef DEBUG
   virtual void List(FILE* out = stdout, int32_t aIndent = 0) const = 0;
 #endif
 
-  // The constants in this list must maintain the following invariants:
-  //   If a rule of type N must appear before a rule of type M in stylesheets
-  //   then N < M
-  // Note that CSSStyleSheet::RebuildChildList assumes that no other kinds of
-  // rules can come between two rules of type IMPORT_RULE.
-  enum {
-    UNKNOWN_RULE = 0,
-    CHARSET_RULE,
-    IMPORT_RULE,
-    NAMESPACE_RULE,
-    STYLE_RULE,
-    MEDIA_RULE,
-    FONT_FACE_RULE,
-    PAGE_RULE,
-    KEYFRAME_RULE,
-    KEYFRAMES_RULE,
-    DOCUMENT_RULE,
-    SUPPORTS_RULE,
-    FONT_FEATURE_VALUES_RULE,
-    COUNTER_STYLE_RULE
-  };
-
-  virtual int32_t GetType() const = 0;
-
   StyleSheet* GetStyleSheet() const { return mSheet; }
 
   // Return the document the rule lives in, if any
   nsIDocument* GetDocument() const
   {
     StyleSheet* sheet = GetStyleSheet();
     return sheet ? sheet->GetAssociatedDocument() : nullptr;
   }
--- a/layout/style/ServoStyleRule.cpp
+++ b/layout/style/ServoStyleRule.cpp
@@ -190,22 +190,16 @@ ServoStyleRule::List(FILE* out, int32_t 
   }
   Servo_StyleRule_Debug(mRawRule, &str);
   fprintf_stderr(out, "%s\n", str.get());
 }
 #endif
 
 /* CSSRule implementation */
 
-uint16_t
-ServoStyleRule::Type() const
-{
-  return CSSRuleBinding::STYLE_RULE;
-}
-
 void
 ServoStyleRule::GetCssText(nsAString& aCssText) const
 {
   Servo_StyleRule_GetCssText(mRawRule, &aCssText);
 }
 
 nsICSSDeclaration*
 ServoStyleRule::Style()
--- a/layout/style/ServoStyleRule.h
+++ b/layout/style/ServoStyleRule.h
@@ -76,26 +76,25 @@ public:
                           uint64_t* aSpecificity) override;
   nsresult SelectorMatchesElement(dom::Element* aElement,
                                   uint32_t aSelectorIndex,
                                   const nsAString& aPseudo,
                                   bool* aMatches) override;
   NotNull<DeclarationBlock*> GetDeclarationBlock() const override;
 
   // WebIDL interface
-  uint16_t Type() const final;
+  uint16_t Type() const final { return dom::CSSRuleBinding::STYLE_RULE; }
   void GetCssText(nsAString& aCssText) const final;
   void GetSelectorText(nsAString& aSelectorText) final;
   void SetSelectorText(const nsAString& aSelectorText) final;
   nsICSSDeclaration* Style() final;
 
   RawServoStyleRule* Raw() const { return mRawRule; }
 
   // Methods of mozilla::css::Rule
-  int32_t GetType() const final { return css::Rule::STYLE_RULE; }
   already_AddRefed<Rule> Clone() const final;
   size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const final;
 #ifdef DEBUG
   void List(FILE* out = stdout, int32_t aIndent = 0) const final;
 #endif
 
 private:
   ~ServoStyleRule() {}
--- a/layout/style/ServoStyleSheet.cpp
+++ b/layout/style/ServoStyleSheet.cpp
@@ -318,17 +318,17 @@ ServoStyleSheet::ReparseSheet(const nsAS
   {
     ServoCSSRuleList* ruleList = GetCssRulesInternal();
     MOZ_ASSERT(ruleList);
 
     uint32_t ruleCount = ruleList->Length();
     for (uint32_t i = 0; i < ruleCount; ++i) {
       css::Rule* rule = ruleList->GetRule(i);
       MOZ_ASSERT(rule);
-      if (rule->GetType() == css::Rule::IMPORT_RULE &&
+      if (rule->Type() == CSSRuleBinding::IMPORT_RULE &&
           RuleHasPendingChildSheet(rule)) {
         continue; // notify when loaded (see StyleSheetLoaded)
       }
       RuleRemoved(*rule);
     }
   }
 
   DropRuleList();
@@ -349,17 +349,17 @@ ServoStyleSheet::ReparseSheet(const nsAS
     // Get the rule list (which will need to be regenerated after ParseSheet).
     ServoCSSRuleList* ruleList = GetCssRulesInternal();
     MOZ_ASSERT(ruleList);
 
     uint32_t ruleCount = ruleList->Length();
     for (uint32_t i = 0; i < ruleCount; ++i) {
       css::Rule* rule = ruleList->GetRule(i);
       MOZ_ASSERT(rule);
-      if (rule->GetType() == css::Rule::IMPORT_RULE &&
+      if (rule->Type() == CSSRuleBinding::IMPORT_RULE &&
           RuleHasPendingChildSheet(rule)) {
         continue; // notify when loaded (see StyleSheetLoaded)
       }
 
       RuleAdded(*rule);
     }
   }
 
@@ -441,17 +441,17 @@ ServoStyleSheet::InsertRuleInternal(cons
   aRv = mRuleList->InsertRule(aRule, aIndex);
   if (aRv.Failed()) {
     return 0;
   }
 
   // XXX We may not want to get the rule when stylesheet change event
   // is not enabled.
   css::Rule* rule = mRuleList->GetRule(aIndex);
-  if (rule->GetType() != css::Rule::IMPORT_RULE ||
+  if (rule->Type() != CSSRuleBinding::IMPORT_RULE ||
       !RuleHasPendingChildSheet(rule)) {
     RuleAdded(*rule);
   }
 
   return aIndex;
 }
 
 void
--- a/layout/style/StyleSheet.cpp
+++ b/layout/style/StyleSheet.cpp
@@ -873,17 +873,17 @@ JSObject*
 StyleSheet::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
 {
   return dom::CSSStyleSheetBinding::Wrap(aCx, this, aGivenProto);
 }
 
 /* static */ bool
 StyleSheet::RuleHasPendingChildSheet(css::Rule* aRule)
 {
-  MOZ_ASSERT(aRule->GetType() == css::Rule::IMPORT_RULE);
+  MOZ_ASSERT(aRule->Type() == dom::CSSRuleBinding::IMPORT_RULE);
   auto rule = static_cast<dom::CSSImportRule*>(aRule);
   if (StyleSheet* childSheet = rule->GetStyleSheet()) {
     return !childSheet->IsComplete();
   }
   return false;
 }
 
 } // namespace mozilla
--- a/layout/style/nsCSSCounterStyleRule.cpp
+++ b/layout/style/nsCSSCounterStyleRule.cpp
@@ -70,22 +70,16 @@ nsCSSCounterStyleRule::List(FILE* out, i
   fprintf_stderr(out, "%s@counter-style %s (rev.%u) {\n",
                  baseInd.get(), NS_ConvertUTF16toUTF8(name).get(),
                  mGeneration);
   // TODO
   fprintf_stderr(out, "%s}\n", baseInd.get());
 }
 #endif
 
-/* virtual */ int32_t
-nsCSSCounterStyleRule::GetType() const
-{
-  return Rule::COUNTER_STYLE_RULE;
-}
-
 uint16_t
 nsCSSCounterStyleRule::Type() const
 {
   return CSSRuleBinding::COUNTER_STYLE_RULE;
 }
 
 void
 nsCSSCounterStyleRule::GetCssText(nsAString& aCssText) const
--- a/layout/style/nsCSSCounterStyleRule.h
+++ b/layout/style/nsCSSCounterStyleRule.h
@@ -27,17 +27,16 @@ private:
   ~nsCSSCounterStyleRule();
 
 public:
   virtual bool IsCCLeaf() const override;
 
 #ifdef DEBUG
   virtual void List(FILE* out = stdout, int32_t aIndent = 0) const override;
 #endif
-  virtual int32_t GetType() const override;
   virtual already_AddRefed<mozilla::css::Rule> Clone() const override;
 
   // WebIDL interface
   uint16_t Type() const override;
   void GetCssText(nsAString& aCssText) const override;
   void GetName(nsAString& aName);
   void SetName(const nsAString& aName);
   void GetSystem(nsAString& aSystem);
--- a/layout/style/nsCSSFontFaceRule.cpp
+++ b/layout/style/nsCSSFontFaceRule.cpp
@@ -357,22 +357,16 @@ nsCSSFontFaceRule::List(FILE* out, int32
       fprintf_stderr(out, "%s%s: %s\n",
                      descInd.get(), nsCSSProps::GetStringValue(id).get(),
                      NS_ConvertUTF16toUTF8(descStr).get());
     }
   fprintf_stderr(out, "%s}\n", baseInd.get());
 }
 #endif
 
-/* virtual */ int32_t
-nsCSSFontFaceRule::GetType() const
-{
-  return Rule::FONT_FACE_RULE;
-}
-
 uint16_t
 nsCSSFontFaceRule::Type() const
 {
   return CSSRuleBinding::FONT_FACE_RULE;
 }
 
 void
 nsCSSFontFaceRule::GetCssText(nsAString& aCssText) const
--- a/layout/style/nsCSSFontFaceRule.h
+++ b/layout/style/nsCSSFontFaceRule.h
@@ -91,17 +91,16 @@ public:
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(nsCSSFontFaceRule,
                                                          mozilla::css::Rule)
   virtual bool IsCCLeaf() const override;
 
 #ifdef DEBUG
   virtual void List(FILE* out = stdout, int32_t aIndent = 0) const override;
 #endif
-  virtual int32_t GetType() const override;
   virtual already_AddRefed<mozilla::css::Rule> Clone() const override;
 
   void SetDesc(nsCSSFontDesc aDescID, nsCSSValue const & aValue);
   void GetDesc(nsCSSFontDesc aDescID, nsCSSValue & aValue);
 
   // WebIDL interface
   uint16_t Type() const override;
   void GetCssText(nsAString& aCssText) const override;