Bug 1352763 part 4 - Pass CSS loader to Servo for insertRule. r?emilio
MozReview-Commit-ID: 6yalz8D8BWc
--- 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)