Avoid Assertion Failure in HarfBuzzRun::characterIndexForXPosition
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 30 Jul 2012 23:13:25 +0000 (23:13 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 30 Jul 2012 23:13:25 +0000 (23:13 +0000)
commit89866de4ab0dbaeb649c565bfd901f8457bab558
tree96755718e7b2b9c11b9cf8ab3377a0158a347b09
parenta1a6823a988b7bed88072c77674ed82ebc4f83c0
Avoid Assertion Failure in HarfBuzzRun::characterIndexForXPosition
https://bugs.webkit.org/show_bug.cgi?id=92376

Patch by Dominik Röttsches <dominik.rottsches@intel.com> on 2012-07-30
Reviewed by Tony Chang.

.:

Added manual test to reliably reproduce assertion failure which is solved by this patch.

* ManualTests/harfbuzz-mouse-selection-crash.html: Added.

Source/WebCore:

Previously, the if condition in offsetForPosition gating the call to
characterIndexForXPosition was comparing a different value than what was actually used
as the argument to calling it. In some cases, this can lead to a minuscule difference
when comparing the two floats - enough to trigger the assertion. To resolve this,
the accuracy of the index calculation is improved by changing the types from int
to floats and rephrasing the if condition to be exactly the same as what is checked
for in the assertion.

Manual test ManualTests/harfbuzz-mouse-selection-crash.html added
which reliably reproduces the assertion failure before this change.

* platform/graphics/harfbuzz/ng/HarfBuzzShaper.cpp:
(WebCore::HarfBuzzShaper::HarfBuzzRun::characterIndexForXPosition): Types changed to float.
(WebCore::HarfBuzzShaper::offsetForPosition): Types changed to float, if condition rephrased.
* platform/graphics/harfbuzz/ng/HarfBuzzShaper.h:
(HarfBuzzRun):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@124111 268f45cc-cd09-0410-ab3c-d52691b4dbfc
ChangeLog
ManualTests/harfbuzz-mouse-selection-crash.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/harfbuzz/ng/HarfBuzzShaper.cpp
Source/WebCore/platform/graphics/harfbuzz/ng/HarfBuzzShaper.h