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
--- 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;