<rdar://problem/10520670> REGRESSION (r91738): didFinishLoad is called before custom...
authormitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 2 Dec 2011 22:49:53 +0000 (22:49 +0000)
committermitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 2 Dec 2011 22:49:53 +0000 (22:49 +0000)
commitcc1eb7a53a010ad619744c20fe8c97c58e0dfbd6
treee28a87c80f754109e9cc3cada4ece0813eaa3d34
parenta5a7c9efc07c210792326ecb33f97e29eec14354
<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.

Source/WebCore:

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:

LayoutTests:

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:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@101858 268f45cc-cd09-0410-ab3c-d52691b4dbfc
21 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/css/color-leakage.html
LayoutTests/fast/css/custom-font-xheight.html
LayoutTests/fast/css/font-face-multiple-faces.html
LayoutTests/fast/css/font-face-multiple-remote-sources.html
LayoutTests/fast/css/font-face-remote.html
LayoutTests/fast/css/font-face-woff.html
LayoutTests/fast/writing-mode/broken-ideograph-small-caps.html
LayoutTests/svg/W3C-SVG-1.1-SE/text-intro-09-b.svg
LayoutTests/svg/W3C-SVG-1.1/fonts-elem-07-b.svg
LayoutTests/svg/custom/svg-fonts-fallback.xhtml
LayoutTests/svg/custom/svg-fonts-in-html.html
LayoutTests/svg/custom/svg-fonts-segmented.xhtml
LayoutTests/svg/custom/svg-fonts-with-no-element-reference.html
LayoutTests/svg/custom/svg-fonts-without-missing-glyph.xhtml
LayoutTests/svg/text/text-overflow-ellipsis-svgfont.html
Source/WebCore/ChangeLog
Source/WebCore/css/CSSFontFaceSource.cpp
Source/WebCore/css/CSSFontFaceSource.h
Source/WebCore/css/CSSFontSelector.cpp
Source/WebCore/css/CSSFontSelector.h