Commit b042a70b authored by mihaip@chromium.org's avatar mihaip@chromium.org

2010-12-14 Mihai Parparita <mihaip@chromium.org>

        Reviewed by Dimitri Glazkov.

        Move asynchronous event dispatching out of Document
        https://bugs.webkit.org/show_bug.cgi?id=49785

        Move asynchonous event code out of Document and into a standalone
        EventQueue class (which supports async events for both regular nodes
        and the window object).

        No new tests necessary, since no new functionality is exposed (existing
        layout tests pass).

        * Android.mk:
        * CMakeLists.txt:
        * GNUmakefile.am:
        * WebCore.gypi:
        * WebCore.pro:
        * WebCore.vcproj/WebCore.vcproj:
        * WebCore.xcodeproj/project.pbxproj:
        * dom/Document.cpp:
        (WebCore::Document::Document):
        (WebCore::Document::enqueueWindowEvent):
        (WebCore::Document::enqueueHashchangeEvent):
        * dom/DOMAllInOne.cpp:
        (WebCore::Document::eventQueue):
        * dom/Document.h:
        * dom/EventQueue.cpp: Added.
        (WebCore::EventQueue::EventQueue):
        (WebCore::EventQueue::enqueueEvent):
        (WebCore::EventQueue::pendingEventTimerFired):
        (WebCore::EventQueue::dispatchEvent):
        * dom/EventQueue.h: Added.
        * storage/StorageEventDispatcher.cpp:
        (WebCore::StorageEventDispatcher::dispatch):
2010-12-14  Mihai Parparita  <mihaip@chromium.org>

        Reviewed by Dimitri Glazkov.

        Move asynchronous event dispatching out of Document
        https://bugs.webkit.org/show_bug.cgi?id=49785

        Change enqueueEvent callsite.

        * src/StorageAreaProxy.cpp:
        (WebCore::StorageAreaProxy::storageEvent):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@74062 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 022531bd
......@@ -132,6 +132,7 @@ LOCAL_SRC_FILES := $(LOCAL_SRC_FILES) \
dom/EventContext.cpp \
dom/EventNames.cpp \
dom/EventTarget.cpp \
dom/EventQueue.cpp \
dom/ExceptionBase.cpp \
dom/ExceptionCode.cpp \
dom/InputElement.cpp \
......
......@@ -852,6 +852,7 @@ SET(WebCore_SOURCES
dom/EventContext.cpp
dom/EventNames.cpp
dom/EventTarget.cpp
dom/EventQueue.cpp
dom/ExceptionBase.cpp
dom/ExceptionCode.cpp
dom/InputElement.cpp
......
2010-12-14 Mihai Parparita <mihaip@chromium.org>
Reviewed by Dimitri Glazkov.
Move asynchronous event dispatching out of Document
https://bugs.webkit.org/show_bug.cgi?id=49785
Move asynchonous event code out of Document and into a standalone
EventQueue class (which supports async events for both regular nodes
and the window object).
No new tests necessary, since no new functionality is exposed (existing
layout tests pass).
* Android.mk:
* CMakeLists.txt:
* GNUmakefile.am:
* WebCore.gypi:
* WebCore.pro:
* WebCore.vcproj/WebCore.vcproj:
* WebCore.xcodeproj/project.pbxproj:
* dom/Document.cpp:
(WebCore::Document::Document):
(WebCore::Document::enqueueWindowEvent):
(WebCore::Document::enqueueHashchangeEvent):
* dom/DOMAllInOne.cpp:
(WebCore::Document::eventQueue):
* dom/Document.h:
* dom/EventQueue.cpp: Added.
(WebCore::EventQueue::EventQueue):
(WebCore::EventQueue::enqueueEvent):
(WebCore::EventQueue::pendingEventTimerFired):
(WebCore::EventQueue::dispatchEvent):
* dom/EventQueue.h: Added.
* storage/StorageEventDispatcher.cpp:
(WebCore::StorageEventDispatcher::dispatch):
2010-12-14 Kyounga Ra <kyounga.ra@gmail.com>
Reviewed by Adam Barth.
......
......@@ -1206,6 +1206,8 @@ webcore_sources += \
WebCore/dom/EventNames.h \
WebCore/dom/EventTarget.cpp \
WebCore/dom/EventTarget.h \
WebCore/dom/EventQueue.cpp \
WebCore/dom/EventQueue.h \
WebCore/dom/ExceptionBase.cpp \
WebCore/dom/ExceptionBase.h \
WebCore/dom/ExceptionCode.cpp \
......
......@@ -1246,6 +1246,8 @@
'dom/EventNames.h',
'dom/EventTarget.cpp',
'dom/EventTarget.h',
'dom/EventQueue.cpp',
'dom/EventQueue.h',
'dom/ExceptionBase.cpp',
'dom/ExceptionBase.h',
'dom/ExceptionCode.cpp',
......
......@@ -730,6 +730,7 @@ SOURCES += \
dom/EventContext.cpp \
dom/EventNames.cpp \
dom/EventTarget.cpp \
dom/EventQueue.cpp \
dom/ExceptionBase.cpp \
dom/ExceptionCode.cpp \
dom/InputElement.cpp \
......
......@@ -43697,6 +43697,62 @@
RelativePath="..\dom\EventTarget.h"
>
</File>
<File
RelativePath="..\dom\EventQueue.cpp"
>
<FileConfiguration
Name="Debug|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug_Internal|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug_Cairo|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
<FileConfiguration
Name="Release_Cairo|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug_All|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\dom\EventQueue.h"
>
</File>
<File
RelativePath="..\dom\ExceptionBase.cpp"
>
......@@ -2690,6 +2690,8 @@
8AF4E55C11DC5A63000ED3DE /* PerformanceTiming.h in Headers */ = {isa = PBXBuildFile; fileRef = 8AF4E55911DC5A63000ED3DE /* PerformanceTiming.h */; };
8C6EA61911EF7E0400FD8EE3 /* RuntimeEnabledFeatures.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8C6EA61711EF7E0400FD8EE3 /* RuntimeEnabledFeatures.cpp */; };
8C6EA61A11EF7E0400FD8EE3 /* RuntimeEnabledFeatures.h in Headers */ = {isa = PBXBuildFile; fileRef = 8C6EA61811EF7E0400FD8EE3 /* RuntimeEnabledFeatures.h */; };
8F67561B1288B17B0047ACA3 /* EventQueue.h in Headers */ = {isa = PBXBuildFile; fileRef = 8F6756191288B17B0047ACA3 /* EventQueue.h */; };
8F67561C1288B17B0047ACA3 /* EventQueue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8F67561A1288B17B0047ACA3 /* EventQueue.cpp */; };
8FAC774D119872CB0015AE94 /* JSMainThreadExecState.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8F934D841189F1EE00508D5D /* JSMainThreadExecState.cpp */; };
9302B0BD0D79F82900C7EE83 /* PageGroup.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9302B0BC0D79F82900C7EE83 /* PageGroup.cpp */; };
9302B0BF0D79F82C00C7EE83 /* PageGroup.h in Headers */ = {isa = PBXBuildFile; fileRef = 9302B0BE0D79F82C00C7EE83 /* PageGroup.h */; settings = {ATTRIBUTES = (Private, ); }; };
......@@ -9027,6 +9029,8 @@
8AF4E55A11DC5A63000ED3DE /* PerformanceTiming.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = PerformanceTiming.idl; sourceTree = "<group>"; };
8C6EA61711EF7E0400FD8EE3 /* RuntimeEnabledFeatures.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RuntimeEnabledFeatures.cpp; path = generic/RuntimeEnabledFeatures.cpp; sourceTree = "<group>"; };
8C6EA61811EF7E0400FD8EE3 /* RuntimeEnabledFeatures.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RuntimeEnabledFeatures.h; path = generic/RuntimeEnabledFeatures.h; sourceTree = "<group>"; };
8F6756191288B17B0047ACA3 /* EventQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EventQueue.h; sourceTree = "<group>"; };
8F67561A1288B17B0047ACA3 /* EventQueue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EventQueue.cpp; sourceTree = "<group>"; };
8F934D831189F1EE00508D5D /* JSMainThreadExecState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSMainThreadExecState.h; sourceTree = "<group>"; };
8F934D841189F1EE00508D5D /* JSMainThreadExecState.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSMainThreadExecState.cpp; sourceTree = "<group>"; };
9302B0BC0D79F82900C7EE83 /* PageGroup.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PageGroup.cpp; sourceTree = "<group>"; };
......@@ -18806,6 +18810,8 @@
85AFA7410AAF298400E84305 /* EventListener.idl */,
939885C108B7E3D100E707C4 /* EventNames.cpp */,
939885C208B7E3D100E707C4 /* EventNames.h */,
8F6756191288B17B0047ACA3 /* EventQueue.h */,
8F67561A1288B17B0047ACA3 /* EventQueue.cpp */,
E12EDBE90B308E0B002704B6 /* EventTarget.cpp */,
E12EDB7A0B308A78002704B6 /* EventTarget.h */,
85AFA7420AAF298400E84305 /* EventTarget.idl */,
......@@ -20331,6 +20337,7 @@
935FBC4509BA00B900E230B1 /* EventListener.h in Headers */,
1CA19E160DC255CA0065A994 /* EventLoop.h in Headers */,
939885C408B7E3D100E707C4 /* EventNames.h in Headers */,
8F67561B1288B17B0047ACA3 /* EventQueue.h in Headers */,
E0FEF372B17C53EAC1C1FBEE /* EventSource.h in Headers */,
E12EDB7B0B308A78002704B6 /* EventTarget.h in Headers */,
BC60D8F30D2A11E000B9918F /* ExceptionBase.h in Headers */,
......@@ -23090,6 +23097,7 @@
93C09A7F0B064EEF005ABD4D /* EventHandlerMac.mm in Sources */,
1CA19E050DC255950065A994 /* EventLoopMac.mm in Sources */,
939885C308B7E3D100E707C4 /* EventNames.cpp in Sources */,
8F67561C1288B17B0047ACA3 /* EventQueue.cpp in Sources */,
E0FEF372B27C53EAC1C1FBEE /* EventSource.cpp in Sources */,
E12EDBEA0B308E0B002704B6 /* EventTarget.cpp in Sources */,
BC60D8F20D2A11E000B9918F /* ExceptionBase.cpp in Sources */,
......@@ -71,6 +71,7 @@
#include "Event.cpp"
#include "EventContext.cpp"
#include "EventNames.cpp"
#include "EventQueue.cpp"
#include "EventTarget.cpp"
#include "ExceptionBase.cpp"
#include "ExceptionCode.cpp"
......
......@@ -59,6 +59,7 @@
#include "EventHandler.h"
#include "EventListener.h"
#include "EventNames.h"
#include "EventQueue.h"
#include "ExceptionCode.h"
#include "FocusController.h"
#include "FormAssociatedElement.h"
......@@ -403,7 +404,7 @@ Document::Document(Frame* frame, const KURL& url, bool isXHTML, bool isHTML, con
, m_normalWorldWrapperCache(0)
#endif
, m_usingGeolocation(false)
, m_pendingEventTimer(this, &Document::pendingEventTimerFired)
, m_eventQueue(adoptPtr(new EventQueue))
#if ENABLE(WML)
, m_containsWMLContent(false)
#endif
......@@ -3473,23 +3474,10 @@ void Document::dispatchWindowLoadEvent()
domWindow->dispatchLoadEvent();
}
void Document::enqueueEvent(PassRefPtr<Event> event)
void Document::enqueueWindowEvent(PassRefPtr<Event> event)
{
m_pendingEventQueue.append(event);
if (!m_pendingEventTimer.isActive())
m_pendingEventTimer.startOneShot(0);
}
void Document::pendingEventTimerFired(Timer<Document>*)
{
ASSERT(!m_pendingEventTimer.isActive());
Vector<RefPtr<Event> > eventQueue;
eventQueue.swap(m_pendingEventQueue);
typedef Vector<RefPtr<Event> >::const_iterator Iterator;
Iterator end = eventQueue.end();
for (Iterator it = eventQueue.begin(); it != end; ++it)
dispatchWindowEvent(*it);
event->setTarget(domWindow());
m_eventQueue->enqueueEvent(event);
}
PassRefPtr<Event> Document::createEvent(const String& eventType, ExceptionCode& ec)
......@@ -4751,7 +4739,7 @@ void Document::enqueuePageshowEvent(PageshowEventPersistence persisted)
void Document::enqueueHashchangeEvent(const String& oldURL, const String& newURL)
{
enqueueEvent(HashChangeEvent::create(oldURL, newURL));
enqueueWindowEvent(HashChangeEvent::create(oldURL, newURL));
}
void Document::enqueuePopstateEvent(PassRefPtr<SerializedScriptValue> stateObject)
......
......@@ -76,6 +76,7 @@ class Element;
class EntityReference;
class Event;
class EventListener;
class EventQueue;
class FormAssociatedElement;
class Frame;
class FrameView;
......@@ -1026,10 +1027,11 @@ public:
bool containsValidityStyleRules() const { return m_containsValidityStyleRules; }
void setContainsValidityStyleRules() { m_containsValidityStyleRules = true; }
void enqueueEvent(PassRefPtr<Event>);
void enqueueWindowEvent(PassRefPtr<Event>);
void enqueuePageshowEvent(PageshowEventPersistence);
void enqueueHashchangeEvent(const String& oldURL, const String& newURL);
void enqueuePopstateEvent(PassRefPtr<SerializedScriptValue> stateObject);
EventQueue* eventQueue() const { return m_eventQueue.get(); }
void addMediaCanStartListener(MediaCanStartListener*);
void removeMediaCanStartListener(MediaCanStartListener*);
......@@ -1128,8 +1130,6 @@ private:
void createStyleSelector();
void pendingEventTimerFired(Timer<Document>*);
PassRefPtr<NodeList> handleZeroPadding(const HitTestRequest&, HitTestResult&) const;
void loadEventDelayTimerFired(Timer<Document>*);
......@@ -1352,9 +1352,8 @@ private:
#endif
bool m_usingGeolocation;
Timer<Document> m_pendingEventTimer;
Vector<RefPtr<Event> > m_pendingEventQueue;
OwnPtr<EventQueue> m_eventQueue;
#if ENABLE(WML)
bool m_containsWMLContent;
......
/*
* Copyright (C) 2010 Google Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include "config.h"
#include "EventQueue.h"
#include "DOMWindow.h"
#include "Document.h"
#include "Event.h"
#include "EventNames.h"
namespace WebCore {
EventQueue::EventQueue()
: m_pendingEventTimer(this, &EventQueue::pendingEventTimerFired)
{
}
void EventQueue::enqueueEvent(PassRefPtr<Event> event)
{
ASSERT(event->target()->toNode() || event->target()->toDOMWindow());
m_queuedEvents.append(event);
if (!m_pendingEventTimer.isActive())
m_pendingEventTimer.startOneShot(0);
}
void EventQueue::pendingEventTimerFired(Timer<EventQueue>*)
{
ASSERT(!m_pendingEventTimer.isActive());
Vector<RefPtr<Event> > queuedEvents;
queuedEvents.swap(m_queuedEvents);
for (size_t i = 0; i < queuedEvents.size(); i++)
dispatchEvent(queuedEvents[i].release());
}
void EventQueue::dispatchEvent(PassRefPtr<Event> event)
{
EventTarget* eventTarget = event->target();
if (eventTarget->toNode())
eventTarget->dispatchEvent(event);
else if (eventTarget->toDOMWindow())
eventTarget->toDOMWindow()->dispatchEvent(event, 0);
else
ASSERT_NOT_REACHED();
}
}
/*
* Copyright (C) 2010 Google Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef EventQueue_h
#define EventQueue_h
#include "Timer.h"
#include <wtf/Noncopyable.h>
#include <wtf/RefPtr.h>
#include <wtf/Vector.h>
namespace WebCore {
class Event;
class Node;
class EventQueue {
WTF_MAKE_NONCOPYABLE(EventQueue);
public:
EventQueue();
void enqueueEvent(PassRefPtr<Event>);
private:
void pendingEventTimerFired(Timer<EventQueue>*);
void dispatchEvent(PassRefPtr<Event>);
Timer<EventQueue> m_pendingEventTimer;
Vector<RefPtr<Event> > m_queuedEvents;
};
}
#endif // EventQueue_h
......@@ -58,7 +58,7 @@ void StorageEventDispatcher::dispatch(const String& key, const String& oldValue,
ExceptionCode ec = 0;
Storage* storage = frames[i]->domWindow()->sessionStorage(ec);
if (!ec)
frames[i]->document()->enqueueEvent(StorageEvent::create(eventNames().storageEvent, key, oldValue, newValue, sourceFrame->document()->url(), storage));
frames[i]->document()->enqueueWindowEvent(StorageEvent::create(eventNames().storageEvent, key, oldValue, newValue, sourceFrame->document()->url(), storage));
}
} else {
// Send events to every page.
......@@ -75,7 +75,7 @@ void StorageEventDispatcher::dispatch(const String& key, const String& oldValue,
ExceptionCode ec = 0;
Storage* storage = frames[i]->domWindow()->localStorage(ec);
if (!ec)
frames[i]->document()->enqueueEvent(StorageEvent::create(eventNames().storageEvent, key, oldValue, newValue, sourceFrame->document()->url(), storage));
frames[i]->document()->enqueueWindowEvent(StorageEvent::create(eventNames().storageEvent, key, oldValue, newValue, sourceFrame->document()->url(), storage));
}
}
}
......
2010-12-14 Mihai Parparita <mihaip@chromium.org>
Reviewed by Dimitri Glazkov.
Move asynchronous event dispatching out of Document
https://bugs.webkit.org/show_bug.cgi?id=49785
Change enqueueEvent callsite.
* src/StorageAreaProxy.cpp:
(WebCore::StorageAreaProxy::storageEvent):
2010-12-13 Mike Lawther <mikelawther@chromium.org>
Reviewed by James Robinson.
......
......@@ -129,7 +129,7 @@ void StorageAreaProxy::storageEvent(const String& key, const String& oldValue, c
ExceptionCode ec = 0;
Storage* storage = frames[i]->domWindow()->sessionStorage(ec);
if (!ec)
frames[i]->document()->enqueueEvent(StorageEvent::create(eventNames().storageEvent, key, oldValue, newValue, sourceFrame->document()->url(), storage));
frames[i]->document()->enqueueWindowEvent(StorageEvent::create(eventNames().storageEvent, key, oldValue, newValue, sourceFrame->document()->url(), storage));
}
} else {
// Send events to every page.
......@@ -146,7 +146,7 @@ void StorageAreaProxy::storageEvent(const String& key, const String& oldValue, c
ExceptionCode ec = 0;
Storage* storage = frames[i]->domWindow()->localStorage(ec);
if (!ec)
frames[i]->document()->enqueueEvent(StorageEvent::create(eventNames().storageEvent, key, oldValue, newValue, sourceFrame->document()->url(), storage));
frames[i]->document()->enqueueWindowEvent(StorageEvent::create(eventNames().storageEvent, key, oldValue, newValue, sourceFrame->document()->url(), storage));
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment