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

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

Issue 206793005: Expand WidthCache for complex text width queries (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Addressing Dominiks comments Created 6 years, 9 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 | « no previous file | Source/platform/fonts/WidthCache.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/fonts/Font.cpp
diff --git a/Source/platform/fonts/Font.cpp b/Source/platform/fonts/Font.cpp
index 722ac9d117e28d2e0fc9f9f9ea65a5d1f096aa98..b6046a0e71887ab313030a95ee2953db75f36e7c 100644
--- a/Source/platform/fonts/Font.cpp
+++ b/Source/platform/fonts/Font.cpp
@@ -151,7 +151,14 @@ float Font::width(const TextRun& run, HashSet<const SimpleFontData*>* fallbackFo
bool hasKerningOrLigatures = fontDescription().typesettingFeatures() & (Kerning | Ligatures);
bool hasWordSpacingOrLetterSpacing = fontDescription().wordSpacing() || fontDescription().letterSpacing();
- float* cacheEntry = m_fontFallbackList->widthCache().add(run, std::numeric_limits<float>::quiet_NaN(), hasKerningOrLigatures, hasWordSpacingOrLetterSpacing, glyphOverflow);
+ bool isCacheable = (codePathToUse == ComplexPath || hasKerningOrLigatures)
+ && !hasWordSpacingOrLetterSpacing // Word spacing and letter spacing can change the width of a word.
+ && !glyphOverflow // Since this is just a width cache, we don't have enough information to satisfy glyph queries.
+ && !run.allowTabs(); // If we allow tabs and a tab occurs inside a word, the width of the word varies based on its position on the line.
+
+ float* cacheEntry = isCacheable
+ ? m_fontFallbackList->widthCache().add(run, std::numeric_limits<float>::quiet_NaN())
+ : 0;
if (cacheEntry && !std::isnan(*cacheEntry))
return *cacheEntry;
« no previous file with comments | « no previous file | Source/platform/fonts/WidthCache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698