Title: [159071] trunk
Revision
159071
Author
an...@apple.com
Date
2013-11-11 14:39:40 -0800 (Mon, 11 Nov 2013)

Log Message

End of line whitespace should collapse with white-space:pre-wrap; overflow-wrap:break-word in all cases
https://bugs.webkit.org/show_bug.cgi?id=124158

Source/WebCore: 

Reviewed by Dave Hyatt.
        
If a word just fits the line but the following space overflows we fail to collapse whitespaces 
at the end of the line. This happens because with break-word we end up taking word breaking
code path that does not have pre-wrap whitespace handling.
        
This patch makes the behavior consistent and also matches Firefox.

Test: fast/text/break-word-pre-wrap.html

* rendering/RenderBlockLineLayout.cpp:
(WebCore::BreakingContext::handleText):
        
    Don't take the word break code path if we are pre-wrap and the current character is space.
    Instead proceed to break the line normally as this is a valid break position.

LayoutTests: 

Reviewed by Dave Hyatt.
        
Added a specific test and updates the test results of some complex tests that demonstrate the same issue.

* fast/text/break-word-pre-wrap-expected.html: Added.
* fast/text/break-word-pre-wrap.html: Added.
* platform/mac/fast/forms/basic-textareas-expected.png:
* platform/mac/fast/forms/basic-textareas-expected.txt:
* platform/mac/fast/forms/basic-textareas-quirks-expected.png:
* platform/mac/fast/forms/basic-textareas-quirks-expected.txt:
* platform/mac-mountainlion/fast/forms/basic-textareas-expected.txt:
* platform/mac-mountainlion/fast/forms/basic-textareas-quirks-expected.txt:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (159070 => 159071)


--- trunk/LayoutTests/ChangeLog	2013-11-11 22:25:26 UTC (rev 159070)
+++ trunk/LayoutTests/ChangeLog	2013-11-11 22:39:40 UTC (rev 159071)
@@ -1,3 +1,21 @@
+2013-11-11  Antti Koivisto  <an...@apple.com>
+
+        End of line whitespace should collapse with white-space:pre-wrap; overflow-wrap:break-word in all cases
+        https://bugs.webkit.org/show_bug.cgi?id=124158
+
+        Reviewed by Dave Hyatt.
+        
+        Added a specific test and updates the test results of some complex tests that demonstrate the same issue.
+
+        * fast/text/break-word-pre-wrap-expected.html: Added.
+        * fast/text/break-word-pre-wrap.html: Added.
+        * platform/mac/fast/forms/basic-textareas-expected.png:
+        * platform/mac/fast/forms/basic-textareas-expected.txt:
+        * platform/mac/fast/forms/basic-textareas-quirks-expected.png:
+        * platform/mac/fast/forms/basic-textareas-quirks-expected.txt:
+        * platform/mac-mountainlion/fast/forms/basic-textareas-expected.txt:
+        * platform/mac-mountainlion/fast/forms/basic-textareas-quirks-expected.txt:
+
 2013-11-11  Bear Travis  <betra...@adobe.com>
 
         Web Inspector: [CSS Shapes] Highlight shape-outside when its element is selected in the Web Inspector

Added: trunk/LayoutTests/fast/text/break-word-pre-wrap-expected.html (0 => 159071)


--- trunk/LayoutTests/fast/text/break-word-pre-wrap-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text/break-word-pre-wrap-expected.html	2013-11-11 22:39:40 UTC (rev 159071)
@@ -0,0 +1,10 @@
+<style>
+div { position:relative; white-space:pre; border:1px solid blue; font-family:ahem; }
+</style>
+<div style="width:4ex">xxx
+x
+x</div>
+<div style="width:5ex">xxxx
+x</div>
+<div style="width:6ex">xxxx
+x</div>

Added: trunk/LayoutTests/fast/text/break-word-pre-wrap.html (0 => 159071)


--- trunk/LayoutTests/fast/text/break-word-pre-wrap.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text/break-word-pre-wrap.html	2013-11-11 22:39:40 UTC (rev 159071)
@@ -0,0 +1,6 @@
+<style>
+div { position:relative; white-space:pre-wrap; overflow-wrap: break-word; border:1px solid blue; font-family:ahem; }
+</style>
+<div style="width:4ex">xxxx   x</div>
+<div style="width:5ex">xxxx   x</div>
+<div style="width:6ex">xxxx   x</div>

Modified: trunk/LayoutTests/platform/mac/fast/forms/basic-textareas-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/mac/fast/forms/basic-textareas-expected.txt (159070 => 159071)


--- trunk/LayoutTests/platform/mac/fast/forms/basic-textareas-expected.txt	2013-11-11 22:25:26 UTC (rev 159070)
+++ trunk/LayoutTests/platform/mac/fast/forms/basic-textareas-expected.txt	2013-11-11 22:39:40 UTC (rev 159071)
@@ -546,27 +546,27 @@
                 text run at (0,26) width 30: "WXYZ"
                 text run at (29,26) width 5: " "
                 text run at (0,39) width 130: "abcdefghijklmnopqrstuv"
-        layer at (583,422) size 56x58 clip at (584,423) size 39x56 scrollHeight 186
+        layer at (583,422) size 56x58 clip at (584,423) size 39x56 scrollHeight 173
           RenderTextControl {TEXTAREA} at (3,31) size 56x58 [bgcolor=#FFFFFF] [border: (1px solid #000000)]
-            RenderBlock {DIV} at (3,3) size 35x182
-              RenderText {#text} at (0,0) size 35x182
+            RenderBlock {DIV} at (3,3) size 35x169
+              RenderText {#text} at (0,0) size 35x169
                 text run at (0,0) width 34: "Lorem"
                 text run at (33,0) width 2: " "
                 text run at (0,13) width 33: "ipsum"
-                text run at (0,26) width 7: "  "
-                text run at (0,39) width 29: "dolor"
-                text run at (28,39) width 4: " "
-                text run at (0,52) width 30: "ABCD"
-                text run at (0,65) width 35: "EFGHIJ"
-                text run at (0,78) width 31: "KLMN"
-                text run at (0,91) width 31: "OPQR"
-                text run at (0,104) width 28: "STUV"
-                text run at (0,117) width 30: "WXYZ"
-                text run at (29,117) width 5: " "
-                text run at (0,130) width 32: "abcde"
-                text run at (0,143) width 34: "fghijkl"
-                text run at (0,156) width 31: "mnop"
-                text run at (0,169) width 34: "qrstuv"
+                text run at (32,13) width 3: "  "
+                text run at (0,26) width 29: "dolor"
+                text run at (28,26) width 4: " "
+                text run at (0,39) width 30: "ABCD"
+                text run at (0,52) width 35: "EFGHIJ"
+                text run at (0,65) width 31: "KLMN"
+                text run at (0,78) width 31: "OPQR"
+                text run at (0,91) width 28: "STUV"
+                text run at (0,104) width 30: "WXYZ"
+                text run at (29,104) width 5: " "
+                text run at (0,117) width 32: "abcde"
+                text run at (0,130) width 34: "fghijkl"
+                text run at (0,143) width 31: "mnop"
+                text run at (0,156) width 34: "qrstuv"
         layer at (3,503) size 161x47 clip at (4,504) size 159x30 scrollWidth 425
           RenderTextControl {TEXTAREA} at (3,17) size 161x47 [bgcolor=#FFFFFF] [border: (1px solid #000000)]
             RenderBlock {DIV} at (3,3) size 155x13
@@ -1245,27 +1245,27 @@
                 text run at (0,26) width 30: "WXYZ"
                 text run at (29,26) width 5: " "
                 text run at (0,39) width 130: "abcdefghijklmnopqrstuv"
-        layer at (583,401) size 56x58 clip at (584,402) size 39x56 scrollHeight 186
+        layer at (583,401) size 56x58 clip at (584,402) size 39x56 scrollHeight 173
           RenderTextControl {TEXTAREA} at (3,31) size 56x58 [bgcolor=#FFFFFF] [border: (1px solid #000000)]
-            RenderBlock {DIV} at (3,3) size 35x182
-              RenderText {#text} at (0,0) size 35x182
+            RenderBlock {DIV} at (3,3) size 35x169
+              RenderText {#text} at (0,0) size 35x169
                 text run at (0,0) width 34: "Lorem"
                 text run at (33,0) width 2: " "
                 text run at (0,13) width 33: "ipsum"
-                text run at (0,26) width 7: "  "
-                text run at (0,39) width 29: "dolor"
-                text run at (28,39) width 4: " "
-                text run at (0,52) width 30: "ABCD"
-                text run at (0,65) width 35: "EFGHIJ"
-                text run at (0,78) width 31: "KLMN"
-                text run at (0,91) width 31: "OPQR"
-                text run at (0,104) width 28: "STUV"
-                text run at (0,117) width 30: "WXYZ"
-                text run at (29,117) width 5: " "
-                text run at (0,130) width 32: "abcde"
-                text run at (0,143) width 34: "fghijkl"
-                text run at (0,156) width 31: "mnop"
-                text run at (0,169) width 34: "qrstuv"
+                text run at (32,13) width 3: "  "
+                text run at (0,26) width 29: "dolor"
+                text run at (28,26) width 4: " "
+                text run at (0,39) width 30: "ABCD"
+                text run at (0,52) width 35: "EFGHIJ"
+                text run at (0,65) width 31: "KLMN"
+                text run at (0,78) width 31: "OPQR"
+                text run at (0,91) width 28: "STUV"
+                text run at (0,104) width 30: "WXYZ"
+                text run at (29,104) width 5: " "
+                text run at (0,117) width 32: "abcde"
+                text run at (0,130) width 34: "fghijkl"
+                text run at (0,143) width 31: "mnop"
+                text run at (0,156) width 34: "qrstuv"
         layer at (3,479) size 161x47 clip at (4,480) size 159x30 scrollWidth 425
           RenderTextControl {TEXTAREA} at (3,17) size 161x47 [bgcolor=#FFFFFF] [border: (1px solid #000000)]
             RenderBlock {DIV} at (3,3) size 155x13

Modified: trunk/LayoutTests/platform/mac/fast/forms/basic-textareas-quirks-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/mac/fast/forms/basic-textareas-quirks-expected.txt (159070 => 159071)


--- trunk/LayoutTests/platform/mac/fast/forms/basic-textareas-quirks-expected.txt	2013-11-11 22:25:26 UTC (rev 159070)
+++ trunk/LayoutTests/platform/mac/fast/forms/basic-textareas-quirks-expected.txt	2013-11-11 22:39:40 UTC (rev 159071)
@@ -365,10 +365,10 @@
         text run at (29,26) width 5: " "
         text run at (0,39) width 130: "abcdefghijklmnopqrstuv"
         text run at (129,39) width 4: " "
-layer at (26,761) size 56x58 clip at (27,762) size 39x56 scrollHeight 186
+layer at (26,761) size 56x58 clip at (27,762) size 39x56 scrollHeight 173
   RenderTextControl {TEXTAREA} at (17,3) size 56x58 [bgcolor=#FFFFFF] [border: (1px solid #000000)]
-    RenderBlock {DIV} at (3,3) size 35x182
-      RenderText {#text} at (0,0) size 35x182
+    RenderBlock {DIV} at (3,3) size 35x169
+      RenderText {#text} at (0,0) size 35x169
         text run at (0,0) width 34: "Lorem"
         text run at (33,0) width 2: " "
         text run at (0,13) width 33: "ipsum"
@@ -386,7 +386,7 @@
         text run at (0,130) width 34: "fghijkl"
         text run at (0,143) width 31: "mnop"
         text run at (0,156) width 34: "qrstuv"
-        text run at (0,169) width 4: " "
+        text run at (33,156) width 2: " "
 layer at (376,26) size 60x32 clip at (377,27) size 43x30 scrollHeight 160
   RenderTextControl {TEXTAREA} at (15,3) size 60x32 [bgcolor=#FFFFFF] [border: (1px solid #000000)]
     RenderBlock {DIV} at (3,3) size 39x156

Modified: trunk/LayoutTests/platform/mac-mountainlion/fast/forms/basic-textareas-expected.txt (159070 => 159071)


--- trunk/LayoutTests/platform/mac-mountainlion/fast/forms/basic-textareas-expected.txt	2013-11-11 22:25:26 UTC (rev 159070)
+++ trunk/LayoutTests/platform/mac-mountainlion/fast/forms/basic-textareas-expected.txt	2013-11-11 22:39:40 UTC (rev 159071)
@@ -546,27 +546,27 @@
                 text run at (0,26) width 30: "WXYZ"
                 text run at (29,26) width 5: " "
                 text run at (0,39) width 130: "abcdefghijklmnopqrstuv"
-        layer at (583,422) size 56x58 clip at (584,423) size 39x56 scrollHeight 186
+        layer at (583,422) size 56x58 clip at (584,423) size 39x56 scrollHeight 173
           RenderTextControl {TEXTAREA} at (3,31) size 56x58 [bgcolor=#FFFFFF] [border: (1px solid #000000)]
-            RenderBlock {DIV} at (3,3) size 35x182
-              RenderText {#text} at (0,0) size 35x182
+            RenderBlock {DIV} at (3,3) size 35x169
+              RenderText {#text} at (0,0) size 35x169
                 text run at (0,0) width 34: "Lorem"
                 text run at (33,0) width 2: " "
                 text run at (0,13) width 33: "ipsum"
-                text run at (0,26) width 7: "  "
-                text run at (0,39) width 29: "dolor"
-                text run at (28,39) width 4: " "
-                text run at (0,52) width 30: "ABCD"
-                text run at (0,65) width 35: "EFGHIJ"
-                text run at (0,78) width 31: "KLMN"
-                text run at (0,91) width 31: "OPQR"
-                text run at (0,104) width 28: "STUV"
-                text run at (0,117) width 30: "WXYZ"
-                text run at (29,117) width 5: " "
-                text run at (0,130) width 32: "abcde"
-                text run at (0,143) width 34: "fghijkl"
-                text run at (0,156) width 31: "mnop"
-                text run at (0,169) width 34: "qrstuv"
+                text run at (32,13) width 3: "  "
+                text run at (0,26) width 29: "dolor"
+                text run at (28,26) width 4: " "
+                text run at (0,39) width 30: "ABCD"
+                text run at (0,52) width 35: "EFGHIJ"
+                text run at (0,65) width 31: "KLMN"
+                text run at (0,78) width 31: "OPQR"
+                text run at (0,91) width 28: "STUV"
+                text run at (0,104) width 30: "WXYZ"
+                text run at (29,104) width 5: " "
+                text run at (0,117) width 32: "abcde"
+                text run at (0,130) width 34: "fghijkl"
+                text run at (0,143) width 31: "mnop"
+                text run at (0,156) width 34: "qrstuv"
         layer at (3,503) size 161x47 clip at (4,504) size 159x30 scrollWidth 427
           RenderTextControl {TEXTAREA} at (3,17) size 161x47 [bgcolor=#FFFFFF] [border: (1px solid #000000)]
             RenderBlock {DIV} at (3,3) size 155x13
@@ -1245,27 +1245,27 @@
                 text run at (0,26) width 30: "WXYZ"
                 text run at (29,26) width 5: " "
                 text run at (0,39) width 130: "abcdefghijklmnopqrstuv"
-        layer at (583,401) size 56x58 clip at (584,402) size 39x56 scrollHeight 186
+        layer at (583,401) size 56x58 clip at (584,402) size 39x56 scrollHeight 173
           RenderTextControl {TEXTAREA} at (3,31) size 56x58 [bgcolor=#FFFFFF] [border: (1px solid #000000)]
-            RenderBlock {DIV} at (3,3) size 35x182
-              RenderText {#text} at (0,0) size 35x182
+            RenderBlock {DIV} at (3,3) size 35x169
+              RenderText {#text} at (0,0) size 35x169
                 text run at (0,0) width 34: "Lorem"
                 text run at (33,0) width 2: " "
                 text run at (0,13) width 33: "ipsum"
-                text run at (0,26) width 7: "  "
-                text run at (0,39) width 29: "dolor"
-                text run at (28,39) width 4: " "
-                text run at (0,52) width 30: "ABCD"
-                text run at (0,65) width 35: "EFGHIJ"
-                text run at (0,78) width 31: "KLMN"
-                text run at (0,91) width 31: "OPQR"
-                text run at (0,104) width 28: "STUV"
-                text run at (0,117) width 30: "WXYZ"
-                text run at (29,117) width 5: " "
-                text run at (0,130) width 32: "abcde"
-                text run at (0,143) width 34: "fghijkl"
-                text run at (0,156) width 31: "mnop"
-                text run at (0,169) width 34: "qrstuv"
+                text run at (32,13) width 3: "  "
+                text run at (0,26) width 29: "dolor"
+                text run at (28,26) width 4: " "
+                text run at (0,39) width 30: "ABCD"
+                text run at (0,52) width 35: "EFGHIJ"
+                text run at (0,65) width 31: "KLMN"
+                text run at (0,78) width 31: "OPQR"
+                text run at (0,91) width 28: "STUV"
+                text run at (0,104) width 30: "WXYZ"
+                text run at (29,104) width 5: " "
+                text run at (0,117) width 32: "abcde"
+                text run at (0,130) width 34: "fghijkl"
+                text run at (0,143) width 31: "mnop"
+                text run at (0,156) width 34: "qrstuv"
         layer at (3,479) size 161x47 clip at (4,480) size 159x30 scrollWidth 427
           RenderTextControl {TEXTAREA} at (3,17) size 161x47 [bgcolor=#FFFFFF] [border: (1px solid #000000)]
             RenderBlock {DIV} at (3,3) size 155x13

Modified: trunk/LayoutTests/platform/mac-mountainlion/fast/forms/basic-textareas-quirks-expected.txt (159070 => 159071)


--- trunk/LayoutTests/platform/mac-mountainlion/fast/forms/basic-textareas-quirks-expected.txt	2013-11-11 22:25:26 UTC (rev 159070)
+++ trunk/LayoutTests/platform/mac-mountainlion/fast/forms/basic-textareas-quirks-expected.txt	2013-11-11 22:39:40 UTC (rev 159071)
@@ -365,10 +365,10 @@
         text run at (29,26) width 5: " "
         text run at (0,39) width 130: "abcdefghijklmnopqrstuv"
         text run at (129,39) width 5: " "
-layer at (26,761) size 56x58 clip at (27,762) size 39x56 scrollHeight 186
+layer at (26,761) size 56x58 clip at (27,762) size 39x56 scrollHeight 173
   RenderTextControl {TEXTAREA} at (17,3) size 56x58 [bgcolor=#FFFFFF] [border: (1px solid #000000)]
-    RenderBlock {DIV} at (3,3) size 35x182
-      RenderText {#text} at (0,0) size 35x182
+    RenderBlock {DIV} at (3,3) size 35x169
+      RenderText {#text} at (0,0) size 35x169
         text run at (0,0) width 34: "Lorem"
         text run at (33,0) width 2: " "
         text run at (0,13) width 33: "ipsum"
@@ -386,7 +386,7 @@
         text run at (0,130) width 34: "fghijkl"
         text run at (0,143) width 31: "mnop"
         text run at (0,156) width 34: "qrstuv"
-        text run at (0,169) width 4: " "
+        text run at (33,156) width 2: " "
 layer at (376,26) size 60x32 clip at (377,27) size 43x30 scrollHeight 160
   RenderTextControl {TEXTAREA} at (15,3) size 60x32 [bgcolor=#FFFFFF] [border: (1px solid #000000)]
     RenderBlock {DIV} at (3,3) size 39x156

Modified: trunk/Source/WebCore/ChangeLog (159070 => 159071)


--- trunk/Source/WebCore/ChangeLog	2013-11-11 22:25:26 UTC (rev 159070)
+++ trunk/Source/WebCore/ChangeLog	2013-11-11 22:39:40 UTC (rev 159071)
@@ -1,3 +1,24 @@
+2013-11-11  Antti Koivisto  <an...@apple.com>
+
+        End of line whitespace should collapse with white-space:pre-wrap; overflow-wrap:break-word in all cases
+        https://bugs.webkit.org/show_bug.cgi?id=124158
+
+        Reviewed by Dave Hyatt.
+        
+        If a word just fits the line but the following space overflows we fail to collapse whitespaces 
+        at the end of the line. This happens because with break-word we end up taking word breaking
+        code path that does not have pre-wrap whitespace handling.
+        
+        This patch makes the behavior consistent and also matches Firefox.
+
+        Test: fast/text/break-word-pre-wrap.html
+
+        * rendering/RenderBlockLineLayout.cpp:
+        (WebCore::BreakingContext::handleText):
+        
+            Don't take the word break code path if we are pre-wrap and the current character is space.
+            Instead proceed to break the line normally as this is a valid break position.
+
 2013-11-11  Bear Travis  <betra...@adobe.com>
 
         Web Inspector: [CSS Shapes] Highlight shape-outside when its element is selected in the Web Inspector

Modified: trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp (159070 => 159071)


--- trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp	2013-11-11 22:25:26 UTC (rev 159070)
+++ trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp	2013-11-11 22:39:40 UTC (rev 159071)
@@ -3090,7 +3090,7 @@
 
         m_currentCharacterIsWS = m_currentCharacterIsSpace || (breakNBSP && c == noBreakSpace);
 
-        if ((breakAll || breakWords) && !midWordBreak) {
+        if ((breakAll || breakWords) && !midWordBreak && (!m_currentCharacterIsSpace || style.whiteSpace() != PRE_WRAP)) {
             wrapW += charWidth;
             bool midWordBreakIsBeforeSurrogatePair = U16_IS_LEAD(c) && m_current.m_pos + 1 < renderText->textLength() && U16_IS_TRAIL((*renderText)[m_current.m_pos + 1]);
             charWidth = textWidth(renderText, m_current.m_pos, midWordBreakIsBeforeSurrogatePair ? 2 : 1, font, m_width.committedWidth() + wrapW, isFixedPitch, m_collapseWhiteSpace, fallbackFonts, textLayout);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to