From a8f560ec17b8e8920712da37f311110b4905230d Mon Sep 17 00:00:00 2001 From: Ting-Yu Lin Date: Mon, 5 Jun 2017 14:21:32 +0800 Subject: [PATCH] Bug 1290276 Part 7 - Restyle element and its descendant after loading XBL bindings. r=heycam MozReview-Commit-ID: 1WiioW3xxMX --HG-- extra : rebase_source : fd0820151911e7c1b69ed2524282ecbd72a42c57 --- layout/base/nsCSSFrameConstructor.cpp | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index a92bca1672b6..994dd7e73a8c 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -5819,14 +5819,27 @@ nsCSSFrameConstructor::AddFrameConstructionItemsInternal(nsFrameConstructorState 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; }