Index: Source/platform/fonts/shaping/CachingWordShapeIterator.h |
diff --git a/Source/platform/fonts/shaping/CachingWordShapeIterator.h b/Source/platform/fonts/shaping/CachingWordShapeIterator.h |
index 526c7e397483827ef471c7de46bed6ec12342215..e004766e5a721191ff7c02ed99683d620eb8d260 100644 |
--- a/Source/platform/fonts/shaping/CachingWordShapeIterator.h |
+++ b/Source/platform/fonts/shaping/CachingWordShapeIterator.h |
@@ -36,9 +36,10 @@ |
class CachingWordShapeIterator { |
public: |
- CachingWordShapeIterator(ShapeCache* cache, const TextRun& run |
- , const Font* font) |
- : m_shapeCache(cache), m_textRun(run), m_font(font), m_startIndex(0) |
+ CachingWordShapeIterator(ShapeCache* cache, const TextRun& run, |
+ const Font* font, HashSet<const SimpleFontData*>* fallbackFonts) |
+ : m_shapeCache(cache), m_textRun(run), m_font(font) |
+ , m_fallbackFonts(fallbackFonts), m_startIndex(0) |
{ |
ASSERT(font); |
const FontDescription& fontDescription = font->fontDescription(); |
@@ -62,7 +63,7 @@ |
if (!m_shapeByWord) { |
if (m_startIndex) |
return false; |
- *wordResult = shapeWord(m_textRun, m_font); |
+ *wordResult = shapeWord(m_textRun, m_font, m_fallbackFonts); |
m_startIndex = 1; |
return *wordResult; |
} |
@@ -71,7 +72,7 @@ |
if (m_startIndex < length) { |
if (m_textRun[m_startIndex] == spaceCharacter) { |
TextRun wordRun = m_textRun.subRun(m_startIndex, 1); |
- *wordResult = shapeWord(wordRun, m_font); |
+ *wordResult = shapeWord(wordRun, m_font, m_fallbackFonts); |
m_startIndex++; |
return true; |
} |
@@ -80,7 +81,7 @@ |
if (i == length || m_textRun[i] == spaceCharacter) { |
TextRun wordRun = m_textRun.subRun(m_startIndex, |
i - m_startIndex); |
- *wordResult = shapeWord(wordRun, m_font); |
+ *wordResult = shapeWord(wordRun, m_font, m_fallbackFonts); |
m_startIndex = i; |
return true; |
} |
@@ -90,15 +91,31 @@ |
} |
private: |
- PassRefPtr<ShapeResult> shapeWord(const TextRun& wordRun, const Font* font) |
+ void setFallbackFonts(const ShapeResult* wordResult, |
+ HashSet<const SimpleFontData*>* fallbackFonts) |
+ { |
+ if (fallbackFonts) { |
+ const HashSet<const SimpleFontData*>* fontsForWord = |
+ wordResult->fallbackFonts(); |
+ HashSet<const SimpleFontData*>::const_iterator it; |
+ for (it = fontsForWord->begin(); it != fontsForWord->end(); ++it) |
+ fallbackFonts->add(*it); |
+ } |
+ } |
+ |
+ PassRefPtr<ShapeResult> shapeWord(const TextRun& wordRun, |
+ const Font* font, HashSet<const SimpleFontData*>* fallbackFonts) |
{ |
ShapeCacheEntry* cacheEntry = m_wordResultCachable |
? m_shapeCache->add(wordRun, ShapeCacheEntry()) |
: nullptr; |
- if (cacheEntry && cacheEntry->m_shapeResult) |
+ if (cacheEntry && cacheEntry->m_shapeResult) { |
+ setFallbackFonts(cacheEntry->m_shapeResult.get(), fallbackFonts); |
return cacheEntry->m_shapeResult; |
+ } |
- HarfBuzzShaper shaper(font, wordRun); |
+ HashSet<const SimpleFontData*> fallbackFontsForWord; |
+ HarfBuzzShaper shaper(font, wordRun, &fallbackFontsForWord); |
RefPtr<ShapeResult> shapeResult = shaper.shapeResult(); |
if (!shapeResult) |
return nullptr; |
@@ -106,12 +123,14 @@ |
if (cacheEntry) |
cacheEntry->m_shapeResult = shapeResult; |
+ setFallbackFonts(shapeResult.get(), fallbackFonts); |
return shapeResult.release(); |
} |
ShapeCache* m_shapeCache; |
const TextRun& m_textRun; |
const Font* m_font; |
+ HashSet<const SimpleFontData*>* m_fallbackFonts; |
unsigned m_startIndex : 30; |
unsigned m_wordResultCachable : 1; |
unsigned m_shapeByWord : 1; |