Simple line layout: Add support for non-breaking space character.
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 20 Jan 2017 22:12:02 +0000 (22:12 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 20 Jan 2017 22:12:02 +0000 (22:12 +0000)
https://bugs.webkit.org/show_bug.cgi?id=167250
<rdar://problem/30119638>

Reviewed by Antti Koivisto.
Source/WebCore:

Do not bail out on noBreakSpace character.
The line breaking logic already takes noBreakSpace characters into account.
(except the peculiar "-webkit-nbsp-mode: space" mode)

Covered by existing test cases.

* rendering/SimpleLineLayout.cpp:
(WebCore::SimpleLineLayout::canUseForText):
(WebCore::SimpleLineLayout::canUseForStyle):
(WebCore::SimpleLineLayout::printReason):

LayoutTests:

These are output progressions (they do not reflect changes in functionality).

* fast/block/float/br-with-clear-2-expected.txt:
* platform/mac/css1/text_properties/text_transform-expected.txt:
* platform/mac/tables/mozilla/bugs/bug4427-expected.txt:

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

LayoutTests/ChangeLog
LayoutTests/fast/block/float/br-with-clear-2-expected.txt
LayoutTests/platform/mac/css1/text_properties/text_transform-expected.txt
LayoutTests/platform/mac/tables/mozilla/bugs/bug4427-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/rendering/SimpleLineLayout.cpp

index 07f4fc0..9805aac 100644 (file)
@@ -1,3 +1,17 @@
+2017-01-20  Zalan Bujtas  <zalan@apple.com>
+
+        Simple line layout: Add support for non-breaking space character.
+        https://bugs.webkit.org/show_bug.cgi?id=167250
+        <rdar://problem/30119638>
+
+        Reviewed by Antti Koivisto.
+        
+        These are output progressions (they do not reflect changes in functionality).
+
+        * fast/block/float/br-with-clear-2-expected.txt:
+        * platform/mac/css1/text_properties/text_transform-expected.txt:
+        * platform/mac/tables/mozilla/bugs/bug4427-expected.txt:
+
 2017-01-20  Ryan Haddad  <ryanhaddad@apple.com>
 
         Marking macos-fullscreen-media-controls/macos-fullscreen-media-controls-buttons-containers-styles.html as flaky on mac-wk1.
index efd3782..35bd696 100644 (file)
@@ -7,7 +7,7 @@ layer at (0,0) size 785x1228
         RenderBlock (floating) {DIV} at (0,0) size 50x50 [color=#FF0000] [bgcolor=#FFFFE0]
           RenderText {#text} at (0,0) size 75x25
             text run at (0,0) width 75: "  A"
-          RenderBR {BR} at (0,0) size 0x0
+          RenderBR {BR} at (75,20) size 0x0
           RenderBR {BR} at (0,25) size 0x25
           RenderText {#text} at (0,50) size 25x25
             text run at (0,50) width 25: "B"
@@ -22,7 +22,7 @@ layer at (0,0) size 785x1228
         RenderBlock (floating) {DIV} at (0,0) size 50x50 [color=#FF0000] [bgcolor=#FFFFE0]
           RenderText {#text} at (0,0) size 75x25
             text run at (0,0) width 75: "  A"
-          RenderBR {BR} at (0,0) size 0x0
+          RenderBR {BR} at (75,20) size 0x0
           RenderBR {BR} at (0,25) size 0x25
           RenderText {#text} at (0,50) size 25x25
             text run at (0,50) width 25: "B"
index 3a83597..c338914 100644 (file)
@@ -70,7 +70,7 @@ layer at (0,0) size 785x732
               RenderBlock {P} at (4,56) size 747x54
                 RenderText {#text} at (0,0) size 724x54
                   text run at (0,0) width 724: "This Paragraph Is Capitalized And The First Letter In Each Word Should Therefore Appear In Uppercase. Words"
-                  text run at (0,18) width 719: "That Are In Uppercase In The Source (E.g. USA) Should Remain So. There Should Be A Capital Letter After A"
+                  text run at (0,18) width 718: "That Are In Uppercase In The Source (E.g. USA) Should Remain So. There Should Be A Capital Letter After A"
                   text run at (0,36) width 577: "Non-Breaking Space (&Nbsp;). Both Those Characters Appear In The Previous Sentence."
               RenderBlock {P} at (4,126) size 747x36
                 RenderText {#text} at (0,0) size 743x36
index 4d1741d..da9b331 100644 (file)
@@ -94,7 +94,7 @@ layer at (0,0) size 800x600
                 text run at (2,56) width 103: "San Francisco,  "
                 text run at (104,56) width 31: "CA  "
                 text run at (134,56) width 45: "94132 "
-              RenderBR {BR} at (0,0) size 0x0
+              RenderBR {BR} at (178,70) size 1x0
             RenderTableCell {TD} at (252,1) size 25x5 [border: (1px inset #808080)] [r=0 c=2 rs=1 cs=1]
               RenderImage {IMG} at (2,2) size 20x1
             RenderTableCell {TD} at (277,1) size 148x38 [border: (1px inset #808080)] [r=0 c=3 rs=1 cs=1]
@@ -125,7 +125,7 @@ layer at (0,0) size 800x600
               RenderText {#text} at (2,56) size 75x18
                 text run at (2,56) width 31: "CA  "
                 text run at (32,56) width 45: "00000 "
-              RenderBR {BR} at (0,0) size 0x0
+              RenderBR {BR} at (76,70) size 1x0
               RenderText {#text} at (2,74) size 100x18
                 text run at (2,74) width 100: "(000) 000-0000"
             RenderTableCell {TD} at (252,102) size 25x5 [border: (1px inset #808080)] [r=2 c=2 rs=1 cs=1]
index 76d1303..0c0ec6f 100644 (file)
@@ -1,3 +1,22 @@
+2017-01-20  Zalan Bujtas  <zalan@apple.com>
+
+        Simple line layout: Add support for non-breaking space character.
+        https://bugs.webkit.org/show_bug.cgi?id=167250
+        <rdar://problem/30119638>
+
+        Reviewed by Antti Koivisto.
+
+        Do not bail out on noBreakSpace character.
+        The line breaking logic already takes noBreakSpace characters into account.
+        (except the peculiar "-webkit-nbsp-mode: space" mode)
+
+        Covered by existing test cases.
+
+        * rendering/SimpleLineLayout.cpp:
+        (WebCore::SimpleLineLayout::canUseForText):
+        (WebCore::SimpleLineLayout::canUseForStyle):
+        (WebCore::SimpleLineLayout::printReason):
+
 2017-01-20  Antoine Quint  <graouts@apple.com>
 
         Web Animations should be off by default and enabled as an experimental feature
index 98488b1..e88258d 100644 (file)
@@ -76,27 +76,27 @@ enum AvoidanceReason_ : uint64_t {
     FlowHasUnsupportedUnderlineDecoration = 1LLU  << 11,
     FlowHasJustifiedNonLatinText          = 1LLU  << 12,
     FlowHasOverflowVisible                = 1LLU  << 13,
-    FlowIsNotLTR                          = 1LLU  << 14,
-    FlowHasLineBoxContainProperty         = 1LLU  << 15,
-    FlowIsNotTopToBottom                  = 1LLU  << 16,
-    FlowHasLineBreak                      = 1LLU  << 17,
-    FlowHasNonNormalUnicodeBiDi           = 1LLU  << 18,
-    FlowHasRTLOrdering                    = 1LLU  << 19,
-    FlowHasLineAlignEdges                 = 1LLU  << 20,
-    FlowHasLineSnap                       = 1LLU  << 21,
-    FlowHasHypensAuto                     = 1LLU  << 22,
-    FlowHasTextEmphasisFillOrMark         = 1LLU  << 23,
-    FlowHasTextShadow                     = 1LLU  << 24,
-    FlowHasPseudoFirstLine                = 1LLU  << 25,
-    FlowHasPseudoFirstLetter              = 1LLU  << 26,
-    FlowHasTextCombine                    = 1LLU  << 27,
-    FlowHasTextFillBox                    = 1LLU  << 28,
-    FlowHasBorderFitLines                 = 1LLU  << 29,
-    FlowHasNonAutoLineBreak               = 1LLU  << 30,
-    FlowHasNonAutoTrailingWord            = 1LLU  << 31,
-    FlowHasSVGFont                        = 1LLU  << 32,
-    FlowTextIsEmpty                       = 1LLU  << 33,
-    FlowTextHasNoBreakSpace               = 1LLU  << 34,
+    FlowHasWebKitNBSPMode                 = 1LLU  << 14,
+    FlowIsNotLTR                          = 1LLU  << 15,
+    FlowHasLineBoxContainProperty         = 1LLU  << 16,
+    FlowIsNotTopToBottom                  = 1LLU  << 17,
+    FlowHasLineBreak                      = 1LLU  << 18,
+    FlowHasNonNormalUnicodeBiDi           = 1LLU  << 19,
+    FlowHasRTLOrdering                    = 1LLU  << 20,
+    FlowHasLineAlignEdges                 = 1LLU  << 21,
+    FlowHasLineSnap                       = 1LLU  << 22,
+    FlowHasHypensAuto                     = 1LLU  << 23,
+    FlowHasTextEmphasisFillOrMark         = 1LLU  << 24,
+    FlowHasTextShadow                     = 1LLU  << 25,
+    FlowHasPseudoFirstLine                = 1LLU  << 26,
+    FlowHasPseudoFirstLetter              = 1LLU  << 27,
+    FlowHasTextCombine                    = 1LLU  << 28,
+    FlowHasTextFillBox                    = 1LLU  << 29,
+    FlowHasBorderFitLines                 = 1LLU  << 30,
+    FlowHasNonAutoLineBreak               = 1LLU  << 31,
+    FlowHasNonAutoTrailingWord            = 1LLU  << 32,
+    FlowHasSVGFont                        = 1LLU  << 33,
+    FlowTextIsEmpty                       = 1LLU  << 34,
     FlowTextHasSoftHyphen                 = 1LLU  << 35,
     FlowTextHasDirectionCharacter         = 1LLU  << 36,
     FlowIsMissingPrimaryFont              = 1LLU  << 37,
@@ -156,9 +156,6 @@ static AvoidanceReasonFlags canUseForText(const CharacterType* text, unsigned le
                 SET_REASON_AND_RETURN_IF_NEEDED(FlowHasJustifiedNonLatinText, reasons, includeReasons);
         }
 
-        // These would be easy to support.
-        if (character == noBreakSpace)
-            SET_REASON_AND_RETURN_IF_NEEDED(FlowTextHasNoBreakSpace, reasons, includeReasons);
         if (character == softHyphen)
             SET_REASON_AND_RETURN_IF_NEEDED(FlowTextHasSoftHyphen, reasons, includeReasons);
 
@@ -257,6 +254,8 @@ static AvoidanceReasonFlags canUseForStyle(const RenderStyle& style, IncludeReas
         SET_REASON_AND_RETURN_IF_NEEDED(FlowHasBorderFitLines, reasons, includeReasons);
     if (style.lineBreak() != LineBreakAuto)
         SET_REASON_AND_RETURN_IF_NEEDED(FlowHasNonAutoLineBreak, reasons, includeReasons);
+    if (style.nbspMode() != NBNORMAL)
+        SET_REASON_AND_RETURN_IF_NEEDED(FlowHasWebKitNBSPMode, reasons, includeReasons);
 #if ENABLE(CSS_TRAILING_WORD)
     if (style.trailingWord() != TrailingWord::Auto)
         SET_REASON_AND_RETURN_IF_NEEDED(FlowHasNonAutoTrailingWord, reasons, includeReasons);
@@ -930,6 +929,9 @@ static void printReason(AvoidanceReason reason, TextStream& stream)
     case FlowHasOverflowVisible:
         stream << "overflow: visible";
         break;
+    case FlowHasWebKitNBSPMode:
+        stream << "-webkit-nbsp-mode: space";
+        break;
     case FlowIsNotLTR:
         stream << "dir is not LTR";
         break;
@@ -984,9 +986,6 @@ static void printReason(AvoidanceReason reason, TextStream& stream)
     case FlowHasSVGFont:
         stream << "SVG font";
         break;
-    case FlowTextHasNoBreakSpace:
-        stream << "No-break-space character";
-        break;
     case FlowTextHasSoftHyphen:
         stream << "soft hyphen character";
         break;