Commit 5926bfa8 authored by eae@chromium.org's avatar eae@chromium.org

Expand WidthCache for complex text width queries

Expand use of WidthCache to apply to all complex text width queries.
It'll still bail out for queries where the GlyphOverflow bounds are
needed.

BUG=347186
R=dominik.rottsches@intel.com

Review URL: https://codereview.chromium.org/206793005

git-svn-id: svn://svn.chromium.org/blink/trunk@169800 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent fef81767
...@@ -151,7 +151,14 @@ float Font::width(const TextRun& run, HashSet<const SimpleFontData*>* fallbackFo ...@@ -151,7 +151,14 @@ float Font::width(const TextRun& run, HashSet<const SimpleFontData*>* fallbackFo
bool hasKerningOrLigatures = fontDescription().typesettingFeatures() & (Kerning | Ligatures); bool hasKerningOrLigatures = fontDescription().typesettingFeatures() & (Kerning | Ligatures);
bool hasWordSpacingOrLetterSpacing = fontDescription().wordSpacing() || fontDescription().letterSpacing(); 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)) if (cacheEntry && !std::isnan(*cacheEntry))
return *cacheEntry; return *cacheEntry;
......
...@@ -119,20 +119,8 @@ public: ...@@ -119,20 +119,8 @@ public:
{ {
} }
float* add(const TextRun& run, float entry, bool hasKerningOrLigatures, bool hasWordSpacingOrLetterSpacing, GlyphOverflow* glyphOverflow) float* add(const TextRun& run, float entry)
{ {
// The width cache is not really profitable unless we're doing expensive glyph transformations.
if (!hasKerningOrLigatures)
return 0;
// Word spacing and letter spacing can change the width of a word.
if (hasWordSpacingOrLetterSpacing)
return 0;
// Since this is just a width cache, we don't have enough information to satisfy glyph queries.
if (glyphOverflow)
return 0;
// If we allow tabs and a tab occurs inside a word, the width of the word varies based on its position on the line.
if (run.allowTabs())
return 0;
if (static_cast<unsigned>(run.length()) > SmallStringKey::capacity()) if (static_cast<unsigned>(run.length()) > SmallStringKey::capacity())
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment