[LFC][IFC] Do not text-align: justify the runs on the current line if they are follow...
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 7 Mar 2020 16:06:35 +0000 (16:06 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 7 Mar 2020 16:06:35 +0000 (16:06 +0000)
https://bugs.webkit.org/show_bug.cgi?id=208761
<rdar://problem/59825136>

Reviewed by Antti Koivisto.

Source/WebCore:

https://www.w3.org/TR/css-text-3/#text-align-property
"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."

Test: fast/text/text-align-justify-and-forced-line-break.html

* layout/inlineformatting/InlineLineBuilder.cpp:
(WebCore::Layout::LineBuilder::alignHorizontally):

LayoutTests:

* fast/text/text-align-justify-and-forced-line-break-expected.html: Added.
* fast/text/text-align-justify-and-forced-line-break.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@258070 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/text/text-align-justify-and-forced-line-break-expected.html [new file with mode: 0644]
LayoutTests/fast/text/text-align-justify-and-forced-line-break.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/layout/inlineformatting/InlineLineBuilder.cpp

index 47ddcb6..3654488 100644 (file)
@@ -1,3 +1,14 @@
+2020-03-07  Zalan Bujtas  <zalan@apple.com>
+
+        [LFC][IFC] Do not text-align: justify the runs on the current line if they are followed by a forced break
+        https://bugs.webkit.org/show_bug.cgi?id=208761
+        <rdar://problem/59825136>
+
+        Reviewed by Antti Koivisto.
+
+        * fast/text/text-align-justify-and-forced-line-break-expected.html: Added.
+        * fast/text/text-align-justify-and-forced-line-break.html: Added.
+
 2020-03-06  Rob Buis  <rbuis@igalia.com>
 
         Fix original-crossorigin-applied.sub.html WPT test
diff --git a/LayoutTests/fast/text/text-align-justify-and-forced-line-break-expected.html b/LayoutTests/fast/text/text-align-justify-and-forced-line-break-expected.html
new file mode 100644 (file)
index 0000000..55d3abb
--- /dev/null
@@ -0,0 +1,11 @@
+<style>
+div {
+    width: 200px;
+    background-color: yellow;
+    font-size: 16px;
+}
+</style>
+<div style="text-align: justify">Unless otherwise specified by text-align-last, the</dov>
+<div>last line before a forced break</div>
+<div>or the end of the block</div>
+<div>is start-aligned.</divv>
diff --git a/LayoutTests/fast/text/text-align-justify-and-forced-line-break.html b/LayoutTests/fast/text/text-align-justify-and-forced-line-break.html
new file mode 100644 (file)
index 0000000..87ff192
--- /dev/null
@@ -0,0 +1,9 @@
+<style>
+div {
+    text-align: justify;
+    width: 200px;
+    background-color: yellow;
+    font-size: 16px;
+}
+</style>
+<div>Unless otherwise specified by text-align-last, the<br> last line before a forced break<br> or the end of the block<br> is start-aligned.</divv>
index e0e7eac..96defc4 100644 (file)
@@ -1,3 +1,21 @@
+2020-03-07  Zalan Bujtas  <zalan@apple.com>
+
+        [LFC][IFC] Do not text-align: justify the runs on the current line if they are followed by a forced break
+        https://bugs.webkit.org/show_bug.cgi?id=208761
+        <rdar://problem/59825136>
+
+        Reviewed by Antti Koivisto.
+
+        https://www.w3.org/TR/css-text-3/#text-align-property
+        "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."
+
+        Test: fast/text/text-align-justify-and-forced-line-break.html
+
+        * layout/inlineformatting/InlineLineBuilder.cpp:
+        (WebCore::Layout::LineBuilder::alignHorizontally):
+
 2020-03-07  Konstantin Tokarev  <annulen@yandex.ru>
 
         REGRESSION(r257975): [GTK][WPE] Build failure after a clean build
index 64a00e5..76017c2 100644 (file)
@@ -233,7 +233,7 @@ void LineBuilder::justifyRuns(InlineLayoutUnit availableWidth)
     }
 }
 
-void LineBuilder::alignHorizontally(const HangingContent& hangingContent, IsLastLineWithInlineContent lastLine)
+void LineBuilder::alignHorizontally(const HangingContent& hangingContent, IsLastLineWithInlineContent isLastLine)
 {
     ASSERT(!m_isIntrinsicSizing);
     auto availableWidth = this->availableWidth() + hangingContent.width();
@@ -241,8 +241,9 @@ void LineBuilder::alignHorizontally(const HangingContent& hangingContent, IsLast
         return;
 
     if (isTextAlignJustify()) {
-        // Do not justify align the last line.
-        if (lastLine == IsLastLineWithInlineContent::No)
+        // Unless otherwise specified by text-align-last, the last line before a forced break or
+        // the end of the block is start-aligned.
+        if (!m_runs.last().isLineBreak() && isLastLine == IsLastLineWithInlineContent::No)
             justifyRuns(availableWidth);
         return;
     }