REGRESSION (r129176): Incorrect line breaking when kerning occurs between a space...
authormitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 22 Sep 2012 01:00:01 +0000 (01:00 +0000)
committermitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 22 Sep 2012 01:00:01 +0000 (01:00 +0000)
https://bugs.webkit.org/show_bug.cgi?id=97377

Reviewed by Enrica Casucci.

Source/WebCore:

Test: fast/text/kerning-with-TextLayout.html

When kerning is enabled, the last character in a word may have its advance shortened because
of its trailing space. To account for that, words are measured along with the trailing space,
then the width of a space is subtracted from the result. This doesn’t work when the trailing
space itself has its advance shortened due to the character following it, which can happen
when using the TextLayout optimization. However, when the optimization is used, the advance
of the last character of the word is already adjusted for the trailing space, so there is no
need to measure with that space and subtract its advance.

* rendering/RenderBlockLineLayout.cpp:
(WebCore::RenderBlock::LineBreaker::nextLineBreak): Changed to not use the trailingSpaceWidth
mechanism when TextLayout is being used.

LayoutTests:

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

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

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

index 1199903..94eec66 100644 (file)
@@ -1,3 +1,13 @@
+2012-09-21  Dan Bernstein  <mitz@apple.com>
+
+        REGRESSION (r129176): Incorrect line breaking when kerning occurs between a space and the following character
+        https://bugs.webkit.org/show_bug.cgi?id=97377
+
+        Reviewed by Enrica Casucci.
+
+        * fast/text/kerning-with-TextLayout-expected.html: Added.
+        * fast/text/kerning-with-TextLayout.html: Added.
+
 2012-09-21  Gavin Barraclough  <barraclough@apple.com>
 
         instanceof should not get the prototype for non-default HasInstance
diff --git a/LayoutTests/fast/text/kerning-with-TextLayout-expected.html b/LayoutTests/fast/text/kerning-with-TextLayout-expected.html
new file mode 100644 (file)
index 0000000..e980f2f
--- /dev/null
@@ -0,0 +1,3 @@
+<div style="width: 80px; border: solid blue; font-size: 56px; -webkit-font-kerning: normal;">
+.<br>W
+</div>
diff --git a/LayoutTests/fast/text/kerning-with-TextLayout.html b/LayoutTests/fast/text/kerning-with-TextLayout.html
new file mode 100644 (file)
index 0000000..742c1fc
--- /dev/null
@@ -0,0 +1,3 @@
+<div style="width: 80px; border: solid blue; font-size: 56px; -webkit-font-kerning: normal;">
+.  W
+</div>
index eef3fae..b13a294 100644 (file)
@@ -1,3 +1,24 @@
+2012-09-21  Dan Bernstein  <mitz@apple.com>
+
+        REGRESSION (r129176): Incorrect line breaking when kerning occurs between a space and the following character
+        https://bugs.webkit.org/show_bug.cgi?id=97377
+
+        Reviewed by Enrica Casucci.
+
+        Test: fast/text/kerning-with-TextLayout.html
+
+        When kerning is enabled, the last character in a word may have its advance shortened because
+        of its trailing space. To account for that, words are measured along with the trailing space,
+        then the width of a space is subtracted from the result. This doesn’t work when the trailing
+        space itself has its advance shortened due to the character following it, which can happen
+        when using the TextLayout optimization. However, when the optimization is used, the advance
+        of the last character of the word is already adjusted for the trailing space, so there is no
+        need to measure with that space and subtract its advance.
+
+        * rendering/RenderBlockLineLayout.cpp:
+        (WebCore::RenderBlock::LineBreaker::nextLineBreak): Changed to not use the trailingSpaceWidth
+        mechanism when TextLayout is being used.
+
 2012-09-21  Adam Klein  <adamk@chromium.org>
 
         Simplify and optimize ChildListMutationScope
index cbcc988..bfe03b8 100755 (executable)
@@ -2414,10 +2414,6 @@ InlineIterator RenderBlock::LineBreaker::nextLineBreak(InlineBidiResolver& resol
             float wordSpacing = currentStyle->wordSpacing();
             float lastSpaceWordSpacing = 0;
 
-            // 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(constructTextRun(t, f, &space, 1, style)) + wordSpacing : 0;
-
             float wrapW = width.uncommittedWidth() + inlineLogicalWidth(current.m_obj, !appliedStartWidth, true);
             float charWidth = 0;
             bool breakNBSP = autoWrap && currentStyle->nbspMode() == SPACE;
@@ -2447,6 +2443,10 @@ InlineIterator RenderBlock::LineBreaker::nextLineBreak(InlineBidiResolver& resol
 
             TextLayout* textLayout = renderTextInfo.m_layout.get();
 
+            // Non-zero only when kerning is enabled and TextLayout isn't used, in which case we measure
+            // words with their trailing space, then subtract its width.
+            float wordTrailingSpaceWidth = (f.typesettingFeatures() & Kerning) && !textLayout ? f.width(constructTextRun(t, f, &space, 1, style)) + wordSpacing : 0;
+
             for (; current.m_pos < t->textLength(); current.fastIncrementInTextNode()) {
                 bool previousCharacterIsSpace = currentCharacterIsSpace;
                 bool previousCharacterIsWS = currentCharacterIsWS;