Changeset 52174 in webkit


Ignore:
Timestamp:
Dec 15, 2009, 2:12:50 PM (15 years ago)
Author:
mitz@apple.com
Message:

<rdar://problem/7470452> Safari/Chromium crashes on complicated @font-face rule
https://bugs.webkit.org/show_bug.cgi?id=32257

Reviewed by Darin Adler.

WebCore:

Test: fast/css/font-face-unused-source-loaded.html

The loading of a font resource caused a CSSFontFace that had the resource in one of its
sources, but wasn’t using it (due to using an earlier source) to invalidate its
CSSSegmentedFontFaces. This caused FontData for the active source (the one that did not just
finish loading) to be deleted, but that went unnoticed by Font::operator==(), since the
corresponding FontFallbackLists were not in the loading state. The fix is for CSSFontFace to
ignore loads from unused sources.

  • css/CSSFontFace.cpp:

(WebCore::CSSFontFace::fontLoaded): Bail out if the loaded source is not the active source.
(WebCore::CSSFontFace::getFontData): Set m_activeSource to the source that supplied the

FontData.

  • css/CSSFontFace.h:

(WebCore::CSSFontFace::CSSFontFace): Initialize m_activeSource.

LayoutTests:

  • fast/css/font-face-unused-source-loaded-expected.txt: Added.
  • fast/css/font-face-unused-source-loaded.html: Added.
Location:
trunk
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r52164 r52174  
     12009-12-15  Dan Bernstein  <mitz@apple.com>
     2
     3        Reviewed by Darin Adler.
     4
     5        <rdar://problem/7470452> Safari/Chromium crashes on complicated @font-face rule
     6        https://bugs.webkit.org/show_bug.cgi?id=32257
     7
     8        * fast/css/font-face-unused-source-loaded-expected.txt: Added.
     9        * fast/css/font-face-unused-source-loaded.html: Added.
     10
    1112009-12-15  Kenneth Russell  <kbr@google.com>
    212
  • trunk/WebCore/ChangeLog

    r52172 r52174  
     12009-12-15  Dan Bernstein  <mitz@apple.com>
     2
     3        Reviewed by Darin Adler.
     4
     5        <rdar://problem/7470452> Safari/Chromium crashes on complicated @font-face rule
     6        https://bugs.webkit.org/show_bug.cgi?id=32257
     7
     8        Test: fast/css/font-face-unused-source-loaded.html
     9
     10        The loading of a font resource caused a CSSFontFace that had the resource in one of its
     11        sources, but wasn’t using it (due to using an earlier source) to invalidate its
     12        CSSSegmentedFontFaces. This caused FontData for the active source (the one that did not just
     13        finish loading) to be deleted, but that went unnoticed by Font::operator==(), since the
     14        corresponding FontFallbackLists were not in the loading state. The fix is for CSSFontFace to
     15        ignore loads from unused sources.
     16
     17        * css/CSSFontFace.cpp:
     18        (WebCore::CSSFontFace::fontLoaded): Bail out if the loaded source is not the active source.
     19        (WebCore::CSSFontFace::getFontData): Set m_activeSource to the source that supplied the
     20            FontData.
     21        * css/CSSFontFace.h:
     22        (WebCore::CSSFontFace::CSSFontFace): Initialize m_activeSource.
     23
    1242009-12-15  Yael Aharon  <yael.aharon@nokia.com>
    225
  • trunk/WebCore/css/CSSFontFace.cpp

    r38843 r52174  
    7878}
    7979
    80 void CSSFontFace::fontLoaded(CSSFontFaceSource*)
     80void CSSFontFace::fontLoaded(CSSFontFaceSource* source)
    8181{
     82    if (source != m_activeSource)
     83        return;
     84
    8285    // FIXME: Can we assert that m_segmentedFontFaces is not empty? That may
    8386    // require stopping in-progress font loading when the last
     
    98101SimpleFontData* CSSFontFace::getFontData(const FontDescription& fontDescription, bool syntheticBold, bool syntheticItalic)
    99102{
     103    m_activeSource = 0;
    100104    if (!isValid())
    101105        return 0;
    102        
     106
    103107    ASSERT(!m_segmentedFontFaces.isEmpty());
    104108    CSSFontSelector* fontSelector = (*m_segmentedFontFaces.begin())->fontSelector();
    105109
    106     SimpleFontData* result = 0;
    107     unsigned size = m_sources.size();
    108     for (unsigned i = 0; i < size && !result; i++)
    109         result = m_sources[i]->getFontData(fontDescription, syntheticBold, syntheticItalic, fontSelector);
    110     return result;
     110    size_t size = m_sources.size();
     111    for (size_t i = 0; i < size; ++i) {
     112        if (SimpleFontData* result = m_sources[i]->getFontData(fontDescription, syntheticBold, syntheticItalic, fontSelector)) {
     113            m_activeSource = m_sources[i];
     114            return result;
     115        }
     116    }
     117
     118    return 0;
    111119}
    112120
  • trunk/WebCore/css/CSSFontFace.h

    r34794 r52174  
    8383    CSSFontFace(FontTraitsMask traitsMask)
    8484        : m_traitsMask(traitsMask)
     85        , m_activeSource(0)
    8586    {
    8687    }
     
    9091    HashSet<CSSSegmentedFontFace*> m_segmentedFontFaces;
    9192    Vector<CSSFontFaceSource*> m_sources;
     93    CSSFontFaceSource* m_activeSource;
    9294};
    9395
Note: See TracChangeset for help on using the changeset viewer.