Chromium Code Reviews| Index: third_party/WebKit/Source/platform/fonts/shaping/CachingWordShaper.cpp |
| diff --git a/third_party/WebKit/Source/platform/fonts/shaping/CachingWordShaper.cpp b/third_party/WebKit/Source/platform/fonts/shaping/CachingWordShaper.cpp |
| index 5cc8b7f6c4d2d4f9e46336eec79f9f56759e47be..3393b04a932809641549cd9016bf205ce478a68c 100644 |
| --- a/third_party/WebKit/Source/platform/fonts/shaping/CachingWordShaper.cpp |
| +++ b/third_party/WebKit/Source/platform/fonts/shaping/CachingWordShaper.cpp |
| @@ -35,13 +35,16 @@ |
| namespace blink { |
| -float CachingWordShaper::width(const Font* font, |
| - const TextRun& run, |
| +CachingWordShaper::CachingWordShaper(const Font& font) |
| + : CachingWordShaper(font, |
| + font.m_fontFallbackList->shapeCache(font.m_fontDescription)) {} |
| + |
| +float CachingWordShaper::width(const TextRun& run, |
| HashSet<const SimpleFontData*>* fallbackFonts, |
| FloatRect* glyphBounds) { |
| float width = 0; |
| RefPtr<const ShapeResult> wordResult; |
| - CachingWordShapeIterator iterator(m_shapeCache, run, font); |
| + CachingWordShapeIterator iterator(m_shapeCache, run, &m_font); |
| while (iterator.next(&wordResult)) { |
| if (wordResult) { |
| if (glyphBounds) { |
| @@ -64,7 +67,6 @@ static inline float shapeResultsForRun( |
| ShapeCache* shapeCache, |
| const Font* font, |
| const TextRun& run, |
| - HashSet<const SimpleFontData*>* fallbackFonts, |
| ShapeResultBuffer* resultsBuffer) { |
| CachingWordShapeIterator iterator(shapeCache, run, font); |
| RefPtr<const ShapeResult> wordResult; |
| @@ -72,68 +74,60 @@ static inline float shapeResultsForRun( |
| while (iterator.next(&wordResult)) { |
| if (wordResult) { |
| totalWidth += wordResult->width(); |
| - if (fallbackFonts) |
|
eae
2017/02/27 23:24:59
The reason fallback fonts was populate here was to
|
| - wordResult->fallbackFonts(fallbackFonts); |
| resultsBuffer->appendResult(std::move(wordResult)); |
| } |
| } |
| return totalWidth; |
| } |
| -int CachingWordShaper::offsetForPosition(const Font* font, |
| - const TextRun& run, |
| +int CachingWordShaper::offsetForPosition(const TextRun& run, |
| float targetX, |
| bool includePartialGlyphs) { |
| ShapeResultBuffer buffer; |
| - shapeResultsForRun(m_shapeCache, font, run, nullptr, &buffer); |
| + shapeResultsForRun(m_shapeCache, &m_font, run, &buffer); |
| return buffer.offsetForPosition(run, targetX, includePartialGlyphs); |
| } |
| float CachingWordShaper::fillGlyphBuffer( |
| - const Font* font, |
| const TextRun& run, |
| - HashSet<const SimpleFontData*>* fallbackFonts, |
| GlyphBuffer* glyphBuffer, |
| unsigned from, |
| unsigned to) { |
| ShapeResultBuffer buffer; |
| - shapeResultsForRun(m_shapeCache, font, run, fallbackFonts, &buffer); |
| + shapeResultsForRun(m_shapeCache, &m_font, run, &buffer); |
| return buffer.fillGlyphBuffer(glyphBuffer, run, from, to); |
| } |
| float CachingWordShaper::fillGlyphBufferForTextEmphasis( |
| - const Font* font, |
| const TextRun& run, |
| const GlyphData* emphasisData, |
| GlyphBuffer* glyphBuffer, |
| unsigned from, |
| unsigned to) { |
| ShapeResultBuffer buffer; |
| - shapeResultsForRun(m_shapeCache, font, run, nullptr, &buffer); |
| + shapeResultsForRun(m_shapeCache, &m_font, run, &buffer); |
| return buffer.fillGlyphBufferForTextEmphasis(glyphBuffer, run, emphasisData, |
| from, to); |
| } |
| -CharacterRange CachingWordShaper::getCharacterRange(const Font* font, |
| - const TextRun& run, |
| +CharacterRange CachingWordShaper::getCharacterRange(const TextRun& run, |
| unsigned from, |
| unsigned to) { |
| ShapeResultBuffer buffer; |
| float totalWidth = |
| - shapeResultsForRun(m_shapeCache, font, run, nullptr, &buffer); |
| + shapeResultsForRun(m_shapeCache, &m_font, run, &buffer); |
| return buffer.getCharacterRange(run.direction(), totalWidth, from, to); |
| } |
| Vector<CharacterRange> CachingWordShaper::individualCharacterRanges( |
| - const Font* font, |
| const TextRun& run) { |
| ShapeResultBuffer buffer; |
| float totalWidth = |
| - shapeResultsForRun(m_shapeCache, font, run, nullptr, &buffer); |
| + shapeResultsForRun(m_shapeCache, &m_font, run, &buffer); |
| auto ranges = buffer.individualCharacterRanges(run.direction(), totalWidth); |
| // The shaper can fail to return glyph metrics for all characters (see |
| @@ -144,4 +138,12 @@ Vector<CharacterRange> CachingWordShaper::individualCharacterRanges( |
| return ranges; |
| } |
| +Vector<std::tuple<SimpleFontData*, size_t>> CachingWordShaper::getRunFontData( |
| + const TextRun& run) const { |
| + ShapeResultBuffer buffer; |
| + shapeResultsForRun(m_shapeCache, &m_font, run, &buffer); |
| + |
| + return buffer.getRunFontData(); |
| +} |
| + |
| }; // namespace blink |