White space between inline blocks should be affected by word-spacing property
authorrobert@webkit.org <robert@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 12 Dec 2012 19:43:45 +0000 (19:43 +0000)
committerrobert@webkit.org <robert@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 12 Dec 2012 19:43:45 +0000 (19:43 +0000)
https://bugs.webkit.org/show_bug.cgi?id=69072

Reviewed by Levi Weintraub.

Source/WebCore:

Allow word-spacing to get added to the spaces between inline blocks in placeBoxesInInlineDirection by setting
needsWordSpacing to true each time an inline block is encountered. This ensures that the next space encountered
in a text run will be treated as a space between two words and will get word-spacing added to it if it is present
in the style.

Tests: fast/css/word-spacing-between-blocks.html
       fast/css/word-spacing-between-inlines.html

* rendering/InlineFlowBox.cpp:
(WebCore::InlineFlowBox::placeBoxRangeInInlineDirection):

LayoutTests:

* fast/css/word-spacing-between-blocks-expected.html: Added.
* fast/css/word-spacing-between-blocks.html: Added.
* fast/css/word-spacing-between-inlines-expected.html: Added.
* fast/css/word-spacing-between-inlines.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/fast/css/word-spacing-between-blocks-expected.html [new file with mode: 0644]
LayoutTests/fast/css/word-spacing-between-blocks.html [new file with mode: 0644]
LayoutTests/fast/css/word-spacing-between-inlines-expected.html [new file with mode: 0644]
LayoutTests/fast/css/word-spacing-between-inlines.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/rendering/InlineFlowBox.cpp

index 4c7c779..6750a0e 100644 (file)
@@ -1,3 +1,15 @@
+2012-12-12  Robert Hogan  <robert@webkit.org>
+
+        White space between inline blocks should be affected by word-spacing property
+        https://bugs.webkit.org/show_bug.cgi?id=69072
+
+        Reviewed by Levi Weintraub.
+
+        * fast/css/word-spacing-between-blocks-expected.html: Added.
+        * fast/css/word-spacing-between-blocks.html: Added.
+        * fast/css/word-spacing-between-inlines-expected.html: Added.
+        * fast/css/word-spacing-between-inlines.html: Added.
+
 2012-12-12  Adam Klein  <adamk@chromium.org>
 
         Mark calendar-picker-appearance tests as ImageOnlyFailures on cr-mac after r137473
diff --git a/LayoutTests/fast/css/word-spacing-between-blocks-expected.html b/LayoutTests/fast/css/word-spacing-between-blocks-expected.html
new file mode 100644 (file)
index 0000000..e94afc0
--- /dev/null
@@ -0,0 +1,56 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+    <meta charset="utf-8">
+    <title>White space processing</title>
+    <meta name="flags" content="ahem">
+    <link rel="help" href="http://www.w3.org/TR/CSS21/text.html#spacing-props" title="16.4 Letter and word spacing: the 'letter-spacing' and 'word-spacing' properties">
+    <link rel="author" title="Robert Hogan">
+    <style type="text/css">
+        .wordspacing {
+            margin:.2em 0;
+            word-spacing:-.5em;
+            font:18px Ahem,sans-serif;
+        }
+        .test {
+            margin:.2em 0;
+            font:18px Ahem,sans-serif;
+        }
+        .wordspacing>span,
+        .wordspacing-letters>span {
+            display:inline-block;
+        }
+    </style>
+</head>
+
+<body>
+
+<p> White space between inline blocks should be affected by the word-spacing property.
+     https://bugs.webkit.org/show_bug.cgi?id=69072 </p>
+
+<p>The following strings must be the same:</p>
+<div class="wordspacing">x x x</div>
+<div class="wordspacing">x x x</div>
+<div class="wordspacing">x x x</div>
+<div class="wordspacing">x x x</div>
+<div class="wordspacing">x x x</div>
+<div class="wordspacing">x x x</div>
+<div class="wordspacing">x x x</div>
+<div class="wordspacing">x x x</div>
+<div class="wordspacing">x x x</div>
+
+<p>The following strings must be the same:</p>
+<div class="test">x x x</div>
+<div class="test">x x x</div>
+<div class="test">x x x</div>
+<div class="test">x x x</div>
+<div class="test">x x x</div>
+<div class="test">x x x</div>
+<div class="test">x x x</div>
+
+<p>The following strings must be the same:</p>
+<div class="test">xxx</div>
+<div class="test">xxx</div>
+<div class="test">xxx</div>
+</body>
+</html>
diff --git a/LayoutTests/fast/css/word-spacing-between-blocks.html b/LayoutTests/fast/css/word-spacing-between-blocks.html
new file mode 100644 (file)
index 0000000..73ed393
--- /dev/null
@@ -0,0 +1,95 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+    <meta charset="utf-8">
+    <title>White space processing</title>
+    <meta name="flags" content="ahem">
+    <link rel="help" href="http://www.w3.org/TR/CSS21/text.html#spacing-props" title="16.4 Letter and word spacing: the 'letter-spacing' and 'word-spacing' properties">
+    <link rel="author" title="Robert Hogan">
+    <style type="text/css">
+        .wordspacing {
+            margin:.2em 0;
+            word-spacing:-.5em;
+            font:18px Ahem,sans-serif;
+        }
+        .nowordspacing {
+            font:18px Ahem,sans-serif;
+            margin:.2em 0;
+        }
+        .wordspacing>span,
+        .wordspacing-letters>span {
+            display:inline-block;
+        }
+    </style>
+</head>
+
+<body>
+
+<p> White space between inline blocks should be affected by the word-spacing property.
+     https://bugs.webkit.org/show_bug.cgi?id=69072 </p>
+
+<p>The following strings must be the same:</p>
+<div class="wordspacing">x x x</div>
+
+<div class="wordspacing">
+    <span>x</span>
+    <span>x</span>
+    <span>x</span>
+</div>
+
+<div class="wordspacing"><span>x</span> <span>x</span> <span>x</span></div>
+
+<div class="wordspacing"><span>x</span>  <span>x</span>  <span>x</span></div>
+
+<div class="wordspacing"><span>x</span> <span>x <span>x</span> </span></div>
+
+<div class="wordspacing"><span>x </span>  <span>x</span>  <span>x</span></div>
+
+<div class="wordspacing"> <span> x </span>  <span>x</span>  <span>x</span></div>
+
+<div class="wordspacing">
+    <span>x</span> 
+    <span>x <span>x</span> </span>
+</div>
+
+<div class="wordspacing">
+    <span>x</span> 
+    <span>x 
+        <span>x</span> 
+    </span>
+</div>
+
+<p>The following strings must be the same:</p>
+<div class="nowordspacing">x x x</div>
+
+<div class="nowordspacing">
+    <span>x</span>
+    <span>x</span>
+    <span>x</span>
+</div>
+
+<div class="nowordspacing"><span>x</span> <span>x</span> <span>x</span></div>
+
+<div class="nowordspacing"><span>x</span> <span>x <span>x</span> </span></div>
+
+<div class="nowordspacing"><span>x</span> <span>x <span>x</span> </span></div>
+
+<div class="nowordspacing">
+    <span>x</span> 
+    <span>x <span>x</span> </span>
+</div>
+
+<div class="nowordspacing">
+    <span>x</span> 
+    <span>x 
+        <span>x</span> 
+    </span>
+</div>
+
+<p>The following strings must be the same:</p>
+<div class="wordspacing">xxx</div>
+<div class="wordspacing"><span>x</span><span>x</span><span>x</span></div>
+<div class="nowordspacing"><span>x</span><span>x</span><span>x</span></div>
+
+</body>
+</html>
diff --git a/LayoutTests/fast/css/word-spacing-between-inlines-expected.html b/LayoutTests/fast/css/word-spacing-between-inlines-expected.html
new file mode 100644 (file)
index 0000000..5345275
--- /dev/null
@@ -0,0 +1,53 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+    <meta charset="utf-8">
+    <title>White space processing</title>
+    <meta name="flags" content="ahem">
+    <link rel="help" href="http://www.w3.org/TR/CSS21/text.html#spacing-props" title="16.4 Letter and word spacing: the 'letter-spacing' and 'word-spacing' properties">
+    <link rel="author" title="Robert Hogan">
+    <style type="text/css">
+        .wordspacing {
+            margin:.2em 0;
+            word-spacing:-.5em;
+            font:18px Ahem,sans-serif;
+        }
+        .test {
+            margin:.2em 0;
+            font:18px Ahem,sans-serif;
+        }
+        .wordspacing>span {
+            display:inline;
+        }
+    </style>
+</head>
+
+<body>
+
+<p> White space between inline blocks should be affected by the word-spacing property.
+     https://bugs.webkit.org/show_bug.cgi?id=69072 </p>
+
+<p>The following strings must be the same:</p>
+<div class="wordspacing">x x x</div>
+<div class="wordspacing">x x x</div>
+<div class="wordspacing">x x x</div>
+<div class="wordspacing">x x x</div>
+<div class="wordspacing">x x x</div>
+<div class="wordspacing">x x x</div>
+<div class="wordspacing">x x x</div>
+
+<p>The following strings must be the same:</p>
+<div class="test">x x x</div>
+<div class="test">x x x</div>
+<div class="test">x x x</div>
+<div class="test">x x x</div>
+<div class="test">x x x</div>
+<div class="test">x x x</div>
+<div class="test">x x x</div>
+
+<p>The following strings must be the same:</p>
+<div class="test">xxx</div>
+<div class="test">xxx</div>
+<div class="test">xxx</div>
+</body>
+</html>
diff --git a/LayoutTests/fast/css/word-spacing-between-inlines.html b/LayoutTests/fast/css/word-spacing-between-inlines.html
new file mode 100644 (file)
index 0000000..7240c15
--- /dev/null
@@ -0,0 +1,81 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+    <meta charset="utf-8">
+    <title>White space processing</title>
+    <meta name="flags" content="ahem">
+    <link rel="help" href="http://www.w3.org/TR/CSS21/text.html#spacing-props" title="16.4 Letter and word spacing: the 'letter-spacing' and 'word-spacing' properties">
+    <link rel="author" title="Robert Hogan">
+    <style type="text/css">
+        .wordspacing {
+            margin:.2em 0;
+            word-spacing:-.5em;
+            font:18px Ahem,sans-serif;
+        }
+        .nowordspacing {
+            font:18px Ahem,sans-serif;
+            margin:.2em 0;
+        }
+        .wordspacing>span,
+        .wordspacing-letters>span {
+            display:inline;
+        }
+    </style>
+</head>
+
+<body>
+
+<p> White space between inline blocks should be affected by the word-spacing property.
+     https://bugs.webkit.org/show_bug.cgi?id=69072 </p>
+
+<p>The following strings must be the same:</p>
+<div class="wordspacing">x x x</div>
+
+<div class="wordspacing">
+    <span>x</span>
+    <span>x</span>
+    <span>x</span>
+</div>
+<div class="wordspacing"><span>x</span> <span>x</span> <span>x</span></div>
+<div class="wordspacing"><span>x</span>  <span>x</span>  <span>x</span></div>
+
+<div class="wordspacing"><span>x</span> <span>x <span>x</span> </span></div>
+<div class="wordspacing">
+    <span>x</span> 
+    <span>x <span>x</span> </span>
+</div>
+<div class="wordspacing">
+    <span>x</span> 
+    <span>x 
+        <span>x</span> 
+    </span>
+</div>
+
+<p>The following strings must be the same:</p>
+<div class="nowordspacing">x x x</div>
+<div class="nowordspacing">
+    <span>x</span>
+    <span>x</span>
+    <span>x</span>
+</div>
+<div class="nowordspacing"><span>x</span> <span>x</span> <span>x</span></div>
+<div class="nowordspacing"><span>x</span> <span>x <span>x</span> </span></div>
+<div class="nowordspacing"><span>x</span> <span>x <span>x</span> </span></div>
+<div class="nowordspacing">
+    <span>x</span> 
+    <span>x <span>x</span> </span>
+</div>
+<div class="nowordspacing">
+    <span>x</span> 
+    <span>x 
+        <span>x</span> 
+    </span>
+</div>
+
+<p>The following strings must be the same:</p>
+<div class="wordspacing">xxx</div>
+<div class="wordspacing"><span>x</span><span>x</span><span>x</span></div>
+<div class="nowordspacing"><span>x</span><span>x</span><span>x</span></div>
+
+</body>
+</html>
index 308ba32..708b72e 100644 (file)
@@ -1,3 +1,21 @@
+2012-12-12  Robert Hogan  <robert@webkit.org>
+
+        White space between inline blocks should be affected by word-spacing property
+        https://bugs.webkit.org/show_bug.cgi?id=69072
+
+        Reviewed by Levi Weintraub.
+
+        Allow word-spacing to get added to the spaces between inline blocks in placeBoxesInInlineDirection by setting
+        needsWordSpacing to true each time an inline block is encountered. This ensures that the next space encountered
+        in a text run will be treated as a space between two words and will get word-spacing added to it if it is present
+        in the style.
+
+        Tests: fast/css/word-spacing-between-blocks.html
+               fast/css/word-spacing-between-inlines.html
+
+        * rendering/InlineFlowBox.cpp:
+        (WebCore::InlineFlowBox::placeBoxRangeInInlineDirection):
+
 2012-12-12  Xianzhu Wang  <wangxianzhu@chromium.org>
 
         Pre-painting should not paint out-of-view fixed position elements
index 387f8b2..691c07b 100644 (file)
@@ -435,6 +435,8 @@ float InlineFlowBox::placeBoxRangeInInlineDirection(InlineBox* firstChild, Inlin
                 if (knownToHaveNoOverflow())
                     maxLogicalRight = max(logicalLeft, maxLogicalRight);
                 logicalLeft += logicalRightMargin;
+                // If we encounter any space after this inline block then ensure it is treated as the space between two words.
+                needsWordSpacing = true;
             }
         }
     }