Bug 1366721: Restyle additional style contexts in ServoRestyleManager. r=heycam

I was about to assert that other non-primary frames don't have additional style
contexts everywhere, but that wouldn't make much sense, given they don't
correspond to an element we could selector-match against.

MozReview-Commit-ID: EtAQbSg6nP6

--HG--
extra : rebase_source : e9e10c53b7a69506750bd3c7c985946f7027dc30
This commit is contained in:
Emilio Cobos Álvarez 2017-07-20 18:29:14 +02:00
Родитель 2e66317b01
Коммит 821b4127c4
2 изменённых файлов: 58 добавлений и 0 удалений

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

@ -422,6 +422,58 @@ UpdateFirstLetterIfNeeded(nsIFrame* aFrame, ServoRestyleState& aRestyleState)
UpdateFirstLetterStyle(aRestyleState);
}
static void
UpdateOneAdditionalStyleContext(nsIFrame* aFrame,
uint32_t aIndex,
ServoStyleContext& aOldContext,
ServoRestyleState& aRestyleState)
{
auto pseudoType = aOldContext.GetPseudoType();
MOZ_ASSERT(pseudoType != CSSPseudoElementType::NotPseudo);
MOZ_ASSERT(
!nsCSSPseudoElements::PseudoElementSupportsUserActionState(pseudoType));
RefPtr<ServoStyleContext> newContext =
aRestyleState.StyleSet().ResolvePseudoElementStyle(
aFrame->GetContent()->AsElement(),
pseudoType,
aFrame->StyleContext()->AsServo(),
/* aPseudoElement = */ nullptr);
uint32_t equalStructs, samePointerStructs; // Not used, actually.
nsChangeHint childHint = aOldContext.CalcStyleDifference(
newContext,
&equalStructs,
&samePointerStructs);
if (!aFrame->HasAnyStateBits(NS_FRAME_OUT_OF_FLOW)) {
childHint = NS_RemoveSubsumedHints(
childHint, aRestyleState.ChangesHandledFor(*aFrame));
}
if (childHint) {
aRestyleState.ChangeList().AppendChange(
aFrame, aFrame->GetContent(), childHint);
}
aFrame->SetAdditionalStyleContext(aIndex, newContext);
}
static void
UpdateAdditionalStyleContexts(nsIFrame* aFrame,
ServoRestyleState& aRestyleState)
{
MOZ_ASSERT(aFrame);
MOZ_ASSERT(aFrame->GetContent() && aFrame->GetContent()->IsElement());
// FIXME(emilio): Consider adding a bit or something to avoid the initial
// virtual call?
uint32_t index = 0;
while (auto* oldContext = aFrame->GetAdditionalStyleContext(index)) {
UpdateOneAdditionalStyleContext(
aFrame, index++, *oldContext->AsServo(), aRestyleState);
}
}
static void
UpdateFramePseudoElementStyles(nsIFrame* aFrame,
ServoRestyleState& aRestyleState)
@ -571,6 +623,7 @@ ServoRestyleManager::ProcessPostTraversal(
// This does mean that we may be setting the wrong style context on our
// initial continuations; ::first-line fixes that up after the fact.
for (nsIFrame* f = styleFrame; f; f = f->GetNextContinuation()) {
MOZ_ASSERT_IF(f != styleFrame, !f->GetAdditionalStyleContext(0));
f->SetStyleContext(newContext);
}
@ -580,6 +633,7 @@ ServoRestyleManager::ProcessPostTraversal(
}
if (styleFrame) {
UpdateAdditionalStyleContexts(styleFrame, aRestyleState);
styleFrame->UpdateStyleOfOwnedAnonBoxes(childrenRestyleState);
}

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

@ -10257,6 +10257,9 @@ nsIFrame::UpdateStyleOfOwnedChildFrame(
ServoRestyleState& aRestyleState,
const Maybe<nsStyleContext*>& aContinuationStyleContext)
{
MOZ_ASSERT(!aChildFrame->GetAdditionalStyleContext(0),
"We don't handle additional style contexts here");
// Figure out whether we have an actual change. It's important that we do
// this, for several reasons:
//
@ -10304,6 +10307,7 @@ nsIFrame::UpdateStyleOfOwnedChildFrame(
for (nsIFrame* kid = aChildFrame->GetNextContinuation();
kid;
kid = kid->GetNextContinuation()) {
MOZ_ASSERT(!kid->GetAdditionalStyleContext(0));
kid->SetStyleContext(continuationStyle);
}