Diff
Modified: trunk/LayoutTests/ChangeLog (173208 => 173209)
--- trunk/LayoutTests/ChangeLog 2014-09-03 17:05:08 UTC (rev 173208)
+++ trunk/LayoutTests/ChangeLog 2014-09-03 17:26:09 UTC (rev 173209)
@@ -1,3 +1,17 @@
+2014-09-03 Bear Travis <betra...@adobe.com>
+
+ [CSS Font Loading] Enable Page Caching
+ https://bugs.webkit.org/show_bug.cgi?id=136044
+
+ Reviewed by Andreas Kling.
+
+ Adding test that loads a font then navigates away and back.
+ Test must also be disabled while feature is turned off.
+
+ * TestExpectations: Skip test.
+ * fast/css/fontloader-page-cache-expected.txt: Added.
+ * fast/css/fontloader-page-cache.html: Added.
+
2014-09-02 Brian J. Burg <b...@cs.washington.edu>
LegacyProfiler: remove redundant ProfileNode members and other cleanup
Modified: trunk/LayoutTests/TestExpectations (173208 => 173209)
--- trunk/LayoutTests/TestExpectations 2014-09-03 17:05:08 UTC (rev 173208)
+++ trunk/LayoutTests/TestExpectations 2014-09-03 17:26:09 UTC (rev 173209)
@@ -140,6 +140,7 @@
webkit.org/b/135390 fast/css/fontloader-multiple-faces-download-error.html [ Skip ]
webkit.org/b/135390 fast/css/fontloader-multiple-faces.html [ Skip ]
webkit.org/b/135390 fast/css/fontloader-multiple-families.html [ Skip ]
+webkit.org/b/135390 fast/css/fontloader-page-cache.html [ Skip ]
webkit.org/b/135390 http/tests/webfont/fontloader-loading-attribute.html [ Skip ]
# Various failures from the W3C CSS Shapes test suite import
Added: trunk/LayoutTests/fast/css/fontloader-page-cache-expected.txt (0 => 173209)
--- trunk/LayoutTests/fast/css/fontloader-page-cache-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/css/fontloader-page-cache-expected.txt 2014-09-03 17:26:09 UTC (rev 173209)
@@ -0,0 +1,2 @@
+This test verifies that the page cache preserves pages with fonts loaded via the document.fonts API. The test loads a font, then navigates away and back, confirming that the font remains loaded. If successful, it outputs 'PASS' below.
+PASS
Added: trunk/LayoutTests/fast/css/fontloader-page-cache.html (0 => 173209)
--- trunk/LayoutTests/fast/css/fontloader-page-cache.html (rev 0)
+++ trunk/LayoutTests/fast/css/fontloader-page-cache.html 2014-09-03 17:26:09 UTC (rev 173209)
@@ -0,0 +1,47 @@
+<!doctype html>
+<html>
+<style>
+@font-face {
+ font-family: TestFont;
+ src: url(../../resources/Ahem.ttf);
+}
+</style>
+<script>
+var timeoutValue = 100; //ms
+
+var timestamp;
+function verify() {
+ document.getElementById("result").innerHTML =
+ document.fonts.checkFont("10px TestFont") ? 'PASS' : 'FAIL with TestFont missing';
+
+ if (window.testRunner)
+ testRunner.notifyDone();
+}
+
+function runTest() {
+ if (window.testRunner) {
+ testRunner.dumpAsText();
+ testRunner.waitUntilDone();
+ testRunner.overridePreference("WebKitUsesPageCachePreferenceKey", 1);
+ }
+ document.fonts.loadFont({ font: '10px TestFont', onsuccess: onsuccess, onerror: onerror });
+}
+
+function onsuccess() {
+ window.setTimeout(verify, timeoutValue);
+ window.setTimeout(function() {
+ window.location.href = "" _onload_='history.back()'></body>";
+}, 0);
+}
+
+function onerror() {
+ document.getElementById("result").innerHTML = "FAIL with font load error";
+ testRunner.notifyDone();
+}
+
+</script>
+<body _onload_='runTest()'>
+This test verifies that the page cache preserves pages with fonts loaded via the document.fonts API. The test loads a font, then navigates away and back, confirming that the font remains loaded. If successful, it outputs 'PASS' below.
+<div id="result"></div>
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (173208 => 173209)
--- trunk/Source/WebCore/ChangeLog 2014-09-03 17:05:08 UTC (rev 173208)
+++ trunk/Source/WebCore/ChangeLog 2014-09-03 17:26:09 UTC (rev 173209)
@@ -1,3 +1,37 @@
+2014-09-03 Bear Travis <betra...@adobe.com>
+
+ [CSS Font Loading] Enable Page Caching
+ https://bugs.webkit.org/show_bug.cgi?id=136044
+
+ Reviewed by Andreas Kling.
+
+ Modifying FontLoader to track fonts loaded via the loadFont
+ method as well as via CSS rules. Fonts loaded via loadFont are
+ tracked in m_numLoadingFromJS, while fonts loaded via CSS rules
+ are tracked in m_numLoadingFromCSS. The page is cacheable when no
+ fonts are currently loading.
+
+ Added fast/css/fontloader-page-cache.html
+
+ * css/FontLoader.cpp:
+ (WebCore::LoadFontCallback::create): Modified to take and store
+ the number of fonts it will be loading.
+ (WebCore::LoadFontCallback::createFromParams): Ditto.
+ (WebCore::LoadFontCallback::familyCount): Getter for number of
+ fonts loaded via this callback.
+ (WebCore::LoadFontCallback::LoadFontCallback):
+ (WebCore::LoadFontCallback::notifyLoaded): Callback the FontLoader
+ to let it update its count when all the fonts have finished loading.
+ (WebCore::FontLoader::loadFontDone): Ditto.
+ (WebCore::FontLoader::FontLoader):
+ (WebCore::FontLoader::beginFontLoading): Track the number of fonts
+ loading.
+ (WebCore::FontLoader::fontLoaded): Ditto.
+ (WebCore::FontLoader::loadError): Ditto.
+ (WebCore::FontLoader::loadFont):
+ * css/FontLoader.h:
+ (WebCore::FontLoader::loading):
+
2014-08-29 Gavin Barraclough <barraclo...@apple.com>
Simplify DOMTimer::adjustMinimumTimerInterval -> updateTimerIntervalIfNecessary
Modified: trunk/Source/WebCore/css/FontLoader.cpp (173208 => 173209)
--- trunk/Source/WebCore/css/FontLoader.cpp 2014-09-03 17:05:08 UTC (rev 173208)
+++ trunk/Source/WebCore/css/FontLoader.cpp 2014-09-03 17:26:09 UTC (rev 173209)
@@ -48,12 +48,12 @@
class LoadFontCallback : public CSSSegmentedFontFace::LoadFontCallback {
public:
- static PassRefPtr<LoadFontCallback> create(int numLoading, PassRefPtr<VoidCallback> loadCallback, PassRefPtr<VoidCallback> errorCallback)
+ static PassRefPtr<LoadFontCallback> create(int numLoading, FontLoader& fontLoader, PassRefPtr<VoidCallback> loadCallback, PassRefPtr<VoidCallback> errorCallback)
{
- return adoptRef<LoadFontCallback>(new LoadFontCallback(numLoading, loadCallback, errorCallback));
+ return adoptRef<LoadFontCallback>(new LoadFontCallback(numLoading, fontLoader, loadCallback, errorCallback));
}
- static PassRefPtr<LoadFontCallback> createFromParams(const Dictionary& params, const Font& font)
+ static PassRefPtr<LoadFontCallback> createFromParams(const Dictionary& params, FontLoader& fontLoader, const Font& font)
{
RefPtr<VoidCallback> onsuccess;
RefPtr<VoidCallback> onerror;
@@ -62,23 +62,29 @@
if (!onsuccess && !onerror)
return 0;
int numFamilies = font.familyCount();
- return LoadFontCallback::create(numFamilies, onsuccess, onerror);
+ return LoadFontCallback::create(numFamilies, fontLoader, onsuccess, onerror);
}
virtual void notifyLoaded() override;
virtual void notifyError() override;
virtual ~LoadFontCallback() { };
+ int familyCount() const { return m_familyCount; }
+
private:
- LoadFontCallback(int numLoading, PassRefPtr<VoidCallback> loadCallback, PassRefPtr<VoidCallback> errorCallback)
- : m_numLoading(numLoading)
+ LoadFontCallback(int numLoading, FontLoader& fontLoader, PassRefPtr<VoidCallback> loadCallback, PassRefPtr<VoidCallback> errorCallback)
+ : m_familyCount(numLoading)
+ , m_numLoading(numLoading)
, m_errorOccured(false)
+ , m_fontLoader(fontLoader)
, m_loadCallback(loadCallback)
, m_errorCallback(errorCallback)
{ }
+ int m_familyCount;
int m_numLoading;
bool m_errorOccured;
+ FontLoader& m_fontLoader;
RefPtr<VoidCallback> m_loadCallback;
RefPtr<VoidCallback> m_errorCallback;
};
@@ -96,6 +102,7 @@
if (m_loadCallback)
m_loadCallback->handleEvent();
}
+ m_fontLoader.loadFontDone(*this);
}
void LoadFontCallback::notifyError()
@@ -104,10 +111,16 @@
notifyLoaded();
}
+void FontLoader::loadFontDone(const LoadFontCallback& callback)
+{
+ m_numLoadingFromJS -= callback.familyCount();
+}
+
FontLoader::FontLoader(Document* document)
: ActiveDOMObject(document)
, m_document(document)
- , m_loadingCount(0)
+ , m_numLoadingFromCSS(0)
+ , m_numLoadingFromJS(0)
{
suspendIfNeeded();
}
@@ -167,31 +180,31 @@
void FontLoader::beginFontLoading(CSSFontFaceRule* rule)
{
- ++m_loadingCount;
- if (m_loadingCount == 1 && !m_loadingDoneEvent)
+ ++m_numLoadingFromCSS;
+ if (m_numLoadingFromCSS == 1 && !m_loadingDoneEvent)
scheduleEvent(CSSFontFaceLoadEvent::createForFontFaceRule(eventNames().loadingEvent, rule));
scheduleEvent(CSSFontFaceLoadEvent::createForFontFaceRule(eventNames().loadstartEvent, rule));
}
void FontLoader::fontLoaded(CSSFontFaceRule* rule)
{
- ASSERT(m_loadingCount > 0);
+ ASSERT(m_numLoadingFromCSS > 0);
scheduleEvent(CSSFontFaceLoadEvent::createForFontFaceRule(eventNames().loadEvent, rule));
- --m_loadingCount;
- if (!m_loadingCount)
+ --m_numLoadingFromCSS;
+ if (!m_numLoadingFromCSS)
m_loadingDoneEvent = CSSFontFaceLoadEvent::createForFontFaceRule(eventNames().loadingdoneEvent, rule);
}
void FontLoader::loadError(CSSFontFaceRule* rule, CSSFontFaceSource* source)
{
- ASSERT(m_loadingCount > 0);
+ ASSERT(m_numLoadingFromCSS > 0);
// FIXME: We should report NetworkError in case of timeout, etc.
String errorName = (source && source->isDecodeError()) ? "InvalidFontDataError" : ExceptionCodeDescription(NOT_FOUND_ERR).name;
scheduleEvent(CSSFontFaceLoadEvent::createForError(rule, DOMError::create(errorName)));
- --m_loadingCount;
- if (!m_loadingCount)
+ --m_numLoadingFromCSS;
+ if (!m_numLoadingFromCSS)
m_loadingDoneEvent = CSSFontFaceLoadEvent::createForFontFaceRule(eventNames().loadingdoneEvent, rule);
}
@@ -236,8 +249,9 @@
Font font;
if (!resolveFontStyle(fontString, font))
return;
- RefPtr<LoadFontCallback> callback = LoadFontCallback::createFromParams(params, font);
-
+ RefPtr<LoadFontCallback> callback = LoadFontCallback::createFromParams(params, *this, font);
+ m_numLoadingFromJS += callback->familyCount();
+
for (unsigned i = 0; i < font.familyCount(); i++) {
CSSSegmentedFontFace* face = m_document->ensureStyleResolver().fontSelector()->getFontFace(font.fontDescription(), font.familyAt(i));
if (!face) {
Modified: trunk/Source/WebCore/css/FontLoader.h (173208 => 173209)
--- trunk/Source/WebCore/css/FontLoader.h 2014-09-03 17:05:08 UTC (rev 173208)
+++ trunk/Source/WebCore/css/FontLoader.h 2014-09-03 17:26:09 UTC (rev 173209)
@@ -45,6 +45,7 @@
class Document;
class Event;
class Font;
+class LoadFontCallback;
class ScriptExecutionContext;
class FontLoader : public RefCounted<FontLoader>, public ActiveDOMObject, public EventTarget {
@@ -63,9 +64,11 @@
bool checkFont(const String&, const String&);
void loadFont(const Dictionary&);
+ void loadFontDone(const LoadFontCallback&);
+
void notifyWhenFontsReady(PassRefPtr<VoidCallback>);
- bool loading() const { return m_loadingCount > 0; }
+ bool loading() const { return m_numLoadingFromCSS > 0; }
virtual ScriptExecutionContext* scriptExecutionContext() const;
virtual EventTargetInterface eventTargetInterface() const;
@@ -81,6 +84,8 @@
void loadError(CSSFontFaceRule*, CSSFontFaceSource*);
void loadingDone();
+ virtual bool canSuspend() const override { return !m_numLoadingFromCSS && !m_numLoadingFromJS; }
+
private:
FontLoader(Document*);
@@ -95,7 +100,8 @@
Document* m_document;
EventTargetData m_eventTargetData;
- unsigned m_loadingCount;
+ unsigned m_numLoadingFromCSS;
+ unsigned m_numLoadingFromJS;
Vector<RefPtr<Event>> m_pendingEvents;
Vector<RefPtr<VoidCallback>> m_callbacks;
RefPtr<Event> m_loadingDoneEvent;