[Harfbuzz] Wrong offset returned by HarfBuzzShaper::offsetForPosition() when target...
authorcarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 14 Sep 2017 15:37:44 +0000 (15:37 +0000)
committercarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 14 Sep 2017 15:37:44 +0000 (15:37 +0000)
https://bugs.webkit.org/show_bug.cgi?id=176897

Reviewed by Michael Catanzaro.

We should include the character when the point is greater than the center of the character.

Fixes: fast/multicol/hit-test-end-of-column-with-line-height.html
       fast/multicol/newmulticol/compare-with-old-impl/hit-test-end-of-column-with-line-height.html

* platform/graphics/harfbuzz/HarfBuzzShaper.cpp:
(WebCore::HarfBuzzShaper::HarfBuzzRun::characterIndexForXPosition):

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

Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/harfbuzz/HarfBuzzShaper.cpp

index d7fef62..bfe37d2 100644 (file)
@@ -1,3 +1,18 @@
+2017-09-14  Carlos Garcia Campos  <cgarcia@igalia.com>
+
+        [Harfbuzz] Wrong offset returned by HarfBuzzShaper::offsetForPosition() when target point is at the middle of a character
+        https://bugs.webkit.org/show_bug.cgi?id=176897
+
+        Reviewed by Michael Catanzaro.
+
+        We should include the character when the point is greater than the center of the character.
+
+        Fixes: fast/multicol/hit-test-end-of-column-with-line-height.html
+               fast/multicol/newmulticol/compare-with-old-impl/hit-test-end-of-column-with-line-height.html
+
+        * platform/graphics/harfbuzz/HarfBuzzShaper.cpp:
+        (WebCore::HarfBuzzShaper::HarfBuzzRun::characterIndexForXPosition):
+
 2017-09-14  Yusuke Suzuki  <utatane.tea@gmail.com>
 
         [JSC] Add PrivateSymbolMode::{Include,Exclude} for PropertyNameArray
index c7b1b83..e772d85 100644 (file)
@@ -114,11 +114,11 @@ unsigned HarfBuzzShaper::HarfBuzzRun::characterIndexForXPosition(float targetX,
         while (glyphIndex < m_numGlyphs - 1 && m_glyphToCharacterIndexes[glyphIndex + 1] == characterIndex)
             characterWidth += m_advances[++glyphIndex];
 
-        if ((includePartialGlyphs && (targetX < currentX + characterWidth / 2.0))
+        if ((includePartialGlyphs && (targetX <= currentX + characterWidth / 2.0))
             || (!includePartialGlyphs && (targetX < currentX + characterWidth)))
             return rtl() ? std::min(m_numCharacters, characterIndex + 1) : characterIndex;
 
-        if ((includePartialGlyphs && (targetX >= (currentX + characterWidth / 2.0) && targetX < currentX + characterWidth))
+        if ((includePartialGlyphs && (targetX > (currentX + characterWidth / 2.0) && targetX < currentX + characterWidth))
             || (!includePartialGlyphs && (targetX >= currentX && targetX < currentX + characterWidth)))
             break;