Bug 1861716 - Ensure we don't try to apply text-indent within ruby text container frame. r=TYLin

Differential Revision: https://phabricator.services.mozilla.com/D192164
This commit is contained in:
Jonathan Kew
2023-10-31 08:49:27 +00:00
parent 4350337ecb
commit 44cf9fe64c
2 changed files with 30 additions and 19 deletions

View File

@@ -207,26 +207,28 @@ void nsLineLayout::BeginLineReflow(nscoord aICoord, nscoord aBCoord,
// Determine if this is the first line of the block (or first after a hard
// line-break, if `each-line` is in effect).
nsIFrame* containerFrame = LineContainerFrame();
bool isFirstLineOrAfterHardBreak = [&] {
if (mLineNumber > 0) {
return mStyleText->mTextIndent.each_line && GetLine() &&
!GetLine()->prev()->IsLineWrapped();
}
if (nsBlockFrame* prevBlock =
do_QueryFrame(containerFrame->GetPrevInFlow())) {
return mStyleText->mTextIndent.each_line &&
(prevBlock->Lines().empty() ||
!prevBlock->LinesEnd().prev()->IsLineWrapped());
}
return true;
}();
if (!containerFrame->IsRubyTextContainerFrame()) {
bool isFirstLineOrAfterHardBreak = [&] {
if (mLineNumber > 0) {
return mStyleText->mTextIndent.each_line && GetLine() &&
!GetLine()->prev()->IsLineWrapped();
}
if (nsBlockFrame* prevBlock =
do_QueryFrame(containerFrame->GetPrevInFlow())) {
return mStyleText->mTextIndent.each_line &&
(prevBlock->Lines().empty() ||
!prevBlock->LinesEnd().prev()->IsLineWrapped());
}
return true;
}();
// Resolve and apply the text-indent value if this line requires it.
// The `hanging` option inverts which lines are to be indented.
if (isFirstLineOrAfterHardBreak != mStyleText->mTextIndent.hanging) {
nscoord pctBasis = mLineContainerRI.ComputedISize();
mTextIndent = mStyleText->mTextIndent.length.Resolve(pctBasis);
psd->mICoord += mTextIndent;
// Resolve and apply the text-indent value if this line requires it.
// The `hanging` option inverts which lines are to be indented.
if (isFirstLineOrAfterHardBreak != mStyleText->mTextIndent.hanging) {
nscoord pctBasis = mLineContainerRI.ComputedISize();
mTextIndent = mStyleText->mTextIndent.length.Resolve(pctBasis);
psd->mICoord += mTextIndent;
}
}
PerFrameData* pfd = NewPerFrameData(containerFrame);