Bug 1428164: Restyle owned anon boxes after processing children. r?bz draft
authorEmilio Cobos Álvarez <emilio@crisal.io>
Fri, 05 Jan 2018 00:56:12 +0100
changeset 716025 6d852a33adb06041b17d619bafc1b4248d1b5b03
parent 716024 21d7521c2f36d9d263016386b42cb8fae702da09
child 744927 7a7ca38f0db8f631962b2ea393abe22fde8a89f0
push id94304
push userbmo:emilio@crisal.io
push dateThu, 04 Jan 2018 23:58:01 +0000
reviewersbz
bugs1428164
milestone59.0a1
Bug 1428164: Restyle owned anon boxes after processing children. r?bz Otherwise the text post-traversal may clobber the first-letter style, and that causes the ::first-letter style to get lost. MozReview-Commit-ID: IlrGwQFPxYg
layout/base/ServoRestyleManager.cpp
--- a/layout/base/ServoRestyleManager.cpp
+++ b/layout/base/ServoRestyleManager.cpp
@@ -826,17 +826,16 @@ ServoRestyleManager::ProcessPostTraversa
     if (MOZ_UNLIKELY(displayContentsStyle)) {
       MOZ_ASSERT(!styleFrame);
       PresContext()->FrameConstructor()->
         ChangeRegisteredDisplayContentsStyleFor(aElement, upToDateContext);
     }
 
     if (styleFrame) {
       UpdateAdditionalStyleContexts(styleFrame, aRestyleState);
-      styleFrame->UpdateStyleOfOwnedAnonBoxes(childrenRestyleState);
     }
 
     if (!aElement->GetParent()) {
       // This is the root.  Update styles on the viewport as needed.
       ViewportFrame* viewport =
         do_QueryFrame(mPresContext->PresShell()->GetRootFrame());
       if (viewport) {
         // NB: The root restyle state, not the one for our children!
@@ -886,20 +885,21 @@ ServoRestyleManager::ProcessPostTraversa
     }
   }
 
   // We want to update frame pseudo-element styles after we've traversed our
   // kids, because some of those updates (::first-line/::first-letter) need to
   // modify the styles of the kids, and the child traversal above would just
   // clobber those modifications.
   if (styleFrame) {
-    // Process anon box wrapper frames before ::first-line bits.
+    // Process anon boxes and other pseudos before ::first-line bits.
     childrenRestyleState.ProcessWrapperRestyles(styleFrame);
 
     if (wasRestyled) {
+      styleFrame->UpdateStyleOfOwnedAnonBoxes(childrenRestyleState);
       styleFrame->UpdatePseudoElementStylesIfNeeded(childrenRestyleState);
     } else if (traverseElementChildren &&
                styleFrame->IsFrameOfType(nsIFrame::eBlockFrame)) {
       // Even if we were not restyled, if we're a block with a first-line and
       // one of our descendant elements which is on the first line was restyled,
       // we need to update the styles of things on the first line, because
       // they're wrong now.
       //