From 0da68a43f676a0b161d52c8d5636d81088da8473 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Mon, 26 Jun 2017 23:35:08 -0700 Subject: [PATCH] Bug 1324618 part 5. Add a way to pass a different style context for later continuations to UpdateStyleOfOwnedChildFrame. r=emilio We're going to want this for first-letter, because the primary frame and its continuations have different styles. MozReview-Commit-ID: 6ZjtnRWXgd9 --HG-- extra : rebase_source : 52286f984973b9d0e1a1ea51c439e599eae00a38 --- layout/generic/nsFrame.cpp | 17 ++++++++++++----- layout/generic/nsIFrame.h | 7 ++++++- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/layout/generic/nsFrame.cpp b/layout/generic/nsFrame.cpp index 7037bd28916e..da16ff113916 100644 --- a/layout/generic/nsFrame.cpp +++ b/layout/generic/nsFrame.cpp @@ -10245,9 +10245,11 @@ nsIFrame::UpdateStyleOfChildAnonBox(nsIFrame* aChildFrame, } nsChangeHint -nsIFrame::UpdateStyleOfOwnedChildFrame(nsIFrame* aChildFrame, - nsStyleContext* aNewStyleContext, - ServoRestyleState& aRestyleState) +nsIFrame::UpdateStyleOfOwnedChildFrame( + nsIFrame* aChildFrame, + nsStyleContext* aNewStyleContext, + ServoRestyleState& aRestyleState, + const Maybe& aContinuationStyleContext) { // Figure out whether we have an actual change. It's important that we do // this, for several reasons: @@ -10276,8 +10278,13 @@ nsIFrame::UpdateStyleOfOwnedChildFrame(nsIFrame* aChildFrame, aChildFrame, aChildFrame->GetContent(), childHint); } - for (nsIFrame* kid = aChildFrame; kid; kid = kid->GetNextContinuation()) { - kid->SetStyleContext(aNewStyleContext); + aChildFrame->SetStyleContext(aNewStyleContext); + nsStyleContext* continuationStyle = + aContinuationStyleContext ? *aContinuationStyleContext : aNewStyleContext; + for (nsIFrame* kid = aChildFrame->GetNextContinuation(); + kid; + kid = kid->GetNextContinuation()) { + kid->SetStyleContext(continuationStyle); } return childHint; diff --git a/layout/generic/nsIFrame.h b/layout/generic/nsIFrame.h index cae792d3b588..8c9d7737900d 100644 --- a/layout/generic/nsIFrame.h +++ b/layout/generic/nsIFrame.h @@ -3329,11 +3329,16 @@ public: // `aChildFrame`, and takes care of updating it, calling CalcStyleDifference, // and adding to the change list as appropriate. // + // If aContinuationStyleContext is not Nothing, it should be used for + // continuations instead of aNewStyleContext. In either case, changehints are + // only computed based on aNewStyleContext. + // // Returns the generated change hint for the frame. nsChangeHint UpdateStyleOfOwnedChildFrame( nsIFrame* aChildFrame, nsStyleContext* aNewStyleContext, - mozilla::ServoRestyleState& aRestyleState); + mozilla::ServoRestyleState& aRestyleState, + const Maybe& aContinuationStyleContext = Nothing()); struct OwnedAnonBox {