Changeset 52091 in webkit


Ignore:
Timestamp:
Dec 14, 2009 7:21:41 AM (14 years ago)
Author:
eric@webkit.org
Message:

2009-12-14 Yael Aharon <yael.aharon@nokia.com>

Reviewed by Antti Koivisto.

handling scripts can block UI
https://bugs.webkit.org/show_bug.cgi?id=27612

Break execution of external scrips to smaller chunks.
No new tests since no new functionality was introduced.

  • html/HTMLTokenizer.cpp: (WebCore::HTMLTokenizer::HTMLTokenizer): (WebCore::HTMLTokenizer::reset): (WebCore::HTMLTokenizer::notifyFinished): (WebCore::HTMLTokenizer::executeExternalScriptsIfReady): (WebCore::HTMLTokenizer::executeExternalScriptsTimerFired): (WebCore::HTMLTokenizer::continueExecutingExternalScripts):
  • html/HTMLTokenizer.h:
Location:
trunk/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r52089 r52091  
     12009-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
    1202009-12-03  Holger Hans Peter Freyther  <zecke@selfish.org>
    221
  • trunk/WebCore/html/HTMLTokenizer.cpp

    r50523 r52091  
    168168    , m_hasScriptsWaitingForStylesheets(false)
    169169    , m_timer(this, &HTMLTokenizer::timerFired)
     170    , m_externalScriptsTimer(this, &HTMLTokenizer::executeExternalScriptsTimerFired)
    170171    , m_doc(doc)
    171172    , m_parser(new HTMLParser(doc, reportErrors))
     
    187188    , m_hasScriptsWaitingForStylesheets(false)
    188189    , m_timer(this, &HTMLTokenizer::timerFired)
     190    , m_externalScriptsTimer(this, &HTMLTokenizer::executeExternalScriptsTimerFired)
    189191    , m_doc(doc)
    190192    , m_parser(0)
     
    205207    , m_hasScriptsWaitingForStylesheets(false)
    206208    , m_timer(this, &HTMLTokenizer::timerFired)
     209    , m_externalScriptsTimer(this, &HTMLTokenizer::executeExternalScriptsTimerFired)
    207210    , m_doc(frag->document())
    208211    , m_parser(new HTMLParser(frag))
     
    233236
    234237    m_timer.stop();
     238    m_externalScriptsTimer.stop();
     239
    235240    m_state.setAllowYield(false);
    236241    m_state.setForceSynchronous(false);
     
    20082013void HTMLTokenizer::notifyFinished(CachedResource*)
    20092014{
     2015    executeExternalScriptsIfReady();
     2016}
     2017
     2018void HTMLTokenizer::executeExternalScriptsIfReady()
     2019{
    20102020#ifdef INSTRUMENT_LAYOUT_SCHEDULING
    20112021    if (!m_doc->ownerElement())
     
    20222032
    20232033    bool finished = false;
     2034   
     2035    double startTime = currentTime();
    20242036    while (!finished && m_pendingScripts.first()->isLoaded()) {
     2037        if (!continueExecutingExternalScripts(startTime))
     2038            break;
     2039
    20252040        CachedScript* cs = m_pendingScripts.first().get();
    20262041        m_pendingScripts.removeFirst();
     
    20822097}
    20832098
     2099void 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
     2111bool 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
    20842124bool HTMLTokenizer::isWaitingForScripts() const
    20852125{
  • trunk/WebCore/html/HTMLTokenizer.h

    r45787 r52091  
    205205    // from CachedResourceClient
    206206    void notifyFinished(CachedResource*);
     207
     208    void executeExternalScriptsIfReady();
     209    void executeExternalScriptsTimerFired(Timer<HTMLTokenizer>*);
     210    bool continueExecutingExternalScripts(double startTime);
    207211
    208212    // Internal buffers
     
    402406    Timer<HTMLTokenizer> m_timer;
    403407
     408    // The timer for continued executing external scripts.
     409    Timer<HTMLTokenizer> m_externalScriptsTimer;
     410
    404411// This buffer can hold arbitrarily long user-defined attribute names, such as in EMBED tags.
    405412// 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.