Bug 1352968 part 5 - Add a param to ctor of ServoCSSRuleList for top level list. r=heycam
authorXidorn Quan <me@upsuper.org>
Tue, 30 May 2017 11:10:25 +1000
changeset 409275 afe344d438168a0b7ce4bb2a50e679712f7c77e7
parent 409274 28676da16b1613c4b7e36b7012fd8d46d7905291
child 409276 dd3c0e2db9cb7f437475e06f810d249e3579ed8f
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam
bugs1352968
milestone55.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 1352968 part 5 - Add a param to ctor of ServoCSSRuleList for top level list. r=heycam @import rules can only exist in top level rule lists, and we need the stylesheet to construct the import rules. MozReview-Commit-ID: APCyGW8re8f
layout/style/GroupRule.h
layout/style/ServoCSSRuleList.cpp
layout/style/ServoCSSRuleList.h
layout/style/ServoStyleSheet.cpp
--- a/layout/style/GroupRule.h
+++ b/layout/style/GroupRule.h
@@ -74,17 +74,17 @@ struct GeckoGroupRuleRules
 
   IncrementalClearCOMRuleArray mRules;
   RefPtr<GroupRuleRuleList> mRuleCollection; // lazily constructed
 };
 
 struct ServoGroupRuleRules
 {
   explicit ServoGroupRuleRules(already_AddRefed<ServoCssRules> aRawRules)
-    : mRuleList(new ServoCSSRuleList(Move(aRawRules))) {}
+    : mRuleList(new ServoCSSRuleList(Move(aRawRules), nullptr)) {}
   ServoGroupRuleRules(ServoGroupRuleRules&& aOther)
     : mRuleList(Move(aOther.mRuleList)) {}
   ServoGroupRuleRules(const ServoGroupRuleRules& aCopy) {
     // Do we ever clone Servo rules?
     MOZ_ASSERT_UNREACHABLE("stylo: Cloning GroupRule not implemented");
   }
 
   void SetParentRule(GroupRule* aParentRule) {
--- a/layout/style/ServoCSSRuleList.cpp
+++ b/layout/style/ServoCSSRuleList.cpp
@@ -17,18 +17,20 @@
 #include "mozilla/ServoPageRule.h"
 #include "mozilla/ServoStyleRule.h"
 #include "mozilla/ServoSupportsRule.h"
 #include "nsCSSCounterStyleRule.h"
 #include "nsCSSFontFaceRule.h"
 
 namespace mozilla {
 
-ServoCSSRuleList::ServoCSSRuleList(already_AddRefed<ServoCssRules> aRawRules)
-  : mRawRules(aRawRules)
+ServoCSSRuleList::ServoCSSRuleList(already_AddRefed<ServoCssRules> aRawRules,
+                                   ServoStyleSheet* aDirectOwnerStyleSheet)
+  : mStyleSheet(aDirectOwnerStyleSheet)
+  , mRawRules(aRawRules)
 {
   Servo_CssRules_ListTypes(mRawRules, &mRules);
   // XXX We may want to eagerly create object for import rule, so that
   //     we don't lose the reference to child stylesheet when our own
   //     stylesheet goes away.
 }
 
 // QueryInterface implementation for ServoCSSRuleList
--- a/layout/style/ServoCSSRuleList.h
+++ b/layout/style/ServoCSSRuleList.h
@@ -20,17 +20,22 @@ class ServoStyleSheet;
 namespace css {
 class GroupRule;
 class Rule;
 } // namespace css
 
 class ServoCSSRuleList final : public dom::CSSRuleList
 {
 public:
-  explicit ServoCSSRuleList(already_AddRefed<ServoCssRules> aRawRules);
+  // @param aDirectOwnerStyleSheet should be set to the owner stylesheet
+  // if this rule list is owned directly by a stylesheet, which means it
+  // is a top level CSSRuleList. If it's owned by a group rule, nullptr.
+  // If this param is set, the caller doesn't need to call SetStyleSheet.
+  ServoCSSRuleList(already_AddRefed<ServoCssRules> aRawRules,
+                   ServoStyleSheet* aDirectOwnerStyleSheet);
   css::GroupRule* GetParentRule() const { return mParentRule; }
   void SetParentRule(css::GroupRule* aParentRule);
   void SetStyleSheet(StyleSheet* aSheet);
 
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(ServoCSSRuleList, dom::CSSRuleList)
 
   ServoStyleSheet* GetParentObject() final { return mStyleSheet; }
--- a/layout/style/ServoStyleSheet.cpp
+++ b/layout/style/ServoStyleSheet.cpp
@@ -216,18 +216,17 @@ CSSRuleList*
 ServoStyleSheet::GetCssRulesInternal(ErrorResult& aRv)
 {
   if (!mRuleList) {
     EnsureUniqueInner();
 
     RefPtr<ServoCssRules> rawRules =
       Servo_StyleSheet_GetRules(Inner()->mSheet).Consume();
     MOZ_ASSERT(rawRules);
-    mRuleList = new ServoCSSRuleList(rawRules.forget());
-    mRuleList->SetStyleSheet(this);
+    mRuleList = new ServoCSSRuleList(rawRules.forget(), this);
   }
   return mRuleList;
 }
 
 uint32_t
 ServoStyleSheet::InsertRuleInternal(const nsAString& aRule,
                                     uint32_t aIndex, ErrorResult& aRv)
 {