Title: [209811] trunk/Source/WebCore
Revision
209811
Author
[email protected]
Date
2016-12-14 09:41:28 -0800 (Wed, 14 Dec 2016)

Log Message

EventDispatcher::dispatchEvent() should take its Node by reference
https://bugs.webkit.org/show_bug.cgi?id=165840

Reviewed by Andreas Kling.

No new tests. No change in behavior.

* dom/Element.cpp:
(WebCore::Element::dispatchWheelEvent): Dereferenced |this| when calling
EventDispatcher::dispatchEvent().
(WebCore::Element::dispatchKeyEvent): Ditto.
(WebCore::Element::dispatchFocusEvent): Ditto.
(WebCore::Element::dispatchBlurEvent): Ditto.
* dom/EventDispatcher.cpp:
(WebCore::EventDispatcher::dispatchEvent): Changed |origin| from a Node* to a Node&, renamed
it to |node|, and protected it with a Ref called |protectedNode| to match our preferred
style.
* dom/EventDispatcher.h: Changed dispatchEvent's first parameter type from Node* to Node&.
* dom/Node.cpp:
(WebCore::Node::dispatchEvent): Dereferenced |this| when calling
EventDispatcher::dispatchEvent().
(WebCore::Node::dispatchTouchEvent): Ditto.
(WebCore::Node::dispatchUIRequestEvent): Ditto.
* dom/ScopedEventQueue.cpp:
(WebCore::ScopedEventQueue::dispatchEvent): Dereferenced |node| when calling
EventDispatcher::dispatchEvent().
* dom/SimulatedClick.cpp:
(WebCore::simulateMouseEvent): Passed |element| as a reference to
EventDispatcher::dispatchEvent().

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (209810 => 209811)


--- trunk/Source/WebCore/ChangeLog	2016-12-14 17:37:24 UTC (rev 209810)
+++ trunk/Source/WebCore/ChangeLog	2016-12-14 17:41:28 UTC (rev 209811)
@@ -1,3 +1,35 @@
+2016-12-14  Andy Estes  <[email protected]>
+
+        EventDispatcher::dispatchEvent() should take its Node by reference
+        https://bugs.webkit.org/show_bug.cgi?id=165840
+
+        Reviewed by Andreas Kling.
+
+        No new tests. No change in behavior.
+
+        * dom/Element.cpp:
+        (WebCore::Element::dispatchWheelEvent): Dereferenced |this| when calling
+        EventDispatcher::dispatchEvent().
+        (WebCore::Element::dispatchKeyEvent): Ditto.
+        (WebCore::Element::dispatchFocusEvent): Ditto.
+        (WebCore::Element::dispatchBlurEvent): Ditto.
+        * dom/EventDispatcher.cpp:
+        (WebCore::EventDispatcher::dispatchEvent): Changed |origin| from a Node* to a Node&, renamed
+        it to |node|, and protected it with a Ref called |protectedNode| to match our preferred
+        style.
+        * dom/EventDispatcher.h: Changed dispatchEvent's first parameter type from Node* to Node&.
+        * dom/Node.cpp:
+        (WebCore::Node::dispatchEvent): Dereferenced |this| when calling
+        EventDispatcher::dispatchEvent().
+        (WebCore::Node::dispatchTouchEvent): Ditto.
+        (WebCore::Node::dispatchUIRequestEvent): Ditto.
+        * dom/ScopedEventQueue.cpp:
+        (WebCore::ScopedEventQueue::dispatchEvent): Dereferenced |node| when calling
+        EventDispatcher::dispatchEvent().
+        * dom/SimulatedClick.cpp:
+        (WebCore::simulateMouseEvent): Passed |element| as a reference to
+        EventDispatcher::dispatchEvent().
+
 2016-12-14  Chris Dumez  <[email protected]>
 
         Remove Unicode case-insensitive matching for usemap=""

Modified: trunk/Source/WebCore/dom/Element.cpp (209810 => 209811)


--- trunk/Source/WebCore/dom/Element.cpp	2016-12-14 17:37:24 UTC (rev 209810)
+++ trunk/Source/WebCore/dom/Element.cpp	2016-12-14 17:41:28 UTC (rev 209811)
@@ -317,7 +317,7 @@
     if (!event.deltaX() && !event.deltaY())
         wheelEvent->stopPropagation();
 
-    return EventDispatcher::dispatchEvent(this, wheelEvent) && !wheelEvent->defaultHandled();
+    return EventDispatcher::dispatchEvent(*this, wheelEvent) && !wheelEvent->defaultHandled();
 }
 
 bool Element::dispatchKeyEvent(const PlatformKeyboardEvent& platformEvent)
@@ -327,7 +327,7 @@
         if (frame->eventHandler().accessibilityPreventsEventPropogation(event))
             event->stopPropagation();
     }
-    return EventDispatcher::dispatchEvent(this, event) && !event->defaultHandled();
+    return EventDispatcher::dispatchEvent(*this, event) && !event->defaultHandled();
 }
 
 void Element::dispatchSimulatedClick(Event* underlyingEvent, SimulatedClickMouseEventOptions eventOptions, SimulatedClickVisualOptions visualOptions)
@@ -2465,7 +2465,7 @@
     if (document().page())
         document().page()->chrome().client().elementDidFocus(this);
 
-    EventDispatcher::dispatchEvent(this, FocusEvent::create(eventNames().focusEvent, false, false, document().defaultView(), 0, WTFMove(oldFocusedElement)));
+    EventDispatcher::dispatchEvent(*this, FocusEvent::create(eventNames().focusEvent, false, false, document().defaultView(), 0, WTFMove(oldFocusedElement)));
 }
 
 void Element::dispatchBlurEvent(RefPtr<Element>&& newFocusedElement)
@@ -2473,7 +2473,7 @@
     if (document().page())
         document().page()->chrome().client().elementDidBlur(this);
 
-    EventDispatcher::dispatchEvent(this, FocusEvent::create(eventNames().blurEvent, false, false, document().defaultView(), 0, WTFMove(newFocusedElement)));
+    EventDispatcher::dispatchEvent(*this, FocusEvent::create(eventNames().blurEvent, false, false, document().defaultView(), 0, WTFMove(newFocusedElement)));
 }
 
 bool Element::dispatchMouseForceWillBegin()

Modified: trunk/Source/WebCore/dom/EventDispatcher.cpp (209810 => 209811)


--- trunk/Source/WebCore/dom/EventDispatcher.cpp	2016-12-14 17:37:24 UTC (rev 209810)
+++ trunk/Source/WebCore/dom/EventDispatcher.cpp	2016-12-14 17:41:28 UTC (rev 209811)
@@ -102,16 +102,15 @@
     }
 }
 
-bool EventDispatcher::dispatchEvent(Node* origin, Event& event)
+bool EventDispatcher::dispatchEvent(Node& node, Event& event)
 {
     ASSERT_WITH_SECURITY_IMPLICATION(!NoEventDispatchAssertion::isEventDispatchForbidden());
-    ASSERT(origin);
-    RefPtr<Node> node(origin);
-    RefPtr<FrameView> view = node->document().view();
-    EventPath eventPath(*node, event);
+    Ref<Node> protectedNode(node);
+    RefPtr<FrameView> view = node.document().view();
+    EventPath eventPath(node, event);
 
     if (EventTarget* relatedTarget = event.relatedTarget())
-        eventPath.setRelatedTarget(*node, *relatedTarget);
+        eventPath.setRelatedTarget(node, *relatedTarget);
 #if ENABLE(TOUCH_EVENTS)
     if (is<TouchEvent>(event))
         eventPath.retargetTouchLists(downcast<TouchEvent>(event));
@@ -119,7 +118,7 @@
 
     ChildNodesLazySnapshot::takeChildNodesLazySnapshot();
 
-    EventTarget* target = EventPath::eventTargetRespectingTargetRules(*node);
+    EventTarget* target = EventPath::eventTargetRespectingTargetRules(node);
     event.setTarget(target);
     if (!event.target())
         return true;
@@ -127,8 +126,8 @@
     ASSERT_WITH_SECURITY_IMPLICATION(!NoEventDispatchAssertion::isEventDispatchForbidden());
 
     InputElementClickState clickHandlingState;
-    if (is<HTMLInputElement>(*node))
-        downcast<HTMLInputElement>(*node).willDispatchEvent(event, clickHandlingState);
+    if (is<HTMLInputElement>(node))
+        downcast<HTMLInputElement>(node).willDispatchEvent(event, clickHandlingState);
 
     if (!event.propagationStopped() && !eventPath.isEmpty()) {
         event.setEventPath(eventPath);
@@ -137,13 +136,13 @@
     }
 
     auto* finalTarget = event.target();
-    event.setTarget(EventPath::eventTargetRespectingTargetRules(*node));
+    event.setTarget(EventPath::eventTargetRespectingTargetRules(node));
     event.setCurrentTarget(nullptr);
     event.resetPropagationFlags();
     event.setEventPhase(Event::NONE);
 
     if (clickHandlingState.stateful)
-        downcast<HTMLInputElement>(*node).didDispatchClickEvent(event, clickHandlingState);
+        downcast<HTMLInputElement>(node).didDispatchClickEvent(event, clickHandlingState);
 
     // Call default event handlers. While the DOM does have a concept of preventing
     // default handling, the detail of which handlers are called is an internal

Modified: trunk/Source/WebCore/dom/EventDispatcher.h (209810 => 209811)


--- trunk/Source/WebCore/dom/EventDispatcher.h	2016-12-14 17:37:24 UTC (rev 209810)
+++ trunk/Source/WebCore/dom/EventDispatcher.h	2016-12-14 17:41:28 UTC (rev 209811)
@@ -35,7 +35,7 @@
 
 namespace EventDispatcher {
 
-bool dispatchEvent(Node*, Event&);
+bool dispatchEvent(Node&, Event&);
 void dispatchScopedEvent(Node&, Event&);
 
 }

Modified: trunk/Source/WebCore/dom/Node.cpp (209810 => 209811)


--- trunk/Source/WebCore/dom/Node.cpp	2016-12-14 17:37:24 UTC (rev 209810)
+++ trunk/Source/WebCore/dom/Node.cpp	2016-12-14 17:41:28 UTC (rev 209811)
@@ -2178,7 +2178,7 @@
     if (is<TouchEvent>(event))
         return dispatchTouchEvent(downcast<TouchEvent>(event));
 #endif
-    return EventDispatcher::dispatchEvent(this, event);
+    return EventDispatcher::dispatchEvent(*this, event);
 }
 
 void Node::dispatchSubtreeModifiedEvent()
@@ -2209,7 +2209,7 @@
 #if ENABLE(TOUCH_EVENTS) && !PLATFORM(IOS)
 bool Node::dispatchTouchEvent(TouchEvent& event)
 {
-    return EventDispatcher::dispatchEvent(this, event);
+    return EventDispatcher::dispatchEvent(*this, event);
 }
 #endif
 
@@ -2216,7 +2216,7 @@
 #if ENABLE(INDIE_UI)
 bool Node::dispatchUIRequestEvent(UIRequestEvent& event)
 {
-    EventDispatcher::dispatchEvent(this, event);
+    EventDispatcher::dispatchEvent(*this, event);
     return event.defaultHandled() || event.defaultPrevented();
 }
 #endif

Modified: trunk/Source/WebCore/dom/ScopedEventQueue.cpp (209810 => 209811)


--- trunk/Source/WebCore/dom/ScopedEventQueue.cpp	2016-12-14 17:37:24 UTC (rev 209810)
+++ trunk/Source/WebCore/dom/ScopedEventQueue.cpp	2016-12-14 17:41:28 UTC (rev 209811)
@@ -56,7 +56,7 @@
     ASSERT(event.target());
     // Store the target in a local variable to avoid possibly dereferencing a nullified PassRefPtr after it's passed on.
     Node* node = event.target()->toNode();
-    EventDispatcher::dispatchEvent(node, event);
+    EventDispatcher::dispatchEvent(*node, event);
 }
 
 void ScopedEventQueue::dispatchAllEvents()

Modified: trunk/Source/WebCore/dom/SimulatedClick.cpp (209810 => 209811)


--- trunk/Source/WebCore/dom/SimulatedClick.cpp	2016-12-14 17:37:24 UTC (rev 209810)
+++ trunk/Source/WebCore/dom/SimulatedClick.cpp	2016-12-14 17:41:28 UTC (rev 209811)
@@ -81,7 +81,7 @@
 static void simulateMouseEvent(const AtomicString& eventType, Element& element, Event* underlyingEvent, SimulatedClickSource source)
 {
     auto event = SimulatedMouseEvent::create(eventType, element.document().defaultView(), underlyingEvent, element, source);
-    EventDispatcher::dispatchEvent(&element, event);
+    EventDispatcher::dispatchEvent(element, event);
 }
 
 void simulateClick(Element& element, Event* underlyingEvent, SimulatedClickMouseEventOptions mouseEventOptions, SimulatedClickVisualOptions visualOptions, SimulatedClickSource creationOptions)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to