From cbebceac222a8bc72e5e674fd53b10c790e4ce2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Fri, 19 May 2017 23:58:22 +0200 Subject: [PATCH] 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 --HG-- extra : rebase_source : 2d0b8dbcf451b8e9bc69759681dbce1f35ad28c5 --- layout/base/ServoRestyleManager.cpp | 35 +++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/layout/base/ServoRestyleManager.cpp b/layout/base/ServoRestyleManager.cpp index 27052c26a890..ba49cefdf4a0 100644 --- a/layout/base/ServoRestyleManager.cpp +++ b/layout/base/ServoRestyleManager.cpp @@ -12,6 +12,8 @@ #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" @@ -203,6 +205,38 @@ struct ServoRestyleManager::TextPostTraversalState } }; +static void +UpdateBlockFramePseudoElements(nsBlockFrame* aFrame, + ServoStyleSet& aStyleSet, + nsChangeHint aChangeHintForFrame, + nsStyleChangeList& aChangeList) +{ + if (nsBulletFrame* bullet = aFrame->GetBullet()) { + RefPtr 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(aFrame), + aStyleSet, + aChangeHintForFrame, + aChangeList); + } +} + void ServoRestyleManager::ProcessPostTraversal(Element* aElement, nsStyleContext* aParentContext, @@ -314,6 +348,7 @@ ServoRestyleManager::ProcessPostTraversal(Element* aElement, if (styleFrame) { styleFrame->UpdateStyleOfOwnedAnonBoxes(*aStyleSet, aChangeList, changeHint); + UpdateFramePseudoElementStyles(styleFrame, *aStyleSet, changeHint, aChangeList); } }