Reviewed by Darin Adler.
Source/WebCore:
Test: fast/css/font-face-used-after-retired.html
During style recalc, existing renderers may reference their old style, including font data.
Allow them to do so safely by keeping retired custom font data around until after style recalc.
* css/CSSFontFace.cpp:
(WebCore::CSSFontFace::retireCustomFont): Added. Calls through to CSSFontSelector, if the font
face is still part of any segmented font face. Otherwise, deletes the custom font data.
* css/CSSFontFace.h:
* css/CSSFontFaceSource.cpp:
(WebCore::CSSFontFaceSource::pruneTable): Changed to call retireCustomFont() instead of deleting
retired font data.
* css/CSSFontSelector.cpp:
(WebCore::CSSFontSelector::retireCustomFont): Added. Calls through to the Document, if this is
still the active font selector for a document. Otherwise, deletes the custom font data.
* css/CSSFontSelector.h:
* css/CSSSegmentedFontFace.cpp:
(WebCore::CSSSegmentedFontFace::pruneTable): Changed to call retireCustomFont() instead of
deleting retired font data.
* dom/Document.cpp:
(WebCore::Document::~Document): Added a call to deleteRetiredCustomFonts(), in case the Document
is destroyed before getting a chance to recalc style after custom fonts have been retired.
(WebCore::Document::recalcStyle): Added a call to deleteRetiredCustomFonts() after style recalc.
(WebCore::Document::deleteRetiredCustomFonts): Added. Deletes all previously-retired custom font
data.
* dom/Document.h:
(WebCore::Document::retireCustomFont): Added.
LayoutTests:
* fast/css/font-face-used-after-retired-expected.txt: Added.
* fast/css/font-face-used-after-retired.html: Added.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@94508
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2011-09-04 Dan Bernstein <mitz@apple.com>
+
+ <rdar://problem/10071256> Retain retired custom fonts until the next style recalc
+
+ Reviewed by Darin Adler.
+
+ * fast/css/font-face-used-after-retired-expected.txt: Added.
+ * fast/css/font-face-used-after-retired.html: Added.
+
2011-09-04 Sam Weinig <sam@webkit.org>
Forgot to check in new results for fast/events/event-creation.html
--- /dev/null
+<style>
+ @font-face {
+ font-family: custom;
+ src: url(no-such-file.ttf);
+ }
+</style>
+<!-- content: counter(page) causes the style diff to be "detach" -->
+<div style="font-family: custom; content: counter(page);">
+ <br>PASS
+</div>
+<script>
+ if (window.layoutTestController) {
+ layoutTestController.dumpAsText();
+ layoutTestController.waitUntilDone();
+ // Must wait for the font to fail to load.
+ setTimeout(function() { layoutTestController.notifyDone() }, 100);
+ }
+
+ document.execCommand("SelectAll");
+</script>
+2011-09-04 Dan Bernstein <mitz@apple.com>
+
+ <rdar://problem/10071256> Retain retired custom fonts until the next style recalc
+
+ Reviewed by Darin Adler.
+
+ Test: fast/css/font-face-used-after-retired.html
+
+ During style recalc, existing renderers may reference their old style, including font data.
+ Allow them to do so safely by keeping retired custom font data around until after style recalc.
+
+ * css/CSSFontFace.cpp:
+ (WebCore::CSSFontFace::retireCustomFont): Added. Calls through to CSSFontSelector, if the font
+ face is still part of any segmented font face. Otherwise, deletes the custom font data.
+ * css/CSSFontFace.h:
+ * css/CSSFontFaceSource.cpp:
+ (WebCore::CSSFontFaceSource::pruneTable): Changed to call retireCustomFont() instead of deleting
+ retired font data.
+ * css/CSSFontSelector.cpp:
+ (WebCore::CSSFontSelector::retireCustomFont): Added. Calls through to the Document, if this is
+ still the active font selector for a document. Otherwise, deletes the custom font data.
+ * css/CSSFontSelector.h:
+ * css/CSSSegmentedFontFace.cpp:
+ (WebCore::CSSSegmentedFontFace::pruneTable): Changed to call retireCustomFont() instead of
+ deleting retired font data.
+ * dom/Document.cpp:
+ (WebCore::Document::~Document): Added a call to deleteRetiredCustomFonts(), in case the Document
+ is destroyed before getting a chance to recalc style after custom fonts have been retired.
+ (WebCore::Document::recalcStyle): Added a call to deleteRetiredCustomFonts() after style recalc.
+ (WebCore::Document::deleteRetiredCustomFonts): Added. Deletes all previously-retired custom font
+ data.
+ * dom/Document.h:
+ (WebCore::Document::retireCustomFont): Added.
+
2011-09-04 Sam Weinig <sam@webkit.org>
Document.createEvent should support all the interfaces of Event we got
return 0;
}
+void CSSFontFace::retireCustomFont(SimpleFontData* fontData)
+{
+ if (m_segmentedFontFaces.isEmpty()) {
+ GlyphPageTreeNode::pruneTreeCustomFontData(fontData);
+ delete fontData;
+ return;
+ }
+
+ // Use one of the CSSSegmentedFontFaces' font selector. They all have
+ // the same font selector.
+ (*m_segmentedFontFaces.begin())->fontSelector()->retireCustomFont(fontData);
+}
+
#if ENABLE(SVG_FONTS)
bool CSSFontFace::hasSVGFontFaceSource() const
{
void addSource(CSSFontFaceSource*);
void fontLoaded(CSSFontFaceSource*);
+ void retireCustomFont(SimpleFontData*);
SimpleFontData* getFontData(const FontDescription&, bool syntheticBold, bool syntheticItalic);
{
if (m_fontDataTable.isEmpty())
return;
+
HashMap<unsigned, SimpleFontData*>::iterator end = m_fontDataTable.end();
for (HashMap<unsigned, SimpleFontData*>::iterator it = m_fontDataTable.begin(); it != end; ++it)
- GlyphPageTreeNode::pruneTreeCustomFontData(it->second);
- deleteAllValues(m_fontDataTable);
+ m_face->retireCustomFont(it->second);
+
m_fontDataTable.clear();
}
dispatchInvalidationCallbacks();
}
+void CSSFontSelector::retireCustomFont(FontData* fontData)
+{
+ if (m_document)
+ m_document->retireCustomFont(fontData);
+ else {
+ GlyphPageTreeNode::pruneTreeCustomFontData(fontData);
+ delete fontData;
+ }
+}
+
static FontData* fontDataForGenericFamily(Document* document, const FontDescription& fontDescription, const AtomicString& familyName)
{
if (!document || !document->frame())
void fontLoaded();
virtual void fontCacheInvalidated();
+ void retireCustomFont(FontData*);
+
bool isEmpty() const;
CachedResourceLoader* cachedResourceLoader() const;
// Make sure the glyph page tree prunes out all uses of this custom font.
if (m_fontDataTable.isEmpty())
return;
+
HashMap<unsigned, SegmentedFontData*>::iterator end = m_fontDataTable.end();
for (HashMap<unsigned, SegmentedFontData*>::iterator it = m_fontDataTable.begin(); it != end; ++it)
- GlyphPageTreeNode::pruneTreeCustomFontData(it->second);
- deleteAllValues(m_fontDataTable);
+ m_fontSelector->retireCustomFont(it->second);
+
m_fontDataTable.clear();
}
(*m_userSheets)[i]->clearOwnerNode();
}
+ deleteRetiredCustomFonts();
+
m_weakReference->clear();
if (m_mediaQueryMatcher)
element->recalcStyle(change);
}
+ // Now that all RenderStyles that pointed to retired fonts have been updated, the fonts can safely be deleted.
+ deleteRetiredCustomFonts();
+
#if USE(ACCELERATED_COMPOSITING)
if (view()) {
bool layoutPending = view()->layoutPending() || renderer()->needsLayout();
return style.release();
}
+void Document::retireCustomFont(FontData* fontData)
+{
+ m_retiredCustomFonts.append(adoptPtr(fontData));
+}
+
+void Document::deleteRetiredCustomFonts()
+{
+ size_t size = m_retiredCustomFonts.size();
+ for (size_t i = 0; i < size; ++i)
+ GlyphPageTreeNode::pruneTreeCustomFontData(m_retiredCustomFonts[i].get());
+
+ m_retiredCustomFonts.clear();
+}
+
bool Document::isPageBoxVisible(int pageIndex)
{
RefPtr<RenderStyle> style = styleForPage(pageIndex);
class Event;
class EventListener;
class EventQueue;
+class FontData;
class FormAssociatedElement;
class Frame;
class FrameView;
PassRefPtr<RenderStyle> styleForElementIgnoringPendingStylesheets(Element*);
PassRefPtr<RenderStyle> styleForPage(int pageIndex);
+ void retireCustomFont(FontData*);
+
// Returns true if page box (margin boxes and page borders) is visible.
bool isPageBoxVisible(int pageIndex);
void createStyleSelector();
+ void deleteRetiredCustomFonts();
+
PassRefPtr<NodeList> handleZeroPadding(const HitTestRequest&, HitTestResult&) const;
void loadEventDelayTimerFired(Timer<Document>*);
OwnPtr<CSSStyleSelector> m_styleSelector;
bool m_didCalculateStyleSelector;
bool m_hasDirtyStyleSelector;
-
+ Vector<OwnPtr<FontData> > m_retiredCustomFonts;
+
mutable RefPtr<CSSPrimitiveValueCache> m_cssPrimitiveValueCache;
Frame* m_frame;