Title: [105241] trunk/Source/WebCore
Revision
105241
Author
[email protected]
Date
2012-01-17 21:49:52 -0800 (Tue, 17 Jan 2012)

Log Message

Clean EventContext and move phase-tweaking logic to EventDispatcher.
https://bugs.webkit.org/show_bug.cgi?id=76414

Reviewed by Dimitri Glazkov.

No tests. No change in behavior.

* dom/EventContext.cpp:
(WebCore::EventContext::handleLocalEvents):
* dom/EventContext.h:
(WebCore::EventContext::currentTargetSameAsTarget):
* dom/EventDispatcher.cpp:
(WebCore::EventDispatcher::dispatchEvent):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (105240 => 105241)


--- trunk/Source/WebCore/ChangeLog	2012-01-18 04:28:36 UTC (rev 105240)
+++ trunk/Source/WebCore/ChangeLog	2012-01-18 05:49:52 UTC (rev 105241)
@@ -1,3 +1,19 @@
+2012-01-17  Hayato Ito  <[email protected]>
+
+        Clean EventContext and move phase-tweaking logic to EventDispatcher.
+        https://bugs.webkit.org/show_bug.cgi?id=76414
+
+        Reviewed by Dimitri Glazkov.
+
+        No tests. No change in behavior.
+
+        * dom/EventContext.cpp:
+        (WebCore::EventContext::handleLocalEvents):
+        * dom/EventContext.h:
+        (WebCore::EventContext::currentTargetSameAsTarget):
+        * dom/EventDispatcher.cpp:
+        (WebCore::EventDispatcher::dispatchEvent):
+
 2012-01-17  David Levin  <[email protected]>
 
         Need to figure out which assert is firing when worker-read-blob-async.html fails.

Modified: trunk/Source/WebCore/dom/EventContext.cpp (105240 => 105241)


--- trunk/Source/WebCore/dom/EventContext.cpp	2012-01-18 04:28:36 UTC (rev 105240)
+++ trunk/Source/WebCore/dom/EventContext.cpp	2012-01-18 05:49:52 UTC (rev 105241)
@@ -43,16 +43,9 @@
 
 void EventContext::handleLocalEvents(Event* event) const
 {
-    unsigned short eventPhase = event->eventPhase();
-    if (m_target.get() == m_currentTarget.get()) {
-        if (eventPhase == Event::CAPTURING_PHASE && event->bubbles())
-            return;
-        event->setEventPhase(Event::AT_TARGET);
-    }
     event->setTarget(m_target.get());
     event->setCurrentTarget(m_currentTarget.get());
     m_node->handleLocalEvents(event);
-    event->setEventPhase(eventPhase);
 }
 
 }

Modified: trunk/Source/WebCore/dom/EventContext.h (105240 => 105241)


--- trunk/Source/WebCore/dom/EventContext.h	2012-01-18 04:28:36 UTC (rev 105240)
+++ trunk/Source/WebCore/dom/EventContext.h	2012-01-18 05:49:52 UTC (rev 105241)
@@ -42,6 +42,7 @@
 
     Node* node() const;
     EventTarget* target() const;
+    bool currentTargetSameAsTarget() const;
     void handleLocalEvents(Event*) const;
 
 private:
@@ -60,6 +61,11 @@
     return m_target.get();
 }
 
+inline bool EventContext::currentTargetSameAsTarget() const
+{
+    return m_currentTarget.get() == m_target.get();
 }
 
+}
+
 #endif // EventContext_h

Modified: trunk/Source/WebCore/dom/EventDispatcher.cpp (105240 => 105241)


--- trunk/Source/WebCore/dom/EventDispatcher.cpp	2012-01-18 04:28:36 UTC (rev 105240)
+++ trunk/Source/WebCore/dom/EventDispatcher.cpp	2012-01-18 05:49:52 UTC (rev 105241)
@@ -308,7 +308,14 @@
         goto doneDispatching;
 
     for (size_t i = m_ancestors.size(); i; --i) {
-        m_ancestors[i - 1].handleLocalEvents(event.get());
+        const EventContext& eventContext = m_ancestors[i-1];
+        if (eventContext.currentTargetSameAsTarget()) {
+            if (event->bubbles())
+                continue;
+            event->setEventPhase(Event::AT_TARGET);
+        } else
+            event->setEventPhase(Event::CAPTURING_PHASE);
+        eventContext.handleLocalEvents(event.get());
         if (event->propagationStopped())
             goto doneDispatching;
     }
@@ -326,7 +333,12 @@
 
         size_t size = m_ancestors.size();
         for (size_t i = 0; i < size; ++i) {
-            m_ancestors[i].handleLocalEvents(event.get());
+            const EventContext& eventContext = m_ancestors[i];
+            if (eventContext.currentTargetSameAsTarget())
+                event->setEventPhase(Event::AT_TARGET);
+            else
+                event->setEventPhase(Event::BUBBLING_PHASE);
+            eventContext.handleLocalEvents(event.get());
             if (event->propagationStopped() || event->cancelBubble())
                 goto doneDispatching;
         }
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to