Title: [135650] trunk/Source/WebCore
Revision
135650
Author
[email protected]
Date
2012-11-24 07:11:55 -0800 (Sat, 24 Nov 2012)

Log Message

It's confusing that return values of 'bool Node::dispatchEvent(...)' and 'bool Node::dispatchMouseEvent(..)' have the opposite meanings.
https://bugs.webkit.org/show_bug.cgi?id=103058

Reviewed by Ojan Vafai.

Refactor MouseEventDispatchMediator::dispatchEvent() and
EventHandler::dispatchMouseEvent() so that they return bool
which has the same meaning of the return value of
Node::dispatchEvent().

No tests. No change in behavior.

* dom/MouseEvent.cpp:
(WebCore::MouseEventDispatchMediator::dispatchEvent):
* page/EventHandler.cpp:
(WebCore::EventHandler::handleMousePressEvent):
(WebCore::EventHandler::handleMouseDoubleClickEvent):
(WebCore::EventHandler::handleMouseMoveEvent):
(WebCore::EventHandler::handleMouseReleaseEvent):
(WebCore::EventHandler::dispatchMouseEvent):
(WebCore::EventHandler::sendContextMenuEvent):
(WebCore::EventHandler::sendContextMenuEventForKey):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (135649 => 135650)


--- trunk/Source/WebCore/ChangeLog	2012-11-24 15:11:27 UTC (rev 135649)
+++ trunk/Source/WebCore/ChangeLog	2012-11-24 15:11:55 UTC (rev 135650)
@@ -1,3 +1,28 @@
+2012-11-24  Hayato Ito  <[email protected]>
+
+        It's confusing that return values of 'bool Node::dispatchEvent(...)' and 'bool Node::dispatchMouseEvent(..)' have the opposite meanings.
+        https://bugs.webkit.org/show_bug.cgi?id=103058
+
+        Reviewed by Ojan Vafai.
+
+        Refactor MouseEventDispatchMediator::dispatchEvent() and
+        EventHandler::dispatchMouseEvent() so that they return bool
+        which has the same meaning of the return value of
+        Node::dispatchEvent().
+
+        No tests. No change in behavior.
+
+        * dom/MouseEvent.cpp:
+        (WebCore::MouseEventDispatchMediator::dispatchEvent):
+        * page/EventHandler.cpp:
+        (WebCore::EventHandler::handleMousePressEvent):
+        (WebCore::EventHandler::handleMouseDoubleClickEvent):
+        (WebCore::EventHandler::handleMouseMoveEvent):
+        (WebCore::EventHandler::handleMouseReleaseEvent):
+        (WebCore::EventHandler::dispatchMouseEvent):
+        (WebCore::EventHandler::sendContextMenuEvent):
+        (WebCore::EventHandler::sendContextMenuEventForKey):
+
 2012-11-23  Kangil Han  <[email protected]>
 
         Fix unused parameter compile warnings

Modified: trunk/Source/WebCore/dom/MouseEvent.cpp (135649 => 135650)


--- trunk/Source/WebCore/dom/MouseEvent.cpp	2012-11-24 15:11:27 UTC (rev 135649)
+++ trunk/Source/WebCore/dom/MouseEvent.cpp	2012-11-24 15:11:55 UTC (rev 135650)
@@ -227,10 +227,10 @@
 bool MouseEventDispatchMediator::dispatchEvent(EventDispatcher* dispatcher) const
 {
     if (dispatcher->node()->disabled()) // Don't even send DOM events for disabled controls..
-        return true;
+        return false;
 
     if (event()->type().isEmpty())
-        return false; // Shouldn't happen.
+        return true; // Shouldn't happen.
 
     EventTarget* relatedTarget = event()->relatedTarget();
     dispatcher->adjustRelatedTarget(event(), relatedTarget);
@@ -239,7 +239,7 @@
     bool swallowEvent = event()->defaultHandled() || event()->defaultPrevented();
 
     if (event()->type() != eventNames().clickEvent || event()->detail() != 2)
-        return swallowEvent;
+        return !swallowEvent;
     // Special case: If it's a double click event, we also send the dblclick event. This is not part
     // of the DOM specs, but is used for compatibility with the _ondblclick_="" attribute. This is treated
     // as a separate event in other DOM-compliant browsers like Firefox, and so we do the same.
@@ -252,8 +252,8 @@
         doubleClickEvent->setDefaultHandled();
     EventDispatcher::dispatchEvent(dispatcher->node(), MouseEventDispatchMediator::create(doubleClickEvent));
     if (doubleClickEvent->defaultHandled() || doubleClickEvent->defaultPrevented())
-        return true;
-    return swallowEvent;
+        return false;
+    return !swallowEvent;
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/page/EventHandler.cpp (135649 => 135650)


--- trunk/Source/WebCore/page/EventHandler.cpp	2012-11-24 15:11:27 UTC (rev 135649)
+++ trunk/Source/WebCore/page/EventHandler.cpp	2012-11-24 15:11:55 UTC (rev 135650)
@@ -1646,7 +1646,7 @@
 
     m_frame->selection()->setCaretBlinkingSuspended(true);
 
-    bool swallowEvent = dispatchMouseEvent(eventNames().mousedownEvent, mev.targetNode(), true, m_clickCount, mouseEvent, true);
+    bool swallowEvent = !dispatchMouseEvent(eventNames().mousedownEvent, mev.targetNode(), true, m_clickCount, mouseEvent, true);
     m_capturesDragging = !swallowEvent || mev.scrollbar();
 
     // If the hit testing originally determined the event was in a scrollbar, refetch the MouseEventWithHitTestResults
@@ -1690,7 +1690,7 @@
             swallowEvent = handleMousePressEvent(mev);
     }
 
-    return swallowEvent;
+    return !swallowEvent;
 }
 
 // This method only exists for platforms that don't know how to deliver 
@@ -1714,9 +1714,9 @@
         return true;
 
     m_clickCount = mouseEvent.clickCount();
-    bool swallowMouseUpEvent = dispatchMouseEvent(eventNames().mouseupEvent, mev.targetNode(), true, m_clickCount, mouseEvent, false);
+    bool swallowMouseUpEvent = !dispatchMouseEvent(eventNames().mouseupEvent, mev.targetNode(), true, m_clickCount, mouseEvent, false);
 
-    bool swallowClickEvent = mouseEvent.button() != RightButton && mev.targetNode() == m_clickNode && dispatchMouseEvent(eventNames().clickEvent, mev.targetNode(), true, m_clickCount, mouseEvent, true);
+    bool swallowClickEvent = mouseEvent.button() != RightButton && mev.targetNode() == m_clickNode && !dispatchMouseEvent(eventNames().clickEvent, mev.targetNode(), true, m_clickCount, mouseEvent, true);
 
     if (m_lastScrollbarUnderMouse)
         swallowMouseUpEvent = m_lastScrollbarUnderMouse->mouseUp(mouseEvent);
@@ -1813,7 +1813,7 @@
 #endif
 
     if (m_frameSetBeingResized)
-        return dispatchMouseEvent(eventNames().mousemoveEvent, m_frameSetBeingResized.get(), false, 0, mouseEvent, false);
+        return !dispatchMouseEvent(eventNames().mousemoveEvent, m_frameSetBeingResized.get(), false, 0, mouseEvent, false);
 
     // Send events right to a scrollbar if the mouse is pressed.
     if (m_lastScrollbarUnderMouse && m_mousePressed)
@@ -1888,7 +1888,7 @@
     if (swallowEvent)
         return true;
     
-    swallowEvent = dispatchMouseEvent(eventNames().mousemoveEvent, mev.targetNode(), false, 0, mouseEvent, true);
+    swallowEvent = !dispatchMouseEvent(eventNames().mousemoveEvent, mev.targetNode(), false, 0, mouseEvent, true);
 #if ENABLE(DRAG_SUPPORT)
     if (!swallowEvent)
         swallowEvent = handleMouseDraggedEvent(mev);
@@ -1935,7 +1935,7 @@
 #endif
 
     if (m_frameSetBeingResized)
-        return dispatchMouseEvent(eventNames().mouseupEvent, m_frameSetBeingResized.get(), true, m_clickCount, mouseEvent, false);
+        return !dispatchMouseEvent(eventNames().mouseupEvent, m_frameSetBeingResized.get(), true, m_clickCount, mouseEvent, false);
 
     if (m_lastScrollbarUnderMouse) {
         invalidateClick();
@@ -1950,14 +1950,14 @@
     if (subframe && passMouseReleaseEventToSubframe(mev, subframe))
         return true;
 
-    bool swallowMouseUpEvent = dispatchMouseEvent(eventNames().mouseupEvent, mev.targetNode(), true, m_clickCount, mouseEvent, false);
+    bool swallowMouseUpEvent = !dispatchMouseEvent(eventNames().mouseupEvent, mev.targetNode(), true, m_clickCount, mouseEvent, false);
 
     Node* clickTarget = mev.targetNode();
     if (clickTarget)
         clickTarget = clickTarget->shadowAncestorNode();
     Node* adjustedClickNode = m_clickNode ? m_clickNode->shadowAncestorNode() : 0;
 
-    bool swallowClickEvent = m_clickCount > 0 && mouseEvent.button() != RightButton && clickTarget == adjustedClickNode && dispatchMouseEvent(eventNames().clickEvent, mev.targetNode(), true, m_clickCount, mouseEvent, true);
+    bool swallowClickEvent = m_clickCount > 0 && mouseEvent.button() != RightButton && clickTarget == adjustedClickNode && !dispatchMouseEvent(eventNames().clickEvent, mev.targetNode(), true, m_clickCount, mouseEvent, true);
 
     if (m_resizeLayer) {
         m_resizeLayer->setInResizeMode(false);
@@ -2342,14 +2342,14 @@
     bool swallowEvent = false;
 
     if (m_nodeUnderMouse)
-        swallowEvent = m_nodeUnderMouse->dispatchMouseEvent(mouseEvent, eventType, clickCount);
+        swallowEvent = !(m_nodeUnderMouse->dispatchMouseEvent(mouseEvent, eventType, clickCount));
 
     if (!swallowEvent && eventType == eventNames().mousedownEvent) {
 
         // If clicking on a frame scrollbar, do not mess up with content focus.
         if (FrameView* view = m_frame->view()) {
             if (view->scrollbarAtPoint(mouseEvent.position()))
-                return false;
+                return true;
         }
 
         // The layout needs to be up to date to determine if an element is focusable.
@@ -2372,7 +2372,7 @@
                 if (m_frame->selection()->isRange()
                     && m_frame->selection()->toNormalizedRange()->compareNode(n, ec) == Range::NODE_INSIDE
                     && n->isDescendantOf(m_frame->document()->focusedNode()))
-                    return false;
+                    return true;
                     
                 break;
             }
@@ -2392,7 +2392,7 @@
         }
     }
 
-    return swallowEvent;
+    return !swallowEvent;
 }
 
 #if !PLATFORM(GTK) && !(PLATFORM(CHROMIUM) && (OS(UNIX) && !OS(DARWIN)))
@@ -2796,7 +2796,7 @@
         selectClosestWordOrLinkFromMouseEvent(mev);
     }
 
-    swallowEvent = dispatchMouseEvent(eventNames().contextmenuEvent, mev.targetNode(), true, 0, event, false);
+    swallowEvent = !dispatchMouseEvent(eventNames().contextmenuEvent, mev.targetNode(), true, 0, event, false);
     
     return swallowEvent;
 }
@@ -2874,7 +2874,7 @@
 
     PlatformMouseEvent mouseEvent(position, globalPosition, RightButton, eventType, 1, false, false, false, false, WTF::currentTime());
 
-    return dispatchMouseEvent(eventNames().contextmenuEvent, targetNode, true, 0, mouseEvent, false);
+    return !dispatchMouseEvent(eventNames().contextmenuEvent, targetNode, true, 0, mouseEvent, false);
 }
 
 #if ENABLE(GESTURE_EVENTS)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to