Bug 1352763 part 4 - Pass CSS loader to Servo for insertRule. r=emilio
authorXidorn Quan <me@upsuper.org>
Mon, 03 Apr 2017 20:04:32 +1000
changeset 350931 4487ef34d11058888d6335f28cd049efc0861db6
parent 350930 3de3d7d4725eefe688e76e2f5a00388b41041dd8
child 350932 b5e5c568c04fa3dbcb2f5c99b2f83c174ee20b0b
push id39989
push userxquan@mozilla.com
push dateMon, 03 Apr 2017 12:50:15 +0000
treeherderautoland@4487ef34d110 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemilio
bugs1352763
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 1352763 part 4 - Pass CSS loader to Servo for insertRule. r=emilio MozReview-Commit-ID: 6yalz8D8BWc
layout/style/ServoBindingList.h
layout/style/ServoCSSRuleList.cpp
--- a/layout/style/ServoBindingList.h
+++ b/layout/style/ServoBindingList.h
@@ -73,17 +73,19 @@ SERVO_BINDING_FUNC(Servo_StyleSet_GetFon
 
 // CSSRuleList
 SERVO_BINDING_FUNC(Servo_CssRules_ListTypes, void,
                    ServoCssRulesBorrowed rules,
                    nsTArrayBorrowed_uintptr_t result)
 SERVO_BINDING_FUNC(Servo_CssRules_InsertRule, nsresult,
                    ServoCssRulesBorrowed rules,
                    RawServoStyleSheetBorrowed sheet, const nsACString* rule,
-                   uint32_t index, bool nested, uint16_t* rule_type)
+                   uint32_t index, bool nested, mozilla::css::Loader* loader,
+                   mozilla::ServoStyleSheet* gecko_stylesheet,
+                   uint16_t* rule_type)
 SERVO_BINDING_FUNC(Servo_CssRules_DeleteRule, nsresult,
                    ServoCssRulesBorrowed rules, uint32_t index)
 
 // CSS Rules
 #define BASIC_RULE_FUNCS(type_) \
   SERVO_BINDING_FUNC(Servo_CssRules_Get##type_##RuleAt, \
                      RawServo##type_##RuleStrong, \
                      ServoCssRulesBorrowed rules, uint32_t index) \
--- a/layout/style/ServoCSSRuleList.cpp
+++ b/layout/style/ServoCSSRuleList.cpp
@@ -155,21 +155,28 @@ ServoCSSRuleList::DropReference()
   mStyleSheet = nullptr;
   mParentRule = nullptr;
   DropAllRules();
 }
 
 nsresult
 ServoCSSRuleList::InsertRule(const nsAString& aRule, uint32_t aIndex)
 {
+  MOZ_ASSERT(mStyleSheet, "Caller must ensure that "
+             "the list is not unlinked from stylesheet");
   NS_ConvertUTF16toUTF8 rule(aRule);
   bool nested = !!mParentRule;
+  css::Loader* loader = nullptr;
+  if (nsIDocument* doc = mStyleSheet->GetAssociatedDocument()) {
+    loader = doc->CSSLoader();
+  }
   uint16_t type;
   nsresult rv = Servo_CssRules_InsertRule(mRawRules, mStyleSheet->RawSheet(),
-                                          &rule, aIndex, nested, &type);
+                                          &rule, aIndex, nested,
+                                          loader, mStyleSheet, &type);
   if (!NS_FAILED(rv)) {
     mRules.InsertElementAt(aIndex, type);
   }
   return rv;
 }
 
 nsresult
 ServoCSSRuleList::DeleteRule(uint32_t aIndex)