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);
}
if (resolveStyle) {
// FIXME: Should this use ResolveStyleContext? (The calls in
// this function are the only case in nsCSSFrameConstructor
// where we don't do so for the construction of a style context
// for an element.)
if (resolveStyle || styleContext->IsServo()) {
// FIXME: Should this use ResolveStyleContext? (The calls in this
// function are the only case in nsCSSFrameConstructor where we don't do
// so for the construction of a style context 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(
aDocElement, nullptr, LazyComputeBehavior::Assert);
display = styleContext->StyleDisplay();
@ -5907,11 +5911,13 @@ nsCSSFrameConstructor::AddFrameConstructionItemsInternal(nsFrameConstructorState
aState.AddPendingBinding(newPendingBinding.forget());
}
if (resolveStyle) {
// See the comment in the similar-looking block in
// ConstructDocElementFrame to see why we always re-fetch the style
// context in Servo.
if (styleContext->IsServo()) {
styleContext =
mPresShell->StyleSet()->AsServo()->ResolveServoStyle(aContent->AsElement());
} else {
} else if (resolveStyle) {
styleContext =
ResolveStyleContext(styleContext->AsGecko()->GetParent(),
aContent, &aState);
@ -5919,8 +5925,6 @@ nsCSSFrameConstructor::AddFrameConstructionItemsInternal(nsFrameConstructorState
display = styleContext->StyleDisplay();
aStyleContext = styleContext;
}
aTag = mDocument->BindingManager()->ResolveTag(aContent, &aNameSpaceID);
}
}