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
This commit is contained in:
Emilio Cobos Álvarez 2017-05-19 23:58:22 +02:00
Родитель 56e549e4af
Коммит cbebceac22
1 изменённых файлов: 35 добавлений и 0 удалений

Просмотреть файл

@ -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<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,
@ -314,6 +348,7 @@ ServoRestyleManager::ProcessPostTraversal(Element* aElement,
if (styleFrame) {
styleFrame->UpdateStyleOfOwnedAnonBoxes(*aStyleSet, aChangeList, changeHint);
UpdateFramePseudoElementStyles(styleFrame, *aStyleSet, changeHint, aChangeList);
}
}