Title: [176470] trunk
Revision
176470
Author
za...@apple.com
Date
2014-11-21 13:08:55 -0800 (Fri, 21 Nov 2014)

Log Message

REGRESSION(r175259) Simple line layout text measuring behavior changed.
https://bugs.webkit.org/show_bug.cgi?id=138947
rdar://problem/19050653

Reviewed by Antti Koivisto.

In certain cases, when block flow needs to compute the preferred width of a particular text
renderer, we use the non-simple line layout text measuring.
However, the same text renderer might end up at simple line layout later.
Complex line layout measures text including the trailing space and it subtracts
(the constant value of) space width afterwards, while simple line layout measures
runs without the extra space.
In such cases, this may result different word widths and produce unexpected line breaking. (preferred width != final width)
In long term, any text renderer qualified for simple line layout should go through the simple
text measuring code path. (https://bugs.webkit.org/show_bug.cgi?id=138973)
For now, just copy complex line layout behaviour. This also matches the previous simple line layout line breaking implementation.

Source/WebCore:

Test: fast/text/simple-line-text-measuring-with-trailing-space.html

* rendering/SimpleLineLayoutFlowContents.cpp:
(WebCore::SimpleLineLayout::FlowContents::textWidth):

LayoutTests:

* fast/text/simple-line-text-measuring-with-trailing-space-expected.html: Added.
* fast/text/simple-line-text-measuring-with-trailing-space.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (176469 => 176470)


--- trunk/LayoutTests/ChangeLog	2014-11-21 21:01:46 UTC (rev 176469)
+++ trunk/LayoutTests/ChangeLog	2014-11-21 21:08:55 UTC (rev 176470)
@@ -1,3 +1,25 @@
+2014-11-21  Zalan Bujtas  <za...@apple.com>
+
+        REGRESSION(r175259) Simple line layout text measuring behavior changed.
+        https://bugs.webkit.org/show_bug.cgi?id=138947
+        rdar://problem/19050653
+
+        Reviewed by Antti Koivisto.
+
+        In certain cases, when block flow needs to compute the preferred width of a particular text
+        renderer, we use the non-simple line layout text measuring.
+        However, the same text renderer might end up at simple line layout later.
+        Complex line layout measures text including the trailing space and it subtracts
+        (the constant value of) space width afterwards, while simple line layout measures
+        runs without the extra space.
+        In such cases, this may result different word widths and produce unexpected line breaking. (preferred width != final width)
+        In long term, any text renderer qualified for simple line layout should go through the simple
+        text measuring code path. (https://bugs.webkit.org/show_bug.cgi?id=138973)
+        For now, just copy complex line layout behaviour. This also matches the previous simple line layout line breaking implementation.
+
+        * fast/text/simple-line-text-measuring-with-trailing-space-expected.html: Added.
+        * fast/text/simple-line-text-measuring-with-trailing-space.html: Added.
+
 2014-11-21  Chris Dumez  <cdu...@apple.com>
 
         Crash when setting 'transition-delay' CSS property to a calculated value

Added: trunk/LayoutTests/fast/text/simple-line-text-measuring-with-trailing-space-expected.html (0 => 176470)


--- trunk/LayoutTests/fast/text/simple-line-text-measuring-with-trailing-space-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text/simple-line-text-measuring-with-trailing-space-expected.html	2014-11-21 21:08:55 UTC (rev 176470)
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>This tests that simple line layout text measuring matches complex line layout. (trailing space included and then subtracted)</title>
+<style>
+ .content {
+    float: left;
+    border: 1px solid green;
+ }
+</style>
+<script>
+  if (window.internals)
+    internals.settings.setSimpleLineLayoutEnabled(false);
+</script>
+</head>
+<body>
+	<div class="content">FOP bar</div>
+</body>
+</html>

Added: trunk/LayoutTests/fast/text/simple-line-text-measuring-with-trailing-space.html (0 => 176470)


--- trunk/LayoutTests/fast/text/simple-line-text-measuring-with-trailing-space.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text/simple-line-text-measuring-with-trailing-space.html	2014-11-21 21:08:55 UTC (rev 176470)
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>This tests that simple line layout text measuring matches complex line layout. (trailing space included and then subtracted)</title>
+<style>
+ .content {
+    float: left;
+    border: 1px solid green;
+ }
+</style>
+</head>
+<body>
+	<div class="content">FOP bar</div>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (176469 => 176470)


--- trunk/Source/WebCore/ChangeLog	2014-11-21 21:01:46 UTC (rev 176469)
+++ trunk/Source/WebCore/ChangeLog	2014-11-21 21:08:55 UTC (rev 176470)
@@ -1,3 +1,27 @@
+2014-11-21  Zalan Bujtas  <za...@apple.com>
+
+        REGRESSION(r175259) Simple line layout text measuring behavior changed.
+        https://bugs.webkit.org/show_bug.cgi?id=138947
+        rdar://problem/19050653
+
+        Reviewed by Antti Koivisto.
+
+        In certain cases, when block flow needs to compute the preferred width of a particular text
+        renderer, we use the non-simple line layout text measuring.
+        However, the same text renderer might end up at simple line layout later.
+        Complex line layout measures text including the trailing space and it subtracts
+        (the constant value of) space width afterwards, while simple line layout measures
+        runs without the extra space.
+        In such cases, this may result different word widths and produce unexpected line breaking. (preferred width != final width)
+        In long term, any text renderer qualified for simple line layout should go through the simple
+        text measuring code path. (https://bugs.webkit.org/show_bug.cgi?id=138973)
+        For now, just copy complex line layout behaviour. This also matches the previous simple line layout line breaking implementation.
+
+        Test: fast/text/simple-line-text-measuring-with-trailing-space.html
+
+        * rendering/SimpleLineLayoutFlowContents.cpp:
+        (WebCore::SimpleLineLayout::FlowContents::textWidth):
+
 2014-11-21  Anders Carlsson  <ander...@apple.com>
 
         More Windows build fixes.

Modified: trunk/Source/WebCore/rendering/SimpleLineLayoutFlowContents.cpp (176469 => 176470)


--- trunk/Source/WebCore/rendering/SimpleLineLayoutFlowContents.cpp	2014-11-21 21:01:46 UTC (rev 176469)
+++ trunk/Source/WebCore/rendering/SimpleLineLayoutFlowContents.cpp	2014-11-21 21:08:55 UTC (rev 176470)
@@ -180,10 +180,16 @@
 {
     ASSERT(from < to);
     String string = renderer.text();
+    bool measureWithEndSpace = m_style.collapseWhitespace && to < string.length() && string[to] == ' ';
+    if (measureWithEndSpace)
+        ++to;
     TextRun run(string.characters8() + from, to - from);
     run.setXPos(xPosition);
     run.setTabSize(!!m_style.tabWidth, m_style.tabWidth);
-    return m_style.font.width(run);
+    float width = m_style.font.width(run);
+    if (measureWithEndSpace)
+        width -= m_style.spaceWidth;
+    return width;
 }
 
 }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to