Bug 1418456: Yet another followup: Always re-get the style context in the servo case after loading an XBL binding to avoid tripping otherwise useful assertions. r=me

Now we always restyle the whole subtree for Servo, so we may create another
style context for the bound element.

This trips assertions if we happen to create pseudo-element styles for them.

Since that assertion is pretty useful, just re-get the style context all the
time, which is a cheap operation otherwise.

The CLOSED TREE nightmare should end. This wasn't caught in my try run because
another assertion made the crashtests stop running, apparently.

MozReview-Commit-ID: 6U0phWFvvXO
This commit is contained in:
Emilio Cobos Álvarez 2017-11-20 17:09:29 +01:00
Родитель 210e8376a8
Коммит 8025679be5
1 изменённых файлов: 21 добавлений и 17 удалений

Просмотреть файл

@ -2602,11 +2602,15 @@ nsCSSFrameConstructor::ConstructDocElementFrame(Element* aDocEle
mDocument->BindingManager()->AddToAttachedQueue(binding); mDocument->BindingManager()->AddToAttachedQueue(binding);
} }
if (resolveStyle) { if (resolveStyle || styleContext->IsServo()) {
// FIXME: Should this use ResolveStyleContext? (The calls in // FIXME: Should this use ResolveStyleContext? (The calls in this
// this function are the only case in nsCSSFrameConstructor // function are the only case in nsCSSFrameConstructor where we don't do
// where we don't do so for the construction of a style context // so for the construction of a style context for an element.)
// for an element.) //
// NOTE(emilio): In the case of Servo, even though resolveStyle returns
// false, we re-get the style context to avoid tripping otherwise-useful
// assertions when resolving pseudo-elements. Note that this operation in
// Servo is cheap.
styleContext = mPresShell->StyleSet()->ResolveStyleFor( styleContext = mPresShell->StyleSet()->ResolveStyleFor(
aDocElement, nullptr, LazyComputeBehavior::Assert); aDocElement, nullptr, LazyComputeBehavior::Assert);
display = styleContext->StyleDisplay(); display = styleContext->StyleDisplay();
@ -5907,20 +5911,20 @@ nsCSSFrameConstructor::AddFrameConstructionItemsInternal(nsFrameConstructorState
aState.AddPendingBinding(newPendingBinding.forget()); aState.AddPendingBinding(newPendingBinding.forget());
} }
if (resolveStyle) { // See the comment in the similar-looking block in
if (styleContext->IsServo()) { // ConstructDocElementFrame to see why we always re-fetch the style
styleContext = // context in Servo.
mPresShell->StyleSet()->AsServo()->ResolveServoStyle(aContent->AsElement()); if (styleContext->IsServo()) {
} else { styleContext =
styleContext = mPresShell->StyleSet()->AsServo()->ResolveServoStyle(aContent->AsElement());
ResolveStyleContext(styleContext->AsGecko()->GetParent(), } else if (resolveStyle) {
aContent, &aState); styleContext =
} ResolveStyleContext(styleContext->AsGecko()->GetParent(),
aContent, &aState);
display = styleContext->StyleDisplay();
aStyleContext = styleContext;
} }
display = styleContext->StyleDisplay();
aStyleContext = styleContext;
aTag = mDocument->BindingManager()->ResolveTag(aContent, &aNameSpaceID); aTag = mDocument->BindingManager()->ResolveTag(aContent, &aNameSpaceID);
} }
} }