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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 if (m_shapeCache) | 49 if (m_shapeCache) |
50 m_shapeCache->clear(); | 50 m_shapeCache->clear(); |
51 } | 51 } |
52 | 52 |
53 float CachingWordShaper::width(const Font* font, const TextRun& run, | 53 float CachingWordShaper::width(const Font* font, const TextRun& run, |
54 HashSet<const SimpleFontData*>* fallbackFonts, | 54 HashSet<const SimpleFontData*>* fallbackFonts, |
55 FloatRect* glyphBounds) | 55 FloatRect* glyphBounds) |
56 { | 56 { |
57 float width = 0; | 57 float width = 0; |
58 RefPtr<ShapeResult> wordResult; | 58 RefPtr<ShapeResult> wordResult; |
59 CachingWordShapeIterator iterator(m_shapeCache, run, font); | 59 CachingWordShapeIterator iterator(m_shapeCache, run, font, fallbackFonts); |
60 while (iterator.next(&wordResult)) { | 60 while (iterator.next(&wordResult)) { |
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 if (fallbackFonts) | |
66 wordResult->fallbackFonts(fallbackFonts); | |
67 } | 65 } |
68 } | 66 } |
69 | 67 |
70 return width; | 68 return width; |
71 } | 69 } |
72 | 70 |
73 static inline float shapeResultsForRun(ShapeCache* shapeCache, const Font* font, | 71 static inline float shapeResultsForRun(ShapeCache* shapeCache, const Font* font, |
74 const TextRun& run, HashSet<const SimpleFontData*>* fallbackFonts, | 72 const TextRun& run, HashSet<const SimpleFontData*>* fallbackFonts, |
75 Vector<RefPtr<ShapeResult>>* results) | 73 Vector<RefPtr<ShapeResult>>* results) |
76 { | 74 { |
77 CachingWordShapeIterator iterator(shapeCache, run, font); | 75 CachingWordShapeIterator iterator(shapeCache, run, font, fallbackFonts); |
78 RefPtr<ShapeResult> wordResult; | 76 RefPtr<ShapeResult> wordResult; |
79 float totalWidth = 0; | 77 float totalWidth = 0; |
80 while (iterator.next(&wordResult)) { | 78 while (iterator.next(&wordResult)) { |
81 if (wordResult) { | 79 if (wordResult) { |
82 results->append(wordResult); | 80 results->append(wordResult); |
83 totalWidth += wordResult->width(); | 81 totalWidth += wordResult->width(); |
84 if (fallbackFonts) | |
85 wordResult->fallbackFonts(fallbackFonts); | |
86 } | 82 } |
87 } | 83 } |
88 return totalWidth; | 84 return totalWidth; |
89 } | 85 } |
90 | 86 |
91 float CachingWordShaper::fillGlyphBuffer(const Font* font, const TextRun& run, | 87 float CachingWordShaper::fillGlyphBuffer(const Font* font, const TextRun& run, |
92 HashSet<const SimpleFontData*>* fallbackFonts, | 88 HashSet<const SimpleFontData*>* fallbackFonts, |
93 GlyphBuffer* glyphBuffer, unsigned from, unsigned to) | 89 GlyphBuffer* glyphBuffer, unsigned from, unsigned to) |
94 { | 90 { |
95 Vector<RefPtr<ShapeResult>> results; | 91 Vector<RefPtr<ShapeResult>> results; |
(...skipping 18 matching lines...) Expand all Loading... |
114 { | 110 { |
115 Vector<RefPtr<ShapeResult>> results; | 111 Vector<RefPtr<ShapeResult>> results; |
116 float totalWidth = shapeResultsForRun(m_shapeCache, font, run, nullptr, | 112 float totalWidth = shapeResultsForRun(m_shapeCache, font, run, nullptr, |
117 &results); | 113 &results); |
118 | 114 |
119 return ShapeResult::selectionRect(results, run.direction(), totalWidth, | 115 return ShapeResult::selectionRect(results, run.direction(), totalWidth, |
120 point, height, from, to); | 116 point, height, from, to); |
121 } | 117 } |
122 | 118 |
123 }; // namespace blink | 119 }; // namespace blink |
OLD | NEW |