Title: [253912] trunk
Revision
253912
Author
[email protected]
Date
2019-12-25 18:06:13 -0800 (Wed, 25 Dec 2019)

Log Message

Run with offset from the content box's logical left paint its tab stop at wrong position.
https://bugs.webkit.org/show_bug.cgi?id=205595
<rdar://problem/58194698>

Reviewed by Antti Koivisto.

Source/WebCore:

Test: fast/text/tab-stops-with-offset-from-parent.html

Use the run's left offset from the line as the xPos for the TextRun. Most cases the line has only one run
with 0 offset. This patch fixes the case when the additional runs (with offset != 0) paint their tab positions at the wrong place.

* layout/integration/LayoutIntegrationLineLayout.cpp:
(WebCore::LayoutIntegration::LineLayout::paint):
* rendering/SimpleLineLayoutFunctions.cpp:
(WebCore::SimpleLineLayout::paintFlow):

LayoutTests:

* fast/text/tab-stops-with-offset-from-parent-expected.html: Added.
* fast/text/tab-stops-with-offset-from-parent.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (253911 => 253912)


--- trunk/LayoutTests/ChangeLog	2019-12-25 18:26:36 UTC (rev 253911)
+++ trunk/LayoutTests/ChangeLog	2019-12-26 02:06:13 UTC (rev 253912)
@@ -1,3 +1,14 @@
+2019-12-25  Zalan Bujtas  <[email protected]>
+
+        Run with offset from the content box's logical left paint its tab stop at wrong position.
+        https://bugs.webkit.org/show_bug.cgi?id=205595
+        <rdar://problem/58194698>
+
+        Reviewed by Antti Koivisto.
+
+        * fast/text/tab-stops-with-offset-from-parent-expected.html: Added.
+        * fast/text/tab-stops-with-offset-from-parent.html: Added.
+
 2019-12-24  Alexey Proskuryakov  <[email protected]>
 
         REGRESSION: [ Catalina wk1 ] imported/w3c/web-platform-tests/fetch/content-type/script.window.html is failing

Added: trunk/LayoutTests/fast/text/tab-stops-with-offset-from-parent-expected.html (0 => 253912)


--- trunk/LayoutTests/fast/text/tab-stops-with-offset-from-parent-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text/tab-stops-with-offset-from-parent-expected.html	2019-12-26 02:06:13 UTC (rev 253912)
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>Test: Check if the tab stop positions are computed properly when their runs are not adjacent to the parent's content box.</title>
+<style>
+pre {
+    font-size: 12px;
+}
+</style>
+</head>
+<body>
+<pre id=content>lines should match      with tabs
+lines should match      with tabs</pre>
+</body>
+</html>
\ No newline at end of file

Added: trunk/LayoutTests/fast/text/tab-stops-with-offset-from-parent.html (0 => 253912)


--- trunk/LayoutTests/fast/text/tab-stops-with-offset-from-parent.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text/tab-stops-with-offset-from-parent.html	2019-12-26 02:06:13 UTC (rev 253912)
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>Test: Check if the tab stop positions are computed properly when their runs are not adjacent to the parent's content box.</title>
+<style>
+pre {
+    font-size: 12px;
+}
+</style>
+</head>
+<body>
+<pre id=content>lines should match      with tabs
+</pre>
+</body>
+<script>
+content.appendChild(document.createTextNode("lines should match "));
+content.appendChild(document.createTextNode("	with tabs"));
+</script>
+</html>
\ No newline at end of file

Modified: trunk/Source/WebCore/ChangeLog (253911 => 253912)


--- trunk/Source/WebCore/ChangeLog	2019-12-25 18:26:36 UTC (rev 253911)
+++ trunk/Source/WebCore/ChangeLog	2019-12-26 02:06:13 UTC (rev 253912)
@@ -1,5 +1,23 @@
 2019-12-25  Zalan Bujtas  <[email protected]>
 
+        Run with offset from the content box's logical left paint its tab stop at wrong position.
+        https://bugs.webkit.org/show_bug.cgi?id=205595
+        <rdar://problem/58194698>
+
+        Reviewed by Antti Koivisto.
+
+        Test: fast/text/tab-stops-with-offset-from-parent.html
+
+        Use the run's left offset from the line as the xPos for the TextRun. Most cases the line has only one run
+        with 0 offset. This patch fixes the case when the additional runs (with offset != 0) paint their tab positions at the wrong place.
+
+        * layout/integration/LayoutIntegrationLineLayout.cpp:
+        (WebCore::LayoutIntegration::LineLayout::paint):
+        * rendering/SimpleLineLayoutFunctions.cpp:
+        (WebCore::SimpleLineLayout::paintFlow):
+
+2019-12-25  Zalan Bujtas  <[email protected]>
+
         [LFC][Painting] Fix LayoutTests/imported/w3c/web-platform-tests/css/css-text/white-space/tab-stop-threshold-001.html
         https://bugs.webkit.org/show_bug.cgi?id=205594
         <rdar://problem/58194138>

Modified: trunk/Source/WebCore/layout/displaytree/DisplayPainter.cpp (253911 => 253912)


--- trunk/Source/WebCore/layout/displaytree/DisplayPainter.cpp	2019-12-25 18:26:36 UTC (rev 253911)
+++ trunk/Source/WebCore/layout/displaytree/DisplayPainter.cpp	2019-12-26 02:06:13 UTC (rev 253912)
@@ -131,7 +131,7 @@
             auto& lineBox = displayInlineContent->lineBoxForRun(run);
             auto baselineOffset = absoluteOffset.y() + lineBox.logicalTop() + lineBox.baselineOffset();
             auto expansionContext = textContext->expansion();
-            auto textRun = TextRun { textContext->content(), run.logicalLeft(),
+            auto textRun = TextRun { textContext->content(), run.logicalLeft() - lineBox.logicalLeft(),
                 expansionContext ? expansionContext->horizontalExpansion : 0,
                 expansionContext ? expansionContext->behavior : DefaultExpansion };
             textRun.setTabSize(!style.collapseWhiteSpace(), style.tabSize());

Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp (253911 => 253912)


--- trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp	2019-12-25 18:26:36 UTC (rev 253911)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp	2019-12-26 02:06:13 UTC (rev 253912)
@@ -265,8 +265,7 @@
         String textWithHyphen;
         if (textContext.needsHyphen())
             textWithHyphen = makeString(textContext.content(), style.hyphenString());
-        // x position indicates the line offset from the rootbox. It's always 0 in case of integrated line layout setup.
-        TextRun textRun { !textWithHyphen.isEmpty() ? textWithHyphen : textContext.content(), 0, horizontalExpansion, behavior };
+        TextRun textRun { !textWithHyphen.isEmpty() ? textWithHyphen : textContext.content(), run.logicalLeft() - lineBox.logicalLeft(), horizontalExpansion, behavior };
         textRun.setTabSize(!style.collapseWhiteSpace(), style.tabSize());
         FloatPoint textOrigin { rect.x() + paintOffset.x(), roundToDevicePixel(baselineOffset, deviceScaleFactor) };
 

Modified: trunk/Source/WebCore/rendering/SimpleLineLayoutFunctions.cpp (253911 => 253912)


--- trunk/Source/WebCore/rendering/SimpleLineLayoutFunctions.cpp	2019-12-25 18:26:36 UTC (rev 253911)
+++ trunk/Source/WebCore/rendering/SimpleLineLayoutFunctions.cpp	2019-12-26 02:06:13 UTC (rev 253912)
@@ -131,8 +131,10 @@
         String textWithHyphen;
         if (run.hasHyphen())
             textWithHyphen = run.textWithHyphen();
-        // x position indicates the line offset from the rootbox. It's always 0 in case of simple line layout.
-        TextRun textRun { run.hasHyphen() ? textWithHyphen : run.text(), 0, run.expansion(), run.expansionBehavior() };
+        // xPos is relative to the line box's logical left.
+        // We don't have any line geometry here in SLL, so let's get the first run's logical left in the current line and use it as the line's logical left.
+        auto lineLogicalLeft = (*resolver.rangeForLine(run.lineIndex()).begin()).logicalLeft();
+        TextRun textRun { run.hasHyphen() ? textWithHyphen : run.text(), run.logicalLeft() - lineLogicalLeft, run.expansion(), run.expansionBehavior() };
         textRun.setTabSize(!style.collapseWhiteSpace(), style.tabSize());
         FloatPoint textOrigin { rect.x() + paintOffset.x(), roundToDevicePixel(run.baselinePosition() + paintOffset.y(), deviceScaleFactor) };
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to