Bug 1328652: Ensure we do actual restyling work after calling RebuildAllStyleData. r=bz draft
authorEmilio Cobos Álvarez <emilio@crisal.io>
Sat, 11 Mar 2017 00:25:37 +0100
changeset 498440 c5b8df6a9394ec7da7075b2c00e2a9f21d60933b
parent 498439 dd0a71a2cbbea314e66f9f10f5aa52b2b62d59e6
child 498467 81e71ecf4a427d6d42190ce26e9d394545ab9d61
push id49184
push userbmo:emilio+bugs@crisal.io
push dateTue, 14 Mar 2017 18:54:29 +0000
reviewersbz
bugs1328652
milestone55.0a1
Bug 1328652: Ensure we do actual restyling work after calling RebuildAllStyleData. r=bz The Gecko restyle manager does this synchronously, along with a content flush. In my testing there's no need to do so, and Boris couldn't think off-hand of why, except the fact that we have this mRebuildAllStyleData thing that takes care of rebuilding the rule tree, which is quite sensitive. Also, Boris made a good point about non-inheriting anon boxes, that could technically change style. I've left a note about it too. MozReview-Commit-ID: 2lvzhxugKB0
layout/base/ServoRestyleManager.cpp
--- a/layout/base/ServoRestyleManager.cpp
+++ b/layout/base/ServoRestyleManager.cpp
@@ -75,19 +75,29 @@ ServoRestyleManager::PostRestyleEventFor
 {
   Servo_NoteExplicitHints(aElement, aRestyleHint, nsChangeHint(0));
 }
 
 void
 ServoRestyleManager::RebuildAllStyleData(nsChangeHint aExtraHint,
                                          nsRestyleHint aRestyleHint)
 {
-  // TODO(emilio, bz): We probably need to do some actual restyling here too.
-  NS_WARNING("stylo: ServoRestyleManager::RebuildAllStyleData is incomplete");
   StyleSet()->RebuildData();
+
+  // NOTE(emilio): GeckoRestlyeManager does a sync style flush, which seems
+  // not to be needed in my testing.
+  //
+  // If it is, we can just do a content flush and call ProcessPendingRestyles.
+  if (Element* root = mPresContext->Document()->GetRootElement()) {
+    PostRestyleEvent(root, aRestyleHint, aExtraHint);
+  }
+
+  // TODO(emilio, bz): Extensions can add/remove stylesheets that can affect
+  // non-inheriting anon boxes. It's not clear if we want to support that, but
+  // if we do, we need to re-selector-match them here.
 }
 
 void
 ServoRestyleManager::PostRebuildAllStyleDataEvent(nsChangeHint aExtraHint,
                                                   nsRestyleHint aRestyleHint)
 {
   NS_WARNING("stylo: ServoRestyleManager::PostRebuildAllStyleDataEvent not implemented");
 }