Changeset 154674 in webkit


Ignore:
Timestamp:
Aug 27, 2013 3:22:20 AM (11 years ago)
Author:
allan.jensen@digia.com
Message:

Font's fast code path doesn't handle partial runs correctly when kerning or ligatures are enabled
https://bugs.webkit.org/show_bug.cgi?id=100050

Reviewed by Darin Adler.

Renamed m_characterIndex to m_characterIndexOfGlyph and gave it an inline size of 10,
which covers around 66% of all cases. The rest of the cases are now preallocated to the
upper limit which is length of the original TextRun.

  • platform/graphics/FontFastPath.cpp:

(WebCore::Font::getGlyphsAndAdvancesForSimpleText):
(WebCore::Font::selectionRectForSimpleText):
(WebCore::Font::offsetForPositionForSimpleText):

  • platform/graphics/WidthIterator.cpp:

(WebCore::WidthIterator::WidthIterator):
(WebCore::WidthIterator::advanceInternal):

  • platform/graphics/WidthIterator.h:
Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r154673 r154674  
     12013-08-27  Allan Sandfeld Jensen  <allan.jensen@digia.com>
     2
     3        Font's fast code path doesn't handle partial runs correctly when kerning or ligatures are enabled
     4        https://bugs.webkit.org/show_bug.cgi?id=100050
     5
     6        Reviewed by Darin Adler.
     7
     8        Renamed m_characterIndex to m_characterIndexOfGlyph and gave it an inline size of 10,
     9        which covers around 66% of all cases. The rest of the cases are now preallocated to the
     10        upper limit which is length of the original TextRun.
     11
     12        * platform/graphics/FontFastPath.cpp:
     13        (WebCore::Font::getGlyphsAndAdvancesForSimpleText):
     14        (WebCore::Font::selectionRectForSimpleText):
     15        (WebCore::Font::offsetForPositionForSimpleText):
     16        * platform/graphics/WidthIterator.cpp:
     17        (WebCore::WidthIterator::WidthIterator):
     18        (WebCore::WidthIterator::advanceInternal):
     19        * platform/graphics/WidthIterator.h:
     20
    1212013-08-27  Christophe Dumez  <ch.dumez@sisa.samsung.com>
    222
  • trunk/Source/WebCore/platform/graphics/FontFastPath.cpp

    r154384 r154674  
    140140    float beforeWidth = 0;
    141141    int glyphPos = 0;
    142     for (; glyphPos < localGlyphBuffer.size() && it.m_characterIndex[glyphPos] < from; ++glyphPos)
     142    for (; glyphPos < localGlyphBuffer.size() && it.m_characterIndexOfGlyph[glyphPos] < from; ++glyphPos)
    143143        beforeWidth += localGlyphBuffer.advanceAt(glyphPos).width();
    144144    int glyphFrom = glyphPos;
     
    146146    float afterWidth = totalWidth;
    147147    glyphPos = localGlyphBuffer.size() - 1;
    148     for (; glyphPos >= glyphFrom && it.m_characterIndex[glyphPos] >= to; --glyphPos)
     148    for (; glyphPos >= glyphFrom && it.m_characterIndexOfGlyph[glyphPos] >= to; --glyphPos)
    149149        afterWidth -= localGlyphBuffer.advanceAt(glyphPos).width();
    150150    int glyphTo = glyphPos + 1;
     
    304304    float beforeWidth = 0;
    305305    int glyphPos = 0;
    306     for (; glyphPos < glyphBuffer.size() && it.m_characterIndex[glyphPos] < from; ++glyphPos)
     306    for (; glyphPos < glyphBuffer.size() && it.m_characterIndexOfGlyph[glyphPos] < from; ++glyphPos)
    307307        beforeWidth += glyphBuffer.advanceAt(glyphPos).width();
    308308    int glyphFrom = glyphPos;
     
    310310    float afterWidth = totalWidth;
    311311    glyphPos = glyphBuffer.size() - 1;
    312     for (; glyphPos >= glyphFrom && it.m_characterIndex[glyphPos] >= to; --glyphPos)
     312    for (; glyphPos >= glyphFrom && it.m_characterIndexOfGlyph[glyphPos] >= to; --glyphPos)
    313313        afterWidth -= glyphBuffer.advanceAt(glyphPos).width();
    314314
     
    335335                break;
    336336            }
    337             characterOffset = it.m_characterIndex[glyphPosition];
     337            characterOffset = it.m_characterIndexOfGlyph[glyphPosition];
    338338            float glyphWidth = glyphBuffer.advanceAt(glyphPosition).width();
    339339            if (includePartialGlyphs) {
     
    353353                break;
    354354            }
    355             characterOffset = it.m_characterIndex[glyphPosition];
     355            characterOffset = it.m_characterIndexOfGlyph[glyphPosition];
    356356            float glyphWidth = glyphBuffer.advanceAt(glyphPosition).width();
    357357            if (includePartialGlyphs) {
  • trunk/Source/WebCore/platform/graphics/WidthIterator.cpp

    r154384 r154674  
    6868            m_expansionPerOpportunity = m_expansion / expansionOpportunityCount;
    6969    }
     70    // Character-index will end up the same or slightly shorter than m_run, so if we reserve that much it will never need to resize.
     71    m_characterIndexOfGlyph.reserveInitialCapacity(m_run.length());
    7072}
    7173
     
    232234                                else
    233235                                    glyphBuffer->add(fontData->spaceGlyph(), fontData, expansionAtThisOpportunity);
    234                                 m_characterIndex.append(currentCharacterIndex);
     236                                m_characterIndexOfGlyph.append(currentCharacterIndex);
    235237                            } else
    236238                                glyphBuffer->expandLastAdvance(expansionAtThisOpportunity);
     
    301303        if (glyphBuffer) {
    302304            glyphBuffer->add(glyph, fontData, (rtl ? oldWidth + lastRoundingWidth : width));
    303             m_characterIndex.append(currentCharacterIndex);
     305            m_characterIndexOfGlyph.append(currentCharacterIndex);
    304306        }
    305307
  • trunk/Source/WebCore/platform/graphics/WidthIterator.h

    r154384 r154674  
    8383    bool m_isAfterExpansion;
    8484    float m_finalRoundingWidth;
    85     Vector<int> m_characterIndex;
     85    // An inline capacity of 10 catches around 2/3 of the cases. To catch 90% we would need 32.
     86    Vector<int, 10> m_characterIndexOfGlyph;
    8687
    8788#if ENABLE(SVG_FONTS)
Note: See TracChangeset for help on using the changeset viewer.