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

Side by Side Diff: Source/platform/fonts/shaping/CachingWordShaper.cpp

Issue 1248453004: Change Font::offsetForPositionForComplexText to use CachingWordShapeIterator (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: TestExpectations and rebase Created 5 years, 5 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2015 Google Inc. All rights reserved. 2 * Copyright (C) 2015 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 if (wordResult) { 61 if (wordResult) {
62 width += wordResult->width(); 62 width += wordResult->width();
63 if (glyphBounds) 63 if (glyphBounds)
64 glyphBounds->unite(wordResult->bounds()); 64 glyphBounds->unite(wordResult->bounds());
65 } 65 }
66 } 66 }
67 67
68 return width; 68 return width;
69 } 69 }
70 70
71 int CachingWordShaper::offsetForPosition(const Font* font, const TextRun& run, f loat targetX)
72 {
73 HashSet<const SimpleFontData*> fallbackFonts;
74 CachingWordShapeIterator iterator(m_shapeCache, run, font, &fallbackFonts);
75 return ShapeResult::offsetForPosition(iterator, run, targetX);
76 }
77
71 static inline float shapeResultsForRun(ShapeCache* shapeCache, const Font* font, 78 static inline float shapeResultsForRun(ShapeCache* shapeCache, const Font* font,
72 const TextRun& run, HashSet<const SimpleFontData*>* fallbackFonts, 79 const TextRun& run, HashSet<const SimpleFontData*>* fallbackFonts,
73 Vector<RefPtr<ShapeResult>>* results) 80 Vector<RefPtr<ShapeResult>>* results)
74 { 81 {
75 CachingWordShapeIterator iterator(shapeCache, run, font, fallbackFonts); 82 CachingWordShapeIterator iterator(shapeCache, run, font, fallbackFonts);
76 RefPtr<ShapeResult> wordResult; 83 RefPtr<ShapeResult> wordResult;
77 float totalWidth = 0; 84 float totalWidth = 0;
78 while (iterator.next(&wordResult)) { 85 while (iterator.next(&wordResult)) {
79 if (wordResult) { 86 if (wordResult) {
80 results->append(wordResult); 87 results->append(wordResult);
(...skipping 29 matching lines...) Expand all
110 { 117 {
111 Vector<RefPtr<ShapeResult>> results; 118 Vector<RefPtr<ShapeResult>> results;
112 float totalWidth = shapeResultsForRun(m_shapeCache, font, run, nullptr, 119 float totalWidth = shapeResultsForRun(m_shapeCache, font, run, nullptr,
113 &results); 120 &results);
114 121
115 return ShapeResult::selectionRect(results, run.direction(), totalWidth, 122 return ShapeResult::selectionRect(results, run.direction(), totalWidth,
116 point, height, from, to); 123 point, height, from, to);
117 } 124 }
118 125
119 }; // namespace blink 126 }; // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698