Changeset 176453 in webkit
- Timestamp:
- Nov 21, 2014, 10:43:21 AM (10 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r176447 r176453 1 2014-11-21 Bear Travis <betravis@gmail.com> 2 3 [CSS Font Loading] Switch to dispatching events asynchronously 4 https://bugs.webkit.org/show_bug.cgi?id=138755 5 6 Reviewed by Simon Fraser. 7 8 Refactoring tests to check for all events only after the FontLoader 9 itself has completed. Tests were previously checking after a specific font 10 had loaded, at which point some of the events may have yet to fire. 11 12 * fast/css/fontloader-multiple-faces-download-error-expected.txt: 13 * fast/css/fontloader-multiple-faces-download-error.html: 14 * fast/css/fontloader-multiple-faces-expected.txt: 15 * fast/css/fontloader-multiple-faces.html: 16 * fast/css/fontloader-multiple-families-expected.txt: 17 * fast/css/fontloader-multiple-families.html: 18 * fast/css/fontloader-svg-select-expected.txt: Added 19 * fast/css/fontloader-svg-select.svg: Added 20 1 21 2014-11-21 Chris Fleizach <cfleizach@apple.com> 2 22 -
trunk/LayoutTests/fast/css/fontloader-multiple-faces-download-error-expected.txt
r171886 r176453 8 8 PASS events['load'] is 1 9 9 PASS events['error'] is 1 10 PASS events['loadingdone'] is undefined10 PASS events['loadingdone'] is 1 11 11 PASS document.fonts.checkFont('10px TestFont') is false 12 PASS events['loadingdone'] is 113 12 PASS successfullyParsed is true 14 13 -
trunk/LayoutTests/fast/css/fontloader-multiple-faces-download-error.html
r171886 r176453 44 44 45 45 function onerror() { 46 } 47 48 function verify() { 46 49 shouldBe("events['loading']", "1"); 47 50 shouldBe("events['loadstart']", "2"); 48 51 shouldBe("events['load']", "1"); 49 52 shouldBe("events['error']", "1"); 50 shouldBe("events['loadingdone']", " undefined");53 shouldBe("events['loadingdone']", "1"); 51 54 shouldBe("document.fonts.checkFont('10px TestFont')", "false"); 52 }53 54 function verify() {55 shouldBe("events['loadingdone']", "1");56 55 finishJSTest(); 57 56 } -
trunk/LayoutTests/fast/css/fontloader-multiple-faces-expected.txt
r171886 r176453 8 8 PASS events['load'] is 2 9 9 PASS events['error'] is undefined 10 PASS events['loadingdone'] is undefined10 PASS events['loadingdone'] is 1 11 11 PASS document.fonts.checkFont('10px TestFont') is true 12 PASS events['loadingdone'] is 113 12 PASS successfullyParsed is true 14 13 -
trunk/LayoutTests/fast/css/fontloader-multiple-faces.html
r171886 r176453 39 39 40 40 function onsuccess() { 41 shouldBe("events['loading']", "1");42 shouldBe("events['loadstart']", "2");43 shouldBe("events['load']", "2");44 shouldBe("events['error']", "undefined");45 shouldBe("events['loadingdone']", "undefined");46 shouldBe("document.fonts.checkFont('10px TestFont')", "true");47 41 } 48 42 … … 53 47 54 48 function verify() { 49 shouldBe("events['loading']", "1"); 50 shouldBe("events['loadstart']", "2"); 51 shouldBe("events['load']", "2"); 52 shouldBe("events['error']", "undefined"); 55 53 shouldBe("events['loadingdone']", "1"); 54 shouldBe("document.fonts.checkFont('10px TestFont')", "true"); 56 55 finishJSTest(); 57 56 } -
trunk/LayoutTests/fast/css/fontloader-multiple-families-expected.txt
r171886 r176453 8 8 PASS events['load'] is 2 9 9 PASS events['error'] is undefined 10 PASS events['loadingdone'] is undefined10 PASS events['loadingdone'] is 1 11 11 PASS document.fonts.checkFont('10px TestFont1, TestFont2') is true 12 PASS events['loadingdone'] is 113 12 PASS successfullyParsed is true 14 13 -
trunk/LayoutTests/fast/css/fontloader-multiple-families.html
r171886 r176453 39 39 40 40 function onsuccess() { 41 shouldBe("events['loading']", "1");42 shouldBe("events['loadstart']", "2");43 shouldBe("events['load']", "2");44 shouldBe("events['error']", "undefined");45 shouldBe("events['loadingdone']", "undefined");46 shouldBe("document.fonts.checkFont('10px TestFont1, TestFont2')", "true");47 41 } 48 42 … … 52 46 53 47 function verify() { 48 shouldBe("events['loading']", "1"); 49 shouldBe("events['loadstart']", "2"); 50 shouldBe("events['load']", "2"); 51 shouldBe("events['error']", "undefined"); 54 52 shouldBe("events['loadingdone']", "1"); 53 shouldBe("document.fonts.checkFont('10px TestFont1, TestFont2')", "true"); 55 54 finishJSTest(); 56 55 } -
trunk/Source/WebCore/ChangeLog
r176451 r176453 1 2014-11-21 Bear Travis <betravis@gmail.com> 2 3 [CSS Font Loading] Switch to dispatching events asynchronously 4 https://bugs.webkit.org/show_bug.cgi?id=138755 5 6 Reviewed by Simon Fraser. 7 8 Moving FontLoader to dispatch events and notify callbacks similarly 9 to EventSender or the GenericEventQueue. Several bugs have popped 10 up in the past because FontLoader has been sending events during 11 layout, and there is no need for that to be the case. 12 13 Covered by existing font loader event tests. Added an additional 14 test for the svg case, fontloader-svg-select. 15 16 * css/FontLoader.cpp: 17 (WebCore::FontLoader::didLayout): 18 (WebCore::FontLoader::timerFired): Adding asynchronous callback. 19 (WebCore::FontLoader::scheduleEvent): Add an event to the dispatch 20 queue. 21 (WebCore::FontLoader::firePendingEvents): Modified to handle the 22 loading done event and callbacks. 23 (WebCore::FontLoader::loadingDone): Modified to spin up the timer 24 rather than immediately dispatching events. 25 * css/FontLoader.h: 26 1 27 2014-11-21 Daniel Bates <dabates@apple.com> 2 28 -
trunk/Source/WebCore/css/FontLoader.cpp
r174515 r176453 123 123 , m_numLoadingFromCSS(0) 124 124 , m_numLoadingFromJS(0) 125 , m_pendingEventsTimer(this, &FontLoader::pendingEventsTimerFired) 125 126 { 126 127 suspendIfNeeded(); … … 153 154 void FontLoader::didLayout() 154 155 { 155 firePendingEvents();156 156 loadingDone(); 157 157 } … … 159 159 void FontLoader::scheduleEvent(PassRefPtr<Event> event) 160 160 { 161 if (FrameView* view = m_document->view()) { 162 if (view->isInLayout()) { 163 m_pendingEvents.append(event); 164 return; 165 } 166 } 167 firePendingEvents(); 168 dispatchEvent(event); 161 m_pendingEvents.append(event); 162 if (!m_pendingEventsTimer.isActive()) 163 m_pendingEventsTimer.startOneShot(0); 169 164 } 170 165 171 166 void FontLoader::firePendingEvents() 172 167 { 173 if (m_pendingEvents.isEmpty() )174 return; 175 176 Vector<RefPtr<Event> 168 if (m_pendingEvents.isEmpty() && !m_loadingDoneEvent && !m_callbacks.isEmpty()) 169 return; 170 171 Vector<RefPtr<Event>> pendingEvents; 177 172 m_pendingEvents.swap(pendingEvents); 173 174 bool loadingDone = false; 175 if (m_loadingDoneEvent) { 176 pendingEvents.append(m_loadingDoneEvent.release()); 177 loadingDone = true; 178 } 179 178 180 for (size_t index = 0; index < pendingEvents.size(); ++index) 179 181 dispatchEvent(pendingEvents[index].release()); 182 183 if (loadingDone && !m_callbacks.isEmpty()) { 184 Vector<RefPtr<VoidCallback>> callbacks; 185 m_callbacks.swap(callbacks); 186 for (size_t index = 0; index < callbacks.size(); ++index) 187 callbacks[index]->handleEvent(); 188 } 180 189 } 181 190 … … 219 228 if (loading() || !m_document->haveStylesheetsLoaded()) 220 229 return; 221 if (!m_loadingDoneEvent && m_callbacks.isEmpty() )230 if (!m_loadingDoneEvent && m_callbacks.isEmpty() && m_pendingEvents.isEmpty()) 222 231 return; 223 232 … … 227 236 } 228 237 229 if (m_loadingDoneEvent) 230 dispatchEvent(m_loadingDoneEvent.release()); 231 232 if (!m_callbacks.isEmpty()) { 233 Vector<RefPtr<VoidCallback> > callbacks; 234 m_callbacks.swap(callbacks); 235 for (size_t index = 0; index < callbacks.size(); ++index) 236 callbacks[index]->handleEvent(); 237 } 238 if (!m_pendingEventsTimer.isActive()) 239 m_pendingEventsTimer.startOneShot(0); 238 240 } 239 241 -
trunk/Source/WebCore/css/FontLoader.h
r175391 r176453 32 32 #include "EventListener.h" 33 33 #include "EventTarget.h" 34 #include "Timer.h" 34 35 #include "VoidCallback.h" 35 36 #include <wtf/PassRefPtr.h> … … 95 96 virtual EventTargetData& ensureEventTargetData() override; 96 97 98 void pendingEventsTimerFired(Timer&) { firePendingEvents(); } 97 99 void scheduleEvent(PassRefPtr<Event>); 98 100 void firePendingEvents(); … … 106 108 Vector<RefPtr<VoidCallback>> m_callbacks; 107 109 RefPtr<Event> m_loadingDoneEvent; 110 Timer m_pendingEventsTimer; 108 111 }; 109 112
Note:
See TracChangeset
for help on using the changeset viewer.