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