Bug 1540074 - Make sure to unstyle XBL children before removing the old XBL binding. r=heycam
authorEmilio Cobos Álvarez <emilio@crisal.io>
Tue, 02 Apr 2019 18:50:29 +0200
changeset 467702 15e33e8c7fcc7a0e868d8126cb15c65dac54e67a
parent 467701 08f895aaa82a0604bf9fae118509b6f86d341ba2
child 467904 a36718c8163e75b7aa4b2e49870a96d1bae627ff
push id112657
push useremilio@crisal.io
push dateThu, 04 Apr 2019 00:29:54 +0000
treeherdermozilla-inbound@15e33e8c7fcc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam
bugs1540074
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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.
dom/xbl/nsXBLService.cpp
--- a/dom/xbl/nsXBLService.cpp
+++ b/dom/xbl/nsXBLService.cpp
@@ -490,16 +490,18 @@ nsresult nsXBLService::LoadBindings(Elem
   nsCOMPtr<Document> document = aElement->OwnerDoc();
 
   nsAutoCString urlspec;
   nsresult rv = aURL->GetSpec(urlspec);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
+  AutoStyleElement styleElement(aElement, aResolveStyle);
+
   if (binding) {
     FlushStyleBindings(aElement);
     binding = nullptr;
   }
 
   bool ready;
   RefPtr<nsXBLBinding> newBinding;
   if (NS_FAILED(rv = GetBinding(aElement, aURL, false, aOriginPrincipal, &ready,
@@ -519,18 +521,16 @@ nsresult nsXBLService::LoadBindings(Elem
 #endif
     return NS_OK;
   }
 
   if (::IsAncestorBinding(document, aURL, aElement)) {
     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);
 
   {
     nsAutoScriptBlocker scriptBlocker;
 
     // Set the binding's bound element.