Bug 1412714 - Don't clone inner of XBL stylesheet in Servo. r=bz

MozReview-Commit-ID: Kzrod3SBt1k

--HG--
extra : rebase_source : 4cf96063f372ffbeb6aabde396ef9fd9f547bcb7
This commit is contained in:
Xidorn Quan 2017-10-30 15:16:20 +11:00
parent e0e1cf4354
commit 2ddfdf43a2
5 changed files with 16 additions and 12 deletions

View File

@ -176,10 +176,7 @@ void
ServoStyleRuleMap::FillTableFromStyleSheet(ServoStyleSheet* aSheet)
{
if (aSheet->IsComplete()) {
// XBL stylesheets are not expected to ever change, so it's a waste
// to make its inner unique.
FillTableFromRuleList(aSheet->GetCssRulesInternal(
/* aRequireUniqueInner = */ !mStyleSet->IsForXBL()));
FillTableFromRuleList(aSheet->GetCssRulesInternal());
}
}

View File

@ -449,6 +449,7 @@ public:
// Called by StyleSheet::EnsureUniqueInner to let us know it cloned
// its inner.
void SetNeedsRestyleAfterEnsureUniqueInner() {
MOZ_ASSERT(!IsForXBL(), "Should not be cloning things for XBL stylesheet");
mNeedsRestyleAfterEnsureUniqueInner = true;
}

View File

@ -393,15 +393,10 @@ ServoStyleSheet::Clone(StyleSheet* aCloneParent,
}
ServoCSSRuleList*
ServoStyleSheet::GetCssRulesInternal(bool aRequireUniqueInner)
ServoStyleSheet::GetCssRulesInternal()
{
if (!mRuleList) {
MOZ_ASSERT(aRequireUniqueInner || !mDocument,
"Not requiring unique inner for stylesheet associated "
"with document may have undesired behavior");
if (aRequireUniqueInner) {
EnsureUniqueInner();
}
EnsureUniqueInner();
RefPtr<ServoCssRules> rawRules =
Servo_StyleSheet_GetRules(Inner()->mContents).Consume();

View File

@ -120,7 +120,7 @@ public:
// Internal GetCssRules method which do not have security check and
// completelness check.
ServoCSSRuleList* GetCssRulesInternal(bool aRequireUniqueInner = true);
ServoCSSRuleList* GetCssRulesInternal();
// Returns the stylesheet's Servo origin as an OriginFlags value.
OriginFlags GetOrigin();

View File

@ -454,6 +454,17 @@ StyleSheet::EnsureUniqueInner()
// already unique
return;
}
// If this stylesheet is for XBL with Servo, don't bother cloning
// it, as it may break ServoStyleRuleMap. XBL stylesheets are not
// supposed to change anyway.
// The mDocument check is used as a fast reject path because no
// XBL stylesheets would have associated document, but in normal
// cases, content stylesheets should usually have one.
if (!mDocument && IsServo() &&
mStyleSets.Length() == 1 &&
mStyleSets[0]->AsServo()->IsForXBL()) {
return;
}
StyleSheetInfo* clone = mInner->CloneFor(this);
MOZ_ASSERT(clone);