Diff
Modified: trunk/LayoutTests/ChangeLog (176452 => 176453)
--- trunk/LayoutTests/ChangeLog 2014-11-21 17:40:50 UTC (rev 176452)
+++ trunk/LayoutTests/ChangeLog 2014-11-21 18:43:21 UTC (rev 176453)
@@ -1,3 +1,23 @@
+2014-11-21 Bear Travis <betra...@gmail.com>
+
+ [CSS Font Loading] Switch to dispatching events asynchronously
+ https://bugs.webkit.org/show_bug.cgi?id=138755
+
+ Reviewed by Simon Fraser.
+
+ Refactoring tests to check for all events only after the FontLoader
+ itself has completed. Tests were previously checking after a specific font
+ had loaded, at which point some of the events may have yet to fire.
+
+ * fast/css/fontloader-multiple-faces-download-error-expected.txt:
+ * fast/css/fontloader-multiple-faces-download-error.html:
+ * fast/css/fontloader-multiple-faces-expected.txt:
+ * fast/css/fontloader-multiple-faces.html:
+ * fast/css/fontloader-multiple-families-expected.txt:
+ * fast/css/fontloader-multiple-families.html:
+ * fast/css/fontloader-svg-select-expected.txt: Added
+ * fast/css/fontloader-svg-select.svg: Added
+
2014-11-21 Chris Fleizach <cfleiz...@apple.com>
AX: MathML expressions are misread by VoiceOver
Modified: trunk/LayoutTests/fast/css/fontloader-multiple-faces-download-error-expected.txt (176452 => 176453)
--- trunk/LayoutTests/fast/css/fontloader-multiple-faces-download-error-expected.txt 2014-11-21 17:40:50 UTC (rev 176452)
+++ trunk/LayoutTests/fast/css/fontloader-multiple-faces-download-error-expected.txt 2014-11-21 18:43:21 UTC (rev 176453)
@@ -7,9 +7,8 @@
PASS events['loadstart'] is 2
PASS events['load'] is 1
PASS events['error'] is 1
-PASS events['loadingdone'] is undefined
-PASS document.fonts.checkFont('10px TestFont') is false
PASS events['loadingdone'] is 1
+PASS document.fonts.checkFont('10px TestFont') is false
PASS successfullyParsed is true
TEST COMPLETE
Modified: trunk/LayoutTests/fast/css/fontloader-multiple-faces-download-error.html (176452 => 176453)
--- trunk/LayoutTests/fast/css/fontloader-multiple-faces-download-error.html 2014-11-21 17:40:50 UTC (rev 176452)
+++ trunk/LayoutTests/fast/css/fontloader-multiple-faces-download-error.html 2014-11-21 18:43:21 UTC (rev 176453)
@@ -43,16 +43,15 @@
}
function onerror() {
+}
+
+function verify() {
shouldBe("events['loading']", "1");
shouldBe("events['loadstart']", "2");
shouldBe("events['load']", "1");
shouldBe("events['error']", "1");
- shouldBe("events['loadingdone']", "undefined");
- shouldBe("document.fonts.checkFont('10px TestFont')", "false");
-}
-
-function verify() {
shouldBe("events['loadingdone']", "1");
+ shouldBe("document.fonts.checkFont('10px TestFont')", "false");
finishJSTest();
}
Modified: trunk/LayoutTests/fast/css/fontloader-multiple-faces-expected.txt (176452 => 176453)
--- trunk/LayoutTests/fast/css/fontloader-multiple-faces-expected.txt 2014-11-21 17:40:50 UTC (rev 176452)
+++ trunk/LayoutTests/fast/css/fontloader-multiple-faces-expected.txt 2014-11-21 18:43:21 UTC (rev 176453)
@@ -7,9 +7,8 @@
PASS events['loadstart'] is 2
PASS events['load'] is 2
PASS events['error'] is undefined
-PASS events['loadingdone'] is undefined
-PASS document.fonts.checkFont('10px TestFont') is true
PASS events['loadingdone'] is 1
+PASS document.fonts.checkFont('10px TestFont') is true
PASS successfullyParsed is true
TEST COMPLETE
Modified: trunk/LayoutTests/fast/css/fontloader-multiple-faces.html (176452 => 176453)
--- trunk/LayoutTests/fast/css/fontloader-multiple-faces.html 2014-11-21 17:40:50 UTC (rev 176452)
+++ trunk/LayoutTests/fast/css/fontloader-multiple-faces.html 2014-11-21 18:43:21 UTC (rev 176453)
@@ -38,12 +38,6 @@
}
function onsuccess() {
- shouldBe("events['loading']", "1");
- shouldBe("events['loadstart']", "2");
- shouldBe("events['load']", "2");
- shouldBe("events['error']", "undefined");
- shouldBe("events['loadingdone']", "undefined");
- shouldBe("document.fonts.checkFont('10px TestFont')", "true");
}
function onerror() {
@@ -52,7 +46,12 @@
}
function verify() {
+ shouldBe("events['loading']", "1");
+ shouldBe("events['loadstart']", "2");
+ shouldBe("events['load']", "2");
+ shouldBe("events['error']", "undefined");
shouldBe("events['loadingdone']", "1");
+ shouldBe("document.fonts.checkFont('10px TestFont')", "true");
finishJSTest();
}
Modified: trunk/LayoutTests/fast/css/fontloader-multiple-families-expected.txt (176452 => 176453)
--- trunk/LayoutTests/fast/css/fontloader-multiple-families-expected.txt 2014-11-21 17:40:50 UTC (rev 176452)
+++ trunk/LayoutTests/fast/css/fontloader-multiple-families-expected.txt 2014-11-21 18:43:21 UTC (rev 176453)
@@ -7,9 +7,8 @@
PASS events['loadstart'] is 2
PASS events['load'] is 2
PASS events['error'] is undefined
-PASS events['loadingdone'] is undefined
-PASS document.fonts.checkFont('10px TestFont1, TestFont2') is true
PASS events['loadingdone'] is 1
+PASS document.fonts.checkFont('10px TestFont1, TestFont2') is true
PASS successfullyParsed is true
TEST COMPLETE
Modified: trunk/LayoutTests/fast/css/fontloader-multiple-families.html (176452 => 176453)
--- trunk/LayoutTests/fast/css/fontloader-multiple-families.html 2014-11-21 17:40:50 UTC (rev 176452)
+++ trunk/LayoutTests/fast/css/fontloader-multiple-families.html 2014-11-21 18:43:21 UTC (rev 176453)
@@ -38,12 +38,6 @@
}
function onsuccess() {
- shouldBe("events['loading']", "1");
- shouldBe("events['loadstart']", "2");
- shouldBe("events['load']", "2");
- shouldBe("events['error']", "undefined");
- shouldBe("events['loadingdone']", "undefined");
- shouldBe("document.fonts.checkFont('10px TestFont1, TestFont2')", "true");
}
function onerror() {
@@ -51,7 +45,12 @@
}
function verify() {
+ shouldBe("events['loading']", "1");
+ shouldBe("events['loadstart']", "2");
+ shouldBe("events['load']", "2");
+ shouldBe("events['error']", "undefined");
shouldBe("events['loadingdone']", "1");
+ shouldBe("document.fonts.checkFont('10px TestFont1, TestFont2')", "true");
finishJSTest();
}
Added: trunk/LayoutTests/fast/css/fontloader-svg-select-expected.txt (0 => 176453)
--- trunk/LayoutTests/fast/css/fontloader-svg-select-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/css/fontloader-svg-select-expected.txt 2014-11-21 18:43:21 UTC (rev 176453)
@@ -0,0 +1,3 @@
+abc
+--
+$
Added: trunk/LayoutTests/fast/css/fontloader-svg-select.svg (0 => 176453)
--- trunk/LayoutTests/fast/css/fontloader-svg-select.svg (rev 0)
+++ trunk/LayoutTests/fast/css/fontloader-svg-select.svg 2014-11-21 18:43:21 UTC (rev 176453)
@@ -0,0 +1,41 @@
+<svg viewBox="0 0 480 360" xmlns="http://www.w3.org/2000/svg"
+ xmlns:xlink="http://www.w3.org/1999/xlink" _onload_="doSelection(0,0);">
+ <g id="test-body-content">
+ <defs>
+ <script xlink:href=""
+ <script>
+ description('Test that the event handlers do not run during layout of SVG.');
+ window.jsTestIsAsync = true;
+
+ var startIndex = 0;
+ var numChars = 9;
+ function doSelection(indexDelta, numCharsDelta)
+ {
+ document.getElementById('text').selectSubString(startIndex+indexDelta, numChars+numCharsDelta);
+ finishJSTest();
+ }
+ </script>
+ </defs>
+ <g transform="translate(0,60)">
+ <text id="text" font-size="48" y="128" x="10">
+ abc
+ </text>
+ <g id="buttons">
+ <text x="390" y="175" text-anchor="middle" font-size="16">--</text>
+ </g>
+ </g>
+ </g>
+ <text id="revision" x="10" y="340" font-size="40" stroke="none" fill="black">$</text>
+ <script>
+ document.execCommand("SelectAll");
+ var x = document.fonts;
+ x._onloading_ = doSelection;
+ </script>
+ <style><![CDATA[
+ @font-face {
+ font-family: 'times';
+ src: local('Lucida Grande');
+ }
+ ]]></style>
+ <script xlink:href=""
+</svg>
Modified: trunk/Source/WebCore/ChangeLog (176452 => 176453)
--- trunk/Source/WebCore/ChangeLog 2014-11-21 17:40:50 UTC (rev 176452)
+++ trunk/Source/WebCore/ChangeLog 2014-11-21 18:43:21 UTC (rev 176453)
@@ -1,3 +1,29 @@
+2014-11-21 Bear Travis <betra...@gmail.com>
+
+ [CSS Font Loading] Switch to dispatching events asynchronously
+ https://bugs.webkit.org/show_bug.cgi?id=138755
+
+ Reviewed by Simon Fraser.
+
+ Moving FontLoader to dispatch events and notify callbacks similarly
+ to EventSender or the GenericEventQueue. Several bugs have popped
+ up in the past because FontLoader has been sending events during
+ layout, and there is no need for that to be the case.
+
+ Covered by existing font loader event tests. Added an additional
+ test for the svg case, fontloader-svg-select.
+
+ * css/FontLoader.cpp:
+ (WebCore::FontLoader::didLayout):
+ (WebCore::FontLoader::timerFired): Adding asynchronous callback.
+ (WebCore::FontLoader::scheduleEvent): Add an event to the dispatch
+ queue.
+ (WebCore::FontLoader::firePendingEvents): Modified to handle the
+ loading done event and callbacks.
+ (WebCore::FontLoader::loadingDone): Modified to spin up the timer
+ rather than immediately dispatching events.
+ * css/FontLoader.h:
+
2014-11-21 Daniel Bates <daba...@apple.com>
Attempt to fix the internal Apple Mavericks build after <https://trac.webkit.org/changeset/176448>
Modified: trunk/Source/WebCore/css/FontLoader.cpp (176452 => 176453)
--- trunk/Source/WebCore/css/FontLoader.cpp 2014-11-21 17:40:50 UTC (rev 176452)
+++ trunk/Source/WebCore/css/FontLoader.cpp 2014-11-21 18:43:21 UTC (rev 176453)
@@ -122,6 +122,7 @@
, m_document(document)
, m_numLoadingFromCSS(0)
, m_numLoadingFromJS(0)
+ , m_pendingEventsTimer(this, &FontLoader::pendingEventsTimerFired)
{
suspendIfNeeded();
}
@@ -152,31 +153,39 @@
void FontLoader::didLayout()
{
- firePendingEvents();
loadingDone();
}
void FontLoader::scheduleEvent(PassRefPtr<Event> event)
{
- if (FrameView* view = m_document->view()) {
- if (view->isInLayout()) {
- m_pendingEvents.append(event);
- return;
- }
- }
- firePendingEvents();
- dispatchEvent(event);
+ m_pendingEvents.append(event);
+ if (!m_pendingEventsTimer.isActive())
+ m_pendingEventsTimer.startOneShot(0);
}
void FontLoader::firePendingEvents()
{
- if (m_pendingEvents.isEmpty())
+ if (m_pendingEvents.isEmpty() && !m_loadingDoneEvent && !m_callbacks.isEmpty())
return;
- Vector<RefPtr<Event> > pendingEvents;
+ Vector<RefPtr<Event>> pendingEvents;
m_pendingEvents.swap(pendingEvents);
+
+ bool loadingDone = false;
+ if (m_loadingDoneEvent) {
+ pendingEvents.append(m_loadingDoneEvent.release());
+ loadingDone = true;
+ }
+
for (size_t index = 0; index < pendingEvents.size(); ++index)
dispatchEvent(pendingEvents[index].release());
+
+ if (loadingDone && !m_callbacks.isEmpty()) {
+ Vector<RefPtr<VoidCallback>> callbacks;
+ m_callbacks.swap(callbacks);
+ for (size_t index = 0; index < callbacks.size(); ++index)
+ callbacks[index]->handleEvent();
+ }
}
void FontLoader::beginFontLoading(CSSFontFaceRule* rule)
@@ -218,7 +227,7 @@
{
if (loading() || !m_document->haveStylesheetsLoaded())
return;
- if (!m_loadingDoneEvent && m_callbacks.isEmpty())
+ if (!m_loadingDoneEvent && m_callbacks.isEmpty() && m_pendingEvents.isEmpty())
return;
if (FrameView* view = m_document->view()) {
@@ -226,15 +235,8 @@
return;
}
- if (m_loadingDoneEvent)
- dispatchEvent(m_loadingDoneEvent.release());
-
- if (!m_callbacks.isEmpty()) {
- Vector<RefPtr<VoidCallback> > callbacks;
- m_callbacks.swap(callbacks);
- for (size_t index = 0; index < callbacks.size(); ++index)
- callbacks[index]->handleEvent();
- }
+ if (!m_pendingEventsTimer.isActive())
+ m_pendingEventsTimer.startOneShot(0);
}
void FontLoader::loadFont(const Dictionary& params)
Modified: trunk/Source/WebCore/css/FontLoader.h (176452 => 176453)
--- trunk/Source/WebCore/css/FontLoader.h 2014-11-21 17:40:50 UTC (rev 176452)
+++ trunk/Source/WebCore/css/FontLoader.h 2014-11-21 18:43:21 UTC (rev 176453)
@@ -31,6 +31,7 @@
#include "ActiveDOMObject.h"
#include "EventListener.h"
#include "EventTarget.h"
+#include "Timer.h"
#include "VoidCallback.h"
#include <wtf/PassRefPtr.h>
#include <wtf/RefCounted.h>
@@ -94,6 +95,7 @@
virtual EventTargetData* eventTargetData() override;
virtual EventTargetData& ensureEventTargetData() override;
+ void pendingEventsTimerFired(Timer&) { firePendingEvents(); }
void scheduleEvent(PassRefPtr<Event>);
void firePendingEvents();
bool resolveFontStyle(const String&, Font&);
@@ -105,6 +107,7 @@
Vector<RefPtr<Event>> m_pendingEvents;
Vector<RefPtr<VoidCallback>> m_callbacks;
RefPtr<Event> m_loadingDoneEvent;
+ Timer m_pendingEventsTimer;
};
} // namespace WebCore