Title: [283768] branches/safari-612-branch
Revision
283768
Author
repst...@apple.com
Date
2021-10-07 19:01:16 -0700 (Thu, 07 Oct 2021)

Log Message

Cherry-pick r281463. rdar://problem/83955719

    Pre-formatted content gets distorted when attempting to select content
    https://bugs.webkit.org/show_bug.cgi?id=228655
    <rdar://81288187>

    Reviewed by Simon Fraser.

    Source/WebCore:

    https://drafts.csswg.org/css-text/#overflow-wrap-property

    "This property specifies whether the UA may break at otherwise disallowed points within
    a line to prevent overflow, when an otherwise-unbreakable string is too long to fit within the line box.
    It only has an effect when white-space allows wrapping."

    (also see https://trac.webkit.org/changeset/10095/webkit where the wrapping behavior was introduced)

    Test: fast/text/no-wrap-in-pre-with-word-wrap.html

    * rendering/line/BreakingContext.h:
    (WebCore::BreakingContext::handleText):

    LayoutTests:

    * fast/text/no-wrap-in-pre-with-word-wrap-expected.html: Added.
    * fast/text/no-wrap-in-pre-with-word-wrap.html: Added.

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

Modified Paths

Added Paths

Diff

Modified: branches/safari-612-branch/LayoutTests/ChangeLog (283767 => 283768)


--- branches/safari-612-branch/LayoutTests/ChangeLog	2021-10-08 02:01:12 UTC (rev 283767)
+++ branches/safari-612-branch/LayoutTests/ChangeLog	2021-10-08 02:01:16 UTC (rev 283768)
@@ -1,3 +1,47 @@
+2021-10-07  Alan Coon  <alanc...@apple.com>
+
+        Cherry-pick r281463. rdar://problem/83955719
+
+    Pre-formatted content gets distorted when attempting to select content
+    https://bugs.webkit.org/show_bug.cgi?id=228655
+    <rdar://81288187>
+    
+    Reviewed by Simon Fraser.
+    
+    Source/WebCore:
+    
+    https://drafts.csswg.org/css-text/#overflow-wrap-property
+    
+    "This property specifies whether the UA may break at otherwise disallowed points within
+    a line to prevent overflow, when an otherwise-unbreakable string is too long to fit within the line box.
+    It only has an effect when white-space allows wrapping."
+    
+    (also see https://trac.webkit.org/changeset/10095/webkit where the wrapping behavior was introduced)
+    
+    Test: fast/text/no-wrap-in-pre-with-word-wrap.html
+    
+    * rendering/line/BreakingContext.h:
+    (WebCore::BreakingContext::handleText):
+    
+    LayoutTests:
+    
+    * fast/text/no-wrap-in-pre-with-word-wrap-expected.html: Added.
+    * fast/text/no-wrap-in-pre-with-word-wrap.html: Added.
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@281463 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-08-23  Alan Bujtas  <za...@apple.com>
+
+            Pre-formatted content gets distorted when attempting to select content
+            https://bugs.webkit.org/show_bug.cgi?id=228655
+            <rdar://81288187>
+
+            Reviewed by Simon Fraser.
+
+            * fast/text/no-wrap-in-pre-with-word-wrap-expected.html: Added.
+            * fast/text/no-wrap-in-pre-with-word-wrap.html: Added.
+
 2021-10-06  Russell Epstein  <repst...@apple.com>
 
         Cherry-pick r283410. rdar://problem/83960033

Added: branches/safari-612-branch/LayoutTests/fast/text/no-wrap-in-pre-with-word-wrap-expected.html (0 => 283768)


--- branches/safari-612-branch/LayoutTests/fast/text/no-wrap-in-pre-with-word-wrap-expected.html	                        (rev 0)
+++ branches/safari-612-branch/LayoutTests/fast/text/no-wrap-in-pre-with-word-wrap-expected.html	2021-10-08 02:01:16 UTC (rev 283768)
@@ -0,0 +1,8 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ LayoutFormattingContextIntegrationEnabled=false ] -->
+<style>
+pre {
+  width: 100px;
+  font-family: Ahem;
+}
+</style>
+<pre>Wrapping is not allowed. We should not break the content even when word-wrap: break-word is on.</pre>	

Added: branches/safari-612-branch/LayoutTests/fast/text/no-wrap-in-pre-with-word-wrap.html (0 => 283768)


--- branches/safari-612-branch/LayoutTests/fast/text/no-wrap-in-pre-with-word-wrap.html	                        (rev 0)
+++ branches/safari-612-branch/LayoutTests/fast/text/no-wrap-in-pre-with-word-wrap.html	2021-10-08 02:01:16 UTC (rev 283768)
@@ -0,0 +1,9 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ LayoutFormattingContextIntegrationEnabled=false ] -->
+<style>
+pre {
+  word-wrap: break-word;
+  width: 100px;
+  font-family: Ahem;
+}
+</style>
+<pre>Wrapping is not allowed. We should not break the content even when word-wrap: break-word is on.</pre>	

Modified: branches/safari-612-branch/LayoutTests/platform/ios/fast/forms/basic-textareas-expected.txt (283767 => 283768)


--- branches/safari-612-branch/LayoutTests/platform/ios/fast/forms/basic-textareas-expected.txt	2021-10-08 02:01:12 UTC (rev 283767)
+++ branches/safari-612-branch/LayoutTests/platform/ios/fast/forms/basic-textareas-expected.txt	2021-10-08 02:01:16 UTC (rev 283768)
@@ -588,14 +588,11 @@
                 text run at (0,28) width 56: "TUVWXYZ"
                 text run at (55,28) width 4: " "
                 text run at (0,42) width 127: "abcdefghijklmnopqrstuv"
-        layer at (3,644) size 168x34 clip at (4,645) size 151x32 scrollHeight 60
+        layer at (3,644) size 168x34 clip at (4,645) size 151x17 scrollWidth 434 scrollHeight 18
           RenderTextControl {TEXTAREA} at (3,33) size 168x34 [bgcolor=#FFFFFF] [border: (1px solid #3C3C4399)]
-            RenderBlock {DIV} at (6,3) size 141x56
-              RenderText {#text} at (0,0) size 137x56
-                text run at (0,0) width 135: "Lorem ipsum  dolor ABCD"
-                text run at (0,14) width 132: "EFGHIJKLMNOPQRSTUV"
-                text run at (0,28) width 137: "WXYZ abcdefghijklmnopq"
-                text run at (0,42) width 27: "rstuv"
+            RenderBlock {DIV} at (6,3) size 156x14
+              RenderText {#text} at (0,0) size 429x14
+                text run at (0,0) width 429: "Lorem ipsum  dolor ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuv"
         layer at (177,644) size 168x34 clip at (178,645) size 151x32 scrollHeight 60
           RenderTextControl {TEXTAREA} at (3,33) size 168x34 [bgcolor=#FFFFFF] [border: (1px solid #3C3C4399)]
             RenderBlock {DIV} at (6,3) size 141x56
@@ -1325,14 +1322,11 @@
                 text run at (0,28) width 56: "TUVWXYZ"
                 text run at (55,28) width 4: " "
                 text run at (0,42) width 127: "abcdefghijklmnopqrstuv"
-        layer at (3,587) size 168x34 clip at (4,588) size 151x32 scrollHeight 60
+        layer at (3,587) size 168x34 clip at (4,588) size 151x17 scrollWidth 434 scrollHeight 18
           RenderTextControl {TEXTAREA} at (3,33) size 168x34 [bgcolor=#FFFFFF] [border: (1px solid #3C3C4399)]
-            RenderBlock {DIV} at (6,3) size 141x56
-              RenderText {#text} at (0,0) size 137x56
-                text run at (0,0) width 135: "Lorem ipsum  dolor ABCD"
-                text run at (0,14) width 132: "EFGHIJKLMNOPQRSTUV"
-                text run at (0,28) width 137: "WXYZ abcdefghijklmnopq"
-                text run at (0,42) width 27: "rstuv"
+            RenderBlock {DIV} at (6,3) size 156x14
+              RenderText {#text} at (0,0) size 429x14
+                text run at (0,0) width 429: "Lorem ipsum  dolor ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuv"
         layer at (177,587) size 168x34 clip at (178,588) size 151x32 scrollHeight 60
           RenderTextControl {TEXTAREA} at (3,33) size 168x34 [bgcolor=#FFFFFF] [border: (1px solid #3C3C4399)]
             RenderBlock {DIV} at (6,3) size 141x56

Modified: branches/safari-612-branch/LayoutTests/platform/mac/fast/forms/basic-textareas-expected.txt (283767 => 283768)


--- branches/safari-612-branch/LayoutTests/platform/mac/fast/forms/basic-textareas-expected.txt	2021-10-08 02:01:12 UTC (rev 283767)
+++ branches/safari-612-branch/LayoutTests/platform/mac/fast/forms/basic-textareas-expected.txt	2021-10-08 02:01:16 UTC (rev 283768)
@@ -596,14 +596,11 @@
                 text run at (0,13) width 140: "ABCDEFGHIJKLMNOPQRS"
                 text run at (0,26) width 56: "TUVWXYZ"
                 text run at (0,39) width 127: "abcdefghijklmnopqrstuv"
-        layer at (3,587) size 161x32 clip at (4,588) size 144x30 scrollHeight 56
+        layer at (3,587) size 161x32 clip at (4,588) size 144x15 scrollWidth 430 scrollHeight 17
           RenderTextControl {TEXTAREA} at (3,31) size 161x32 [bgcolor=#FFFFFF] [border: (1px solid #000000)]
-            RenderBlock {DIV} at (3,3) size 140x52
-              RenderText {#text} at (0,0) size 137x52
-                text run at (0,0) width 135: "Lorem ipsum  dolor ABCD"
-                text run at (0,13) width 132: "EFGHIJKLMNOPQRSTUV"
-                text run at (0,26) width 137: "WXYZ abcdefghijklmnopq"
-                text run at (0,39) width 27: "rstuv"
+            RenderBlock {DIV} at (3,3) size 155x13
+              RenderText {#text} at (0,0) size 429x13
+                text run at (0,0) width 429: "Lorem ipsum  dolor ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuv"
         layer at (170,587) size 161x32 clip at (171,588) size 144x30 scrollHeight 56
           RenderTextControl {TEXTAREA} at (3,31) size 161x32 [bgcolor=#FFFFFF] [border: (1px solid #000000)]
             RenderBlock {DIV} at (3,3) size 140x52
@@ -1304,14 +1301,11 @@
                 text run at (0,13) width 140: "ABCDEFGHIJKLMNOPQRS"
                 text run at (0,26) width 56: "TUVWXYZ"
                 text run at (0,39) width 127: "abcdefghijklmnopqrstuv"
-        layer at (3,560) size 161x32 clip at (4,561) size 144x30 scrollHeight 56
+        layer at (3,560) size 161x32 clip at (4,561) size 144x15 scrollWidth 430 scrollHeight 17
           RenderTextControl {TEXTAREA} at (3,31) size 161x32 [bgcolor=#FFFFFF] [border: (1px solid #000000)]
-            RenderBlock {DIV} at (3,3) size 140x52
-              RenderText {#text} at (0,0) size 137x52
-                text run at (0,0) width 135: "Lorem ipsum  dolor ABCD"
-                text run at (0,13) width 132: "EFGHIJKLMNOPQRSTUV"
-                text run at (0,26) width 137: "WXYZ abcdefghijklmnopq"
-                text run at (0,39) width 27: "rstuv"
+            RenderBlock {DIV} at (3,3) size 155x13
+              RenderText {#text} at (0,0) size 429x13
+                text run at (0,0) width 429: "Lorem ipsum  dolor ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuv"
         layer at (170,560) size 161x32 clip at (171,561) size 144x30 scrollHeight 56
           RenderTextControl {TEXTAREA} at (3,31) size 161x32 [bgcolor=#FFFFFF] [border: (1px solid #000000)]
             RenderBlock {DIV} at (3,3) size 140x52

Modified: branches/safari-612-branch/LayoutTests/platform/mac/fast/text/whitespace/tab-character-basics-expected.txt (283767 => 283768)


--- branches/safari-612-branch/LayoutTests/platform/mac/fast/text/whitespace/tab-character-basics-expected.txt	2021-10-08 02:01:12 UTC (rev 283767)
+++ branches/safari-612-branch/LayoutTests/platform/mac/fast/text/whitespace/tab-character-basics-expected.txt	2021-10-08 02:01:16 UTC (rev 283768)
@@ -1,8 +1,8 @@
 layer at (0,0) size 800x600
   RenderView at (0,0) size 800x600
-layer at (0,0) size 800x502
-  RenderBlock {HTML} at (0,0) size 800x502
-    RenderBody {BODY} at (8,8) size 646x486 [border: (3px solid #FF0000)]
+layer at (0,0) size 800x481
+  RenderBlock {HTML} at (0,0) size 800x481
+    RenderBody {BODY} at (8,8) size 646x465 [border: (3px solid #FF0000)]
       RenderBlock {P} at (3,19) size 640x21 [color=#0000FF]
         RenderText {#text} at (0,0) size 509x20
           text run at (0,0) width 509: "-- Following text and list are whitespace:NORMAL only"
@@ -41,22 +41,20 @@
           RenderListMarker at (-34,0) size 29x20: "3"
           RenderText {#text} at (0,0) size 87x20
             text run at (0,0) width 87: "ccc\x{9}X"
-      RenderBlock {P} at (3,309) size 640x63
+      RenderBlock {P} at (3,309) size 640x42
         RenderText {#text} at (0,0) size 490x20
           text run at (0,0) width 490: "012345678901234567890123456789012345678901234567890"
         RenderBR {BR} at (489,0) size 1x20
-        RenderText {#text} at (0,21) size 634x41
-          text run at (0,21) width 634: "X\x{9}\x{9}XX\x{9}\x{9}XXX\x{9}\x{9}XXXX\x{9}\x{9}XX"
-          text run at (0,42) width 29: "XXX"
-      RenderBlock {P} at (3,388) size 640x21 [color=#0000FF]
+        RenderText {#text} at (0,21) size 663x20
+          text run at (0,21) width 663: "X\x{9}\x{9}XX\x{9}\x{9}XXX\x{9}\x{9}XXXX\x{9}\x{9}XXXXX"
+      RenderBlock {P} at (3,367) size 640x21 [color=#0000FF]
         RenderText {#text} at (0,0) size 577x20
           text run at (0,0) width 577: "-- Following text mixes whitespace:NORMAL and whitespace:PRE"
-      RenderBlock {P} at (3,425) size 640x42
+      RenderBlock {P} at (3,404) size 640x42
         RenderText {#text} at (0,0) size 471x20
           text run at (0,0) width 471: "AAAA BBBB CCCC DDDD EEEE FFFF GGGG HHHH IIII JJJJ"
-        RenderInline {SPAN} at (0,0) size 615x41
-          RenderText {#text} at (470,0) size 615x41
-            text run at (470,0) width 145: "\x{9}\x{9}"
-            text run at (0,21) width 154: "\x{9}\x{9}"
-        RenderText {#text} at (153,21) size 40x20
-          text run at (153,21) width 40: "KKKK"
+        RenderInline {SPAN} at (0,0) size 299x20
+          RenderText {#text} at (470,0) size 299x20
+            text run at (470,0) width 299: "\x{9}\x{9}\x{9}\x{9}"
+        RenderText {#text} at (0,21) size 39x20
+          text run at (0,21) width 39: "KKKK"

Modified: branches/safari-612-branch/Source/WebCore/ChangeLog (283767 => 283768)


--- branches/safari-612-branch/Source/WebCore/ChangeLog	2021-10-08 02:01:12 UTC (rev 283767)
+++ branches/safari-612-branch/Source/WebCore/ChangeLog	2021-10-08 02:01:16 UTC (rev 283768)
@@ -1,3 +1,57 @@
+2021-10-07  Alan Coon  <alanc...@apple.com>
+
+        Cherry-pick r281463. rdar://problem/83955719
+
+    Pre-formatted content gets distorted when attempting to select content
+    https://bugs.webkit.org/show_bug.cgi?id=228655
+    <rdar://81288187>
+    
+    Reviewed by Simon Fraser.
+    
+    Source/WebCore:
+    
+    https://drafts.csswg.org/css-text/#overflow-wrap-property
+    
+    "This property specifies whether the UA may break at otherwise disallowed points within
+    a line to prevent overflow, when an otherwise-unbreakable string is too long to fit within the line box.
+    It only has an effect when white-space allows wrapping."
+    
+    (also see https://trac.webkit.org/changeset/10095/webkit where the wrapping behavior was introduced)
+    
+    Test: fast/text/no-wrap-in-pre-with-word-wrap.html
+    
+    * rendering/line/BreakingContext.h:
+    (WebCore::BreakingContext::handleText):
+    
+    LayoutTests:
+    
+    * fast/text/no-wrap-in-pre-with-word-wrap-expected.html: Added.
+    * fast/text/no-wrap-in-pre-with-word-wrap.html: Added.
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@281463 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-08-23  Alan Bujtas  <za...@apple.com>
+
+            Pre-formatted content gets distorted when attempting to select content
+            https://bugs.webkit.org/show_bug.cgi?id=228655
+            <rdar://81288187>
+
+            Reviewed by Simon Fraser.
+
+            https://drafts.csswg.org/css-text/#overflow-wrap-property
+
+            "This property specifies whether the UA may break at otherwise disallowed points within
+            a line to prevent overflow, when an otherwise-unbreakable string is too long to fit within the line box.
+            It only has an effect when white-space allows wrapping."
+
+            (also see https://trac.webkit.org/changeset/10095/webkit where the wrapping behavior was introduced)
+
+            Test: fast/text/no-wrap-in-pre-with-word-wrap.html
+
+            * rendering/line/BreakingContext.h:
+            (WebCore::BreakingContext::handleText):
+
 2021-10-06  Russell Epstein  <repst...@apple.com>
 
         Cherry-pick r283444. rdar://problem/83960033

Modified: branches/safari-612-branch/Source/WebCore/rendering/line/BreakingContext.h (283767 => 283768)


--- branches/safari-612-branch/Source/WebCore/rendering/line/BreakingContext.h	2021-10-08 02:01:12 UTC (rev 283767)
+++ branches/safari-612-branch/Source/WebCore/rendering/line/BreakingContext.h	2021-10-08 02:01:16 UTC (rev 283768)
@@ -701,7 +701,8 @@
     bool breakNBSP = m_autoWrap && style.nbspMode() == NBSPMode::Space;
     // Auto-wrapping text should wrap in the middle of a word only if it could not wrap before the word,
     // which is only possible if the word is the first thing on the line.
-    bool breakWords = style.breakWords() && ((m_autoWrap && (!m_width.committedWidth() && !m_width.hasCommittedReplaced())) || m_currWS == WhiteSpace::Pre);
+    auto isWrappingAllowed = !(m_currWS == WhiteSpace::Pre || m_currWS == WhiteSpace::NoWrap);
+    bool breakWords = isWrappingAllowed && style.breakWords() && !m_width.committedWidth() && !m_width.hasCommittedReplaced();
     bool midWordBreak = false;
     bool breakAnywhere = style.lineBreak() == LineBreak::Anywhere && m_autoWrap;
     bool breakAll = (style.wordBreak() == WordBreak::BreakAll || breakAnywhere) && m_autoWrap;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to