Commit d76893cc authored by Jonathan Kew's avatar Jonathan Kew
Browse files

Bug 1253840 - patch 1 - Allow text-align:justify to take effect when using...

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
parent ca6c4a3c
Loading
Loading
Loading
Loading
+2 −4
Original line number Diff line number Diff line
@@ -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) &&