зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1324618 part 8. Implement restyling for first-letter frames. r=emilio
MozReview-Commit-ID: IPUDD1Q6AFq
This commit is contained in:
Родитель
650a2f7bf1
Коммит
3966a1a2ea
|
@ -11715,7 +11715,8 @@ nsCSSFrameConstructor::CreateLetterFrame(nsContainerFrame* aBlockFrame,
|
|||
NS_ASSERTION(nsLayoutUtils::GetAsBlock(aBlockFrame),
|
||||
"Not a block frame?");
|
||||
|
||||
// Get style context for the first-letter-frame
|
||||
// Get style context for the first-letter-frame. Keep this in sync with
|
||||
// nsBlockFrame::UpdatePseudoElementStyles.
|
||||
nsStyleContext* parentStyleContext =
|
||||
nsFrame::CorrectStyleParentFrame(aParentFrame,
|
||||
nsCSSPseudoElements::firstLetter)->
|
||||
|
|
|
@ -5625,6 +5625,46 @@ nsBlockInFlowLineIterator::nsBlockInFlowLineIterator(nsBlockFrame* aFrame,
|
|||
*aFoundValidLine = FindValidLine();
|
||||
}
|
||||
|
||||
void
|
||||
nsBlockFrame::UpdateFirstLetterStyle(nsIFrame* aLetterFrame,
|
||||
ServoRestyleState& aRestyleState)
|
||||
{
|
||||
// Figure out what the right style parent is. This needs to match
|
||||
// nsCSSFrameConstructor::CreateLetterFrame.
|
||||
nsIFrame* inFlowFrame = aLetterFrame;
|
||||
if (inFlowFrame->GetStateBits() & NS_FRAME_OUT_OF_FLOW) {
|
||||
inFlowFrame = inFlowFrame->GetPlaceholderFrame();
|
||||
}
|
||||
nsIFrame* styleParent =
|
||||
CorrectStyleParentFrame(inFlowFrame->GetParent(),
|
||||
nsCSSPseudoElements::firstLetter);
|
||||
nsStyleContext* parentStyle = styleParent->StyleContext();
|
||||
RefPtr<nsStyleContext> firstLetterStyle =
|
||||
aRestyleState.StyleSet()
|
||||
.ResolvePseudoElementStyle(mContent->AsElement(),
|
||||
CSSPseudoElementType::firstLetter,
|
||||
parentStyle,
|
||||
nullptr);
|
||||
// Note that we don't need to worry about changehints for the continuation
|
||||
// styles: those will be handled by the styleParent already.
|
||||
RefPtr<nsStyleContext> continuationStyle =
|
||||
aRestyleState.StyleSet().ResolveStyleForFirstLetterContinuation(parentStyle);
|
||||
UpdateStyleOfOwnedChildFrame(aLetterFrame, firstLetterStyle, aRestyleState,
|
||||
Some(continuationStyle.get()));
|
||||
|
||||
// We also want to update the style on the textframe inside the first-letter.
|
||||
// We don't need to compute a changehint for this, though, since any changes
|
||||
// to it are handled by the first-letter anyway.
|
||||
nsIFrame* textFrame = aLetterFrame->PrincipalChildList().FirstChild();
|
||||
RefPtr<nsStyleContext> firstTextStyle =
|
||||
aRestyleState.StyleSet().ResolveStyleForText(textFrame->GetContent(),
|
||||
firstLetterStyle);
|
||||
textFrame->SetStyleContext(firstTextStyle);
|
||||
|
||||
// We don't need to update style for textFrame's continuations: it's already
|
||||
// set up to inherit from parentStyle, which is what we want.
|
||||
}
|
||||
|
||||
static nsIFrame*
|
||||
FindChildContaining(nsBlockFrame* aFrame, nsIFrame* aFindFrame)
|
||||
{
|
||||
|
@ -7524,6 +7564,10 @@ nsBlockFrame::UpdatePseudoElementStyles(ServoRestyleState& aRestyleState)
|
|||
ResolveBulletStyle(type, &aRestyleState.StyleSet());
|
||||
UpdateStyleOfOwnedChildFrame(bullet, newBulletStyle, aRestyleState);
|
||||
}
|
||||
|
||||
if (nsIFrame* firstLetter = GetFirstLetter()) {
|
||||
UpdateFirstLetterStyle(firstLetter, aRestyleState);
|
||||
}
|
||||
}
|
||||
|
||||
already_AddRefed<nsStyleContext>
|
||||
|
|
|
@ -923,6 +923,10 @@ protected:
|
|||
mozilla::CSSPseudoElementType aType,
|
||||
mozilla::StyleSetHandle aStyleSet);
|
||||
|
||||
// Update our first-letter styles during stylo post-traversal.
|
||||
void UpdateFirstLetterStyle(nsIFrame* aLetterFrame,
|
||||
mozilla::ServoRestyleState& aRestyleState);
|
||||
|
||||
#ifdef DEBUG
|
||||
void VerifyLines(bool aFinalCheckOK);
|
||||
void VerifyOverflowSituation();
|
||||
|
|
Загрузка…
Ссылка в новой задаче