Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(156)

Unified Diff: Source/platform/fonts/shaping/HarfBuzzShaper.cpp

Issue 1248453004: Change Font::offsetForPositionForComplexText to use CachingWordShapeIterator (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/platform/fonts/shaping/HarfBuzzShaper.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
« no previous file with comments | « Source/platform/fonts/shaping/HarfBuzzShaper.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698