Bug 1290276 Part 7 - Restyle element and its descendant after loading XBL bindings. draft
authorTing-Yu Lin <tlin@mozilla.com>
Mon, 05 Jun 2017 14:21:32 +0800
changeset 590811 325720c90cd7b862d641b755697bb5e0bf64f2a0
parent 590810 c8deafd82c15cc5480061b8be75086575cfb8575
child 590812 68bd31daa555c840e8442c673063b26e316d4a39
push id62831
push userbmo:tlin@mozilla.com
push dateThu, 08 Jun 2017 03:44:02 +0000
bugs1290276
milestone55.0a1
Bug 1290276 Part 7 - Restyle element and its descendant after loading XBL bindings. MozReview-Commit-ID: 1WiioW3xxMX
layout/base/nsCSSFrameConstructor.cpp
--- a/layout/base/nsCSSFrameConstructor.cpp
+++ b/layout/base/nsCSSFrameConstructor.cpp
@@ -5814,24 +5814,37 @@ nsCSSFrameConstructor::AddFrameConstruct
         return;
 
       if (newPendingBinding->mBinding) {
         pendingBinding = newPendingBinding;
         // aState takes over owning newPendingBinding
         aState.AddPendingBinding(newPendingBinding.forget());
       }
 
-      if (aContent->IsStyledByServo()) {
-        NS_WARNING("stylo: Skipping Unsupported binding re-resolve. This needs fixing.");
-        resolveStyle = false;
-      }
-
       if (resolveStyle) {
-        styleContext =
-          ResolveStyleContext(styleContext->GetParent(), aContent, &aState);
+        if (aContent->IsStyledByServo()) {
+          Element* element = aContent->AsElement();
+          ServoStyleSet* styleSet = mPresShell->StyleSet()->AsServo();
+
+          // XXX: We should have a better way to restyle ourselves.
+          ServoRestyleManager::ClearServoDataFromSubtree(element);
+          styleSet->StyleNewSubtree(element);
+
+          // Servo's should_traverse_children() in traversal.rs skips
+          // styling descendants of elements with a -moz-binding the
+          // first time. Thus call StyleNewChildren() again.
+          styleSet->StyleNewChildren(element);
+
+          styleContext =
+            styleSet->ResolveStyleFor(element, nullptr, LazyComputeBehavior::Allow);
+        } else {
+          styleContext =
+            ResolveStyleContext(styleContext->GetParent(), aContent, &aState);
+        }
+
         display = styleContext->StyleDisplay();
         aStyleContext = styleContext;
       }
 
       aTag = mDocument->BindingManager()->ResolveTag(aContent, &aNameSpaceID);
     } else if (display->mBinding.ForceGet()) {
       if (aContent->IsStyledByServo()) {
         // Servo's should_traverse_children skips styling descendants of