Bug 1253840 - patch 1 - Allow text-align:justify to take effect when using white-space:pre-wrap. r=emilio

The CSS Text 3 spec allows this (CSS2 didn't), and other browsers
support it, so for better webcompat/interoperability, we should do the
same. Tests will need updating accordingly.

This first patch enables the property to take effect, but the resulting
layout is not yet correct because the (non-collapsed) whitespace at line
wrap positions needs to be forcibly "hung" into the margin for correct
justification; see following patch.

Differential Revision: https://phabricator.services.mozilla.com/D178210
This commit is contained in:
Jonathan Kew 2023-05-21 13:17:42 +00:00
Родитель ca6c4a3c4f
Коммит d76893ccc8
1 изменённых файлов: 2 добавлений и 4 удалений

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

@ -2229,8 +2229,7 @@ already_AddRefed<gfxTextRun> BuildTextRunsScanner::BuildTextRunForFrames(
flags |= GetSpacingFlags(f);
nsTextFrameUtils::CompressionMode compression =
GetCSSWhitespaceToCompressionMode(f, textStyle);
if ((enabledJustification || f->ShouldSuppressLineBreak()) &&
!textStyle->WhiteSpaceIsSignificant() && !isSVG) {
if ((enabledJustification || f->ShouldSuppressLineBreak()) && !isSVG) {
flags |= gfx::ShapedTextFlags::TEXT_ENABLE_SPACING;
}
fontStyle = f->StyleFont();
@ -9499,8 +9498,7 @@ void nsTextFrame::ReflowText(nsLineLayout& aLineLayout, nscoord aAvailableWidth,
}
// Compute space and letter counts for justification, if required
if (!textStyle->WhiteSpaceIsSignificant() &&
(lineContainer->StyleText()->mTextAlign == StyleTextAlign::Justify ||
if ((lineContainer->StyleText()->mTextAlign == StyleTextAlign::Justify ||
lineContainer->StyleText()->mTextAlignLast ==
StyleTextAlignLast::Justify ||
shouldSuppressLineBreak) &&