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

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 code and adding Layout test case 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
Index: Source/platform/fonts/WidthIterator.cpp
diff --git a/Source/platform/fonts/WidthIterator.cpp b/Source/platform/fonts/WidthIterator.cpp
index 3f797c403a51cfdf2d10663dc62d07ad4cdbef74..fafdd4e1b7c5b5bf4aae30d47f2b8c3d69a659d5 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 spaceNormalize)
{
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(), spaceNormalize);
}
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
eae 2014/09/16 00:46:34 This change doesn't seem related to your space nor
h.joshi 2014/09/16 05:48:11 "glyphDataAndPageForCharacter" method takes care o
- // 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 isSpaceNormalize = m_run.isSpaceNormalize();
eae 2014/09/16 00:46:34 s/isSPaceNormalize/normalizeSpace/
h.joshi 2014/09/16 05:48:11 Done, changed to normalizeSpace
CharacterData charData;
while (textIterator.consume(charData.character, charData.clusterLength)) {
charData.characterOffset = textIterator.currentCharacter();
- const GlyphData glyphData = glyphDataForCharacter(charData);
+ const GlyphData glyphData = glyphDataForCharacter(charData, isSpaceNormalize);
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)

Powered by Google App Engine
This is Rietveld 408576698