Bug 1364871: Factor out some code from UpdateStyleOfChildAnonBox into UpdateStyleOfOwnedChildFrame. r=heycam

MozReview-Commit-ID: 24U6PmmqCeP

--HG--
extra : rebase_source : bf726211d064f7e6274100267d9b1b341c2a2f95
This commit is contained in:
Emilio Cobos Álvarez 2017-05-19 23:56:02 +02:00
Родитель e60859ca4a
Коммит 56e549e4af
2 изменённых файлов: 32 добавлений и 7 удалений

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

@ -10238,17 +10238,32 @@ nsFrame::UpdateStyleOfChildAnonBox(nsIFrame* aChildFrame,
RefPtr<nsStyleContext> newContext = RefPtr<nsStyleContext> newContext =
aStyleSet.ResolveInheritingAnonymousBoxStyle(pseudo, StyleContext()); aStyleSet.ResolveInheritingAnonymousBoxStyle(pseudo, StyleContext());
nsChangeHint childHint =
UpdateStyleOfOwnedChildFrame(aChildFrame, newContext, aChangeList);
// Now that we've updated the style on aChildFrame, check whether it itself
// has anon boxes to deal with.
aChildFrame->UpdateStyleOfOwnedAnonBoxes(aStyleSet, aChangeList, childHint);
}
nsChangeHint
nsIFrame::UpdateStyleOfOwnedChildFrame(nsIFrame* aChildFrame,
nsStyleContext* aNewStyleContext,
nsStyleChangeList& aChangeList)
{
// Figure out whether we have an actual change. It's important that we do // Figure out whether we have an actual change. It's important that we do
// this, for several reasons: // this, for several reasons:
// //
// 1) Even if all the child's changes are due to properties it inherits from // 1) Even if all the child's changes are due to properties it inherits from
// us, it's possible that no one ever asked us for those style structs and // us, it's possible that no one ever asked us for those style structs and
// hence changes to them aren't reflected in aHintForThisFrame at all. // hence changes to them aren't reflected in aHintForThisFrame at all.
// 2) Extensions can add/remove stylesheets that change the styles of //
// anonymous boxed directly. // 2) Content can change stylesheets that change the styles of pseudos, and
// extensions can add/remove stylesheets that change the styles of
// anonymous boxes directly.
uint32_t equalStructs, samePointerStructs; // Not used, actually. uint32_t equalStructs, samePointerStructs; // Not used, actually.
nsChangeHint childHint = aChildFrame->StyleContext()->CalcStyleDifference( nsChangeHint childHint = aChildFrame->StyleContext()->CalcStyleDifference(
newContext, aNewStyleContext,
&equalStructs, &equalStructs,
&samePointerStructs); &samePointerStructs);
if (childHint) { if (childHint) {
@ -10261,12 +10276,10 @@ nsFrame::UpdateStyleOfChildAnonBox(nsIFrame* aChildFrame,
} }
for (nsIFrame* kid = aChildFrame; kid; kid = kid->GetNextContinuation()) { for (nsIFrame* kid = aChildFrame; kid; kid = kid->GetNextContinuation()) {
kid->SetStyleContext(newContext); kid->SetStyleContext(aNewStyleContext);
} }
// Now that we've updated the style on aChildFrame, check whether it itself return childHint;
// has anon boxes to deal with.
aChildFrame->UpdateStyleOfOwnedAnonBoxes(aStyleSet, aChangeList, childHint);
} }
/* static */ void /* static */ void

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

@ -3262,6 +3262,18 @@ public:
} }
} }
// A helper both for UpdateStyleOfChildAnonBox, and to update frame-backed
// pseudo-elements in ServoRestyleManager.
//
// This gets a style context that will be the new style context for
// `aChildFrame`, and takes care of updating it, calling CalcStyleDifference,
// and adding to the change list as appropriate.
//
// Returns the generated change hint for the frame.
nsChangeHint UpdateStyleOfOwnedChildFrame(nsIFrame* aChildFrame,
nsStyleContext* aNewStyleContext,
nsStyleChangeList& aChangeList);
/** /**
* Hook subclasses can override to actually implement updating of style of * Hook subclasses can override to actually implement updating of style of
* owned anon boxes. * owned anon boxes.