Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(36)

Side by Side Diff: third_party/WebKit/Source/core/input/EventHandler.cpp

Issue 1479923002: Enumerate the return value of dispatchEvent so it is clear. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master_passive_uma_add
Patch Set: Rebase Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv ed. 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv ed.
3 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) 3 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org)
4 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies) 4 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies)
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 // is most significant. The enumeration is ordered with smaller specified 112 // is most significant. The enumeration is ordered with smaller specified
113 // numbers first. Examples of merged results are: 113 // numbers first. Examples of merged results are:
114 // (HandledApplication, HandledSystem) -> HandledSystem 114 // (HandledApplication, HandledSystem) -> HandledSystem
115 // (NotHandled, HandledApplication) -> HandledApplication 115 // (NotHandled, HandledApplication) -> HandledApplication
116 static_assert(static_cast<int>(WebInputEventResult::NotHandled) == 0, "WebIn putEventResult not ordered"); 116 static_assert(static_cast<int>(WebInputEventResult::NotHandled) == 0, "WebIn putEventResult not ordered");
117 static_assert(static_cast<int>(WebInputEventResult::HandledSuppressed) < sta tic_cast<int>(WebInputEventResult::HandledApplication), "WebInputEventResult not ordered"); 117 static_assert(static_cast<int>(WebInputEventResult::HandledSuppressed) < sta tic_cast<int>(WebInputEventResult::HandledApplication), "WebInputEventResult not ordered");
118 static_assert(static_cast<int>(WebInputEventResult::HandledApplication) < st atic_cast<int>(WebInputEventResult::HandledSystem), "WebInputEventResult not ord ered"); 118 static_assert(static_cast<int>(WebInputEventResult::HandledApplication) < st atic_cast<int>(WebInputEventResult::HandledSystem), "WebInputEventResult not ord ered");
119 return static_cast<WebInputEventResult>(max(static_cast<int>(responseA), sta tic_cast<int>(responseB))); 119 return static_cast<WebInputEventResult>(max(static_cast<int>(responseA), sta tic_cast<int>(responseB)));
120 } 120 }
121 121
122 WebInputEventResult eventToEventResult(PassRefPtrWillBeRawPtr<Event> event, bool res)
123 {
124 if (event->defaultPrevented())
125 return WebInputEventResult::HandledApplication;
126 if (event->defaultHandled())
127 return WebInputEventResult::HandledSystem;
128
129 // TODO(dtapuska): There are cases in the code where dispatchEvent
130 // returns false (indicated handled) but event is not marked
131 // as default handled or default prevented. crbug.com/560355
132 if (!res)
133 return WebInputEventResult::HandledSuppressed;
134 return WebInputEventResult::NotHandled;
135 }
136
137 bool isNodeInDocument(Node* n) 122 bool isNodeInDocument(Node* n)
138 { 123 {
139 return n && n->inDocument(); 124 return n && n->inDocument();
140 } 125 }
141 126
142 const AtomicString& touchEventNameForTouchPointState(PlatformTouchPoint::State s tate) 127 const AtomicString& touchEventNameForTouchPointState(PlatformTouchPoint::State s tate)
143 { 128 {
144 switch (state) { 129 switch (state) {
145 case PlatformTouchPoint::TouchReleased: 130 case PlatformTouchPoint::TouchReleased:
146 return EventTypeNames::touchend; 131 return EventTypeNames::touchend;
(...skipping 1227 matching lines...) Expand 10 before | Expand all | Expand 10 after
1374 // Both m_clickNode and mev.innerNode() don't need to be updated 1359 // Both m_clickNode and mev.innerNode() don't need to be updated
1375 // because commonAncestor() will exit early if their documents are diffe rent. 1360 // because commonAncestor() will exit early if their documents are diffe rent.
1376 m_clickNode->updateDistribution(); 1361 m_clickNode->updateDistribution();
1377 if (Node* clickTargetNode = mev.innerNode()->commonAncestor( 1362 if (Node* clickTargetNode = mev.innerNode()->commonAncestor(
1378 *m_clickNode, parentForClickEvent)) { 1363 *m_clickNode, parentForClickEvent)) {
1379 1364
1380 // Dispatch mouseup directly w/o calling updateMouseEventTargetNode 1365 // Dispatch mouseup directly w/o calling updateMouseEventTargetNode
1381 // because the mouseup dispatch above has already updated it 1366 // because the mouseup dispatch above has already updated it
1382 // correctly. Moreover, clickTargetNode is different from 1367 // correctly. Moreover, clickTargetNode is different from
1383 // mev.innerNode at drag-release. 1368 // mev.innerNode at drag-release.
1384 if (clickTargetNode->dispatchMouseEvent(mouseEvent, 1369 clickEventResult = clickTargetNode->dispatchMouseEvent(mouseEvent,
1385 EventTypeNames::click, m_clickCount)) { 1370 EventTypeNames::click, m_clickCount);
1386 clickEventResult = WebInputEventResult::HandledApplication;
1387 }
1388 } 1371 }
1389 } 1372 }
1390 1373
1391 if (m_resizeScrollableArea) { 1374 if (m_resizeScrollableArea) {
1392 m_resizeScrollableArea->setInResizeMode(false); 1375 m_resizeScrollableArea->setInResizeMode(false);
1393 m_resizeScrollableArea = nullptr; 1376 m_resizeScrollableArea = nullptr;
1394 } 1377 }
1395 1378
1396 if (eventResult == WebInputEventResult::NotHandled) 1379 if (eventResult == WebInputEventResult::NotHandled)
1397 eventResult = handleMouseReleaseEvent(mev); 1380 eventResult = handleMouseReleaseEvent(mev);
(...skipping 11 matching lines...) Expand all
1409 if (!view) 1392 if (!view)
1410 return WebInputEventResult::NotHandled; 1393 return WebInputEventResult::NotHandled;
1411 1394
1412 RefPtrWillBeRawPtr<DragEvent> me = DragEvent::create(eventType, 1395 RefPtrWillBeRawPtr<DragEvent> me = DragEvent::create(eventType,
1413 true, true, m_frame->document()->domWindow(), 1396 true, true, m_frame->document()->domWindow(),
1414 0, event.globalPosition().x(), event.globalPosition().y(), event.positio n().x(), event.position().y(), 1397 0, event.globalPosition().x(), event.globalPosition().y(), event.positio n().x(), event.position().y(),
1415 event.movementDelta().x(), event.movementDelta().y(), 1398 event.movementDelta().x(), event.movementDelta().y(),
1416 event.modifiers(), 1399 event.modifiers(),
1417 0, MouseEvent::platformModifiersToButtons(event.modifiers()), nullptr, e vent.timestamp(), dataTransfer, event.syntheticEventType()); 1400 0, MouseEvent::platformModifiersToButtons(event.modifiers()), nullptr, e vent.timestamp(), dataTransfer, event.syntheticEventType());
1418 1401
1419 bool dispatchResult = dragTarget->dispatchEvent(me.get()); 1402 return dragTarget->dispatchEvent(me.get());
1420 return eventToEventResult(me, dispatchResult);
1421 } 1403 }
1422 1404
1423 static bool targetIsFrame(Node* target, LocalFrame*& frame) 1405 static bool targetIsFrame(Node* target, LocalFrame*& frame)
1424 { 1406 {
1425 if (!isHTMLFrameElementBase(target)) 1407 if (!isHTMLFrameElementBase(target))
1426 return false; 1408 return false;
1427 1409
1428 // Cross-process drag and drop is not yet supported. 1410 // Cross-process drag and drop is not yet supported.
1429 if (toHTMLFrameElementBase(target)->contentFrame() && !toHTMLFrameElementBas e(target)->contentFrame()->isLocalFrame()) 1411 if (toHTMLFrameElementBase(target)->contentFrame() && !toHTMLFrameElementBas e(target)->contentFrame()->isLocalFrame())
1430 return false; 1412 return false;
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
1649 1631
1650 WebInputEventResult EventHandler::dispatchPointerEvent(Node* target, const Atomi cString& eventType, 1632 WebInputEventResult EventHandler::dispatchPointerEvent(Node* target, const Atomi cString& eventType,
1651 const PlatformMouseEvent& mouseEvent, Node* relatedTarget) 1633 const PlatformMouseEvent& mouseEvent, Node* relatedTarget)
1652 { 1634 {
1653 if (!RuntimeEnabledFeatures::pointerEventEnabled()) 1635 if (!RuntimeEnabledFeatures::pointerEventEnabled())
1654 return WebInputEventResult::NotHandled; 1636 return WebInputEventResult::NotHandled;
1655 1637
1656 RefPtrWillBeRawPtr<PointerEvent> pointerEvent = m_pointerEventFactory.create (eventType, 1638 RefPtrWillBeRawPtr<PointerEvent> pointerEvent = m_pointerEventFactory.create (eventType,
1657 mouseEvent, relatedTarget, m_frame->document()->domWindow()); 1639 mouseEvent, relatedTarget, m_frame->document()->domWindow());
1658 1640
1659 bool dispatchResult = target->dispatchEvent(pointerEvent.get()); 1641 return target->dispatchEvent(pointerEvent.get());
1660 return eventToEventResult(pointerEvent, dispatchResult);
1661 } 1642 }
1662 1643
1663 void EventHandler::sendMouseEventsForNodeTransition(Node* exitedNode, Node* ente redNode, 1644 void EventHandler::sendMouseEventsForNodeTransition(Node* exitedNode, Node* ente redNode,
1664 const PlatformMouseEvent& mouseEvent) 1645 const PlatformMouseEvent& mouseEvent)
1665 { 1646 {
1666 ASSERT(exitedNode != enteredNode); 1647 ASSERT(exitedNode != enteredNode);
1667 1648
1668 // Dispatch pointerout/mouseout events 1649 // Dispatch pointerout/mouseout events
1669 if (isNodeInDocument(exitedNode)) { 1650 if (isNodeInDocument(exitedNode)) {
1670 dispatchPointerEvent(exitedNode, EventTypeNames::pointerout, mouseEvent, enteredNode); 1651 dispatchPointerEvent(exitedNode, EventTypeNames::pointerout, mouseEvent, enteredNode);
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
1763 } 1744 }
1764 } 1745 }
1765 1746
1766 WebInputEventResult EventHandler::dispatchMouseEvent(const AtomicString& eventTy pe, Node* targetNode, int clickCount, const PlatformMouseEvent& mouseEvent) 1747 WebInputEventResult EventHandler::dispatchMouseEvent(const AtomicString& eventTy pe, Node* targetNode, int clickCount, const PlatformMouseEvent& mouseEvent)
1767 { 1748 {
1768 updateMouseEventTargetNode(targetNode, mouseEvent); 1749 updateMouseEventTargetNode(targetNode, mouseEvent);
1769 if (!m_nodeUnderMouse) 1750 if (!m_nodeUnderMouse)
1770 return WebInputEventResult::NotHandled; 1751 return WebInputEventResult::NotHandled;
1771 1752
1772 RefPtrWillBeRawPtr<MouseEvent> event = MouseEvent::create(eventType, m_nodeU nderMouse->document().domWindow(), mouseEvent, clickCount, nullptr); 1753 RefPtrWillBeRawPtr<MouseEvent> event = MouseEvent::create(eventType, m_nodeU nderMouse->document().domWindow(), mouseEvent, clickCount, nullptr);
1773 bool dispatchResult = m_nodeUnderMouse->dispatchEvent(event); 1754 return m_nodeUnderMouse->dispatchEvent(event);
1774 return eventToEventResult(event, dispatchResult);
1775 } 1755 }
1776 1756
1777 // TODO(mustaq): Make PE drive ME dispatch & bookkeeping in EventHandler. 1757 // TODO(mustaq): Make PE drive ME dispatch & bookkeeping in EventHandler.
1778 WebInputEventResult EventHandler::updatePointerTargetAndDispatchEvents(const Ato micString& mouseEventType, Node* targetNode, int clickCount, const PlatformMouse Event& mouseEvent) 1758 WebInputEventResult EventHandler::updatePointerTargetAndDispatchEvents(const Ato micString& mouseEventType, Node* targetNode, int clickCount, const PlatformMouse Event& mouseEvent)
1779 { 1759 {
1780 ASSERT(mouseEventType == EventTypeNames::mousedown 1760 ASSERT(mouseEventType == EventTypeNames::mousedown
1781 || mouseEventType == EventTypeNames::mousemove 1761 || mouseEventType == EventTypeNames::mousemove
1782 || mouseEventType == EventTypeNames::mouseup); 1762 || mouseEventType == EventTypeNames::mouseup);
1783 1763
1784 updateMouseEventTargetNode(targetNode, mouseEvent); 1764 updateMouseEventTargetNode(targetNode, mouseEvent);
1785 if (!m_nodeUnderMouse) 1765 if (!m_nodeUnderMouse)
1786 return WebInputEventResult::NotHandled; 1766 return WebInputEventResult::NotHandled;
1787 1767
1788 WebInputEventResult result = dispatchPointerEvent(m_nodeUnderMouse.get(), 1768 WebInputEventResult result = dispatchPointerEvent(m_nodeUnderMouse.get(),
1789 pointerEventNameForMouseEventName(mouseEventType), 1769 pointerEventNameForMouseEventName(mouseEventType),
1790 mouseEvent); 1770 mouseEvent);
1791 1771
1792 if (result != WebInputEventResult::NotHandled && mouseEventType == EventType Names::mousedown) { 1772 if (result != WebInputEventResult::NotHandled && mouseEventType == EventType Names::mousedown) {
1793 m_preventMouseEventForPointerTypeMouse = true; 1773 m_preventMouseEventForPointerTypeMouse = true;
1794 } 1774 }
1795 1775
1796 if (!m_preventMouseEventForPointerTypeMouse) { 1776 if (!m_preventMouseEventForPointerTypeMouse) {
1797 RefPtrWillBeRawPtr<MouseEvent> event = MouseEvent::create(mouseEventType , m_nodeUnderMouse->document().domWindow(), mouseEvent, clickCount, nullptr); 1777 RefPtrWillBeRawPtr<MouseEvent> event = MouseEvent::create(mouseEventType , m_nodeUnderMouse->document().domWindow(), mouseEvent, clickCount, nullptr);
1798 bool dispatchResult = m_nodeUnderMouse->dispatchEvent(event); 1778 result = mergeEventResult(result, m_nodeUnderMouse->dispatchEvent(event) );
1799 result = mergeEventResult(result, eventToEventResult(event, dispatchResu lt));
1800 } 1779 }
1801 1780
1802 return result; 1781 return result;
1803 } 1782 }
1804 1783
1805 WebInputEventResult EventHandler::handleMouseFocus(const MouseEventWithHitTestRe sults& targetedEvent, InputDeviceCapabilities* sourceCapabilities) 1784 WebInputEventResult EventHandler::handleMouseFocus(const MouseEventWithHitTestRe sults& targetedEvent, InputDeviceCapabilities* sourceCapabilities)
1806 { 1785 {
1807 // If clicking on a frame scrollbar, do not mess up with content focus. 1786 // If clicking on a frame scrollbar, do not mess up with content focus.
1808 if (targetedEvent.hitTestResult().scrollbar() && m_frame->contentLayoutObjec t()) { 1787 if (targetedEvent.hitTestResult().scrollbar() && m_frame->contentLayoutObjec t()) {
1809 if (targetedEvent.hitTestResult().scrollbar()->scrollableArea() == m_fra me->contentLayoutObject()->scrollableArea()) 1788 if (targetedEvent.hitTestResult().scrollbar()->scrollableArea() == m_fra me->contentLayoutObject()->scrollableArea())
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
1960 if (Widget* widget = toLayoutPart(target)->widget()) { 1939 if (Widget* widget = toLayoutPart(target)->widget()) {
1961 WebInputEventResult result = passWheelEventToWidget(event, *widg et); 1940 WebInputEventResult result = passWheelEventToWidget(event, *widg et);
1962 if (result != WebInputEventResult::NotHandled) { 1941 if (result != WebInputEventResult::NotHandled) {
1963 setFrameWasScrolledByUser(); 1942 setFrameWasScrolledByUser();
1964 return result; 1943 return result;
1965 } 1944 }
1966 } 1945 }
1967 } 1946 }
1968 1947
1969 RefPtrWillBeRawPtr<Event> domEvent = WheelEvent::create(event, node->doc ument().domWindow()); 1948 RefPtrWillBeRawPtr<Event> domEvent = WheelEvent::create(event, node->doc ument().domWindow());
1970 if (!node->dispatchEvent(domEvent)) { 1949 WebInputEventResult domEventResult = node->dispatchEvent(domEvent);
1950 if (domEventResult != WebInputEventResult::NotHandled) {
1971 setFrameWasScrolledByUser(); 1951 setFrameWasScrolledByUser();
1972 return eventToEventResult(domEvent, false); 1952 return domEventResult;
1973 } 1953 }
1974 } 1954 }
1975 1955
1976 // We do another check on the frame view because the event handler can run 1956 // We do another check on the frame view because the event handler can run
1977 // JS which results in the frame getting destroyed. 1957 // JS which results in the frame getting destroyed.
1978 view = m_frame->view(); 1958 view = m_frame->view();
1979 if (!view) 1959 if (!view)
1980 return WebInputEventResult::NotHandled; 1960 return WebInputEventResult::NotHandled;
1981 1961
1982 // Wheel events which do not scroll are used to trigger zooming. 1962 // Wheel events which do not scroll are used to trigger zooming.
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
2093 if (scrollbar) { 2073 if (scrollbar) {
2094 bool eventSwallowed = scrollbar->gestureEvent(gestureEvent); 2074 bool eventSwallowed = scrollbar->gestureEvent(gestureEvent);
2095 if (gestureEvent.type() == PlatformEvent::GestureTapDown && eventSwallow ed) 2075 if (gestureEvent.type() == PlatformEvent::GestureTapDown && eventSwallow ed)
2096 m_scrollbarHandlingScrollGesture = scrollbar; 2076 m_scrollbarHandlingScrollGesture = scrollbar;
2097 if (eventSwallowed) 2077 if (eventSwallowed)
2098 return WebInputEventResult::HandledSuppressed; 2078 return WebInputEventResult::HandledSuppressed;
2099 } 2079 }
2100 2080
2101 if (eventTarget) { 2081 if (eventTarget) {
2102 RefPtrWillBeRawPtr<GestureEvent> gestureDomEvent = GestureEvent::create( eventTarget->document().domWindow(), gestureEvent); 2082 RefPtrWillBeRawPtr<GestureEvent> gestureDomEvent = GestureEvent::create( eventTarget->document().domWindow(), gestureEvent);
2103 // TODO(dtapuska): dispatchEvent is inverted for Gesture Events 2083 if (gestureDomEvent.get()) {
2104 // crbug.com/560357 2084 WebInputEventResult gestureDomEventResult = eventTarget->dispatchEve nt(gestureDomEvent);
2105 if (gestureDomEvent.get() && eventTarget->dispatchEvent(gestureDomEvent) ) 2085 if (gestureDomEventResult != WebInputEventResult::NotHandled)
2106 return eventToEventResult(gestureDomEvent, false); 2086 return gestureDomEventResult;
2087 }
2107 } 2088 }
2108 2089
2109 switch (gestureEvent.type()) { 2090 switch (gestureEvent.type()) {
2110 case PlatformEvent::GestureTap: 2091 case PlatformEvent::GestureTap:
2111 return handleGestureTap(targetedEvent); 2092 return handleGestureTap(targetedEvent);
2112 case PlatformEvent::GestureShowPress: 2093 case PlatformEvent::GestureShowPress:
2113 return handleGestureShowPress(); 2094 return handleGestureShowPress();
2114 case PlatformEvent::GestureLongPress: 2095 case PlatformEvent::GestureLongPress:
2115 return handleGestureLongPress(targetedEvent); 2096 return handleGestureLongPress(targetedEvent);
2116 case PlatformEvent::GestureLongTap: 2097 case PlatformEvent::GestureLongTap:
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
2172 } 2153 }
2173 if (eventSwallowed) 2154 if (eventSwallowed)
2174 return WebInputEventResult::HandledSuppressed; 2155 return WebInputEventResult::HandledSuppressed;
2175 } 2156 }
2176 2157
2177 if (eventTarget) { 2158 if (eventTarget) {
2178 if (handleScrollGestureOnResizer(eventTarget.get(), gestureEvent)) 2159 if (handleScrollGestureOnResizer(eventTarget.get(), gestureEvent))
2179 return WebInputEventResult::HandledSuppressed; 2160 return WebInputEventResult::HandledSuppressed;
2180 2161
2181 RefPtrWillBeRawPtr<GestureEvent> gestureDomEvent = GestureEvent::create( eventTarget->document().domWindow(), gestureEvent); 2162 RefPtrWillBeRawPtr<GestureEvent> gestureDomEvent = GestureEvent::create( eventTarget->document().domWindow(), gestureEvent);
2182 // TODO(dtapuska): dispatchEvent is inverted for Gesture Events 2163 if (gestureDomEvent.get()) {
2183 // crbug.com/560357 2164 WebInputEventResult gestureDomEventResult = eventTarget->dispatchEve nt(gestureDomEvent);
2184 if (gestureDomEvent.get() && eventTarget->dispatchEvent(gestureDomEvent) ) 2165 if (gestureDomEventResult != WebInputEventResult::NotHandled)
2185 return eventToEventResult(gestureDomEvent, false); 2166 return gestureDomEventResult;
2167 }
2186 } 2168 }
2187 2169
2188 switch (gestureEvent.type()) { 2170 switch (gestureEvent.type()) {
2189 case PlatformEvent::GestureScrollBegin: 2171 case PlatformEvent::GestureScrollBegin:
2190 return handleGestureScrollBegin(gestureEvent); 2172 return handleGestureScrollBegin(gestureEvent);
2191 case PlatformEvent::GestureScrollUpdate: 2173 case PlatformEvent::GestureScrollUpdate:
2192 return handleGestureScrollUpdate(gestureEvent); 2174 return handleGestureScrollUpdate(gestureEvent);
2193 case PlatformEvent::GestureScrollEnd: 2175 case PlatformEvent::GestureScrollEnd:
2194 return handleGestureScrollEnd(gestureEvent); 2176 return handleGestureScrollEnd(gestureEvent);
2195 case PlatformEvent::GestureFlingStart: 2177 case PlatformEvent::GestureFlingStart:
(...skipping 1034 matching lines...) Expand 10 before | Expand all | Expand 10 after
3230 // On Windows, WebKit explicitly calls handleAccessKey() instead of dispatch ing a keypress event for WM_SYSCHAR messages. 3212 // On Windows, WebKit explicitly calls handleAccessKey() instead of dispatch ing a keypress event for WM_SYSCHAR messages.
3231 // Other platforms currently match either Mac or Windows behavior, depending on whether they send combined KeyDown events. 3213 // Other platforms currently match either Mac or Windows behavior, depending on whether they send combined KeyDown events.
3232 bool matchedAnAccessKey = false; 3214 bool matchedAnAccessKey = false;
3233 if (initialKeyEvent.type() == PlatformEvent::KeyDown) 3215 if (initialKeyEvent.type() == PlatformEvent::KeyDown)
3234 matchedAnAccessKey = handleAccessKey(initialKeyEvent); 3216 matchedAnAccessKey = handleAccessKey(initialKeyEvent);
3235 3217
3236 // FIXME: it would be fair to let an input method handle KeyUp events before DOM dispatch. 3218 // FIXME: it would be fair to let an input method handle KeyUp events before DOM dispatch.
3237 if (initialKeyEvent.type() == PlatformEvent::KeyUp || initialKeyEvent.type() == PlatformEvent::Char) { 3219 if (initialKeyEvent.type() == PlatformEvent::KeyUp || initialKeyEvent.type() == PlatformEvent::Char) {
3238 RefPtrWillBeRawPtr<KeyboardEvent> domEvent = KeyboardEvent::create(initi alKeyEvent, m_frame->document()->domWindow()); 3220 RefPtrWillBeRawPtr<KeyboardEvent> domEvent = KeyboardEvent::create(initi alKeyEvent, m_frame->document()->domWindow());
3239 3221
3240 bool dispatchResult = node->dispatchEvent(domEvent); 3222 return node->dispatchEvent(domEvent);
3241 return eventToEventResult(domEvent, dispatchResult);
3242 } 3223 }
3243 3224
3244 PlatformKeyboardEvent keyDownEvent = initialKeyEvent; 3225 PlatformKeyboardEvent keyDownEvent = initialKeyEvent;
3245 if (keyDownEvent.type() != PlatformEvent::RawKeyDown) 3226 if (keyDownEvent.type() != PlatformEvent::RawKeyDown)
3246 keyDownEvent.disambiguateKeyDownEvent(PlatformEvent::RawKeyDown); 3227 keyDownEvent.disambiguateKeyDownEvent(PlatformEvent::RawKeyDown);
3247 RefPtrWillBeRawPtr<KeyboardEvent> keydown = KeyboardEvent::create(keyDownEve nt, m_frame->document()->domWindow()); 3228 RefPtrWillBeRawPtr<KeyboardEvent> keydown = KeyboardEvent::create(keyDownEve nt, m_frame->document()->domWindow());
3248 if (matchedAnAccessKey) 3229 if (matchedAnAccessKey)
3249 keydown->setDefaultPrevented(true); 3230 keydown->setDefaultPrevented(true);
3250 keydown->setTarget(node); 3231 keydown->setTarget(node);
3251 3232
3252 if (initialKeyEvent.type() == PlatformEvent::RawKeyDown) { 3233 WebInputEventResult dispatchResult = node->dispatchEvent(keydown);
3253 if (!node->dispatchEvent(keydown)) 3234 if (dispatchResult != WebInputEventResult::NotHandled)
3254 return eventToEventResult(keydown, false); 3235 return dispatchResult;
3255 // If frame changed as a result of keydown dispatch, then return true to avoid sending a subsequent keypress message to the new frame.
3256 bool changedFocusedFrame = m_frame->page() && m_frame != m_frame->page() ->focusController().focusedOrMainFrame();
3257 if (changedFocusedFrame)
3258 return WebInputEventResult::HandledSystem;
3259 return WebInputEventResult::NotHandled;
3260 }
3261
3262 if (!node->dispatchEvent(keydown))
3263 return eventToEventResult(keydown, false);
3264 // If frame changed as a result of keydown dispatch, then return early to av oid sending a subsequent keypress message to the new frame. 3236 // If frame changed as a result of keydown dispatch, then return early to av oid sending a subsequent keypress message to the new frame.
3265 bool changedFocusedFrame = m_frame->page() && m_frame != m_frame->page()->fo cusController().focusedOrMainFrame(); 3237 bool changedFocusedFrame = m_frame->page() && m_frame != m_frame->page()->fo cusController().focusedOrMainFrame();
3266 if (changedFocusedFrame) 3238 if (changedFocusedFrame)
3267 return WebInputEventResult::HandledSystem; 3239 return WebInputEventResult::HandledSystem;
3268 3240
3241 if (initialKeyEvent.type() == PlatformEvent::RawKeyDown)
3242 return WebInputEventResult::NotHandled;
3243
3269 // Focus may have changed during keydown handling, so refetch node. 3244 // Focus may have changed during keydown handling, so refetch node.
3270 // But if we are dispatching a fake backward compatibility keypress, then we pretend that the keypress happened on the original node. 3245 // But if we are dispatching a fake backward compatibility keypress, then we pretend that the keypress happened on the original node.
3271 node = eventTargetNodeForDocument(m_frame->document()); 3246 node = eventTargetNodeForDocument(m_frame->document());
3272 if (!node) 3247 if (!node)
3273 return WebInputEventResult::NotHandled; 3248 return WebInputEventResult::NotHandled;
3274 3249
3275 PlatformKeyboardEvent keyPressEvent = initialKeyEvent; 3250 PlatformKeyboardEvent keyPressEvent = initialKeyEvent;
3276 keyPressEvent.disambiguateKeyDownEvent(PlatformEvent::Char); 3251 keyPressEvent.disambiguateKeyDownEvent(PlatformEvent::Char);
3277 if (keyPressEvent.text().isEmpty()) 3252 if (keyPressEvent.text().isEmpty())
3278 return WebInputEventResult::NotHandled; 3253 return WebInputEventResult::NotHandled;
3279 RefPtrWillBeRawPtr<KeyboardEvent> keypress = KeyboardEvent::create(keyPressE vent, m_frame->document()->domWindow()); 3254 RefPtrWillBeRawPtr<KeyboardEvent> keypress = KeyboardEvent::create(keyPressE vent, m_frame->document()->domWindow());
3280 keypress->setTarget(node); 3255 keypress->setTarget(node);
3281 bool dispatchResult = node->dispatchEvent(keypress); 3256 return node->dispatchEvent(keypress);
3282 return eventToEventResult(keypress, dispatchResult);
3283 } 3257 }
3284 3258
3285 static WebFocusType focusDirectionForKey(const AtomicString& keyIdentifier) 3259 static WebFocusType focusDirectionForKey(const AtomicString& keyIdentifier)
3286 { 3260 {
3287 DEFINE_STATIC_LOCAL(AtomicString, Down, ("Down", AtomicString::ConstructFrom Literal)); 3261 DEFINE_STATIC_LOCAL(AtomicString, Down, ("Down", AtomicString::ConstructFrom Literal));
3288 DEFINE_STATIC_LOCAL(AtomicString, Up, ("Up", AtomicString::ConstructFromLite ral)); 3262 DEFINE_STATIC_LOCAL(AtomicString, Up, ("Up", AtomicString::ConstructFromLite ral));
3289 DEFINE_STATIC_LOCAL(AtomicString, Left, ("Left", AtomicString::ConstructFrom Literal)); 3263 DEFINE_STATIC_LOCAL(AtomicString, Left, ("Left", AtomicString::ConstructFrom Literal));
3290 DEFINE_STATIC_LOCAL(AtomicString, Right, ("Right", AtomicString::ConstructFr omLiteral)); 3264 DEFINE_STATIC_LOCAL(AtomicString, Right, ("Right", AtomicString::ConstructFr omLiteral));
3291 3265
3292 WebFocusType retVal = WebFocusTypeNone; 3266 WebFocusType retVal = WebFocusTypeNone;
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after
3856 continue; 3830 continue;
3857 3831
3858 const AtomicString& eventName(touchEventNameForTouchPointState(static_ca st<PlatformTouchPoint::State>(state))); 3832 const AtomicString& eventName(touchEventNameForTouchPointState(static_ca st<PlatformTouchPoint::State>(state)));
3859 for (const auto& eventTarget : changedTouches[state].m_targets) { 3833 for (const auto& eventTarget : changedTouches[state].m_targets) {
3860 EventTarget* touchEventTarget = eventTarget.get(); 3834 EventTarget* touchEventTarget = eventTarget.get();
3861 RefPtrWillBeRawPtr<TouchEvent> touchEvent = TouchEvent::create( 3835 RefPtrWillBeRawPtr<TouchEvent> touchEvent = TouchEvent::create(
3862 touches.get(), touchesByTarget.get(touchEventTarget), changedTou ches[state].m_touches.get(), 3836 touches.get(), touchesByTarget.get(touchEventTarget), changedTou ches[state].m_touches.get(),
3863 eventName, touchEventTarget->toNode()->document().domWindow(), 3837 eventName, touchEventTarget->toNode()->document().domWindow(),
3864 event.modifiers(), event.cancelable(), event.causesScrollingIfUn canceled(), event.timestamp()); 3838 event.modifiers(), event.cancelable(), event.causesScrollingIfUn canceled(), event.timestamp());
3865 3839
3866 bool dispatchResult = touchEventTarget->dispatchEvent(touchEvent.get ()); 3840 eventResult = mergeEventResult(eventResult, touchEventTarget->dispat chEvent(touchEvent.get()));
3867 eventResult = mergeEventResult(eventResult, eventToEventResult(touch Event, dispatchResult));
3868 } 3841 }
3869 } 3842 }
3870 3843
3871 return eventResult; 3844 return eventResult;
3872 } 3845 }
3873 3846
3874 WebInputEventResult EventHandler::handleTouchEvent(const PlatformTouchEvent& eve nt) 3847 WebInputEventResult EventHandler::handleTouchEvent(const PlatformTouchEvent& eve nt)
3875 { 3848 {
3876 TRACE_EVENT0("blink", "EventHandler::handleTouchEvent"); 3849 TRACE_EVENT0("blink", "EventHandler::handleTouchEvent");
3877 3850
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
4135 PlatformEvent::Modifiers EventHandler::accessKeyModifiers() 4108 PlatformEvent::Modifiers EventHandler::accessKeyModifiers()
4136 { 4109 {
4137 #if OS(MACOSX) 4110 #if OS(MACOSX)
4138 return static_cast<PlatformEvent::Modifiers>(PlatformEvent::CtrlKey | Platfo rmEvent::AltKey); 4111 return static_cast<PlatformEvent::Modifiers>(PlatformEvent::CtrlKey | Platfo rmEvent::AltKey);
4139 #else 4112 #else
4140 return PlatformEvent::AltKey; 4113 return PlatformEvent::AltKey;
4141 #endif 4114 #endif
4142 } 4115 }
4143 4116
4144 } // namespace blink 4117 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698