Bug 1364871: Add a function to update frame pseudo-element styles during the post-traversal, and restyle bullet frames. r?heycam draft
authorEmilio Cobos Álvarez <emilio@crisal.io>
Fri, 19 May 2017 23:58:22 +0200
changeset 581948 218b85725b795a50c667c1334e78fbad5f9ef05a
parent 581947 936832cb3366336ba8f1d6facec31fb9c03951b4
child 581949 c31a43a7f29c2219027b5edf498c40d0a82c39d9
child 581954 a99c98dc655d121efa7b4d1a65cd531c8092ae56
push id59918
push userbmo:emilio+bugs@crisal.io
push dateSat, 20 May 2017 08:21:51 +0000
reviewersheycam
bugs1364871
milestone55.0a1
Bug 1364871: Add a function to update frame pseudo-element styles during the post-traversal, and restyle bullet frames. r?heycam MozReview-Commit-ID: 9m0jqmxjOb6
layout/base/ServoRestyleManager.cpp
--- a/layout/base/ServoRestyleManager.cpp
+++ b/layout/base/ServoRestyleManager.cpp
@@ -7,16 +7,18 @@
 #include "mozilla/ServoRestyleManager.h"
 
 #include "mozilla/DocumentStyleRootIterator.h"
 #include "mozilla/ServoBindings.h"
 #include "mozilla/ServoStyleSet.h"
 #include "mozilla/Unused.h"
 #include "mozilla/dom/ChildIterator.h"
 #include "mozilla/dom/ElementInlines.h"
+#include "nsBlockFrame.h"
+#include "nsBulletFrame.h"
 #include "nsContentUtils.h"
 #include "nsCSSFrameConstructor.h"
 #include "nsPrintfCString.h"
 #include "nsRefreshDriver.h"
 #include "nsStyleChangeList.h"
 
 using namespace mozilla::dom;
 
@@ -198,16 +200,48 @@ struct ServoRestyleManager::TextPostTrav
     }
 
     if (mComputedHint) {
       aChangeList.AppendChange(aTextFrame, aContent, mComputedHint);
     }
   }
 };
 
+static void
+UpdateBlockFramePseudoElements(nsBlockFrame* aFrame,
+                               ServoStyleSet& aStyleSet,
+                               nsChangeHint aChangeHintForFrame,
+                               nsStyleChangeList& aChangeList)
+{
+  if (nsBulletFrame* bullet = aFrame->GetBullet()) {
+    RefPtr<nsStyleContext> newContext =
+      aStyleSet.ResolvePseudoElementStyle(
+          aFrame->GetContent()->AsElement(),
+          bullet->StyleContext()->GetPseudoType(),
+          aFrame->StyleContext(),
+          /* aPseudoElement = */ nullptr);
+
+    aFrame->UpdateStyleOfOwnedChildFrame(bullet, newContext, aChangeList);
+  }
+}
+
+static void
+UpdateFramePseudoElementStyles(nsIFrame* aFrame,
+                               ServoStyleSet& aStyleSet,
+                               nsChangeHint aChangeHintForFrame,
+                               nsStyleChangeList& aChangeList)
+{
+  if (aFrame->IsFrameOfType(nsIFrame::eBlockFrame)) {
+    UpdateBlockFramePseudoElements(static_cast<nsBlockFrame*>(aFrame),
+                                   aStyleSet,
+                                   aChangeHintForFrame,
+                                   aChangeList);
+  }
+}
+
 void
 ServoRestyleManager::ProcessPostTraversal(Element* aElement,
                                           nsStyleContext* aParentContext,
                                           ServoStyleSet* aStyleSet,
                                           nsStyleChangeList& aChangeList)
 {
   nsIFrame* styleFrame = nsLayoutUtils::GetStyleFrame(aElement);
 
@@ -309,16 +343,17 @@ ServoRestyleManager::ProcessPostTraversa
 
     if (MOZ_UNLIKELY(displayContentsNode)) {
       MOZ_ASSERT(!styleFrame);
       displayContentsNode->mStyle = newContext;
     }
 
     if (styleFrame) {
       styleFrame->UpdateStyleOfOwnedAnonBoxes(*aStyleSet, aChangeList, changeHint);
+      UpdateFramePseudoElementStyles(styleFrame, *aStyleSet, changeHint, aChangeList);
     }
   }
 
   const bool descendantsNeedFrames =
     aElement->HasFlag(NODE_DESCENDANTS_NEED_FRAMES);
   const bool traverseElementChildren =
     aElement->HasDirtyDescendantsForServo() || descendantsNeedFrames;
   const bool traverseTextChildren = recreateContext || descendantsNeedFrames;