Changeset 131410 in webkit


Ignore:
Timestamp:
Oct 15, 2012 10:07:56 PM (12 years ago)
Author:
mitz@apple.com
Message:

REGRESSION (r131365): WidthIterator::advance() is needlessly passed a GlyphBuffer in many cases
https://bugs.webkit.org/show_bug.cgi?id=99413

Reviewed by Adele Peterson.

r131365 made Font::width() always pass a GlyphBuffer pointer to floatWidthForSimpleText and
from there down to WidthIterator::advance(). However, when measuring the width of a run, a
GlyphBuffer is only needed if font transforms (kerning and ligatures) need to be applied.

No new test, because there is no change in behavior.

  • platform/graphics/Font.cpp:

(WebCore::Font::width): Removed the local GlyphBuffer that was passed down to
floatWidthForSimpleText().

  • platform/graphics/Font.h: Removed the GlyphBuffer* parameter to floatWidthForSimpleText.

All but the above caller were passing 0.

  • platform/graphics/FontFastPath.cpp:

(WebCore::Font::floatWidthForSimpleText): Removed the GlyphBuffer* parameter and added a
local GlyphBuffer, which is passed by reference to WidthIterator::advance() only if
typesetting features require it.
(WebCore::Font::offsetForPositionForSimpleText): Updated for change to
floatWidthForSimpleText.

  • platform/graphics/pango/FontPango.cpp:

(WebCore::Font::floatWidthForComplexText): Ditto.

Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r131408 r131410  
     12012-10-15  Dan Bernstein  <mitz@apple.com>
     2
     3        REGRESSION (r131365): WidthIterator::advance() is needlessly passed a GlyphBuffer in many cases
     4        https://bugs.webkit.org/show_bug.cgi?id=99413
     5
     6        Reviewed by Adele Peterson.
     7
     8        r131365 made Font::width() always pass a GlyphBuffer pointer to floatWidthForSimpleText and
     9        from there down to WidthIterator::advance(). However, when measuring the width of a run, a
     10        GlyphBuffer is only needed if font transforms (kerning and ligatures) need to be applied.
     11
     12        No new test, because there is no change in behavior.
     13
     14        * platform/graphics/Font.cpp:
     15        (WebCore::Font::width): Removed the local GlyphBuffer that was passed down to
     16        floatWidthForSimpleText().
     17        * platform/graphics/Font.h: Removed the GlyphBuffer* parameter to floatWidthForSimpleText.
     18        All but the above caller were passing 0.
     19        * platform/graphics/FontFastPath.cpp:
     20        (WebCore::Font::floatWidthForSimpleText): Removed the GlyphBuffer* parameter and added a
     21        local GlyphBuffer, which is passed by reference to WidthIterator::advance() only if
     22        typesetting features require it.
     23        (WebCore::Font::offsetForPositionForSimpleText): Updated for change to
     24        floatWidthForSimpleText.
     25        * platform/graphics/pango/FontPango.cpp:
     26        (WebCore::Font::floatWidthForComplexText): Ditto.
     27
    1282012-10-15  Pablo Flouret  <pablof@motorola.com>
    229
  • trunk/Source/WebCore/platform/graphics/Font.cpp

    r131365 r131410  
    188188        // returning them for simple text as well.
    189189        static bool returnFallbackFonts = canReturnFallbackFontsForComplexText();
    190         GlyphBuffer glyphBuffer;
    191         return floatWidthForSimpleText(run, &glyphBuffer, returnFallbackFonts ? fallbackFonts : 0, codePathToUse == SimpleWithGlyphOverflow || (glyphOverflow && glyphOverflow->computeBounds) ? glyphOverflow : 0);
     190        return floatWidthForSimpleText(run, returnFallbackFonts ? fallbackFonts : 0, codePathToUse == SimpleWithGlyphOverflow || (glyphOverflow && glyphOverflow->computeBounds) ? glyphOverflow : 0);
    192191    }
    193192
     
    206205
    207206    if (codePath(run) != Complex)
    208         return floatWidthForSimpleText(run, 0);
     207        return floatWidthForSimpleText(run);
    209208
    210209    return floatWidthForComplexText(run);
  • trunk/Source/WebCore/platform/graphics/Font.h

    r131311 r131410  
    224224    void drawGlyphBuffer(GraphicsContext*, const TextRun&, const GlyphBuffer&, const FloatPoint&) const;
    225225    void drawEmphasisMarks(GraphicsContext*, const TextRun&, const GlyphBuffer&, const AtomicString&, const FloatPoint&) const;
    226     float floatWidthForSimpleText(const TextRun&, GlyphBuffer*, HashSet<const SimpleFontData*>* fallbackFonts = 0, GlyphOverflow* = 0) const;
     226    float floatWidthForSimpleText(const TextRun&, HashSet<const SimpleFontData*>* fallbackFonts = 0, GlyphOverflow* = 0) const;
    227227    int offsetForPositionForSimpleText(const TextRun&, float position, bool includePartialGlyphs) const;
    228228    FloatRect selectionRectForSimpleText(const TextRun&, const FloatPoint&, int h, int from, int to) const;
  • trunk/Source/WebCore/platform/graphics/FontFastPath.cpp

    r131365 r131410  
    470470}
    471471
    472 float Font::floatWidthForSimpleText(const TextRun& run, GlyphBuffer* glyphBuffer, HashSet<const SimpleFontData*>* fallbackFonts, GlyphOverflow* glyphOverflow) const
     472float Font::floatWidthForSimpleText(const TextRun& run, HashSet<const SimpleFontData*>* fallbackFonts, GlyphOverflow* glyphOverflow) const
    473473{
    474474    WidthIterator it(this, run, fallbackFonts, glyphOverflow);
    475     it.advance(run.length(), glyphBuffer);
     475    GlyphBuffer glyphBuffer;
     476    it.advance(run.length(), (typesettingFeatures() & (Kerning | Ligatures)) ? &glyphBuffer : 0);
    476477
    477478    if (glyphOverflow) {
     
    512513    unsigned offset;
    513514    if (run.rtl()) {
    514         delta -= floatWidthForSimpleText(run, 0);
     515        delta -= floatWidthForSimpleText(run);
    515516        while (1) {
    516517            offset = it.m_currentCharacter;
  • trunk/Source/WebCore/platform/graphics/pango/FontPango.cpp

    r127801 r131410  
    372372#if USE(FREETYPE)
    373373    if (!primaryFont()->platformData().m_pattern)
    374         return floatWidthForSimpleText(run, 0, fallbackFonts, overflow);
     374        return floatWidthForSimpleText(run, fallbackFonts, overflow);
    375375#endif
    376376
Note: See TracChangeset for help on using the changeset viewer.