OLD | NEW |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |