- Revision
- 295265
- Author
- [email protected]
- Date
- 2022-06-04 07:01:53 -0700 (Sat, 04 Jun 2022)
Log Message
[IFC] Support text-align-last: justify
https://bugs.webkit.org/show_bug.cgi?id=241301
<rdar://94384891>
Reviewed by Alan Bujtas.
`text-align: justify` already worked for the legacy line layout, but not in IFC. Add support for it and a corresponding WPT.
Also removed `text-justify: none` handling from legacy line layout, since IFC doesn't handle it, and legacy line layout also doesn't handle it correctly either. Thankfully `text-justify` is disabled by default.
* LayoutTests/TestExpectations:
* LayoutTests/fast/css3-text/css3-text-align-last/text-align-last-with-text-align-justify-expected.html: Removed.
* LayoutTests/fast/css3-text/css3-text-align-last/text-align-last-with-text-align-justify.html: Removed.
Removed tests that were wrong, compared with other browsers to verify.
* LayoutTests/imported/w3c/resources/resource-files.json:
* LayoutTests/imported/w3c/web-platform-tests/css/css-text/text-align/text-align-last-expected.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-text/text-align/text-align-last-ref.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-text/text-align/text-align-last.html: Added.
WPT is from Blink: https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/web_tests/fast/css3-text/css3-text-align-last/text-align-last.html;drc=77578ccb4082ae20a9326d9e673225f1189ebb63
Upstream WPT PR: https://github.com/web-platform-tests/wpt/pull/34308
* Source/WebCore/layout/formattingContexts/inline/InlineLine.cpp:
(WebCore::Layout::Line::applyRunExpansion):
* Source/WebCore/layout/formattingContexts/inline/InlineLineBuilder.cpp:
(WebCore::Layout::LineBuilder::close):
* Source/WebCore/rendering/LegacyLineLayout.cpp:
(WebCore::LegacyLineLayout::textAlignmentForLine const):
Canonical link: https://commits.webkit.org/251311@main
Modified Paths
Added Paths
Removed Paths
- trunk/LayoutTests/fast/css3-text/css3-text-align-last/
Diff
Modified: trunk/LayoutTests/TestExpectations (295264 => 295265)
--- trunk/LayoutTests/TestExpectations 2022-06-04 13:23:27 UTC (rev 295264)
+++ trunk/LayoutTests/TestExpectations 2022-06-04 14:01:53 UTC (rev 295265)
@@ -2906,8 +2906,6 @@
imported/w3c/web-platform-tests/secure-contexts/basic-dedicated-worker.https.html [ Skip ]
imported/w3c/web-platform-tests/secure-contexts/basic-popup-and-iframe-tests.https.html [ Skip ]
-# text-align-last
-webkit.org/b/76173 fast/css3-text/css3-text-align-last/text-align-last-with-text-align-justify.html [ ImageOnlyFailure ]
# text-justify
webkit.org/b/99945 fast/css3-text/css3-text-justify/text-justify-none.html [ ImageOnlyFailure ]
webkit.org/b/99945 imported/w3c/web-platform-tests/css/css-text/text-justify/text-justify-001.html [ ImageOnlyFailure ]
@@ -2920,6 +2918,7 @@
webkit.org/b/99945 imported/w3c/web-platform-tests/css/css-text/text-justify/text-justify-distribute-001.html [ ImageOnlyFailure ]
webkit.org/b/99945 imported/w3c/web-platform-tests/css/css-text/text-justify/text-justify-inter-character-001.html [ ImageOnlyFailure ]
webkit.org/b/99945 imported/w3c/web-platform-tests/css/css-text/text-justify/text-justify-inter-word-001.html [ ImageOnlyFailure ]
+webkit.org/b/99945 imported/w3c/web-platform-tests/css/css-text/text-justify/text-justify-none-001.html [ ImageOnlyFailure ]
# Link prefetch is disabled by default (needs ENABLE_LINK_PREFETCH)
webkit.org/b/3652 fast/dom/HTMLLinkElement/link-and-subresource-test.html [ Skip ]
Modified: trunk/LayoutTests/imported/w3c/resources/resource-files.json (295264 => 295265)
--- trunk/LayoutTests/imported/w3c/resources/resource-files.json 2022-06-04 13:23:27 UTC (rev 295264)
+++ trunk/LayoutTests/imported/w3c/resources/resource-files.json 2022-06-04 14:01:53 UTC (rev 295265)
@@ -1165,6 +1165,7 @@
"web-platform-tests/css/css-text/text-align/text-align-end-020.html",
"web-platform-tests/css/css-text/text-align/text-align-end-021.html",
"web-platform-tests/css/css-text/text-align/text-align-inline-end-crash.html",
+ "web-platform-tests/css/css-text/text-align/text-align-last-ref.html",
"web-platform-tests/css/css-text/text-align/text-align-last-001.html",
"web-platform-tests/css/css-text/text-align/text-align-last-002.html",
"web-platform-tests/css/css-text/text-align/text-align-last-003.html",
Added: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-text/text-align/text-align-last-expected.html (0 => 295265)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-text/text-align/text-align-last-expected.html (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-text/text-align/text-align-last-expected.html 2022-06-04 14:01:53 UTC (rev 295265)
@@ -0,0 +1,42 @@
+<!DOCTYPE html>
+<html>
+<head>
+<link rel="stylesheet" href=""
+<style>
+.test {
+ width: 208px;
+ border: 1px solid #000000;
+ font-family: Ahem, monospace;
+ font-size: 1em;
+}
+</style>
+</head>
+<body>
+<div>
+This test checks that text-align-last property works properly.<br/>
+</div>
+<div class="test" style="text-align: end">start end</div>
+
+<div class="test" style="text-align: start">end start</div>
+
+<div class="test" style="text-align: right">left right</div>
+
+<div class="test" style="text-align: left">right left</div>
+
+<div class="test" style="text-align: left">center left</div>
+
+<div class="test" style="text-align: start">start auto</div>
+
+<div class="test" style="text-align: end">end auto</div>
+
+<div class="test" style="text-align: left">left auto</div>
+
+<div class="test" style="text-align: right">right auto</div>
+
+<div class="test" style="text-align: center">center auto</div>
+
+<div class="test" style="text-align: start">justify auto</div>
+
+<div class="test" style="text-align: start">auto justify</div>
+</body>
+</html>
Added: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-text/text-align/text-align-last-ref.html (0 => 295265)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-text/text-align/text-align-last-ref.html (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-text/text-align/text-align-last-ref.html 2022-06-04 14:01:53 UTC (rev 295265)
@@ -0,0 +1,42 @@
+<!DOCTYPE html>
+<html>
+<head>
+<link rel="stylesheet" href=""
+<style>
+.test {
+ width: 208px;
+ border: 1px solid #000000;
+ font-family: Ahem, monospace;
+ font-size: 1em;
+}
+</style>
+</head>
+<body>
+<div>
+This test checks that text-align-last property works properly.<br/>
+</div>
+<div class="test" style="text-align: end">start end</div>
+
+<div class="test" style="text-align: start">end start</div>
+
+<div class="test" style="text-align: right">left right</div>
+
+<div class="test" style="text-align: left">right left</div>
+
+<div class="test" style="text-align: left">center left</div>
+
+<div class="test" style="text-align: start">start auto</div>
+
+<div class="test" style="text-align: end">end auto</div>
+
+<div class="test" style="text-align: left">left auto</div>
+
+<div class="test" style="text-align: right">right auto</div>
+
+<div class="test" style="text-align: center">center auto</div>
+
+<div class="test" style="text-align: start">justify auto</div>
+
+<div class="test" style="text-align: start">auto justify</div>
+</body>
+</html>
Added: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-text/text-align/text-align-last.html (0 => 295265)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-text/text-align/text-align-last.html (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-text/text-align/text-align-last.html 2022-06-04 14:01:53 UTC (rev 295265)
@@ -0,0 +1,45 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>text-align-last</title>
+<link rel="help" href=""
+<link rel="match" href=""
+<link rel="stylesheet" href=""
+<style>
+.test {
+ width: 208px;
+ border: 1px solid #000000;
+ font-family: Ahem, monospace;
+ font-size: 1em;
+}
+</style>
+</head>
+<body>
+<div>
+This test checks that text-align-last property works properly.<br/>
+</div>
+<div class="test" style="text-align: start; text-align-last: end">start end</div>
+
+<div class="test" style="text-align: end; text-align-last: start">end start</div>
+
+<div class="test" style="text-align: left; text-align-last: right">left right</div>
+
+<div class="test" style="text-align: right; text-align-last: left">right left</div>
+
+<div class="test" style="text-align: center; text-align-last: left">center left</div>
+
+<div class="test" style="text-align: start; text-align-last: auto">start auto</div>
+
+<div class="test" style="text-align: end; text-align-last: auto">end auto</div>
+
+<div class="test" style="text-align: left; text-align-last: auto">left auto</div>
+
+<div class="test" style="text-align: right; text-align-last: auto">right auto</div>
+
+<div class="test" style="text-align: center; text-align-last: auto">center auto</div>
+
+<div class="test" style="text-align: justify; text-align-last: auto">justify auto</div>
+
+<div class="test" style="text-align: auto; text-align-last: justify">auto justify</div>
+</body>
+</html>
Modified: trunk/Source/WebCore/layout/formattingContexts/inline/InlineLine.cpp (295264 => 295265)
--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineLine.cpp 2022-06-04 13:23:27 UTC (rev 295264)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineLine.cpp 2022-06-04 14:01:53 UTC (rev 295265)
@@ -92,7 +92,7 @@
void Line::applyRunExpansion(InlineLayoutUnit horizontalAvailableSpace)
{
- ASSERT(formattingContext().root().style().textAlign() == TextAlignMode::Justify);
+ ASSERT(formattingContext().root().style().textAlign() == TextAlignMode::Justify || formattingContext().root().style().textAlignLast() == TextAlignLast::Justify);
// Text is justified according to the method specified by the text-justify property,
// in order to exactly fill the line box. Unless otherwise specified by text-align-last,
// the last line before a forced break or the end of the block is start-aligned.
Modified: trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBuilder.cpp (295264 => 295265)
--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBuilder.cpp 2022-06-04 13:23:27 UTC (rev 295264)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBuilder.cpp 2022-06-04 14:01:53 UTC (rev 295265)
@@ -570,8 +570,8 @@
// On each line, reset the embedding level of any sequence of whitespace characters at the end of the line
// to the paragraph embedding level
m_line.resetBidiLevelForTrailingWhitespace(rootStyle.isLeftToRightDirection() ? UBIDI_LTR : UBIDI_RTL);
- auto horizontalAlignment = rootStyle.textAlign();
- auto runsExpandHorizontally = horizontalAlignment == TextAlignMode::Justify && !isLastLine;
+ auto runsExpandHorizontally = isLastLine ? rootStyle.textAlignLast() == TextAlignLast::Justify
+ : rootStyle.textAlign() == TextAlignMode::Justify;
if (runsExpandHorizontally)
m_line.applyRunExpansion(horizontalAvailableSpace);
auto lineEndsWithHyphen = false;
Modified: trunk/Source/WebCore/rendering/LegacyLineLayout.cpp (295264 => 295265)
--- trunk/Source/WebCore/rendering/LegacyLineLayout.cpp 2022-06-04 13:23:27 UTC (rev 295264)
+++ trunk/Source/WebCore/rendering/LegacyLineLayout.cpp 2022-06-04 14:01:53 UTC (rev 295265)
@@ -360,9 +360,6 @@
return *overrideAlignment;
TextAlignMode alignment = style().textAlign();
- TextJustify textJustify = style().textJustify();
- if (alignment == TextAlignMode::Justify && textJustify == TextJustify::None)
- return style().direction() == TextDirection::LTR ? TextAlignMode::Left : TextAlignMode::Right;
if (endsWithSoftBreak)
return alignment;