Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1290)

Unified Diff: Source/platform/fonts/WidthIterator.cpp

Issue 567543002: Avoid re-parsing of string in fillText and measureText in Canvas (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Updating test expectation file Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/platform/fonts/WidthIterator.h ('k') | Source/platform/fonts/harfbuzz/HarfBuzzShaper.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/fonts/WidthIterator.cpp
diff --git a/Source/platform/fonts/WidthIterator.cpp b/Source/platform/fonts/WidthIterator.cpp
index 3f797c403a51cfdf2d10663dc62d07ad4cdbef74..8723a13836f98a5cc4e50433c37be96e2f08ac7f 100644
--- a/Source/platform/fonts/WidthIterator.cpp
+++ b/Source/platform/fonts/WidthIterator.cpp
@@ -69,7 +69,7 @@ WidthIterator::WidthIterator(const Font* font, const TextRun& run, HashSet<const
}
}
-GlyphData WidthIterator::glyphDataForCharacter(CharacterData& charData)
+GlyphData WidthIterator::glyphDataForCharacter(CharacterData& charData, bool normalizeSpace)
{
ASSERT(m_font);
@@ -80,7 +80,7 @@ GlyphData WidthIterator::glyphDataForCharacter(CharacterData& charData)
}
#endif
- return m_font->glyphDataForCharacter(charData.character, m_run.rtl());
+ return m_font->glyphDataForCharacter(charData.character, m_run.rtl(), normalizeSpace);
}
float WidthIterator::characterWidth(UChar32 character, const GlyphData& glyphData) const
@@ -100,23 +100,13 @@ float WidthIterator::characterWidth(UChar32 character, const GlyphData& glyphDat
return width;
}
-void WidthIterator::cacheFallbackFont(UChar32 character, const SimpleFontData* fontData,
+void WidthIterator::cacheFallbackFont(const SimpleFontData* fontData,
const SimpleFontData* primaryFont)
{
if (fontData == primaryFont)
return;
- // FIXME: This does a little extra work that could be avoided if
- // glyphDataForCharacter() returned whether it chose to use a small caps font.
- if (m_font->fontDescription().variant() == FontVariantNormal || character == toUpper(character)) {
- m_fallbackFonts->add(fontData);
- } else {
- ASSERT(m_font->fontDescription().variant() == FontVariantSmallCaps);
- const GlyphData uppercaseGlyphData = m_font->glyphDataForCharacter(toUpper(character),
- m_run.rtl());
- if (uppercaseGlyphData.fontData != primaryFont)
- m_fallbackFonts->add(uppercaseGlyphData.fontData);
- }
+ m_fallbackFonts->add(fontData);
}
float WidthIterator::adjustSpacing(float width, const CharacterData& charData,
@@ -192,12 +182,13 @@ unsigned WidthIterator::advanceInternal(TextIterator& textIterator, GlyphBuffer*
const SimpleFontData* primaryFont = m_font->primaryFont();
const SimpleFontData* lastFontData = primaryFont;
+ bool normalizeSpace = m_run.normalizeSpace();
CharacterData charData;
while (textIterator.consume(charData.character, charData.clusterLength)) {
charData.characterOffset = textIterator.currentCharacter();
- const GlyphData glyphData = glyphDataForCharacter(charData);
+ const GlyphData glyphData = glyphDataForCharacter(charData, normalizeSpace);
Glyph glyph = glyphData.glyph;
const SimpleFontData* fontData = glyphData.fontData;
ASSERT(fontData);
@@ -207,7 +198,7 @@ unsigned WidthIterator::advanceInternal(TextIterator& textIterator, GlyphBuffer*
if (m_fallbackFonts && lastFontData != fontData && width) {
lastFontData = fontData;
- cacheFallbackFont(charData.character, fontData, primaryFont);
+ cacheFallbackFont(fontData, primaryFont);
}
if (hasExtraSpacing)
« no previous file with comments | « Source/platform/fonts/WidthIterator.h ('k') | Source/platform/fonts/harfbuzz/HarfBuzzShaper.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698