Bug 1540074 - Make sure to unstyle XBL children before removing the old XBL binding. r=heycam

This bug is happening because we resolve the child of the content generating the
first-line frame inheriting from the XBL marquee's anonymous content (which
isn't affected by the all:inherit rule and thus is non-floating).

Then we go through frame construction, and remove the <marquee> binding, which
makes the anonymous content go away, but don't restyle the children again.

The correct first-letter style without the binding is floating, but we don't
realize while constructing the frame tree.

We do realize of that afterwards though, when reparenting the styles, and
inherit from the right thing, and thus get the right floating style. But there's
nothing saving us now, since the first-letter frame is in-flow already.

The fix is clearing the style of children before removing the binding, the same
way we do before adding it.

FlushStyleBindings removes the current XBL binding. That shuffles the flattened
tree. We need to ensure the styles are gone on children before that to avoid
getting into a bad state.

AutoStyleElement already does that, just slightly too late if there's a
pre-existing binding, so moving it up a bit does the trick.
This commit is contained in:
Emilio Cobos Álvarez 2019-04-02 18:50:29 +02:00
parent 16792cc14d
commit 0056555f02

View File

@ -495,6 +495,8 @@ nsresult nsXBLService::LoadBindings(Element* aElement, nsIURI* aURL,
return rv;
}
AutoStyleElement styleElement(aElement, aResolveStyle);
if (binding) {
FlushStyleBindings(aElement);
binding = nullptr;
@ -524,8 +526,6 @@ nsresult nsXBLService::LoadBindings(Element* aElement, nsIURI* aURL,
return NS_ERROR_ILLEGAL_VALUE;
}
AutoStyleElement styleElement(aElement, aResolveStyle);
// We loaded a style binding. It goes on the end.
// Install the binding on the content node.
aElement->SetXBLBinding(newBinding);