Title: [157288] trunk/Source/WebCore
Revision
157288
Author
[email protected]
Date
2013-10-10 20:56:23 -0700 (Thu, 10 Oct 2013)

Log Message

EventContext should be used only in EventDispatcher.cpp
https://bugs.webkit.org/show_bug.cgi?id=122631

Reviewed by Anders Carlsson.

Merged WindowEventContext into EventDispatcher. Moved the code to avoid dispatching load event on
window into dispatchEventInDOM so that WindowEventContext's constructor doesn't need Event.

Also replaced DOMWindow, Node, and EventPath arguments to InspectorInstrumentation::willDispatchEvent
by a single boolean indicating whether window, the origin, or the event path has an event listener.

* CMakeLists.txt:
* GNUmakefile.list.am:
* WebCore.vcxproj/WebCore.vcxproj:
* WebCore.vcxproj/WebCore.vcxproj.filters:
* WebCore.xcodeproj/project.pbxproj:
* dom/DOMAllInOne.cpp:
* dom/EventDispatcher.cpp:
(WebCore::WindowEventContext::window): Moved from WindowEventContext.
(WebCore::WindowEventContext::target): Ditto.
(WebCore::WindowEventContext::WindowEventContext): Ditto; removed the code to avoid dispatching load
event on window since that's checked in dispatchEventInDOM now.
(WebCore::WindowEventContext::handleLocalEvents): Ditto.
(WebCore::dispatchEventInDOM): Avoid calling handleLocalEvent on a load event with WindowEventContext.
(WebCore::EventDispatcher::dispatchEvent): Pass a boolean to indicate whether window, the origin, or
the event path contains any event listener to InspectorInstrumentation::willDispatchEvent to hide
EventPath from the inspector code.
* dom/EventDispatcher.h:
* dom/Node.cpp:
* dom/Node.h:
* dom/WindowEventContext.cpp: Removed.
* dom/WindowEventContext.h: Removed.
* inspector/InspectorDOMAgent.cpp:
* inspector/InspectorInstrumentation.cpp:
(WebCore::InspectorInstrumentation::willDispatchEventImpl):
* inspector/InspectorInstrumentation.h:
(WebCore::InspectorInstrumentation::willDispatchEvent):

Modified Paths

Removed Paths

Diff

Modified: trunk/Source/WebCore/CMakeLists.txt (157287 => 157288)


--- trunk/Source/WebCore/CMakeLists.txt	2013-10-11 03:51:44 UTC (rev 157287)
+++ trunk/Source/WebCore/CMakeLists.txt	2013-10-11 03:56:23 UTC (rev 157288)
@@ -1216,7 +1216,6 @@
     dom/WebKitNamedFlow.cpp
     dom/WebKitTransitionEvent.cpp
     dom/WheelEvent.cpp
-    dom/WindowEventContext.cpp
 
     dom/default/PlatformMessagePortChannel.cpp
 

Modified: trunk/Source/WebCore/ChangeLog (157287 => 157288)


--- trunk/Source/WebCore/ChangeLog	2013-10-11 03:51:44 UTC (rev 157287)
+++ trunk/Source/WebCore/ChangeLog	2013-10-11 03:56:23 UTC (rev 157288)
@@ -1,3 +1,43 @@
+2013-10-10  Ryosuke Niwa  <[email protected]>
+
+        EventContext should be used only in EventDispatcher.cpp
+        https://bugs.webkit.org/show_bug.cgi?id=122631
+
+        Reviewed by Anders Carlsson.
+
+        Merged WindowEventContext into EventDispatcher. Moved the code to avoid dispatching load event on
+        window into dispatchEventInDOM so that WindowEventContext's constructor doesn't need Event.
+
+        Also replaced DOMWindow, Node, and EventPath arguments to InspectorInstrumentation::willDispatchEvent
+        by a single boolean indicating whether window, the origin, or the event path has an event listener.
+
+        * CMakeLists.txt:
+        * GNUmakefile.list.am:
+        * WebCore.vcxproj/WebCore.vcxproj:
+        * WebCore.vcxproj/WebCore.vcxproj.filters:
+        * WebCore.xcodeproj/project.pbxproj:
+        * dom/DOMAllInOne.cpp:
+        * dom/EventDispatcher.cpp:
+        (WebCore::WindowEventContext::window): Moved from WindowEventContext.
+        (WebCore::WindowEventContext::target): Ditto.
+        (WebCore::WindowEventContext::WindowEventContext): Ditto; removed the code to avoid dispatching load
+        event on window since that's checked in dispatchEventInDOM now.
+        (WebCore::WindowEventContext::handleLocalEvents): Ditto.
+        (WebCore::dispatchEventInDOM): Avoid calling handleLocalEvent on a load event with WindowEventContext.
+        (WebCore::EventDispatcher::dispatchEvent): Pass a boolean to indicate whether window, the origin, or
+        the event path contains any event listener to InspectorInstrumentation::willDispatchEvent to hide
+        EventPath from the inspector code.
+        * dom/EventDispatcher.h:
+        * dom/Node.cpp:
+        * dom/Node.h:
+        * dom/WindowEventContext.cpp: Removed.
+        * dom/WindowEventContext.h: Removed.
+        * inspector/InspectorDOMAgent.cpp:
+        * inspector/InspectorInstrumentation.cpp:
+        (WebCore::InspectorInstrumentation::willDispatchEventImpl):
+        * inspector/InspectorInstrumentation.h:
+        (WebCore::InspectorInstrumentation::willDispatchEvent):
+
 2013-10-10  Darin Adler  <[email protected]>
 
         REGRESSION (r157205?): Leaks in XPath

Modified: trunk/Source/WebCore/GNUmakefile.list.am (157287 => 157288)


--- trunk/Source/WebCore/GNUmakefile.list.am	2013-10-11 03:51:44 UTC (rev 157287)
+++ trunk/Source/WebCore/GNUmakefile.list.am	2013-10-11 03:56:23 UTC (rev 157288)
@@ -3016,8 +3016,6 @@
 	Source/WebCore/dom/WebKitTransitionEvent.h \
 	Source/WebCore/dom/WheelEvent.cpp \
 	Source/WebCore/dom/WheelEvent.h \
-	Source/WebCore/dom/WindowEventContext.cpp \
-	Source/WebCore/dom/WindowEventContext.h \
 	Source/WebCore/editing/AlternativeTextController.cpp \
 	Source/WebCore/editing/AlternativeTextController.h \
 	Source/WebCore/editing/AppendNodeCommand.cpp \

Modified: trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj (157287 => 157288)


--- trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj	2013-10-11 03:51:44 UTC (rev 157287)
+++ trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj	2013-10-11 03:56:23 UTC (rev 157288)
@@ -13359,20 +13359,6 @@
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|Win32'">true</ExcludedFromBuild>
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|x64'">true</ExcludedFromBuild>
     </ClCompile>
-    <ClCompile Include="..\dom\WindowEventContext.cpp">
-      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
-      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
-      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_WinCairo|Win32'">true</ExcludedFromBuild>
-      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_WinCairo|x64'">true</ExcludedFromBuild>
-      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='DebugSuffix|Win32'">true</ExcludedFromBuild>
-      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='DebugSuffix|x64'">true</ExcludedFromBuild>
-      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
-      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
-      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WinCairo|Win32'">true</ExcludedFromBuild>
-      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WinCairo|x64'">true</ExcludedFromBuild>
-      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|Win32'">true</ExcludedFromBuild>
-      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|x64'">true</ExcludedFromBuild>
-    </ClCompile>
     <ClCompile Include="..\workers\AbstractWorker.cpp" />
     <ClCompile Include="..\workers\DedicatedWorkerGlobalScope.cpp" />
     <ClCompile Include="..\workers\DedicatedWorkerThread.cpp" />
@@ -19814,7 +19800,6 @@
     <ClInclude Include="..\dom\WebKitNamedFlow.h" />
     <ClInclude Include="..\dom\WebKitTransitionEvent.h" />
     <ClInclude Include="..\dom\WheelEvent.h" />
-    <ClInclude Include="..\dom\WindowEventContext.h" />
     <ClInclude Include="..\workers\AbstractWorker.h" />
     <ClInclude Include="..\workers\DedicatedWorkerGlobalScope.h" />
     <ClInclude Include="..\workers\DedicatedWorkerThread.h" />

Modified: trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters (157287 => 157288)


--- trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters	2013-10-11 03:51:44 UTC (rev 157287)
+++ trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters	2013-10-11 03:56:23 UTC (rev 157288)
@@ -3405,9 +3405,6 @@
     <ClCompile Include="..\dom\WheelEvent.cpp">
       <Filter>dom</Filter>
     </ClCompile>
-    <ClCompile Include="..\dom\WindowEventContext.cpp">
-      <Filter>dom</Filter>
-    </ClCompile>
     <ClCompile Include="..\workers\AbstractWorker.cpp">
       <Filter>workers</Filter>
     </ClCompile>
@@ -10287,9 +10284,6 @@
     <ClInclude Include="..\dom\WheelEvent.h">
       <Filter>dom</Filter>
     </ClInclude>
-    <ClInclude Include="..\dom\WindowEventContext.h">
-      <Filter>dom</Filter>
-    </ClInclude>
     <ClInclude Include="..\workers\AbstractWorker.h">
       <Filter>workers</Filter>
     </ClInclude>

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (157287 => 157288)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2013-10-11 03:51:44 UTC (rev 157287)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2013-10-11 03:56:23 UTC (rev 157288)
@@ -1205,8 +1205,6 @@
 		410B7E721045FAB000D8224F /* JSMessageEventCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 410B7E711045FAB000D8224F /* JSMessageEventCustom.cpp */; };
 		4123081B138C429700BCCFCA /* WebCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 93F19B1A08245E5A001E9ABC /* WebCore.framework */; };
 		41230913138C42FF00BCCFCA /* _javascript_Core.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F8216299029F4FB501000131 /* _javascript_Core.framework */; };
-		4123E569127B3041000FEEA7 /* WindowEventContext.h in Headers */ = {isa = PBXBuildFile; fileRef = 4123E567127B3041000FEEA7 /* WindowEventContext.h */; };
-		4123E56A127B3041000FEEA7 /* WindowEventContext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4123E568127B3041000FEEA7 /* WindowEventContext.cpp */; };
 		4127D5370F8AAB1D00E424F5 /* ScriptState.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4127D5360F8AAB1D00E424F5 /* ScriptState.cpp */; };
 		4138D3351244054800323D33 /* EventContext.h in Headers */ = {isa = PBXBuildFile; fileRef = 4138D3331244054800323D33 /* EventContext.h */; };
 		4138D3361244054800323D33 /* EventContext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4138D3341244054800323D33 /* EventContext.cpp */; };
@@ -7706,8 +7704,6 @@
 		41002CCB0F66EDEF009E660D /* ScriptFunctionCall.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptFunctionCall.h; sourceTree = "<group>"; };
 		41002CCC0F66EDEF009E660D /* ScriptFunctionCall.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScriptFunctionCall.cpp; sourceTree = "<group>"; };
 		410B7E711045FAB000D8224F /* JSMessageEventCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSMessageEventCustom.cpp; sourceTree = "<group>"; };
-		4123E567127B3041000FEEA7 /* WindowEventContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WindowEventContext.h; sourceTree = "<group>"; };
-		4123E568127B3041000FEEA7 /* WindowEventContext.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WindowEventContext.cpp; sourceTree = "<group>"; };
 		4127D5360F8AAB1D00E424F5 /* ScriptState.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScriptState.cpp; sourceTree = "<group>"; };
 		4138D3331244054800323D33 /* EventContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EventContext.h; sourceTree = "<group>"; };
 		4138D3341244054800323D33 /* EventContext.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EventContext.cpp; sourceTree = "<group>"; };
@@ -21064,8 +21060,6 @@
 				85031B3A0A44EFC700F992E0 /* WheelEvent.cpp */,
 				85031B3B0A44EFC700F992E0 /* WheelEvent.h */,
 				93EEC1F709C2877700C515D1 /* WheelEvent.idl */,
-				4123E568127B3041000FEEA7 /* WindowEventContext.cpp */,
-				4123E567127B3041000FEEA7 /* WindowEventContext.h */,
 			);
 			path = dom;
 			sourceTree = "<group>";
@@ -24514,7 +24508,6 @@
 				CD9DE17517AAC74C00EA386D /* JSMediaSource.h in Headers */,
 				1411DCB1164C39A800D49BC1 /* WidthCache.h in Headers */,
 				939B02EF0EA2DBC400C54570 /* WidthIterator.h in Headers */,
-				4123E569127B3041000FEEA7 /* WindowEventContext.h in Headers */,
 				BC8243E90D0CFD7500460C8F /* WindowFeatures.h in Headers */,
 				7E99AF530B13846468FB01A5 /* WindowFocusAllowedIndicator.h in Headers */,
 				E1E1BF00115FF6FB006F52CA /* WindowsKeyboardCodes.h in Headers */,
@@ -27562,7 +27555,6 @@
 				9380F47809A11ACC001FDB34 /* WidgetMac.mm in Sources */,
 				073BE35017D181A6002BD431 /* RTCPeerConnectionHandler.cpp in Sources */,
 				939B02EE0EA2DBC400C54570 /* WidthIterator.cpp in Sources */,
-				4123E56A127B3041000FEEA7 /* WindowEventContext.cpp in Sources */,
 				BC8243E80D0CFD7500460C8F /* WindowFeatures.cpp in Sources */,
 				7E99AF510B13846468FB01A5 /* WindowFocusAllowedIndicator.cpp in Sources */,
 				379919961200DDF400EA041C /* WOFFFileFormat.cpp in Sources */,

Modified: trunk/Source/WebCore/dom/DOMAllInOne.cpp (157287 => 157288)


--- trunk/Source/WebCore/dom/DOMAllInOne.cpp	2013-10-11 03:51:44 UTC (rev 157287)
+++ trunk/Source/WebCore/dom/DOMAllInOne.cpp	2013-10-11 03:56:23 UTC (rev 157288)
@@ -151,7 +151,6 @@
 #include "WebKitNamedFlow.cpp"
 #include "WebKitTransitionEvent.cpp"
 #include "WheelEvent.cpp"
-#include "WindowEventContext.cpp"
 #include "XMLDocumentParser.cpp"
 #include "XMLDocumentParserScope.cpp"
 

Modified: trunk/Source/WebCore/dom/EventDispatcher.cpp (157287 => 157288)


--- trunk/Source/WebCore/dom/EventDispatcher.cpp	2013-10-11 03:51:44 UTC (rev 157287)
+++ trunk/Source/WebCore/dom/EventDispatcher.cpp	2013-10-11 03:56:23 UTC (rev 157288)
@@ -5,7 +5,7 @@
  * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2013 Apple Inc. All rights reserved.
  * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
  * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
- * Copyright (C) 2011, 2012, 2013 Google Inc. All rights reserved.
+ * Copyright (C) 2010, 2011, 2012, 2013 Google Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -39,7 +39,6 @@
 #include "ScopedEventQueue.h"
 #include "ShadowRoot.h"
 #include "TouchEvent.h"
-#include "WindowEventContext.h"
 #include <wtf/RefPtr.h>
 
 #if ENABLE(SVG)
@@ -50,6 +49,40 @@
 
 namespace WebCore {
 
+class WindowEventContext {
+public:
+    WindowEventContext(PassRefPtr<Node>, const EventContext*);
+
+    DOMWindow* window() const { return m_window.get(); }
+    EventTarget* target() const { return m_target.get(); }
+    bool handleLocalEvents(Event&);
+
+private:
+    RefPtr<DOMWindow> m_window;
+    RefPtr<EventTarget> m_target;
+};
+
+WindowEventContext::WindowEventContext(PassRefPtr<Node> node, const EventContext* topEventContext)
+{
+    Node* topLevelContainer = topEventContext ? topEventContext->node() : node.get();
+    if (!topLevelContainer->isDocumentNode())
+        return;
+
+    m_window = toDocument(topLevelContainer)->domWindow();
+    m_target = topEventContext ? topEventContext->target() : node.get();
+}
+
+bool WindowEventContext::handleLocalEvents(Event& event)
+{
+    if (!m_window)
+        return false;
+
+    event.setTarget(m_target.get());
+    event.setCurrentTarget(m_window.get());
+    m_window->fireEventListeners(&event);
+    return true;
+}
+
 inline EventTarget& eventTargetRespectingTargetRules(Node& referenceNode)
 {
     if (referenceNode.isPseudoElement()) {
@@ -132,7 +165,10 @@
     // Trigger capturing event handlers, starting at the top and working our way down.
     event.setEventPhase(Event::CAPTURING_PHASE);
 
-    if (windowEventContext.handleLocalEvents(event) && event.propagationStopped())
+    // We don't dispatch load events to the window. This quirk was originally
+    // added because Mozilla doesn't propagate load events to the window object.
+    bool shouldFireEventAtWindow = event.type() != eventNames().loadEvent;
+    if (shouldFireEventAtWindow && windowEventContext.handleLocalEvents(event) && event.propagationStopped())
         return;
 
     for (size_t i = path.size() - 1; i > 0; --i) {
@@ -165,7 +201,8 @@
     }
     if (event.bubbles() && !event.cancelBubble()) {
         event.setEventPhase(Event::BUBBLING_PHASE);
-        windowEventContext.handleLocalEvents(event);
+        if (shouldFireEventAtWindow)
+            windowEventContext.handleLocalEvents(event);
     }
 }
 
@@ -193,8 +230,10 @@
     event->setTarget(&eventTargetRespectingTargetRules(*node));
     ASSERT(!NoEventDispatchAssertion::isEventDispatchForbidden());
     ASSERT(event->target());
-    WindowEventContext windowEventContext(event.get(), node.get(), eventPath.lastContextIfExists());
-    InspectorInstrumentationCookie cookie = InspectorInstrumentation::willDispatchEvent(&node->document(), *event, windowEventContext.window(), node.get(), eventPath);
+    WindowEventContext windowEventContext(node.get(), eventPath.lastContextIfExists());
+    bool hasEventListners = (windowEventContext.window() && windowEventContext.window()->hasEventListeners(event->type()))
+        || node->hasEventListeners(event->type()) || eventPath.hasEventListeners(event->type());
+    InspectorInstrumentationCookie cookie = InspectorInstrumentation::willDispatchEvent(&node->document(), *event, hasEventListners);
 
     InputElementClickState clickHandlingState;
     if (isHTMLInputElement(node.get()))

Modified: trunk/Source/WebCore/dom/EventDispatcher.h (157287 => 157288)


--- trunk/Source/WebCore/dom/EventDispatcher.h	2013-10-11 03:51:44 UTC (rev 157287)
+++ trunk/Source/WebCore/dom/EventDispatcher.h	2013-10-11 03:56:23 UTC (rev 157288)
@@ -26,7 +26,6 @@
 #ifndef EventDispatcher_h
 #define EventDispatcher_h
 
-#include "EventContext.h"
 #include "SimulatedClickOptions.h"
 #include <wtf/Forward.h>
 #include <wtf/HashMap.h>
@@ -35,15 +34,17 @@
 
 namespace WebCore {
 
+class Element;
 class Event;
+class EventContext;
 class EventTarget;
 class FrameView;
 class Node;
 class PlatformKeyboardEvent;
 class PlatformMouseEvent;
 class ShadowRoot;
+class TouchEvent;
 class TreeScope;
-class WindowEventContext;
 struct InputElementClickState;
 
 enum EventDispatchContinuation {

Modified: trunk/Source/WebCore/dom/Node.cpp (157287 => 157288)


--- trunk/Source/WebCore/dom/Node.cpp	2013-10-11 03:51:44 UTC (rev 157287)
+++ trunk/Source/WebCore/dom/Node.cpp	2013-10-11 03:56:23 UTC (rev 157288)
@@ -51,7 +51,6 @@
 #include "ElementIterator.h"
 #include "ElementRareData.h"
 #include "Event.h"
-#include "EventContext.h"
 #include "EventDispatcher.h"
 #include "EventException.h"
 #include "EventHandler.h"
@@ -105,7 +104,6 @@
 #include "UIEvent.h"
 #include "UIEventWithKeyState.h"
 #include "WheelEvent.h"
-#include "WindowEventContext.h"
 #include "XMLNames.h"
 #include "htmlediting.h"
 #include <wtf/HashSet.h>

Modified: trunk/Source/WebCore/dom/Node.h (157287 => 157288)


--- trunk/Source/WebCore/dom/Node.h	2013-10-11 03:51:44 UTC (rev 157287)
+++ trunk/Source/WebCore/dom/Node.h	2013-10-11 03:56:23 UTC (rev 157288)
@@ -56,7 +56,6 @@
 class Document;
 class Element;
 class Event;
-class EventContext;
 class EventListener;
 class FloatPoint;
 class Frame;

Deleted: trunk/Source/WebCore/dom/WindowEventContext.cpp (157287 => 157288)


--- trunk/Source/WebCore/dom/WindowEventContext.cpp	2013-10-11 03:51:44 UTC (rev 157287)
+++ trunk/Source/WebCore/dom/WindowEventContext.cpp	2013-10-11 03:56:23 UTC (rev 157288)
@@ -1,64 +0,0 @@
-/*
- * 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 "WindowEventContext.h"
-
-#include "DOMWindow.h"
-#include "Document.h"
-#include "Event.h"
-#include "EventContext.h"
-#include "Node.h"
-
-namespace WebCore {
-
-WindowEventContext::WindowEventContext(Event* event, PassRefPtr<Node> node, const EventContext* topEventContext)
-{
-    // We don't dispatch load events to the window. This quirk was originally
-    // added because Mozilla doesn't propagate load events to the window object.
-    if (event->type() == eventNames().loadEvent)
-        return;
-
-    Node* topLevelContainer = topEventContext ? topEventContext->node() : node.get();
-    if (!topLevelContainer->isDocumentNode())
-        return;
-
-    m_window = toDocument(topLevelContainer)->domWindow();
-    m_target = topEventContext ? topEventContext->target() : node.get();
-}
-
-bool WindowEventContext::handleLocalEvents(Event& event)
-{
-    if (!m_window)
-        return false;
-
-    event.setTarget(target());
-    event.setCurrentTarget(window());
-    m_window->fireEventListeners(&event);
-    return true;
-}
-
-}

Deleted: trunk/Source/WebCore/dom/WindowEventContext.h (157287 => 157288)


--- trunk/Source/WebCore/dom/WindowEventContext.h	2013-10-11 03:51:44 UTC (rev 157287)
+++ trunk/Source/WebCore/dom/WindowEventContext.h	2013-10-11 03:56:23 UTC (rev 157288)
@@ -1,65 +0,0 @@
-/*
- * 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 WindowEventContext_h
-#define WindowEventContext_h
-
-#include <wtf/RefPtr.h>
-
-namespace WebCore {
-
-class DOMWindow;
-class EventTarget;
-class EventContext;
-class Event;
-class Node;
-
-class WindowEventContext {
-public:
-    WindowEventContext(Event*, PassRefPtr<Node>, const EventContext*);
-
-    DOMWindow* window() const;
-    EventTarget* target() const;
-    bool handleLocalEvents(Event&);
-
-private:
-    RefPtr<DOMWindow> m_window;
-    RefPtr<EventTarget> m_target;
-};
-
-inline DOMWindow* WindowEventContext::window() const
-{
-    return m_window.get();
-}
-
-inline EventTarget* WindowEventContext::target() const
-{
-    return m_target.get();
-}
-
-}
-
-#endif // WindowEventContext_h

Modified: trunk/Source/WebCore/inspector/InspectorDOMAgent.cpp (157287 => 157288)


--- trunk/Source/WebCore/inspector/InspectorDOMAgent.cpp	2013-10-11 03:51:44 UTC (rev 157287)
+++ trunk/Source/WebCore/inspector/InspectorDOMAgent.cpp	2013-10-11 03:56:23 UTC (rev 157288)
@@ -54,7 +54,6 @@
 #include "DocumentType.h"
 #include "Element.h"
 #include "Event.h"
-#include "EventContext.h"
 #include "EventListener.h"
 #include "EventNames.h"
 #include "EventTarget.h"

Modified: trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp (157287 => 157288)


--- trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp	2013-10-11 03:51:44 UTC (rev 157287)
+++ trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp	2013-10-11 03:56:23 UTC (rev 157288)
@@ -44,7 +44,6 @@
 #include "DeviceOrientationData.h"
 #include "DocumentLoader.h"
 #include "Event.h"
-#include "EventContext.h"
 #include "EventDispatcher.h"
 #include "InspectorAgent.h"
 #include "InspectorApplicationCacheAgent.h"
@@ -99,14 +98,6 @@
 
 int InspectorInstrumentation::s_frontendCounter = 0;
 
-static bool eventHasListeners(const AtomicString& eventType, DOMWindow* window, Node* node, const EventPath& eventPath)
-{
-    if (window && window->hasEventListeners(eventType))
-        return true;
-
-    return node->hasEventListeners(eventType) || eventPath.hasEventListeners(eventType);
-}
-
 static Frame* frameForScriptExecutionContext(ScriptExecutionContext* context)
 {
     Frame* frame = 0;
@@ -390,11 +381,11 @@
         timelineAgent->didDispatchXHRReadyStateChangeEvent();
 }
 
-InspectorInstrumentationCookie InspectorInstrumentation::willDispatchEventImpl(InstrumentingAgents* instrumentingAgents, const Event& event, DOMWindow* window, Node* node, const EventPath& eventPath, Document* document)
+InspectorInstrumentationCookie InspectorInstrumentation::willDispatchEventImpl(InstrumentingAgents* instrumentingAgents, const Event& event, bool hasEventListeners, Document* document)
 {
     int timelineAgentId = 0;
     InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent();
-    if (timelineAgent && eventHasListeners(event.type(), window, node, eventPath)) {
+    if (timelineAgent && hasEventListeners) {
         timelineAgent->willDispatchEvent(event, document->frame());
         timelineAgentId = timelineAgent->id();
     }

Modified: trunk/Source/WebCore/inspector/InspectorInstrumentation.h (157287 => 157288)


--- trunk/Source/WebCore/inspector/InspectorInstrumentation.h	2013-10-11 03:51:44 UTC (rev 157287)
+++ trunk/Source/WebCore/inspector/InspectorInstrumentation.h	2013-10-11 03:56:23 UTC (rev 157288)
@@ -35,7 +35,6 @@
 #include "ConsoleAPITypes.h"
 #include "ConsoleTypes.h"
 #include "Element.h"
-#include "EventContext.h"
 #include "FormData.h"
 #include "Frame.h"
 #include "HitTestResult.h"
@@ -56,7 +55,6 @@
 class Database;
 class Document;
 class Element;
-class EventContext;
 class EventPath;
 class DocumentLoader;
 class DocumentStyleSheetCollection;
@@ -150,7 +148,7 @@
     static void didCallFunction(const InspectorInstrumentationCookie&);
     static InspectorInstrumentationCookie willDispatchXHRReadyStateChangeEvent(ScriptExecutionContext*, XMLHttpRequest*);
     static void didDispatchXHRReadyStateChangeEvent(const InspectorInstrumentationCookie&);
-    static InspectorInstrumentationCookie willDispatchEvent(Document*, const Event&, DOMWindow*, Node*, const EventPath&);
+    static InspectorInstrumentationCookie willDispatchEvent(Document*, const Event&, bool hasEventListeners);
     static void didDispatchEvent(const InspectorInstrumentationCookie&);
     static InspectorInstrumentationCookie willHandleEvent(ScriptExecutionContext*, Event*);
     static void didHandleEvent(const InspectorInstrumentationCookie&);
@@ -355,7 +353,7 @@
     static void didCallFunctionImpl(const InspectorInstrumentationCookie&);
     static InspectorInstrumentationCookie willDispatchXHRReadyStateChangeEventImpl(InstrumentingAgents*, XMLHttpRequest*, ScriptExecutionContext*);
     static void didDispatchXHRReadyStateChangeEventImpl(const InspectorInstrumentationCookie&);
-    static InspectorInstrumentationCookie willDispatchEventImpl(InstrumentingAgents*, const Event&, DOMWindow*, Node*, const EventPath&, Document*);
+    static InspectorInstrumentationCookie willDispatchEventImpl(InstrumentingAgents*, const Event&, bool hasEventListeners, Document*);
     static InspectorInstrumentationCookie willHandleEventImpl(InstrumentingAgents*, Event*);
     static void didHandleEventImpl(const InspectorInstrumentationCookie&);
     static void didDispatchEventImpl(const InspectorInstrumentationCookie&);
@@ -884,12 +882,12 @@
 #endif
 }
 
-inline InspectorInstrumentationCookie InspectorInstrumentation::willDispatchEvent(Document* document, const Event& event, DOMWindow* window, Node* node, const EventPath& eventPath)
+inline InspectorInstrumentationCookie InspectorInstrumentation::willDispatchEvent(Document* document, const Event& event, bool hasEventListeners)
 {
 #if ENABLE(INSPECTOR)
     FAST_RETURN_IF_NO_FRONTENDS(InspectorInstrumentationCookie());
     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
-        return willDispatchEventImpl(instrumentingAgents, event, window, node, eventPath, document);
+        return willDispatchEventImpl(instrumentingAgents, event, hasEventListeners, document);
 #else
     UNUSED_PARAM(document);
     UNUSED_PARAM(event);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to