Diff
Copied: branches/chromium/874/LayoutTests/fast/text/custom-font-data-crash2-expected.txt (from rev 97402, trunk/LayoutTests/fast/text/custom-font-data-crash2-expected.txt) (0 => 97403)
--- branches/chromium/874/LayoutTests/fast/text/custom-font-data-crash2-expected.txt (rev 0)
+++ branches/chromium/874/LayoutTests/fast/text/custom-font-data-crash2-expected.txt 2011-10-13 21:40:02 UTC (rev 97403)
@@ -0,0 +1 @@
+PASS
Copied: branches/chromium/874/LayoutTests/fast/text/custom-font-data-crash2.html (from rev 97402, trunk/LayoutTests/fast/text/custom-font-data-crash2.html) (0 => 97403)
--- branches/chromium/874/LayoutTests/fast/text/custom-font-data-crash2.html (rev 0)
+++ branches/chromium/874/LayoutTests/fast/text/custom-font-data-crash2.html 2011-10-13 21:40:02 UTC (rev 97403)
@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<html>
+<style>
+@font-face { font-family: A; src: url(); }
+#y { font-family: A; }
+#y:first-letter { content: "A"; }
+</style>
+<body>
+<div id="y">EFGH</div>
+</body>
+<script>
+function finish() {
+ document.body.innerHTML = "PASS";
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
+}
+
+if (window.layoutTestController) {
+ layoutTestController.dumpAsText();
+ layoutTestController.waitUntilDone();
+}
+
+document.designMode = 'on';
+document.execCommand('selectall');
+
+// Let the font load to finish.
+setTimeout("finish()", 50);
+</script>
+<style>
+#y:before { content: "ABCD"; }
+</style>
+</body>
+</html>
\ No newline at end of file
Modified: branches/chromium/874/Source/WebCore/css/CSSFontFace.cpp (97402 => 97403)
--- branches/chromium/874/Source/WebCore/css/CSSFontFace.cpp 2011-10-13 21:37:04 UTC (rev 97402)
+++ branches/chromium/874/Source/WebCore/css/CSSFontFace.cpp 2011-10-13 21:40:02 UTC (rev 97403)
@@ -118,19 +118,6 @@
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
{
Modified: branches/chromium/874/Source/WebCore/css/CSSFontFace.h (97402 => 97403)
--- branches/chromium/874/Source/WebCore/css/CSSFontFace.h 2011-10-13 21:37:04 UTC (rev 97402)
+++ branches/chromium/874/Source/WebCore/css/CSSFontFace.h 2011-10-13 21:40:02 UTC (rev 97403)
@@ -63,7 +63,6 @@
void addSource(CSSFontFaceSource*);
void fontLoaded(CSSFontFaceSource*);
- void retireCustomFont(SimpleFontData*);
SimpleFontData* getFontData(const FontDescription&, bool syntheticBold, bool syntheticItalic);
Modified: branches/chromium/874/Source/WebCore/css/CSSFontFaceSource.cpp (97402 => 97403)
--- branches/chromium/874/Source/WebCore/css/CSSFontFaceSource.cpp 2011-10-13 21:37:04 UTC (rev 97402)
+++ branches/chromium/874/Source/WebCore/css/CSSFontFaceSource.cpp 2011-10-13 21:40:02 UTC (rev 97403)
@@ -72,10 +72,6 @@
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)
- m_face->retireCustomFont(it->second);
-
m_fontDataTable.clear();
}
@@ -194,6 +190,9 @@
SimpleFontData* fontDataRawPtr = fontData.leakPtr();
m_fontDataTable.set(hashKey, fontDataRawPtr);
+ ASSERT(fontSelector->document());
+ if (Document* doc = fontSelector->document())
+ doc->registerCustomFont(fontDataRawPtr);
return fontDataRawPtr;
}
Modified: branches/chromium/874/Source/WebCore/css/CSSFontSelector.cpp (97402 => 97403)
--- branches/chromium/874/Source/WebCore/css/CSSFontSelector.cpp 2011-10-13 21:37:04 UTC (rev 97402)
+++ branches/chromium/874/Source/WebCore/css/CSSFontSelector.cpp 2011-10-13 21:40:02 UTC (rev 97403)
@@ -383,16 +383,6 @@
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())
Modified: branches/chromium/874/Source/WebCore/css/CSSFontSelector.h (97402 => 97403)
--- branches/chromium/874/Source/WebCore/css/CSSFontSelector.h 2011-10-13 21:37:04 UTC (rev 97402)
+++ branches/chromium/874/Source/WebCore/css/CSSFontSelector.h 2011-10-13 21:40:02 UTC (rev 97403)
@@ -59,8 +59,6 @@
void fontLoaded();
virtual void fontCacheInvalidated();
- void retireCustomFont(FontData*);
-
bool isEmpty() const;
CachedResourceLoader* cachedResourceLoader() const;
Modified: branches/chromium/874/Source/WebCore/css/CSSSegmentedFontFace.cpp (97402 => 97403)
--- branches/chromium/874/Source/WebCore/css/CSSSegmentedFontFace.cpp 2011-10-13 21:37:04 UTC (rev 97402)
+++ branches/chromium/874/Source/WebCore/css/CSSSegmentedFontFace.cpp 2011-10-13 21:40:02 UTC (rev 97403)
@@ -28,6 +28,7 @@
#include "CSSFontFace.h"
#include "CSSFontSelector.h"
+#include "Document.h"
#include "FontDescription.h"
#include "SegmentedFontData.h"
#include "SimpleFontData.h"
@@ -53,10 +54,6 @@
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)
- m_fontSelector->retireCustomFont(it->second);
-
m_fontDataTable.clear();
}
@@ -116,9 +113,12 @@
}
}
}
- if (fontData->numRanges())
+ if (fontData->numRanges()) {
m_fontDataTable.set(hashKey, fontData);
- else {
+ ASSERT(m_fontSelector->document());
+ if (Document* doc = m_fontSelector->document())
+ doc->registerCustomFont(fontData);
+ } else {
delete fontData;
fontData = 0;
}
Modified: branches/chromium/874/Source/WebCore/dom/Document.cpp (97402 => 97403)
--- branches/chromium/874/Source/WebCore/dom/Document.cpp 2011-10-13 21:37:04 UTC (rev 97402)
+++ branches/chromium/874/Source/WebCore/dom/Document.cpp 2011-10-13 21:40:02 UTC (rev 97403)
@@ -574,7 +574,7 @@
(*m_userSheets)[i]->clearOwnerNode();
}
- deleteRetiredCustomFonts();
+ deleteCustomFonts();
m_weakReference->clear();
@@ -1564,15 +1564,6 @@
element->recalcStyle(change);
}
- // FIXME: Disabling the deletion of retired custom font data until
- // we fix all the stale style bugs (68804, 68624, etc). These bugs
- // indicate problems where some styles were not updated in recalcStyle,
- // thereby retaining stale copy of font data. To prevent that, we
- // disable this code for now and only delete retired custom font data
- // in Document destructor.
- // 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();
@@ -1709,18 +1700,18 @@
return style.release();
}
-void Document::retireCustomFont(FontData* fontData)
+void Document::registerCustomFont(FontData* fontData)
{
- m_retiredCustomFonts.append(adoptPtr(fontData));
+ m_customFonts.append(adoptPtr(fontData));
}
-void Document::deleteRetiredCustomFonts()
+void Document::deleteCustomFonts()
{
- size_t size = m_retiredCustomFonts.size();
+ size_t size = m_customFonts.size();
for (size_t i = 0; i < size; ++i)
- GlyphPageTreeNode::pruneTreeCustomFontData(m_retiredCustomFonts[i].get());
+ GlyphPageTreeNode::pruneTreeCustomFontData(m_customFonts[i].get());
- m_retiredCustomFonts.clear();
+ m_customFonts.clear();
}
bool Document::isPageBoxVisible(int pageIndex)
Modified: branches/chromium/874/Source/WebCore/dom/Document.h (97402 => 97403)
--- branches/chromium/874/Source/WebCore/dom/Document.h 2011-10-13 21:37:04 UTC (rev 97402)
+++ branches/chromium/874/Source/WebCore/dom/Document.h 2011-10-13 21:40:02 UTC (rev 97403)
@@ -548,7 +548,7 @@
PassRefPtr<RenderStyle> styleForElementIgnoringPendingStylesheets(Element*);
PassRefPtr<RenderStyle> styleForPage(int pageIndex);
- void retireCustomFont(FontData*);
+ void registerCustomFont(FontData*);
// Returns true if page box (margin boxes and page borders) is visible.
bool isPageBoxVisible(int pageIndex);
@@ -1139,7 +1139,7 @@
void createStyleSelector();
- void deleteRetiredCustomFonts();
+ void deleteCustomFonts();
PassRefPtr<NodeList> handleZeroPadding(const HitTestRequest&, HitTestResult&) const;
@@ -1154,7 +1154,7 @@
OwnPtr<CSSStyleSelector> m_styleSelector;
bool m_didCalculateStyleSelector;
bool m_hasDirtyStyleSelector;
- Vector<OwnPtr<FontData> > m_retiredCustomFonts;
+ Vector<OwnPtr<FontData> > m_customFonts;
mutable RefPtr<CSSPrimitiveValueCache> m_cssPrimitiveValueCache;