Changeset 182192 in webkit


Ignore:
Timestamp:
Mar 31, 2015 11:53:25 AM (9 years ago)
Author:
mmaxfield@apple.com
Message:

Crash in CGContextShowGlyphsWithAdvances when passing kCGFontIndexInvalid
https://bugs.webkit.org/show_bug.cgi?id=143114

This is a workaround for <rdar://problem/20230073>. Please remove when it is no longer necessary.

Reviewed by Alexey Proskuryakov.

Covered by:
compositing/regions/floated-region-with-transformed-child.html
compositing/regions/floated-region-with-transformed-child-expected.html
fast/regions/counters/extract-ordered-lists-in-regions-explicit-counters-005.html
fast/regions/counters/extract-ordered-lists-in-regions-explicit-counters-005-expected.html
fast/regions/overflow/overflow-content-transform-rotate.html
fast/regions/overflow/overflow-content-transform-rotate-expected.html

  • platform/graphics/GlyphBuffer.h:

(WebCore::GlyphBuffer::shrink): Performing shaping may remove glyphs, so we need to shrink the GlyphBuffer.

  • platform/graphics/WidthIterator.cpp:

(WebCore::applyFontTransforms): Filter out kCGFontIndexInvalid.
(WebCore::WidthIterator::advanceInternal): Moved code into applyFontTransforms, and trigger the
shrink of the GlyphBuffer.

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r182191 r182192  
     12015-03-31  Myles C. Maxfield  <mmaxfield@apple.com>
     2
     3        Crash in CGContextShowGlyphsWithAdvances when passing kCGFontIndexInvalid
     4        https://bugs.webkit.org/show_bug.cgi?id=143114
     5
     6        This is a workaround for <rdar://problem/20230073>. Please remove when it is no longer necessary.
     7
     8        Reviewed by Alexey Proskuryakov.
     9
     10        Covered by:
     11        compositing/regions/floated-region-with-transformed-child.html
     12        compositing/regions/floated-region-with-transformed-child-expected.html
     13        fast/regions/counters/extract-ordered-lists-in-regions-explicit-counters-005.html
     14        fast/regions/counters/extract-ordered-lists-in-regions-explicit-counters-005-expected.html
     15        fast/regions/overflow/overflow-content-transform-rotate.html
     16        fast/regions/overflow/overflow-content-transform-rotate-expected.html
     17
     18        * platform/graphics/GlyphBuffer.h:
     19        (WebCore::GlyphBuffer::shrink): Performing shaping may remove glyphs, so we need to shrink the GlyphBuffer.
     20        * platform/graphics/WidthIterator.cpp:
     21        (WebCore::applyFontTransforms): Filter out kCGFontIndexInvalid.
     22        (WebCore::WidthIterator::advanceInternal): Moved code into applyFontTransforms, and trigger the
     23        shrink of the GlyphBuffer.
     24
    1252015-03-31  Beth Dakin  <bdakin@apple.com>
    226
  • trunk/Source/WebCore/platform/graphics/GlyphBuffer.h

    r178940 r182192  
    203203    }
    204204
     205    void shrink(int truncationPoint)
     206    {
     207        m_font.shrink(truncationPoint);
     208        m_glyphs.shrink(truncationPoint);
     209        m_advances.shrink(truncationPoint);
     210        if (m_offsetsInString)
     211            m_offsetsInString->shrink(truncationPoint);
     212#if PLATFORM(WIN)
     213        m_offsets.shrink(truncationPoint);
     214#endif
     215    }
     216
    205217private:
    206218    void swap(int index1, int index2)
  • trunk/Source/WebCore/platform/graphics/WidthIterator.cpp

    r181597 r182192  
    109109
    110110    int glyphBufferSize = glyphBuffer->size();
    111     if (glyphBuffer->size() <= lastGlyphCount + 1)
     111    if (glyphBuffer->size() <= lastGlyphCount + 1) {
     112        lastGlyphCount = glyphBufferSize;
    112113        return 0;
     114    }
    113115
    114116    GlyphBufferAdvance* advances = glyphBuffer->advances(0);
     
    146148    }
    147149    charactersTreatedAsSpace.clear();
     150
     151#if PLATFORM(MAC) || PLATFORM(IOS)
     152    // Workaround for <rdar://problem/20230073> FIXME: Please remove this when no longer needed.
     153    GlyphBufferGlyph* glyphs = glyphBuffer->glyphs(0);
     154    int filteredIndex = lastGlyphCount;
     155    for (int i = lastGlyphCount; i < glyphBufferSize; ++i) {
     156        glyphs[filteredIndex] = glyphs[i];
     157        advances[filteredIndex] = advances[i];
     158        if (glyphs[filteredIndex] != kCGFontIndexInvalid)
     159            ++filteredIndex;
     160    }
     161    glyphBufferSize = filteredIndex;
     162#endif
    148163
    149164    for (int i = lastGlyphCount; i < glyphBufferSize; ++i)
     
    208223            if (shouldApplyFontTransforms()) {
    209224                m_runWidthSoFar += applyFontTransforms(glyphBuffer, m_run.ltr(), lastGlyphCount, lastFontData, *this, m_typesettingFeatures, charactersTreatedAsSpace);
    210                 lastGlyphCount = glyphBuffer->size(); // applyFontTransforms doesn't update when there had been only one glyph.
     225                if (glyphBuffer)
     226                    glyphBuffer->shrink(lastGlyphCount);
    211227            }
    212228
     
    326342    }
    327343
    328     if (shouldApplyFontTransforms())
     344    if (shouldApplyFontTransforms()) {
    329345        m_runWidthSoFar += applyFontTransforms(glyphBuffer, m_run.ltr(), lastGlyphCount, lastFontData, *this, m_typesettingFeatures, charactersTreatedAsSpace);
     346        if (glyphBuffer)
     347            glyphBuffer->shrink(lastGlyphCount);
     348    }
    330349
    331350    unsigned consumedCharacters = textIterator.currentCharacter() - m_currentCharacter;
Note: See TracChangeset for help on using the changeset viewer.