Title: [150714] trunk/Source/WebCore
Revision
150714
Author
[email protected]
Date
2013-05-26 06:32:36 -0700 (Sun, 26 May 2013)

Log Message

Move Node::dispatchSimulatedClick() to Element.
<http://webkit.org/b/116784>

Reviewed by Antti Koivisto.

Only Elements use the dispatchSimulatedClick() functionality, so move it there.

* dom/Node.cpp:
* dom/Node.h:
* dom/Element.h:
* dom/Element.cpp:
(WebCore::Element::dispatchSimulatedClick):
* dom/EventDispatcher.h:
* dom/EventDispatcher.cpp:
(WebCore::EventDispatcher::dispatchSimulatedClick):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (150713 => 150714)


--- trunk/Source/WebCore/ChangeLog	2013-05-26 12:10:23 UTC (rev 150713)
+++ trunk/Source/WebCore/ChangeLog	2013-05-26 13:32:36 UTC (rev 150714)
@@ -1,5 +1,23 @@
 2013-05-26  Andreas Kling  <[email protected]>
 
+        Move Node::dispatchSimulatedClick() to Element.
+        <http://webkit.org/b/116784>
+
+        Reviewed by Antti Koivisto.
+
+        Only Elements use the dispatchSimulatedClick() functionality, so move it there.
+
+        * dom/Node.cpp:
+        * dom/Node.h:
+        * dom/Element.h:
+        * dom/Element.cpp:
+        (WebCore::Element::dispatchSimulatedClick):
+        * dom/EventDispatcher.h:
+        * dom/EventDispatcher.cpp:
+        (WebCore::EventDispatcher::dispatchSimulatedClick):
+
+2013-05-26  Andreas Kling  <[email protected]>
+
         TreeScope::rootNode() should return a ContainerNode.
         <http://webkit.org/b/116782>
 

Modified: trunk/Source/WebCore/dom/Element.cpp (150713 => 150714)


--- trunk/Source/WebCore/dom/Element.cpp	2013-05-26 12:10:23 UTC (rev 150713)
+++ trunk/Source/WebCore/dom/Element.cpp	2013-05-26 13:32:36 UTC (rev 150714)
@@ -40,6 +40,7 @@
 #include "DocumentFragment.h"
 #include "DocumentSharedObjectPool.h"
 #include "ElementRareData.h"
+#include "EventDispatcher.h"
 #include "ExceptionCode.h"
 #include "FlowThreadController.h"
 #include "FocusController.h"
@@ -264,6 +265,11 @@
     return isFocusable();
 }
 
+void Element::dispatchSimulatedClick(Event* underlyingEvent, SimulatedClickMouseEventOptions eventOptions, SimulatedClickVisualOptions visualOptions)
+{
+    EventDispatcher::dispatchSimulatedClick(this, underlyingEvent, eventOptions, visualOptions);
+}
+
 DEFINE_VIRTUAL_ATTRIBUTE_EVENT_LISTENER(Element, blur);
 DEFINE_VIRTUAL_ATTRIBUTE_EVENT_LISTENER(Element, error);
 DEFINE_VIRTUAL_ATTRIBUTE_EVENT_LISTENER(Element, focus);

Modified: trunk/Source/WebCore/dom/Element.h (150713 => 150714)


--- trunk/Source/WebCore/dom/Element.h	2013-05-26 12:10:23 UTC (rev 150713)
+++ trunk/Source/WebCore/dom/Element.h	2013-05-26 13:32:36 UTC (rev 150714)
@@ -632,6 +632,8 @@
     IntSize savedLayerScrollOffset() const;
     void setSavedLayerScrollOffset(const IntSize&);
 
+    void dispatchSimulatedClick(Event* underlyingEvent, SimulatedClickMouseEventOptions = SendNoEvents, SimulatedClickVisualOptions = ShowPressedLook);
+
 protected:
     Element(const QualifiedName& tagName, Document* document, ConstructionType type)
         : ContainerNode(document, type)

Modified: trunk/Source/WebCore/dom/EventDispatcher.cpp (150713 => 150714)


--- trunk/Source/WebCore/dom/EventDispatcher.cpp	2013-05-26 12:10:23 UTC (rev 150713)
+++ trunk/Source/WebCore/dom/EventDispatcher.cpp	2013-05-26 13:32:36 UTC (rev 150714)
@@ -2,7 +2,7 @@
  * Copyright (C) 1999 Lars Knoll ([email protected])
  *           (C) 1999 Antti Koivisto ([email protected])
  *           (C) 2001 Dirk Mueller ([email protected])
- * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
+ * 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 Google Inc. All rights reserved.
@@ -44,8 +44,6 @@
 
 namespace WebCore {
 
-static HashSet<Node*>* gNodesDispatchingSimulatedClicks = 0;
-
 bool EventDispatcher::dispatchEvent(Node* node, PassRefPtr<EventDispatchMediator> mediator)
 {
     ASSERT(!NoEventDispatchAssertion::isEventDispatchForbidden());
@@ -76,32 +74,29 @@
     ScopedEventQueue::instance()->enqueueEventDispatchMediator(mediator);
 }
 
-void EventDispatcher::dispatchSimulatedClick(Node* node, Event* underlyingEvent, SimulatedClickMouseEventOptions mouseEventOptions, SimulatedClickVisualOptions visualOptions)
+void EventDispatcher::dispatchSimulatedClick(Element* element, Event* underlyingEvent, SimulatedClickMouseEventOptions mouseEventOptions, SimulatedClickVisualOptions visualOptions)
 {
-    if (isDisabledFormControl(node))
+    if (element->isDisabledFormControl())
         return;
 
-    if (!gNodesDispatchingSimulatedClicks)
-        gNodesDispatchingSimulatedClicks = new HashSet<Node*>;
-    else if (gNodesDispatchingSimulatedClicks->contains(node))
+    DEFINE_STATIC_LOCAL(HashSet<Element*>, elementsDispatchingSimulatedClicks, ());
+    if (!elementsDispatchingSimulatedClicks.add(element).isNewEntry)
         return;
 
-    gNodesDispatchingSimulatedClicks->add(node);
-
     if (mouseEventOptions == SendMouseOverUpDownEvents)
-        EventDispatcher(node, SimulatedMouseEvent::create(eventNames().mouseoverEvent, node->document()->defaultView(), underlyingEvent)).dispatch();
+        EventDispatcher(element, SimulatedMouseEvent::create(eventNames().mouseoverEvent, element->document()->defaultView(), underlyingEvent)).dispatch();
 
     if (mouseEventOptions != SendNoEvents)
-        EventDispatcher(node, SimulatedMouseEvent::create(eventNames().mousedownEvent, node->document()->defaultView(), underlyingEvent)).dispatch();
-    node->setActive(true, visualOptions == ShowPressedLook);
+        EventDispatcher(element, SimulatedMouseEvent::create(eventNames().mousedownEvent, element->document()->defaultView(), underlyingEvent)).dispatch();
+    element->setActive(true, visualOptions == ShowPressedLook);
     if (mouseEventOptions != SendNoEvents)
-        EventDispatcher(node, SimulatedMouseEvent::create(eventNames().mouseupEvent, node->document()->defaultView(), underlyingEvent)).dispatch();
-    node->setActive(false);
+        EventDispatcher(element, SimulatedMouseEvent::create(eventNames().mouseupEvent, element->document()->defaultView(), underlyingEvent)).dispatch();
+    element->setActive(false);
 
     // always send click
-    EventDispatcher(node, SimulatedMouseEvent::create(eventNames().clickEvent, node->document()->defaultView(), underlyingEvent)).dispatch();
+    EventDispatcher(element, SimulatedMouseEvent::create(eventNames().clickEvent, element->document()->defaultView(), underlyingEvent)).dispatch();
 
-    gNodesDispatchingSimulatedClicks->remove(node);
+    elementsDispatchingSimulatedClicks.remove(element);
 }
 
 bool EventDispatcher::dispatch()

Modified: trunk/Source/WebCore/dom/EventDispatcher.h (150713 => 150714)


--- trunk/Source/WebCore/dom/EventDispatcher.h	2013-05-26 12:10:23 UTC (rev 150713)
+++ trunk/Source/WebCore/dom/EventDispatcher.h	2013-05-26 13:32:36 UTC (rev 150714)
@@ -2,7 +2,7 @@
  * Copyright (C) 1999 Lars Knoll ([email protected])
  *           (C) 1999 Antti Koivisto ([email protected])
  *           (C) 2001 Dirk Mueller ([email protected])
- * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 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 Google Inc. All rights reserved.
@@ -56,7 +56,7 @@
     static bool dispatchEvent(Node*, PassRefPtr<EventDispatchMediator>);
     static void dispatchScopedEvent(Node*, PassRefPtr<EventDispatchMediator>);
 
-    static void dispatchSimulatedClick(Node*, Event* underlyingEvent, SimulatedClickMouseEventOptions, SimulatedClickVisualOptions);
+    static void dispatchSimulatedClick(Element*, Event* underlyingEvent, SimulatedClickMouseEventOptions, SimulatedClickVisualOptions);
 
     bool dispatch();
     Node* node() const { return m_node.get(); }

Modified: trunk/Source/WebCore/dom/Node.cpp (150713 => 150714)


--- trunk/Source/WebCore/dom/Node.cpp	2013-05-26 12:10:23 UTC (rev 150713)
+++ trunk/Source/WebCore/dom/Node.cpp	2013-05-26 13:32:36 UTC (rev 150714)
@@ -2404,11 +2404,6 @@
 }
 #endif
 
-void Node::dispatchSimulatedClick(Event* underlyingEvent, SimulatedClickMouseEventOptions eventOptions, SimulatedClickVisualOptions visualOptions)
-{
-    EventDispatcher::dispatchSimulatedClick(this, underlyingEvent, eventOptions, visualOptions);
-}
-
 bool Node::dispatchBeforeLoadEvent(const String& sourceURL)
 {
     if (!document()->hasListenerType(Document::BEFORELOAD_LISTENER))

Modified: trunk/Source/WebCore/dom/Node.h (150713 => 150714)


--- trunk/Source/WebCore/dom/Node.h	2013-05-26 12:10:23 UTC (rev 150713)
+++ trunk/Source/WebCore/dom/Node.h	2013-05-26 13:32:36 UTC (rev 150714)
@@ -633,7 +633,6 @@
     bool dispatchTouchEvent(PassRefPtr<TouchEvent>);
 #endif
 
-    void dispatchSimulatedClick(Event* underlyingEvent, SimulatedClickMouseEventOptions = SendNoEvents, SimulatedClickVisualOptions = ShowPressedLook);
     bool dispatchBeforeLoadEvent(const String& sourceURL);
 
     virtual void dispatchFocusEvent(PassRefPtr<Node> oldFocusedNode, FocusDirection);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to