Bug 1428610 part 1. Devirtualize nsICSSDeclaration::GetDocGroup. r=emilio
authorBoris Zbarsky <bzbarsky@mit.edu>
Tue, 30 Jan 2018 14:48:26 -0500
changeset 401546 34d077c5c190be75ca099b34301d28f3805b5009
parent 401545 73c8f5ce12856fef30e2d411560d92520569d24a
child 401547 a6b5b4868ead349395ebdfa640f8cf846c047302
push id33347
push userarchaeopteryx@coole-files.de
push dateTue, 30 Jan 2018 22:28:09 +0000
treeherdermozilla-central@217fc14405e7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemilio
bugs1428610
milestone60.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 1428610 part 1. Devirtualize nsICSSDeclaration::GetDocGroup. r=emilio MozReview-Commit-ID: 7OGRkYTjTSQ
layout/style/ServoKeyframeRule.cpp
layout/style/ServoPageRule.cpp
layout/style/ServoPageRule.h
layout/style/ServoStyleRule.cpp
layout/style/ServoStyleRule.h
layout/style/StyleRule.cpp
layout/style/moz.build
layout/style/nsCSSFontFaceRule.cpp
layout/style/nsCSSFontFaceRule.h
layout/style/nsCSSRules.cpp
layout/style/nsCSSRules.h
layout/style/nsComputedDOMStyle.h
layout/style/nsDOMCSSAttrDeclaration.cpp
layout/style/nsDOMCSSAttrDeclaration.h
layout/style/nsICSSDeclaration.cpp
layout/style/nsICSSDeclaration.h
--- a/layout/style/ServoKeyframeRule.cpp
+++ b/layout/style/ServoKeyframeRule.cpp
@@ -69,26 +69,16 @@ public:
   }
   nsIDocument* DocToUpdate() final override { return nullptr; }
 
   nsINode* GetParentObject() final override
   {
     return mRule ? mRule->GetDocument() : nullptr;
   }
 
-  DocGroup* GetDocGroup() const final override
-  {
-    if (!mRule) {
-      return nullptr;
-    }
-
-    nsIDocument* document = mRule->GetDocument();
-    return document ? document->GetDocGroup() : nullptr;
-  }
-
   size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const
   {
     size_t n = aMallocSizeOf(this);
     // TODO we may want to add size of mDecls as well
     return n;
   }
 
 private:
--- a/layout/style/ServoPageRule.cpp
+++ b/layout/style/ServoPageRule.cpp
@@ -53,23 +53,16 @@ ServoPageRuleDeclaration::GetParentRule(
 }
 
 nsINode*
 ServoPageRuleDeclaration::GetParentObject()
 {
   return Rule()->GetDocument();
 }
 
-DocGroup*
-ServoPageRuleDeclaration::GetDocGroup() const
-{
-  nsIDocument* document = Rule()->GetDocument();
-  return document ? document->GetDocGroup() : nullptr;
-}
-
 DeclarationBlock*
 ServoPageRuleDeclaration::GetCSSDeclaration(Operation aOperation)
 {
   return mDecls;
 }
 
 nsresult
 ServoPageRuleDeclaration::SetCSSDeclaration(DeclarationBlock* aDecl)
--- a/layout/style/ServoPageRule.h
+++ b/layout/style/ServoPageRule.h
@@ -25,17 +25,16 @@ class ServoPageRule;
 
 class ServoPageRuleDeclaration final : public nsDOMCSSDeclaration
 {
 public:
   NS_DECL_ISUPPORTS_INHERITED
 
   css::Rule* GetParentRule() final override;
   nsINode* GetParentObject() final override;
-  DocGroup* GetDocGroup() const final override;
 
 protected:
   DeclarationBlock* GetCSSDeclaration(Operation aOperation) final override;
   nsresult SetCSSDeclaration(DeclarationBlock* aDecl) final override;
   nsIDocument* DocToUpdate() final override;
   void GetCSSParsingEnvironment(CSSParsingEnvironment& aCSSParseEnv,
                                 nsIPrincipal* aSubjectPrincipal) final override;
   nsDOMCSSDeclaration::ServoCSSParsingEnvironment
--- a/layout/style/ServoStyleRule.cpp
+++ b/layout/style/ServoStyleRule.cpp
@@ -55,23 +55,16 @@ ServoStyleRuleDeclaration::GetParentRule
 }
 
 nsINode*
 ServoStyleRuleDeclaration::GetParentObject()
 {
   return Rule()->GetDocument();
 }
 
-DocGroup*
-ServoStyleRuleDeclaration::GetDocGroup() const
-{
-  nsIDocument* document = Rule()->GetDocument();
-  return document ? document->GetDocGroup() : nullptr;
-}
-
 DeclarationBlock*
 ServoStyleRuleDeclaration::GetCSSDeclaration(Operation aOperation)
 {
   return mDecls;
 }
 
 nsresult
 ServoStyleRuleDeclaration::SetCSSDeclaration(DeclarationBlock* aDecl)
--- a/layout/style/ServoStyleRule.h
+++ b/layout/style/ServoStyleRule.h
@@ -26,17 +26,16 @@ class ServoStyleRule;
 
 class ServoStyleRuleDeclaration final : public nsDOMCSSDeclaration
 {
 public:
   NS_DECL_ISUPPORTS_INHERITED
 
   css::Rule* GetParentRule() final override;
   nsINode* GetParentObject() final override;
-  mozilla::dom::DocGroup* GetDocGroup() const final override;
 
 protected:
   DeclarationBlock* GetCSSDeclaration(Operation aOperation) final override;
   nsresult SetCSSDeclaration(DeclarationBlock* aDecl) final override;
   nsIDocument* DocToUpdate() final override;
   void GetCSSParsingEnvironment(CSSParsingEnvironment& aCSSParseEnv,
                                 nsIPrincipal* aSubjectPrincipal) final override;
   ServoCSSParsingEnvironment
--- a/layout/style/StyleRule.cpp
+++ b/layout/style/StyleRule.cpp
@@ -1073,26 +1073,16 @@ public:
   // need to forward QI for cycle collection things to StyleRule.
   NS_DECL_ISUPPORTS_INHERITED
 
   virtual nsINode *GetParentObject() override
   {
     return mRule ? mRule->GetDocument() : nullptr;
   }
 
-  virtual DocGroup* GetDocGroup() const override
-  {
-    if (!mRule) {
-      return nullptr;
-    }
-
-    nsIDocument* document = mRule->GetDocument();
-    return document ? document->GetDocGroup() : nullptr;
-  }
-
 protected:
   // This reference is not reference-counted. The rule object owns us and we go
   // away when it does.
   css::StyleRule *mRule;
 };
 
 DOMCSSDeclarationImpl::DOMCSSDeclarationImpl(css::StyleRule *aRule)
   : mRule(aRule)
--- a/layout/style/moz.build
+++ b/layout/style/moz.build
@@ -228,16 +228,17 @@ UNIFIED_SOURCES += [
     'nsDOMCSSDeclaration.cpp',
     'nsDOMCSSRect.cpp',
     'nsDOMCSSRGBColor.cpp',
     'nsDOMCSSValueList.cpp',
     'nsFontFaceLoader.cpp',
     'nsFontFaceUtils.cpp',
     'nsHTMLCSSStyleSheet.cpp',
     'nsHTMLStyleSheet.cpp',
+    'nsICSSDeclaration.cpp',
     'nsMediaFeatures.cpp',
     'nsMediaList.cpp',
     'nsNthIndexCache.cpp',
     'nsROCSSPrimitiveValue.cpp',
     'nsRuleData.cpp',
     'nsRuleNode.cpp',
     'nsStyleContext.cpp',
     'nsStyleCoord.cpp',
--- a/layout/style/nsCSSFontFaceRule.cpp
+++ b/layout/style/nsCSSFontFaceRule.cpp
@@ -284,23 +284,16 @@ nsCSSFontFaceStyleDecl::SetPropertyValue
 }
 
 nsINode*
 nsCSSFontFaceStyleDecl::GetParentObject()
 {
   return ContainingRule()->GetDocument();
 }
 
-DocGroup*
-nsCSSFontFaceStyleDecl::GetDocGroup() const
-{
-  nsIDocument* document = ContainingRule()->GetDocument();
-  return document ? document->GetDocGroup() : nullptr;
-}
-
 JSObject*
 nsCSSFontFaceStyleDecl::WrapObject(JSContext *cx, JS::Handle<JSObject*> aGivenProto)
 {
   return mozilla::dom::CSSStyleDeclarationBinding::Wrap(cx, this, aGivenProto);
 }
 
 // -------------------------------------------
 // nsCSSFontFaceRule
--- a/layout/style/nsCSSFontFaceRule.h
+++ b/layout/style/nsCSSFontFaceRule.h
@@ -41,17 +41,16 @@ public:
   NS_DECL_NSIDOMCSSSTYLEDECLARATION_HELPER
   NS_DECL_NSICSSDECLARATION
   virtual already_AddRefed<mozilla::dom::CSSValue>
   GetPropertyCSSValue(const nsAString& aProp, mozilla::ErrorResult& aRv)
     override;
   using nsICSSDeclaration::GetPropertyCSSValue;
 
   virtual nsINode *GetParentObject() override;
-  virtual mozilla::dom::DocGroup* GetDocGroup() const override;
   virtual void IndexedGetter(uint32_t aIndex, bool& aFound, nsAString& aPropName) override;
 
   nsresult GetPropertyValue(nsCSSFontDesc aFontDescID,
                             nsAString & aResult) const;
 
   virtual JSObject* WrapObject(JSContext *cx, JS::Handle<JSObject*> aGivenProto) override;
 
 protected:
--- a/layout/style/nsCSSRules.cpp
+++ b/layout/style/nsCSSRules.cpp
@@ -883,27 +883,16 @@ nsCSSKeyframeStyleDeclaration::DocToUpda
 }
 
 nsINode*
 nsCSSKeyframeStyleDeclaration::GetParentObject()
 {
   return mRule ? mRule->GetDocument() : nullptr;
 }
 
-DocGroup*
-nsCSSKeyframeStyleDeclaration::GetDocGroup() const
-{
-  if (!mRule) {
-    return nullptr;
-  }
-
-  nsIDocument* document = mRule->GetDocument();
-  return document ? document->GetDocGroup() : nullptr;
-}
-
 // -------------------------------------------
 // nsCSSKeyframeRule
 //
 
 nsCSSKeyframeRule::nsCSSKeyframeRule(const nsCSSKeyframeRule& aCopy)
   // copy everything except our reference count and mDOMDeclaration
   : dom::CSSKeyframeRule(aCopy)
   , mKeys(aCopy.mKeys)
@@ -1307,27 +1296,16 @@ nsCSSPageStyleDeclaration::DocToUpdate()
 }
 
 nsINode*
 nsCSSPageStyleDeclaration::GetParentObject()
 {
   return mRule ? mRule->GetDocument() : nullptr;
 }
 
-DocGroup*
-nsCSSPageStyleDeclaration::GetDocGroup() const
-{
-  if (!mRule) {
-    return nullptr;
-  }
-
-  nsIDocument* document = mRule->GetDocument();
-  return document ? document->GetDocGroup() : nullptr;
-}
-
 // -------------------------------------------
 // nsCSSPageRule
 //
 
 nsCSSPageRule::nsCSSPageRule(const nsCSSPageRule& aCopy)
   // copy everything except our reference count and mDOMDeclaration
   : dom::CSSPageRule(aCopy)
   , mDeclaration(new css::Declaration(*aCopy.mDeclaration))
--- a/layout/style/nsCSSRules.h
+++ b/layout/style/nsCSSRules.h
@@ -217,17 +217,16 @@ public:
   GetServoCSSParsingEnvironment(nsIPrincipal* aSubjectPrincipal) const final override;
   virtual nsIDocument* DocToUpdate() override;
 
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(nsCSSKeyframeStyleDeclaration,
                                                          nsICSSDeclaration)
 
   virtual nsINode* GetParentObject() override;
-  virtual mozilla::dom::DocGroup* GetDocGroup() const override;
 
 protected:
   virtual ~nsCSSKeyframeStyleDeclaration();
 
   // This reference is not reference-counted. The rule object tells us
   // when it's about to go away.
   nsCSSKeyframeRule* MOZ_NON_OWNING_REF mRule;
 };
@@ -336,17 +335,16 @@ public:
   GetServoCSSParsingEnvironment(nsIPrincipal* aSubjectPrincipal) const final override;
   virtual nsIDocument* DocToUpdate() override;
 
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(nsCSSPageStyleDeclaration,
                                                          nsICSSDeclaration)
 
   virtual nsINode *GetParentObject() override;
-  virtual mozilla::dom::DocGroup* GetDocGroup() const override;
 
 protected:
   virtual ~nsCSSPageStyleDeclaration();
 
   // This reference is not reference-counted. The rule object tells us
   // when it's about to go away.
   nsCSSPageRule* MOZ_NON_OWNING_REF mRule;
 };
--- a/layout/style/nsComputedDOMStyle.h
+++ b/layout/style/nsComputedDOMStyle.h
@@ -88,21 +88,16 @@ public:
                      StyleType aStyleType,
                      AnimationFlag aFlag = eWithAnimation);
 
   virtual nsINode *GetParentObject() override
   {
     return mContent;
   }
 
-  virtual mozilla::dom::DocGroup* GetDocGroup() const override
-  {
-    return mContent ? mContent->GetDocGroup() : nullptr;
-  }
-
   static already_AddRefed<nsStyleContext>
   GetStyleContext(mozilla::dom::Element* aElement, nsAtom* aPseudo,
                   nsIPresShell* aPresShell,
                   StyleType aStyleType = eAll);
 
   static already_AddRefed<nsStyleContext>
   GetStyleContextNoFlush(mozilla::dom::Element* aElement,
                          nsAtom* aPseudo,
--- a/layout/style/nsDOMCSSAttrDeclaration.cpp
+++ b/layout/style/nsDOMCSSAttrDeclaration.cpp
@@ -195,22 +195,16 @@ nsDOMCSSAttributeDeclaration::GetParentR
 }
 
 /* virtual */ nsINode*
 nsDOMCSSAttributeDeclaration::GetParentObject()
 {
   return mElement;
 }
 
-/* virtual */ DocGroup*
-nsDOMCSSAttributeDeclaration::GetDocGroup() const
-{
-  return mElement ? mElement->OwnerDoc()->GetDocGroup() : nullptr;
-}
-
 NS_IMETHODIMP
 nsDOMCSSAttributeDeclaration::SetPropertyValue(const nsCSSPropertyID aPropID,
                                                const nsAString& aValue,
                                                nsIPrincipal* aSubjectPrincipal)
 {
   // Scripted modifications to style.opacity or style.transform
   // could immediately force us into the animated state if heuristics suggest
   // this is scripted animation.
--- a/layout/style/nsDOMCSSAttrDeclaration.h
+++ b/layout/style/nsDOMCSSAttrDeclaration.h
@@ -36,17 +36,16 @@ public:
   virtual mozilla::DeclarationBlock* GetCSSDeclaration(Operation aOperation) override;
   virtual void GetCSSParsingEnvironment(CSSParsingEnvironment& aCSSParseEnv,
                                         nsIPrincipal* aSubjectPrincipal) override;
   nsDOMCSSDeclaration::ServoCSSParsingEnvironment
   GetServoCSSParsingEnvironment(nsIPrincipal* aSubjectPrincipal) const final override;
   mozilla::css::Rule* GetParentRule() override;
 
   virtual nsINode* GetParentObject() override;
-  virtual mozilla::dom::DocGroup* GetDocGroup() const override;
 
   NS_IMETHOD SetPropertyValue(const nsCSSPropertyID aPropID,
                               const nsAString& aValue,
                               nsIPrincipal* aSubjectPrincipal) override;
 
 protected:
   ~nsDOMCSSAttributeDeclaration();
 
new file mode 100644
--- /dev/null
+++ b/layout/style/nsICSSDeclaration.cpp
@@ -0,0 +1,24 @@
+/* -*- 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/. */
+
+/* Implementation of non-inline bits of nsICSSDeclaration. */
+
+#include "nsICSSDeclaration.h"
+
+#include "nsINode.h"
+
+using mozilla::dom::DocGroup;
+
+DocGroup*
+nsICSSDeclaration::GetDocGroup()
+{
+  nsINode* parentNode = GetParentObject();
+  if (!parentNode) {
+    return nullptr;
+  }
+
+  return parentNode->GetDocGroup();
+}
--- a/layout/style/nsICSSDeclaration.h
+++ b/layout/style/nsICSSDeclaration.h
@@ -60,17 +60,17 @@ public:
    * method does NOT allow setting a priority (the priority will
    * always be set to default priority).
    */
   NS_IMETHOD SetPropertyValue(const nsCSSPropertyID aPropID,
                               const nsAString& aValue,
                               nsIPrincipal* aSubjectPrincipal = nullptr) = 0;
 
   virtual nsINode *GetParentObject() = 0;
-  virtual mozilla::dom::DocGroup* GetDocGroup() const = 0;
+  mozilla::dom::DocGroup* GetDocGroup();
 
   NS_IMETHOD GetCssText(nsAString& aCssText) = 0;
   NS_IMETHOD SetCssText(const nsAString& aCssText,
                         nsIPrincipal* aSubjectPrincipal = nullptr) = 0;
   NS_IMETHOD GetPropertyValue(const nsAString& aPropName,
                               nsAString& aValue) = 0;
   virtual already_AddRefed<mozilla::dom::CSSValue>
     GetPropertyCSSValue(const nsAString& aPropertyName,