Diff
Modified: trunk/LayoutTests/ChangeLog (101857 => 101858)
--- trunk/LayoutTests/ChangeLog 2011-12-02 22:42:23 UTC (rev 101857)
+++ trunk/LayoutTests/ChangeLog 2011-12-02 22:49:53 UTC (rev 101858)
@@ -1,3 +1,29 @@
+2011-12-02 Dan Bernstein <m...@apple.com>
+
+ <rdar://problem/10520670> REGRESSION (r91738): didFinishLoad is called before custom fonts have finished loading
+ https://bugs.webkit.org/show_bug.cgi?id=73688
+
+ Reviewed by Darin Adler.
+
+ Reverted test chnages from r91738. These tests were made to wait for the fonts to finish loading
+ using a DOM. Now again they do not need to.
+
+ * fast/css/color-leakage.html:
+ * fast/css/custom-font-xheight.html:
+ * fast/css/font-face-multiple-faces.html:
+ * fast/css/font-face-multiple-remote-sources.html:
+ * fast/css/font-face-remote.html:
+ * fast/css/font-face-woff.html:
+ * fast/writing-mode/broken-ideograph-small-caps.html:
+ * svg/W3C-SVG-1.1-SE/text-intro-09-b.svg:
+ * svg/W3C-SVG-1.1/fonts-elem-07-b.svg:
+ * svg/custom/svg-fonts-fallback.xhtml:
+ * svg/custom/svg-fonts-in-html.html:
+ * svg/custom/svg-fonts-segmented.xhtml:
+ * svg/custom/svg-fonts-with-no-element-reference.html:
+ * svg/custom/svg-fonts-without-missing-glyph.xhtml:
+ * svg/text/text-overflow-ellipsis-svgfont.html:
+
2011-12-02 David Tseng <dts...@google.com>
Send an AXCheckedStateChanged notification when the aria-checked attribute changes.
Modified: trunk/LayoutTests/fast/css/color-leakage.html (101857 => 101858)
--- trunk/LayoutTests/fast/css/color-leakage.html 2011-12-02 22:42:23 UTC (rev 101857)
+++ trunk/LayoutTests/fast/css/color-leakage.html 2011-12-02 22:49:53 UTC (rev 101858)
@@ -2,6 +2,10 @@
<head>
<!-- The Ahem font rendered in this test should be displayed black, not blue. -->
<style>
+ @font-face {
+ font-family: 'Ahem';
+ src: url('resources/Ahem.ttf');
+ }
div {
display: block;
font-family: Ahem;
Modified: trunk/LayoutTests/fast/css/custom-font-xheight.html (101857 => 101858)
--- trunk/LayoutTests/fast/css/custom-font-xheight.html 2011-12-02 22:42:23 UTC (rev 101857)
+++ trunk/LayoutTests/fast/css/custom-font-xheight.html 2011-12-02 22:49:53 UTC (rev 101858)
@@ -37,25 +37,17 @@
</div>
<script>
-if (window.layoutTestController) {
+if (window.layoutTestController)
layoutTestController.dumpAsText();
- layoutTestController.waitUntilDone();
-}
function test()
{
- document.body.offsetTop;
- setTimeout(function() {
- var totalHeight = document.defaultView.getComputedStyle(document.getElementById("test"), null).getPropertyCSSValue("height");
- totalHeight = totalHeight.getFloatValue(CSSPrimitiveValue.CSS_PX);
- if (totalHeight > 150 && totalHeight < 300)
- document.getElementById("result").innerHTML = "PASS";
- else
- document.getElementById("result").innerHTML = "FAIL: " + totalHeight + "px";
-
- if (window.layoutTestController)
- layoutTestController.notifyDone();
- }, 100);
+ var totalHeight = document.defaultView.getComputedStyle(document.getElementById("test"), null).getPropertyCSSValue("height");
+ totalHeight = totalHeight.getFloatValue(CSSPrimitiveValue.CSS_PX);
+ if (totalHeight > 150 && totalHeight < 300)
+ document.getElementById("result").innerHTML = "PASS";
+ else
+ document.getElementById("result").innerHTML = "FAIL: " + totalHeight + "px";
}
</script>
</body>
Modified: trunk/LayoutTests/fast/css/font-face-multiple-faces.html (101857 => 101858)
--- trunk/LayoutTests/fast/css/font-face-multiple-faces.html 2011-12-02 22:42:23 UTC (rev 101857)
+++ trunk/LayoutTests/fast/css/font-face-multiple-faces.html 2011-12-02 22:49:53 UTC (rev 101858)
@@ -148,10 +148,3 @@
<div style="font-family: webkit-four;">
AHEM <i>AHEM</i>
</div>
-<script>
- if (window.layoutTestController) {
- layoutTestController.waitUntilDone();
- document.body.offsetTop;
- setTimeout(function() { layoutTestController.notifyDone(); }, 100);
- }
-</script>
Modified: trunk/LayoutTests/fast/css/font-face-multiple-remote-sources.html (101857 => 101858)
--- trunk/LayoutTests/fast/css/font-face-multiple-remote-sources.html 2011-12-02 22:42:23 UTC (rev 101857)
+++ trunk/LayoutTests/fast/css/font-face-multiple-remote-sources.html 2011-12-02 22:49:53 UTC (rev 101858)
@@ -15,10 +15,6 @@
_fail
</div>
<script>
- if (window.layoutTestController) {
- layoutTestController.waitUntilDone();
- document.body.offsetTop;
- setTimeout(function() { layoutTestController.notifyDone(); }, 100);
- }
+ document.body.offsetTop;
</script>
</body>
Modified: trunk/LayoutTests/fast/css/font-face-remote.html (101857 => 101858)
--- trunk/LayoutTests/fast/css/font-face-remote.html 2011-12-02 22:42:23 UTC (rev 101857)
+++ trunk/LayoutTests/fast/css/font-face-remote.html 2011-12-02 22:49:53 UTC (rev 101858)
@@ -8,7 +8,7 @@
div { width: 100px; height: 100px; background-color: red; font-family: 'remote'; font-size: 20px; color: green; }
</style>
</head>
-<body>
+<body _onload_="finished()">
<div>
FAIL_<br>
XXXXX<br>
@@ -17,10 +17,16 @@
_FAIL<br>
</div>
<script>
- if (window.layoutTestController) {
+ if (window.layoutTestController)
layoutTestController.waitUntilDone();
- document.body.offsetTop;
- setTimeout(function() { layoutTestController.notifyDone(); }, 100);
+
+ // Kick off loading of the font
+ document.body.offsetTop;
+
+ function finished()
+ {
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
}
</script>
</body>
Modified: trunk/LayoutTests/fast/css/font-face-woff.html (101857 => 101858)
--- trunk/LayoutTests/fast/css/font-face-woff.html 2011-12-02 22:42:23 UTC (rev 101857)
+++ trunk/LayoutTests/fast/css/font-face-woff.html 2011-12-02 22:49:53 UTC (rev 101858)
@@ -8,10 +8,3 @@
<p>This test tries to render the following text with Ahem, loaded from a WOFF file. The text below should be a series of black boxes.</p>
<p style="font-family: family1; font-size: 4em;">Failure</p>
-<script>
- if (window.layoutTestController) {
- layoutTestController.waitUntilDone();
- document.body.offsetTop;
- setTimeout(function() { layoutTestController.notifyDone(); }, 100);
- }
-</script>
Modified: trunk/LayoutTests/fast/writing-mode/broken-ideograph-small-caps.html (101857 => 101858)
--- trunk/LayoutTests/fast/writing-mode/broken-ideograph-small-caps.html 2011-12-02 22:42:23 UTC (rev 101857)
+++ trunk/LayoutTests/fast/writing-mode/broken-ideograph-small-caps.html 2011-12-02 22:49:53 UTC (rev 101858)
@@ -57,6 +57,10 @@
</style>
+<script type="text/_javascript_">
+
+</script>
+
</head>
<body>
@@ -65,12 +69,5 @@
<div class="basic d1 vert"><p>第一段落 Paragraph 1</p><p>第二段落 Paragraph 2</p></div>
</div>
-<script>
- if (window.layoutTestController) {
- layoutTestController.waitUntilDone();
- document.body.offsetTop;
- setTimeout(function() { layoutTestController.notifyDone(); }, 100);
- }
-</script>
</body>
</html>
Modified: trunk/LayoutTests/svg/W3C-SVG-1.1/fonts-elem-07-b.svg (101857 => 101858)
--- trunk/LayoutTests/svg/W3C-SVG-1.1/fonts-elem-07-b.svg 2011-12-02 22:42:23 UTC (rev 101857)
+++ trunk/LayoutTests/svg/W3C-SVG-1.1/fonts-elem-07-b.svg 2011-12-02 22:49:53 UTC (rev 101858)
@@ -113,11 +113,4 @@
</g>
<text id="revision" x="10" y="340" font-size="40" stroke="none" fill="black">$Revision: 1.7 $</text>
<rect id="test-frame" x="1" y="1" width="478" height="358" fill="none" stroke="#000000"/>
- <script>
- if (window.layoutTestController) {
- layoutTestController.waitUntilDone();
- document.documentElement.offsetTop;
- setTimeout(function() { layoutTestController.notifyDone(); }, 100);
- }
- </script>
</svg>
Modified: trunk/LayoutTests/svg/W3C-SVG-1.1-SE/text-intro-09-b.svg (101857 => 101858)
--- trunk/LayoutTests/svg/W3C-SVG-1.1-SE/text-intro-09-b.svg 2011-12-02 22:42:23 UTC (rev 101857)
+++ trunk/LayoutTests/svg/W3C-SVG-1.1-SE/text-intro-09-b.svg 2011-12-02 22:49:53 UTC (rev 101858)
@@ -86,11 +86,4 @@
<text font-family="SVGFreeSansASCII,sans-serif" font-weight="bold" font-size="20" x="240"
text-anchor="middle" y="18" stroke-width="0.5" stroke="black" fill="white">DRAFT</text>
</g>-->
-<script>
- if (window.layoutTestController) {
- layoutTestController.waitUntilDone();
- document.documentElement.offsetTop;
- setTimeout(function() { layoutTestController.notifyDone(); }, 100);
- }
-</script>
</svg>
Modified: trunk/LayoutTests/svg/custom/svg-fonts-fallback.xhtml (101857 => 101858)
--- trunk/LayoutTests/svg/custom/svg-fonts-fallback.xhtml 2011-12-02 22:42:23 UTC (rev 101857)
+++ trunk/LayoutTests/svg/custom/svg-fonts-fallback.xhtml 2011-12-02 22:49:53 UTC (rev 101858)
@@ -76,12 +76,6 @@
<!-- 'a', ' ', 'o' from TestFont2, '௢' can't be rendered, as none of the default fonts defines it -->
<span style='font-family: TestFont2; font-size: 40px; '>a ௢ o</span><br/>
</p>
-<script>
- if (window.layoutTestController) {
- layoutTestController.waitUntilDone();
- document.documentElement.offsetTop;
- setTimeout(function() { layoutTestController.notifyDone(); }, 100);
- }
-</script>
+
</body>
</html>
Modified: trunk/LayoutTests/svg/custom/svg-fonts-in-html.html (101857 => 101858)
--- trunk/LayoutTests/svg/custom/svg-fonts-in-html.html 2011-12-02 22:42:23 UTC (rev 101857)
+++ trunk/LayoutTests/svg/custom/svg-fonts-in-html.html 2011-12-02 22:49:53 UTC (rev 101858)
@@ -208,12 +208,6 @@
<!-- Add a background image to each and use width and height to control sizing, place with absolute positioning -->
<div id="extraDiv1"><span></span></div><div id="extraDiv2"><span></span></div><div id="extraDiv3"><span></span></div>
<div id="extraDiv4"><span></span></div><div id="extraDiv5"><span></span></div><div id="extraDiv6"><span></span></div>
-<script>
- if (window.layoutTestController) {
- layoutTestController.waitUntilDone();
- document.documentElement.offsetTop;
- setTimeout(function() { layoutTestController.notifyDone(); }, 100);
- }
-</script>
+
</body>
</html>
Modified: trunk/LayoutTests/svg/custom/svg-fonts-segmented.xhtml (101857 => 101858)
--- trunk/LayoutTests/svg/custom/svg-fonts-segmented.xhtml 2011-12-02 22:42:23 UTC (rev 101857)
+++ trunk/LayoutTests/svg/custom/svg-fonts-segmented.xhtml 2011-12-02 22:49:53 UTC (rev 101858)
@@ -37,12 +37,6 @@
<!-- 'ABC' should be rendered using Times, 'def' using Courier, 'o' using the SVG Font, and 'O' again by Times -->
<p style='font-family: TestFont; font-size: 40px; '>ABCdefoooO</p>
-<script>
- if (window.layoutTestController) {
- layoutTestController.waitUntilDone();
- document.documentElement.offsetTop;
- setTimeout(function() { layoutTestController.notifyDone(); }, 100);
- }
-</script>
+
</body>
</html>
Modified: trunk/LayoutTests/svg/custom/svg-fonts-with-no-element-reference.html (101857 => 101858)
--- trunk/LayoutTests/svg/custom/svg-fonts-with-no-element-reference.html 2011-12-02 22:42:23 UTC (rev 101857)
+++ trunk/LayoutTests/svg/custom/svg-fonts-with-no-element-reference.html 2011-12-02 22:49:53 UTC (rev 101858)
@@ -31,13 +31,6 @@
<body>
<p class="first">This text should be rendered with a first font.</p>
<p class="second">This text should be rendered with a second font.</p>
-<script>
- if (window.layoutTestController) {
- layoutTestController.waitUntilDone();
- document.documentElement.offsetTop;
- setTimeout(function() { layoutTestController.notifyDone(); }, 100);
- }
-</script>
</body>
</html>
Modified: trunk/LayoutTests/svg/custom/svg-fonts-without-missing-glyph.xhtml (101857 => 101858)
--- trunk/LayoutTests/svg/custom/svg-fonts-without-missing-glyph.xhtml 2011-12-02 22:42:23 UTC (rev 101857)
+++ trunk/LayoutTests/svg/custom/svg-fonts-without-missing-glyph.xhtml 2011-12-02 22:49:53 UTC (rev 101858)
@@ -30,12 +30,6 @@
<p class="target">AXX</p>
<p class="target">XXX</p>
<p class="target">AAA</p>
-<script>
- if (window.layoutTestController) {
- layoutTestController.waitUntilDone();
- document.documentElement.offsetTop;
- setTimeout(function() { layoutTestController.notifyDone(); }, 100);
- }
-</script>
+
</body>
</html>
Modified: trunk/LayoutTests/svg/text/text-overflow-ellipsis-svgfont.html (101857 => 101858)
--- trunk/LayoutTests/svg/text/text-overflow-ellipsis-svgfont.html 2011-12-02 22:42:23 UTC (rev 101857)
+++ trunk/LayoutTests/svg/text/text-overflow-ellipsis-svgfont.html 2011-12-02 22:49:53 UTC (rev 101858)
@@ -36,12 +36,5 @@
abc abc abc abc abc abc abc abc abc abc
</div>
-<script>
- if (window.layoutTestController) {
- layoutTestController.waitUntilDone();
- document.documentElement.offsetTop;
- setTimeout(function() { layoutTestController.notifyDone(); }, 100);
- }
-</script>
</body>
</html>
Modified: trunk/Source/WebCore/ChangeLog (101857 => 101858)
--- trunk/Source/WebCore/ChangeLog 2011-12-02 22:42:23 UTC (rev 101857)
+++ trunk/Source/WebCore/ChangeLog 2011-12-02 22:49:53 UTC (rev 101858)
@@ -1,3 +1,40 @@
+2011-12-02 Dan Bernstein <m...@apple.com>
+
+ <rdar://problem/10520670> REGRESSION (r91738): didFinishLoad is called before custom fonts have finished loading
+ https://bugs.webkit.org/show_bug.cgi?id=73688
+
+ Reviewed by Darin Adler.
+
+ The problem was that after CSSFontFaceSource::getFontData() had scheduled a 0-delay timer to
+ begin loading the font, but before that timer fired, the subresource loader appeared to have
+ had no resources waiting to be loaded, and therefore didFinishLoad could be called. This change
+ reworks the fix for <http://webkit.org/b/65123> so that while the load is still started on a
+ 0-dealy timer, the subresource loader’s request count is incremented immediately, preventing
+ it from hitting 0 while the font load is scheduled to begin. The delayed load mechanism is
+ moved from CSSFontFaceSource into CSSFontSelector in order to safely handle the possibility of
+ the latter being decommissioned while waiting for font loading to begin.
+
+ * css/CSSFontFaceSource.cpp:
+ (WebCore::CSSFontFaceSource::CSSFontFaceSource): Removed initializer for m_loadStartTimer.
+ (WebCore::CSSFontFaceSource::~CSSFontFaceSource): Removed stopping of m_loadStartTimer.
+ (WebCore::CSSFontFaceSource::getFontData): Replaced code to schedule loading on a timer with
+ a call to CSSFontSelector::beginLoadingFontSoon.
+ * css/CSSFontFaceSource.h: Removed m_loadStartTimer and m_fontSelector member variables.
+ * css/CSSFontSelector.cpp:
+ (WebCore::CSSFontSelector::CSSFontSelector): Added initialized for m_beginLoadingTimer.
+ (WebCore::CSSFontSelector::~CSSFontSelector): Added call to clearDocument(), to deal with
+ anything remaining in m_fontsToBeginLoading at this time.
+ (WebCore::CSSFontSelector::clearDocument): Now stops m_beginLoadingTimer and balances
+ incrementRequestCount() calls for anything remaining in m_fontsToBeginLoading.
+ (WebCore::CSSFontSelector::beginLoadingFontSoon): Added. Schedules the actual call to
+ CachedFont::beginLoadingIfNeeded on a 0-delay timer, and meanwhile increments the request count
+ on the CachedResourceLoader, which ensures that didFinishLoad will not be called while waiting
+ for the timer to fire.
+ (WebCore::CSSFontSelector::beginLoadTimerFired): Added. Actually calls
+ CachedFont::beginLoadIfNeeded and balances the incrementRequestCount() made when the timer was
+ scheduled.
+ * css/CSSFontSelector.h:
+
2011-12-02 David Tseng <dts...@google.com>
Send an AXCheckedStateChanged notification when the aria-checked attribute changes.
Modified: trunk/Source/WebCore/css/CSSFontFaceSource.cpp (101857 => 101858)
--- trunk/Source/WebCore/css/CSSFontFaceSource.cpp 2011-12-02 22:42:23 UTC (rev 101857)
+++ trunk/Source/WebCore/css/CSSFontFaceSource.cpp 2011-12-02 22:49:53 UTC (rev 101858)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2007, 2008, 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2007, 2008, 2010, 2011 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -51,7 +51,6 @@
: m_string(str)
, m_font(font)
, m_face(0)
- , m_loadStartTimer(this, &CSSFontFaceSource::startLoadingTimerFired)
#if ENABLE(SVG_FONTS)
, m_hasExternalSVGFont(false)
#endif
@@ -62,7 +61,6 @@
CSSFontFaceSource::~CSSFontFaceSource()
{
- m_loadStartTimer.stop();
if (m_font)
m_font->removeClient(this);
pruneTable();
@@ -177,11 +175,9 @@
#endif
}
} else {
- // Kick off the load now. Do it on a zero-delay timer rather than synchronously, because we may be in
- // the middle of layout, and the loader may invoke arbitrary delegate or event handler code.
- m_fontSelector = fontSelector;
- if (!m_loadStartTimer.isActive())
- m_loadStartTimer.startOneShot(0);
+ // Kick off the load. Do it soon rather than now, because we may be in the middle of layout,
+ // and the loader may invoke arbitrary delegate or event handler code.
+ fontSelector->beginLoadingFontSoon(m_font.get());
// This temporary font is not retained and should not be returned.
FontCachePurgePreventer fontCachePurgePreventer;
@@ -198,17 +194,6 @@
return fontDataRawPtr;
}
-void CSSFontFaceSource::startLoadingTimerFired(Timer<WebCore::CSSFontFaceSource>*)
-{
- ASSERT(m_font);
- ASSERT(m_fontSelector);
-
- if (CachedResourceLoader* cachedResourceLoader = m_fontSelector->cachedResourceLoader())
- m_font->beginLoadIfNeeded(cachedResourceLoader);
-
- m_fontSelector = nullptr;
-}
-
#if ENABLE(SVG_FONTS)
SVGFontFaceElement* CSSFontFaceSource::svgFontFaceElement() const
{
Modified: trunk/Source/WebCore/css/CSSFontFaceSource.h (101857 => 101858)
--- trunk/Source/WebCore/css/CSSFontFaceSource.h 2011-12-02 22:42:23 UTC (rev 101857)
+++ trunk/Source/WebCore/css/CSSFontFaceSource.h 2011-12-02 22:49:53 UTC (rev 101858)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2007, 2008, 2011 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -78,9 +78,6 @@
CSSFontFace* m_face; // Our owning font face.
HashMap<unsigned, SimpleFontData*> m_fontDataTable; // The hash key is composed of size synthetic styles.
- Timer<CSSFontFaceSource> m_loadStartTimer;
- RefPtr<CSSFontSelector> m_fontSelector;
-
#if ENABLE(SVG_FONTS)
RefPtr<SVGFontFaceElement> m_svgFontFaceElement;
RefPtr<SVGFontElement> m_externalSVGFontElement;
Modified: trunk/Source/WebCore/css/CSSFontSelector.cpp (101857 => 101858)
--- trunk/Source/WebCore/css/CSSFontSelector.cpp 2011-12-02 22:42:23 UTC (rev 101857)
+++ trunk/Source/WebCore/css/CSSFontSelector.cpp 2011-12-02 22:49:53 UTC (rev 101858)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2007, 2008, 2011 Apple Inc. All rights reserved.
* (C) 2007, 2008 Nikolas Zimmermann <zimmerm...@kde.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -60,6 +60,7 @@
CSSFontSelector::CSSFontSelector(Document* document)
: m_document(document)
+ , m_beginLoadingTimer(this, &CSSFontSelector::beginLoadTimerFired)
{
// FIXME: An old comment used to say there was no need to hold a reference to m_document
// because "we are guaranteed to be destroyed before the document". But there does not
@@ -71,6 +72,7 @@
CSSFontSelector::~CSSFontSelector()
{
+ clearDocument();
fontCache()->removeClient(this);
deleteAllValues(m_fontFaces);
deleteAllValues(m_locallyInstalledFontFaces);
@@ -82,11 +84,6 @@
return m_fonts.isEmpty();
}
-CachedResourceLoader* CSSFontSelector::cachedResourceLoader() const
-{
- return m_document ? m_document->cachedResourceLoader() : 0;
-}
-
void CSSFontSelector::addFontFaceRule(const CSSFontFaceRule* fontFaceRule)
{
// Obtain the font-family property and the src property. Both must be defined.
@@ -580,4 +577,51 @@
return face->getFontData(fontDescription);
}
+void CSSFontSelector::clearDocument()
+{
+ if (!m_document) {
+ ASSERT(!m_beginLoadingTimer.isActive());
+ ASSERT(m_fontsToBeginLoading.isEmpty());
+ return;
+ }
+
+ m_beginLoadingTimer.stop();
+
+ CachedResourceLoader* cachedResourceLoader = m_document->cachedResourceLoader();
+ for (size_t i = 0; i < m_fontsToBeginLoading.size(); ++i) {
+ // Balances incrementRequestCount() in beginLoadingFontSoon().
+ cachedResourceLoader->decrementRequestCount(m_fontsToBeginLoading[i].get());
+ }
+
+ m_fontsToBeginLoading.clear();
+
+ m_document = 0;
}
+
+void CSSFontSelector::beginLoadingFontSoon(CachedFont* font)
+{
+ if (!m_document)
+ return;
+
+ m_fontsToBeginLoading.append(font);
+ // Increment the request count now, in order to prevent didFinishLoad from being dispatched
+ // after this font has been requested but before it began loading. Balanced by
+ // decrementRequestCount() in beginLoadTimerFired() and in clearDocument().
+ m_document->cachedResourceLoader()->incrementRequestCount(font);
+ m_beginLoadingTimer.startOneShot(0);
+}
+
+void CSSFontSelector::beginLoadTimerFired(Timer<WebCore::CSSFontSelector>*)
+{
+ Vector<CachedResourceHandle<CachedFont> > fontsToBeginLoading;
+ fontsToBeginLoading.swap(m_fontsToBeginLoading);
+
+ CachedResourceLoader* cachedResourceLoader = m_document->cachedResourceLoader();
+ for (size_t i = 0; i < fontsToBeginLoading.size(); ++i) {
+ fontsToBeginLoading[i]->beginLoadIfNeeded(cachedResourceLoader);
+ // Balances incrementRequestCount() in beginLoadingFontSoon().
+ cachedResourceLoader->decrementRequestCount(fontsToBeginLoading[i].get());
+ }
+}
+
+}
Modified: trunk/Source/WebCore/css/CSSFontSelector.h (101857 => 101858)
--- trunk/Source/WebCore/css/CSSFontSelector.h 2011-12-02 22:42:23 UTC (rev 101857)
+++ trunk/Source/WebCore/css/CSSFontSelector.h 2011-12-02 22:49:53 UTC (rev 101858)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2007, 2008, 2011 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -26,7 +26,9 @@
#ifndef CSSFontSelector_h
#define CSSFontSelector_h
+#include "CachedResourceHandle.h"
#include "FontSelector.h"
+#include "Timer.h"
#include <wtf/Forward.h>
#include <wtf/HashMap.h>
#include <wtf/HashSet.h>
@@ -38,8 +40,8 @@
class CSSFontFace;
class CSSFontFaceRule;
class CSSSegmentedFontFace;
+class CachedFont;
class Document;
-class CachedResourceLoader;
class FontDescription;
class CSSFontSelector : public FontSelector {
@@ -52,7 +54,7 @@
virtual FontData* getFontData(const FontDescription& fontDescription, const AtomicString& familyName);
- void clearDocument() { m_document = 0; }
+ void clearDocument();
void addFontFaceRule(const CSSFontFaceRule*);
@@ -61,23 +63,28 @@
bool isEmpty() const;
- CachedResourceLoader* cachedResourceLoader() const;
-
virtual void registerForInvalidationCallbacks(FontSelectorClient*);
virtual void unregisterForInvalidationCallbacks(FontSelectorClient*);
Document* document() const { return m_document; }
+ void beginLoadingFontSoon(CachedFont*);
+
private:
CSSFontSelector(Document*);
void dispatchInvalidationCallbacks();
+ void beginLoadTimerFired(Timer<CSSFontSelector>*);
+
Document* m_document;
HashMap<String, Vector<RefPtr<CSSFontFace> >*, CaseFoldingHash> m_fontFaces;
HashMap<String, Vector<RefPtr<CSSFontFace> >*, CaseFoldingHash> m_locallyInstalledFontFaces;
HashMap<String, HashMap<unsigned, RefPtr<CSSSegmentedFontFace> >*, CaseFoldingHash> m_fonts;
HashSet<FontSelectorClient*> m_clients;
+
+ Vector<CachedResourceHandle<CachedFont> > m_fontsToBeginLoading;
+ Timer<CSSFontSelector> m_beginLoadingTimer;
};
} // namespace WebCore