Title: [222141] trunk/Source/WebCore
Revision
222141
Author
[email protected]
Date
2017-09-17 22:22:33 -0700 (Sun, 17 Sep 2017)

Log Message

REGRESSION(r221974): [Harfbuzz] Test fast/text/international/hebrew-selection.html is failing since r221974
https://bugs.webkit.org/show_bug.cgi?id=177036

Reviewed by Michael Catanzaro.

In r221974 I rewrote the characterIndexForXPosition implementation without taking into account that there can be
multiple glyphs for the same character, so we can't simply do index++ and index-- to get the next and previous
character index.

* platform/graphics/harfbuzz/HarfBuzzShaper.cpp:
(WebCore::HarfBuzzShaper::HarfBuzzRun::characterIndexForXPosition): Always get the character index from
m_glyphToCharacterIndexes array.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (222140 => 222141)


--- trunk/Source/WebCore/ChangeLog	2017-09-18 05:05:56 UTC (rev 222140)
+++ trunk/Source/WebCore/ChangeLog	2017-09-18 05:22:33 UTC (rev 222141)
@@ -1,5 +1,20 @@
 2017-09-17  Carlos Garcia Campos  <[email protected]>
 
+        REGRESSION(r221974): [Harfbuzz] Test fast/text/international/hebrew-selection.html is failing since r221974
+        https://bugs.webkit.org/show_bug.cgi?id=177036
+
+        Reviewed by Michael Catanzaro.
+
+        In r221974 I rewrote the characterIndexForXPosition implementation without taking into account that there can be
+        multiple glyphs for the same character, so we can't simply do index++ and index-- to get the next and previous
+        character index.
+
+        * platform/graphics/harfbuzz/HarfBuzzShaper.cpp:
+        (WebCore::HarfBuzzShaper::HarfBuzzRun::characterIndexForXPosition): Always get the character index from
+        m_glyphToCharacterIndexes array.
+
+2017-09-17  Carlos Garcia Campos  <[email protected]>
+
         [Harfbuzz] Test fast/text/complex-text-selection.html is failing since r222090
         https://bugs.webkit.org/show_bug.cgi?id=177035
 

Modified: trunk/Source/WebCore/platform/graphics/harfbuzz/HarfBuzzShaper.cpp (222140 => 222141)


--- trunk/Source/WebCore/platform/graphics/harfbuzz/HarfBuzzShaper.cpp	2017-09-18 05:05:56 UTC (rev 222140)
+++ trunk/Source/WebCore/platform/graphics/harfbuzz/HarfBuzzShaper.cpp	2017-09-18 05:22:33 UTC (rev 222141)
@@ -108,6 +108,8 @@
     unsigned glyphIndex = 0;
     float characterWidth = 0;
     unsigned characterIndex = 0;
+    unsigned previousCharacterIndex = m_numCharacters;
+
     do {
         characterIndex = m_glyphToCharacterIndexes[glyphIndex];
         characterWidth = m_advances[glyphIndex];
@@ -116,7 +118,7 @@
 
         if ((includePartialGlyphs && (targetX <= currentX + characterWidth / 2.0))
             || (!includePartialGlyphs && (targetX < currentX + characterWidth)))
-            return rtl() ? std::min(m_numCharacters, characterIndex + 1) : characterIndex;
+            return rtl() ? previousCharacterIndex : characterIndex;
 
         if ((includePartialGlyphs && (targetX > (currentX + characterWidth / 2.0) && targetX < currentX + characterWidth))
             || (!includePartialGlyphs && (targetX >= currentX && targetX < currentX + characterWidth)))
@@ -124,9 +126,10 @@
 
         currentX += characterWidth;
         ++glyphIndex;
+        previousCharacterIndex = characterIndex;
     } while (glyphIndex < m_numGlyphs);
 
-    return rtl() ? characterIndex : std::min(m_numCharacters, characterIndex + 1);
+    return rtl() ? characterIndex : glyphIndex < m_numGlyphs - 1 ? m_glyphToCharacterIndexes[glyphIndex + 1] : m_numCharacters;
 }
 
 float HarfBuzzShaper::HarfBuzzRun::xPositionForOffset(unsigned offset)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to