Commit f6ca06d8 authored by mitz@apple.com's avatar mitz@apple.com

Reviewed by Darin Adler.

        - fix <rdar://problem/6057650> REGRESSION (r35025): Crash beneath FontCache::invalidate() when activating Safari with no windows open

        * css/CSSFontFaceSource.cpp:
        (WebCore::CSSFontFaceSource::getFontData): Added a null check because
        docLoader() can return 0 now.
        * css/CSSFontSelector.cpp:
        (WebCore::CSSFontSelector::docLoader): Added a null check of m_document.
        (WebCore::CSSFontSelector::addFontFaceRule): Ditto.
        (WebCore::CSSFontSelector::fontLoaded): Ditto.
        (WebCore::CSSFontSelector::fontCacheInvalidated): Ditto.
        (WebCore::fontDataForGenericFamily): Added a null check of document.
        * css/CSSFontSelector.h:
        (WebCore::CSSFontSelector::clearDocument): Added.
        * css/CSSStyleSelector.cpp:
        (WebCore::CSSStyleSelector::~CSSStyleSelector): Added a call to
        CSSFontSelector::clearDocument(). When the style selector is destroyed,
        there is no guarantee that the document will continue to exist.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@35047 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent ad8ccce4
2008-07-07 Dan Bernstein <mitz@apple.com>
Reviewed by Darin Adler.
- fix <rdar://problem/6057650> REGRESSION (r35025): Crash beneath FontCache::invalidate() when activating Safari with no windows open
* css/CSSFontFaceSource.cpp:
(WebCore::CSSFontFaceSource::getFontData): Added a null check because
docLoader() can return 0 now.
* css/CSSFontSelector.cpp:
(WebCore::CSSFontSelector::docLoader): Added a null check of m_document.
(WebCore::CSSFontSelector::addFontFaceRule): Ditto.
(WebCore::CSSFontSelector::fontLoaded): Ditto.
(WebCore::CSSFontSelector::fontCacheInvalidated): Ditto.
(WebCore::fontDataForGenericFamily): Added a null check of document.
* css/CSSFontSelector.h:
(WebCore::CSSFontSelector::clearDocument): Added.
* css/CSSStyleSelector.cpp:
(WebCore::CSSStyleSelector::~CSSStyleSelector): Added a call to
CSSFontSelector::clearDocument(). When the style selector is destroyed,
there is no guarantee that the document will continue to exist.
2008-07-07 Julien Chaffraix <jchaffraix@webkit.org>
Not reviewed.
......@@ -173,7 +173,8 @@ SimpleFontData* CSSFontFaceSource::getFontData(const FontDescription& fontDescri
}
} else {
// Kick off the load now.
m_font->beginLoadIfNeeded(fontSelector->docLoader());
if (DocLoader* docLoader = fontSelector->docLoader())
m_font->beginLoadIfNeeded(docLoader);
// FIXME: m_string is a URL so it makes no sense to pass it as a family name.
FontPlatformData* tempData = FontCache::getCachedFontPlatformData(fontDescription, m_string);
if (!tempData)
......
......@@ -83,7 +83,7 @@ bool CSSFontSelector::isEmpty() const
DocLoader* CSSFontSelector::docLoader() const
{
return m_document->docLoader();
return m_document ? m_document->docLoader() : 0;
}
void CSSFontSelector::addFontFaceRule(const CSSFontFaceRule* fontFaceRule)
......@@ -248,7 +248,7 @@ void CSSFontSelector::addFontFaceRule(const CSSFontFaceRule* fontFaceRule)
#endif
if (!item->isLocal()) {
if (item->isSupportedFormat()) {
if (item->isSupportedFormat() && m_document) {
CachedFont* cachedFont = m_document->docLoader()->requestFont(item->resource());
if (cachedFont) {
#if ENABLE(SVG_FONTS)
......@@ -360,7 +360,7 @@ void CSSFontSelector::addFontFaceRule(const CSSFontFaceRule* fontFaceRule)
void CSSFontSelector::fontLoaded(CSSSegmentedFontFace*)
{
if (m_document->inPageCache() || !m_document->renderer())
if (!m_document || m_document->inPageCache() || !m_document->renderer())
return;
m_document->recalcStyle(Document::Force);
m_document->renderer()->setNeedsLayoutAndPrefWidthsRecalc();
......@@ -368,7 +368,7 @@ void CSSFontSelector::fontLoaded(CSSSegmentedFontFace*)
void CSSFontSelector::fontCacheInvalidated()
{
if (m_document->inPageCache() || !m_document->renderer())
if (!m_document || m_document->inPageCache() || !m_document->renderer())
return;
m_document->recalcStyle(Document::Force);
m_document->renderer()->setNeedsLayoutAndPrefWidthsRecalc();
......@@ -376,6 +376,9 @@ void CSSFontSelector::fontCacheInvalidated()
static FontData* fontDataForGenericFamily(Document* document, const FontDescription& fontDescription, const AtomicString& familyName)
{
if (!document)
return 0;
const Settings* settings = document->frame()->settings();
AtomicString genericFamily;
if (familyName == "-webkit-serif")
......
......@@ -52,6 +52,8 @@ public:
virtual FontData* getFontData(const FontDescription& fontDescription, const AtomicString& familyName);
void clearDocument() { m_document = 0; }
void addFontFaceRule(const CSSFontFaceRule*);
void fontLoaded(CSSSegmentedFontFace*);
......
......@@ -387,6 +387,7 @@ void CSSStyleSelector::init()
CSSStyleSelector::~CSSStyleSelector()
{
m_fontSelector->clearDocument();
delete m_medium;
::delete m_rootDefaultStyle;
delete m_authorStyle;
......
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