Changeset 52091 in webkit
- Timestamp:
- Dec 14, 2009 7:21:41 AM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r52089 r52091 1 2009-12-14 Yael Aharon <yael.aharon@nokia.com> 2 3 Reviewed by Antti Koivisto. 4 5 handling scripts can block UI 6 https://bugs.webkit.org/show_bug.cgi?id=27612 7 8 Break execution of external scrips to smaller chunks. 9 No new tests since no new functionality was introduced. 10 11 * html/HTMLTokenizer.cpp: 12 (WebCore::HTMLTokenizer::HTMLTokenizer): 13 (WebCore::HTMLTokenizer::reset): 14 (WebCore::HTMLTokenizer::notifyFinished): 15 (WebCore::HTMLTokenizer::executeExternalScriptsIfReady): 16 (WebCore::HTMLTokenizer::executeExternalScriptsTimerFired): 17 (WebCore::HTMLTokenizer::continueExecutingExternalScripts): 18 * html/HTMLTokenizer.h: 19 1 20 2009-12-03 Holger Hans Peter Freyther <zecke@selfish.org> 2 21 -
trunk/WebCore/html/HTMLTokenizer.cpp
r50523 r52091 168 168 , m_hasScriptsWaitingForStylesheets(false) 169 169 , m_timer(this, &HTMLTokenizer::timerFired) 170 , m_externalScriptsTimer(this, &HTMLTokenizer::executeExternalScriptsTimerFired) 170 171 , m_doc(doc) 171 172 , m_parser(new HTMLParser(doc, reportErrors)) … … 187 188 , m_hasScriptsWaitingForStylesheets(false) 188 189 , m_timer(this, &HTMLTokenizer::timerFired) 190 , m_externalScriptsTimer(this, &HTMLTokenizer::executeExternalScriptsTimerFired) 189 191 , m_doc(doc) 190 192 , m_parser(0) … … 205 207 , m_hasScriptsWaitingForStylesheets(false) 206 208 , m_timer(this, &HTMLTokenizer::timerFired) 209 , m_externalScriptsTimer(this, &HTMLTokenizer::executeExternalScriptsTimerFired) 207 210 , m_doc(frag->document()) 208 211 , m_parser(new HTMLParser(frag)) … … 233 236 234 237 m_timer.stop(); 238 m_externalScriptsTimer.stop(); 239 235 240 m_state.setAllowYield(false); 236 241 m_state.setForceSynchronous(false); … … 2008 2013 void HTMLTokenizer::notifyFinished(CachedResource*) 2009 2014 { 2015 executeExternalScriptsIfReady(); 2016 } 2017 2018 void HTMLTokenizer::executeExternalScriptsIfReady() 2019 { 2010 2020 #ifdef INSTRUMENT_LAYOUT_SCHEDULING 2011 2021 if (!m_doc->ownerElement()) … … 2022 2032 2023 2033 bool finished = false; 2034 2035 double startTime = currentTime(); 2024 2036 while (!finished && m_pendingScripts.first()->isLoaded()) { 2037 if (!continueExecutingExternalScripts(startTime)) 2038 break; 2039 2025 2040 CachedScript* cs = m_pendingScripts.first().get(); 2026 2041 m_pendingScripts.removeFirst(); … … 2082 2097 } 2083 2098 2099 void HTMLTokenizer::executeExternalScriptsTimerFired(Timer<HTMLTokenizer>*) 2100 { 2101 if (m_doc->view() && m_doc->view()->layoutPending() && !m_doc->minimumLayoutDelay()) { 2102 // Restart the timer and do layout first. 2103 m_externalScriptsTimer.startOneShot(0); 2104 return; 2105 } 2106 2107 // Continue executing external scripts. 2108 executeExternalScriptsIfReady(); 2109 } 2110 2111 bool HTMLTokenizer::continueExecutingExternalScripts(double startTime) 2112 { 2113 if (m_externalScriptsTimer.isActive()) 2114 return false; 2115 2116 if (currentTime() - startTime > m_tokenizerTimeDelay) { 2117 // Schedule the timer to keep processing as soon as possible. 2118 m_externalScriptsTimer.startOneShot(0); 2119 return false; 2120 } 2121 return true; 2122 } 2123 2084 2124 bool HTMLTokenizer::isWaitingForScripts() const 2085 2125 { -
trunk/WebCore/html/HTMLTokenizer.h
r45787 r52091 205 205 // from CachedResourceClient 206 206 void notifyFinished(CachedResource*); 207 208 void executeExternalScriptsIfReady(); 209 void executeExternalScriptsTimerFired(Timer<HTMLTokenizer>*); 210 bool continueExecutingExternalScripts(double startTime); 207 211 208 212 // Internal buffers … … 402 406 Timer<HTMLTokenizer> m_timer; 403 407 408 // The timer for continued executing external scripts. 409 Timer<HTMLTokenizer> m_externalScriptsTimer; 410 404 411 // This buffer can hold arbitrarily long user-defined attribute names, such as in EMBED tags. 405 412 // So any fixed number might be too small, but rather than rewriting all usage of this buffer
Note: See TracChangeset
for help on using the changeset viewer.