| Index: Source/platform/fonts/shaping/HarfBuzzShaper.cpp
|
| diff --git a/Source/platform/fonts/shaping/HarfBuzzShaper.cpp b/Source/platform/fonts/shaping/HarfBuzzShaper.cpp
|
| index 22e181f679e9dc53fcc06f0451fa188630533f70..cf38fc428c40509d0026a5b7fe517f2878897fb8 100644
|
| --- a/Source/platform/fonts/shaping/HarfBuzzShaper.cpp
|
| +++ b/Source/platform/fonts/shaping/HarfBuzzShaper.cpp
|
| @@ -39,6 +39,7 @@
|
| #include "platform/fonts/Font.h"
|
| #include "platform/fonts/GlyphBuffer.h"
|
| #include "platform/fonts/UTF16TextIterator.h"
|
| +#include "platform/fonts/shaping/CachingWordShapeIterator.h"
|
| #include "platform/fonts/shaping/HarfBuzzFace.h"
|
| #include "platform/text/TextBreakIterator.h"
|
| #include "wtf/Compiler.h"
|
| @@ -441,6 +442,39 @@ FloatRect ShapeResult::selectionRect(Vector<RefPtr<ShapeResult>>& results,
|
| return FloatRect(point.x() + toX, point.y(), fromX - toX, height);
|
| }
|
|
|
| +int ShapeResult::offsetForPosition(CachingWordShapeIterator& iterator,
|
| + const TextRun& run, float targetX)
|
| +{
|
| + RefPtr<ShapeResult> wordResult;
|
| + unsigned totalOffset;
|
| + if (run.rtl()) {
|
| + totalOffset = run.length();
|
| + while (iterator.next(&wordResult)) {
|
| + if (!wordResult)
|
| + continue;
|
| + totalOffset -= wordResult->numCharacters();
|
| + if (targetX >= 0 && targetX <= wordResult->width()) {
|
| + int offsetForWord = wordResult->offsetForPosition(targetX);
|
| + return totalOffset + offsetForWord;
|
| + }
|
| + targetX -= wordResult->width();
|
| + }
|
| + } else {
|
| + totalOffset = 0;
|
| + while (iterator.next(&wordResult)) {
|
| + if (!wordResult)
|
| + continue;
|
| + int offsetForWord = wordResult->offsetForPosition(targetX);
|
| + ASSERT(offsetForWord >= 0);
|
| + totalOffset += offsetForWord;
|
| + if (targetX >= 0 && targetX <= wordResult->width())
|
| + return totalOffset;
|
| + targetX -= wordResult->width();
|
| + }
|
| + }
|
| + return totalOffset;
|
| +}
|
| +
|
| int ShapeResult::offsetForPosition(float targetX)
|
| {
|
| int charactersSoFar = 0;
|
|
|