Index: Source/platform/fonts/shaping/HarfBuzzShaper.cpp |
diff --git a/Source/platform/fonts/shaping/HarfBuzzShaper.cpp b/Source/platform/fonts/shaping/HarfBuzzShaper.cpp |
index daa42b5a57b288c9b85d1004da4c541f23665783..310eca5f3dec129348e01b46e1f6d3dc5d5f3686 100644 |
--- a/Source/platform/fonts/shaping/HarfBuzzShaper.cpp |
+++ b/Source/platform/fonts/shaping/HarfBuzzShaper.cpp |
@@ -446,6 +446,39 @@ FloatRect ShapeResult::selectionRect(Vector<RefPtr<ShapeResult>>& results, |
return FloatRect(point.x() + toX, point.y(), fromX - toX, height); |
} |
+int ShapeResult::offsetForPosition(Vector<RefPtr<ShapeResult>>& results, |
+ const TextRun& run, float targetX) |
+{ |
+ RefPtr<ShapeResult> wordResult; |
brucedawson
2015/08/11 19:01:06
This variable is never used and should be deleted.
|
+ unsigned totalOffset; |
+ if (run.rtl()) { |
+ totalOffset = run.length(); |
+ for (auto& wordResult : results) { |
+ 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; |
+ for (auto& wordResult : results) { |
+ 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; |