Bug 1352763 part 4 - Pass CSS loader to Servo for insertRule. r?emilio draft
authorXidorn Quan <me@upsuper.org>
Mon, 03 Apr 2017 20:04:32 +1000
changeset 554968 be5460e95b5a1c919ca5b233fbe2faccc091dd34
parent 554967 52a8f13edb283e1e6fbe2ff6ffa1dc8953580b91
child 554969 9219c7ea64baeda2f0ff684cb9a855343127bb64
push id52103
push userxquan@mozilla.com
push dateMon, 03 Apr 2017 11:21:25 +0000
reviewersemilio
bugs1352763
milestone55.0a1
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)