Bug 1364871: Factor out some code from UpdateStyleOfChildAnonBox into UpdateStyleOfOwnedChildFrame. r?heycam
MozReview-Commit-ID: 24U6PmmqCeP
--- a/layout/generic/nsFrame.cpp
+++ b/layout/generic/nsFrame.cpp
@@ -10233,45 +10233,58 @@ nsFrame::UpdateStyleOfChildAnonBox(nsIFr
MOZ_ASSERT(nsCSSAnonBoxes::IsAnonBox(pseudo), "Child is not an anon box?");
MOZ_ASSERT(!nsCSSAnonBoxes::IsNonInheritingAnonBox(pseudo),
"Why did the caller bother calling us?");
// Anon boxes inherit from their parent; that's us.
RefPtr<nsStyleContext> newContext =
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
// this, for several reasons:
//
// 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
// 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.
nsChangeHint childHint = aChildFrame->StyleContext()->CalcStyleDifference(
- newContext,
+ aNewStyleContext,
&equalStructs,
&samePointerStructs);
if (childHint) {
if (childHint & nsChangeHint_ReconstructFrame) {
// If we generate a reconstruct here, remove any non-reconstruct hints we
// may have already generated for this content.
aChangeList.PopChangesForContent(aChildFrame->GetContent());
}
aChangeList.AppendChange(aChildFrame, aChildFrame->GetContent(), childHint);
}
for (nsIFrame* kid = aChildFrame; kid; kid = kid->GetNextContinuation()) {
- kid->SetStyleContext(newContext);
- }
-
- // Now that we've updated the style on aChildFrame, check whether it itself
- // has anon boxes to deal with.
- aChildFrame->UpdateStyleOfOwnedAnonBoxes(aStyleSet, aChangeList, childHint);
+ kid->SetStyleContext(aNewStyleContext);
+ }
+
+ return childHint;
}
/* static */ void
nsIFrame::AddInPopupStateBitToDescendants(nsIFrame* aFrame)
{
if (!aFrame->HasAnyStateBits(NS_FRAME_IN_POPUP) &&
aFrame->TrackingVisibility()) {
// Assume all frames in popups are visible.
--- a/layout/generic/nsIFrame.h
+++ b/layout/generic/nsIFrame.h
@@ -3257,16 +3257,28 @@ public:
void UpdateStyleOfOwnedAnonBoxes(mozilla::ServoStyleSet& aStyleSet,
nsStyleChangeList& aChangeList,
nsChangeHint aHintForThisFrame) {
if (GetStateBits() & NS_FRAME_OWNS_ANON_BOXES) {
DoUpdateStyleOfOwnedAnonBoxes(aStyleSet, aChangeList, aHintForThisFrame);
}
}
+ // 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
* owned anon boxes.
*/
virtual void DoUpdateStyleOfOwnedAnonBoxes(mozilla::ServoStyleSet& aStyleSet,
nsStyleChangeList& aChangeList,
nsChangeHint aHintForThisFrame);