Changeset 56249 in webkit


Ignore:
Timestamp:
Mar 19, 2010 11:25:21 AM (14 years ago)
Author:
beidson@apple.com
Message:

3 of the new HTML5 loading events need to be asynchronous.

Reviewed by Darin Adler.

Laying the groundwork for:
https://bugs.webkit.org/show_bug.cgi?id=36201
https://bugs.webkit.org/show_bug.cgi?id=36202
https://bugs.webkit.org/show_bug.cgi?id=36334
https://bugs.webkit.org/show_bug.cgi?id=36335

Document already had an asynchronous event delivery mechanism for storage events, so
we can repurpose that for all async events.

No new tests. (No change in behavior)

  • dom/Document.cpp:

(WebCore::Document::Document):
(WebCore::Document::implicitClose): Use Document::schedule* for the related events.
(WebCore::Document::enqueueEvent): Renamed from enqueueStorageEvent
(WebCore::Document::pendingEventTimerFired): Renamed from "storageEventTimerFired"
(WebCore::Document::statePopped): Use Document::schedulePopstateEvent
(WebCore::Document::enqueuePageshowEvent): All Pageshow events are piped through here.

This will be made asynchronous in a separate patch.

(WebCore::Document::enqueueHashchangeEvent): All Hashchange events are piped through here.

This will be made asynchronous in a separate patch.

(WebCore::Document::enqueuePopstateEvent): All Popstate events are piped through here.

This will be made asynchronous in a separate patch.

  • dom/Document.h:

(WebCore::):

  • history/CachedFrame.cpp:

(WebCore::CachedFrameBase::restore): Use Document::enqueuePageshowEvent

  • loader/FrameLoader.cpp:

(WebCore::FrameLoader::loadInSameDocument): Use Document::enqueueHashchangeEvent

  • storage/StorageEventDispatcher.cpp:

(WebCore::StorageEventDispatcher::dispatch): Use Document::enqueueEvent

Location:
trunk/WebCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r56246 r56249  
     12010-03-19  Brady Eidson  <beidson@apple.com>
     2
     3        Reviewed by Darin Adler.
     4
     5        3 of the new HTML5 loading events need to be asynchronous.
     6
     7        Laying the groundwork for:
     8        https://bugs.webkit.org/show_bug.cgi?id=36201
     9        https://bugs.webkit.org/show_bug.cgi?id=36202
     10        https://bugs.webkit.org/show_bug.cgi?id=36334
     11        https://bugs.webkit.org/show_bug.cgi?id=36335
     12
     13        Document already had an asynchronous event delivery mechanism for storage events, so
     14        we can repurpose that for all async events.
     15
     16        No new tests. (No change in behavior)
     17
     18        * dom/Document.cpp:
     19        (WebCore::Document::Document):
     20        (WebCore::Document::implicitClose): Use Document::schedule* for the related events.
     21        (WebCore::Document::enqueueEvent): Renamed from enqueueStorageEvent
     22        (WebCore::Document::pendingEventTimerFired): Renamed from "storageEventTimerFired"
     23        (WebCore::Document::statePopped): Use Document::schedulePopstateEvent
     24        (WebCore::Document::enqueuePageshowEvent): All Pageshow events are piped through here.
     25          This will be made asynchronous in a separate patch.
     26        (WebCore::Document::enqueueHashchangeEvent): All Hashchange events are piped through here.
     27          This will be made asynchronous in a separate patch.
     28        (WebCore::Document::enqueuePopstateEvent): All Popstate events are piped through here.
     29          This will be made asynchronous in a separate patch.
     30        * dom/Document.h:
     31        (WebCore::):
     32
     33        * history/CachedFrame.cpp:
     34        (WebCore::CachedFrameBase::restore): Use Document::enqueuePageshowEvent
     35
     36        * loader/FrameLoader.cpp:
     37        (WebCore::FrameLoader::loadInSameDocument): Use Document::enqueueHashchangeEvent
     38
     39        * storage/StorageEventDispatcher.cpp:
     40        (WebCore::StorageEventDispatcher::dispatch): Use Document::enqueueEvent
     41
    1422010-03-19  Kevin Decker  <kdecker@apple.com>
    243
  • trunk/WebCore/dom/Document.cpp

    r56046 r56249  
    391391#endif
    392392    , m_usingGeolocation(false)
    393     , m_storageEventTimer(this, &Document::storageEventTimerFired)
     393    , m_pendingEventTimer(this, &Document::pendingEventTimerFired)
    394394#if ENABLE(WML)
    395395    , m_containsWMLContent(false)
     
    18211821    ImageLoader::dispatchPendingLoadEvents();
    18221822    dispatchWindowLoadEvent();
    1823     dispatchWindowEvent(PageTransitionEvent::create(eventNames().pageshowEvent, false), this);
     1823    enqueuePageshowEvent(PageshowEventNotPersisted);
    18241824    if (m_pendingStateObject)
    1825         dispatchWindowEvent(PopStateEvent::create(m_pendingStateObject.release()));
     1825        enqueuePopstateEvent(m_pendingStateObject.release());
    18261826   
    18271827    if (f)
     
    29942994}
    29952995
    2996 void Document::enqueueStorageEvent(PassRefPtr<Event> storageEvent)
    2997 {
    2998     m_storageEventQueue.append(storageEvent);
    2999     if (!m_storageEventTimer.isActive())
    3000         m_storageEventTimer.startOneShot(0);
    3001 }
    3002 
    3003 void Document::storageEventTimerFired(Timer<Document>*)
    3004 {
    3005     ASSERT(!m_storageEventTimer.isActive());
    3006     Vector<RefPtr<Event> > storageEventQueue;
    3007     storageEventQueue.swap(m_storageEventQueue);
     2996void Document::enqueueEvent(PassRefPtr<Event> event)
     2997{
     2998    m_pendingEventQueue.append(event);
     2999    if (!m_pendingEventTimer.isActive())
     3000        m_pendingEventTimer.startOneShot(0);
     3001}
     3002
     3003void Document::pendingEventTimerFired(Timer<Document>*)
     3004{
     3005    ASSERT(!m_pendingEventTimer.isActive());
     3006    Vector<RefPtr<Event> > eventQueue;
     3007    eventQueue.swap(m_pendingEventQueue);
    30083008
    30093009    typedef Vector<RefPtr<Event> >::const_iterator Iterator;
    3010     Iterator end = storageEventQueue.end();
    3011     for (Iterator it = storageEventQueue.begin(); it != end; ++it)
     3010    Iterator end = eventQueue.end();
     3011    for (Iterator it = eventQueue.begin(); it != end; ++it)
    30123012        dispatchWindowEvent(*it);
    30133013}
     
    45024502   
    45034503    if (f->loader()->isComplete())
    4504         dispatchWindowEvent(PopStateEvent::create(stateObject));
     4504        enqueuePopstateEvent(stateObject);
    45054505    else
    45064506        m_pendingStateObject = stateObject;
     
    47584758}
    47594759
     4760void Document::enqueuePageshowEvent(PageshowEventPersistence persisted)
     4761{
     4762    // FIXME: https://bugs.webkit.org/show_bug.cgi?id=36334 Pageshow event needs to fire asynchronously.
     4763    dispatchWindowEvent(PageTransitionEvent::create(eventNames().pageshowEvent, persisted), this);
     4764}
     4765
     4766void Document::enqueueHashchangeEvent(const String& /*oldURL*/, const String& /*newURL*/)
     4767{
     4768    // FIXME: https://bugs.webkit.org/show_bug.cgi?id=36201 Hashchange event needs to fire asynchronously.
     4769    // FIXME: https://bugs.webkit.org/show_bug.cgi?id=36335 Hashchange event is now its own interface and takes two
     4770    //   URL arguments which we need to pass in here.
     4771    dispatchWindowEvent(Event::create(eventNames().hashchangeEvent, false, false));
     4772}
     4773
     4774void Document::enqueuePopstateEvent(PassRefPtr<SerializedScriptValue> stateObject)
     4775{
     4776    // FIXME: https://bugs.webkit.org/show_bug.cgi?id=36202 Popstate event needs to fire asynchronously
     4777    dispatchWindowEvent(PopStateEvent::create(stateObject));
     4778}
     4779
    47604780#if ENABLE(XHTMLMP)
    47614781bool Document::isXHTMLMPDocument() const
  • trunk/WebCore/dom/Document.h

    r55771 r56249  
    176176};
    177177
     178enum PageshowEventPersistence {
     179    PageshowEventNotPersisted = 0,
     180    PageshowEventPersisted = 1
     181};
     182   
    178183class Document : public ContainerNode, public ScriptExecutionContext {
    179184public:
     
    628633    void dispatchWindowLoadEvent();
    629634
    630     void enqueueStorageEvent(PassRefPtr<Event>);
    631     void storageEventTimerFired(Timer<Document>*);
    632 
    633635    PassRefPtr<Event> createEvent(const String& eventType, ExceptionCode&);
    634636
     
    961963    void setContainsValidityStyleRules() { m_containsValidityStyleRules = true; }
    962964
     965    void enqueueEvent(PassRefPtr<Event>);
     966    void enqueuePageshowEvent(PageshowEventPersistence);
     967    void enqueueHashchangeEvent(const String& oldURL, const String& newURL);
     968
    963969protected:
    964970    Document(Frame*, bool isXHTML, bool isHTML);
     
    9981004
    9991005    void createStyleSelector();
     1006
     1007    void enqueuePopstateEvent(PassRefPtr<SerializedScriptValue> stateObject);
     1008    void pendingEventTimerFired(Timer<Document>*);
    10001009
    10011010    OwnPtr<CSSStyleSelector> m_styleSelector;
     
    12161225    bool m_usingGeolocation;
    12171226
    1218     Timer<Document> m_storageEventTimer;
    1219     Vector<RefPtr<Event> > m_storageEventQueue;
     1227    Timer<Document> m_pendingEventTimer;
     1228    Vector<RefPtr<Event> > m_pendingEventQueue;
    12201229
    12211230#if ENABLE(WML)
  • trunk/WebCore/history/CachedFrame.cpp

    r54069 r56249  
    106106        m_childFrames[i]->open();
    107107
    108     m_document->dispatchWindowEvent(PageTransitionEvent::create(eventNames().pageshowEvent, true), m_document);
     108    m_document->enqueuePageshowEvent(PageshowEventPersisted);
    109109#if ENABLE(TOUCH_EVENTS)
    110110    if (m_document->hasListenerType(Document::TOUCH_LISTENER))
  • trunk/WebCore/loader/FrameLoader.cpp

    r56246 r56249  
    17441744    }
    17451745   
     1746    String oldURL;
    17461747    bool hashChange = equalIgnoringFragmentIdentifier(url, m_URL) && url.fragmentIdentifier() != m_URL.fragmentIdentifier();
     1748    oldURL = m_URL;
     1749   
    17471750    m_URL = url;
    17481751    history()->updateForSameDocumentNavigation();
     
    17791782   
    17801783    if (hashChange) {
    1781         m_frame->document()->dispatchWindowEvent(Event::create(eventNames().hashchangeEvent, false, false));
     1784        m_frame->document()->enqueueHashchangeEvent(oldURL, m_URL);
    17821785        m_client->dispatchDidChangeLocationWithinPage();
    17831786    }
  • trunk/WebCore/storage/StorageEventDispatcher.cpp

    r56002 r56249  
    5656
    5757        for (unsigned i = 0; i < frames.size(); ++i)
    58             frames[i]->document()->enqueueStorageEvent(StorageEvent::create(eventNames().storageEvent, key, oldValue, newValue, sourceFrame->document()->url(), frames[i]->domWindow()->sessionStorage()));
     58            frames[i]->document()->enqueueEvent(StorageEvent::create(eventNames().storageEvent, key, oldValue, newValue, sourceFrame->document()->url(), frames[i]->domWindow()->sessionStorage()));
    5959    } else {
    6060        // Send events to every page.
     
    7272            Storage* storage = frames[i]->domWindow()->localStorage(ec);
    7373            if (!ec)
    74                 frames[i]->document()->enqueueStorageEvent(StorageEvent::create(eventNames().storageEvent, key, oldValue, newValue, sourceFrame->document()->url(), storage));
     74                frames[i]->document()->enqueueEvent(StorageEvent::create(eventNames().storageEvent, key, oldValue, newValue, sourceFrame->document()->url(), storage));
    7575        }
    7676    }
Note: See TracChangeset for help on using the changeset viewer.