When kerning is enabled, word spacing is doubly accounted for in RenderText::computeP...
authormitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 19 Sep 2012 23:37:36 +0000 (23:37 +0000)
committermitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 19 Sep 2012 23:37:36 +0000 (23:37 +0000)
https://bugs.webkit.org/show_bug.cgi?id=97146

Reviewed by Anders Carlsson.

Source/WebCore:

Test: fast/text/word-space-with-kerning.html

* rendering/RenderText.cpp:
(WebCore::RenderText::computePreferredLogicalWidths): When kerning is enabled, words are
measured with their trailing space, if there is one, then the width of a space is subtracted.
Changed that width, stored in the local variable wordTrailingSpaceWidth, to include the
word spacing, since it is included in the result of widthFromCache().

LayoutTests:

* fast/text/word-space-with-kerning-expected.html: Added.
* fast/text/word-space-with-kerning.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/fast/text/word-space-with-kerning-expected.html [new file with mode: 0644]
LayoutTests/fast/text/word-space-with-kerning.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderText.cpp

index 1be2d13..9a932af 100644 (file)
@@ -1,3 +1,13 @@
+2012-09-19  Dan Bernstein  <mitz@apple.com>
+
+        When kerning is enabled, word spacing is doubly accounted for in RenderText::computePreferredLogicalWidths
+        https://bugs.webkit.org/show_bug.cgi?id=97146
+
+        Reviewed by Anders Carlsson.
+
+        * fast/text/word-space-with-kerning-expected.html: Added.
+        * fast/text/word-space-with-kerning.html: Added.
+
 2012-09-19  Dirk Pranke  <dpranke@chromium.org>
 
         Fix lines missed (??) in mac-wk2/TestExpectations
diff --git a/LayoutTests/fast/text/word-space-with-kerning-expected.html b/LayoutTests/fast/text/word-space-with-kerning-expected.html
new file mode 100644 (file)
index 0000000..512363a
--- /dev/null
@@ -0,0 +1,8 @@
+<div style="font-size: 20px; font-family: ahem; -webkit-font-smoothing: none;">
+    <div>
+        <span style="word-spacing: 60px">a b c d </span> e
+    </div>
+    <div>
+        <span style="word-spacing: 60px">a b c d </span> e
+    </div>
+</div>
diff --git a/LayoutTests/fast/text/word-space-with-kerning.html b/LayoutTests/fast/text/word-space-with-kerning.html
new file mode 100644 (file)
index 0000000..48b8d5c
--- /dev/null
@@ -0,0 +1,8 @@
+<div style="font-size: 20px; font-family: ahem; -webkit-font-smoothing: none;">
+    <div>
+        <span style="word-spacing: 60px">a b c d </span> e
+    </div>
+    <div style="-webkit-font-kerning: normal;">
+        <span style="word-spacing: 60px">a b c d </span> e
+    </div>
+</div>
index f9ce4d5..96f177b 100644 (file)
@@ -1,3 +1,18 @@
+2012-09-19  Dan Bernstein  <mitz@apple.com>
+
+        When kerning is enabled, word spacing is doubly accounted for in RenderText::computePreferredLogicalWidths
+        https://bugs.webkit.org/show_bug.cgi?id=97146
+
+        Reviewed by Anders Carlsson.
+
+        Test: fast/text/word-space-with-kerning.html
+
+        * rendering/RenderText.cpp:
+        (WebCore::RenderText::computePreferredLogicalWidths): When kerning is enabled, words are
+        measured with their trailing space, if there is one, then the width of a space is subtracted.
+        Changed that width, stored in the local variable wordTrailingSpaceWidth, to include the
+        word spacing, since it is included in the result of widthFromCache().
+
 2012-09-19  Joshua Bell  <jsbell@chromium.org>
 
         IndexedDB: Remove "current transaction" concept from backing store
index 7edad3b..7761fc1 100644 (file)
@@ -966,7 +966,7 @@ void RenderText::computePreferredLogicalWidths(float leadWidth, HashSet<const Si
 
     // Non-zero only when kerning is enabled, in which case we measure words with their trailing
     // space, then subtract its width.
-    float wordTrailingSpaceWidth = f.typesettingFeatures() & Kerning ? f.width(RenderBlock::constructTextRun(this, f, &space, 1, styleToUse)) : 0;
+    float wordTrailingSpaceWidth = f.typesettingFeatures() & Kerning ? f.width(RenderBlock::constructTextRun(this, f, &space, 1, styleToUse)) + wordSpacing : 0;
 
     // If automatic hyphenation is allowed, we keep track of the width of the widest word (or word
     // fragment) encountered so far, and only try hyphenating words that are wider.