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

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: Rename enum values Created 4 years, 10 months 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 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 // is most significant. The enumeration is ordered with smaller specified 360 // is most significant. The enumeration is ordered with smaller specified
361 // numbers first. Examples of merged results are: 361 // numbers first. Examples of merged results are:
362 // (HandledApplication, HandledSystem) -> HandledSystem 362 // (HandledApplication, HandledSystem) -> HandledSystem
363 // (NotHandled, HandledApplication) -> HandledApplication 363 // (NotHandled, HandledApplication) -> HandledApplication
364 static_assert(static_cast<int>(WebInputEventResult::NotHandled) == 0, "WebIn putEventResult not ordered"); 364 static_assert(static_cast<int>(WebInputEventResult::NotHandled) == 0, "WebIn putEventResult not ordered");
365 static_assert(static_cast<int>(WebInputEventResult::HandledSuppressed) < sta tic_cast<int>(WebInputEventResult::HandledApplication), "WebInputEventResult not ordered"); 365 static_assert(static_cast<int>(WebInputEventResult::HandledSuppressed) < sta tic_cast<int>(WebInputEventResult::HandledApplication), "WebInputEventResult not ordered");
366 static_assert(static_cast<int>(WebInputEventResult::HandledApplication) < st atic_cast<int>(WebInputEventResult::HandledSystem), "WebInputEventResult not ord ered"); 366 static_assert(static_cast<int>(WebInputEventResult::HandledApplication) < st atic_cast<int>(WebInputEventResult::HandledSystem), "WebInputEventResult not ord ered");
367 return static_cast<WebInputEventResult>(max(static_cast<int>(resultA), stati c_cast<int>(resultB))); 367 return static_cast<WebInputEventResult>(max(static_cast<int>(resultA), stati c_cast<int>(resultB)));
368 } 368 }
369 369
370 WebInputEventResult EventHandler::eventToEventResult( 370 WebInputEventResult EventHandler::toWebInputEventResultWithStrictAsserts(
371 PassRefPtrWillBeRawPtr<Event> event, bool result) 371 DispatchEventResult result)
372 { 372 {
373 if (event->defaultPrevented()) 373 switch (result) {
374 case DispatchEventResult::NotCanceled:
375 return WebInputEventResult::NotHandled;
376 case DispatchEventResult::CanceledByEventHandler:
374 return WebInputEventResult::HandledApplication; 377 return WebInputEventResult::HandledApplication;
375 if (event->defaultHandled()) 378 case DispatchEventResult::CanceledByDefaultEventHandler:
379 ASSERT_NOT_REACHED();
376 return WebInputEventResult::HandledSystem; 380 return WebInputEventResult::HandledSystem;
381 case DispatchEventResult::CanceledBeforeDispatch:
382 ASSERT_NOT_REACHED();
383 return WebInputEventResult::HandledSuppressed;
384 }
385 }
377 386
378 // TODO(dtapuska): There are cases in the code where dispatchEvent 387 WebInputEventResult EventHandler::toWebInputEventResult(
379 // returns false (indicated handled) but event is not marked 388 DispatchEventResult result)
380 // as default handled or default prevented. crbug.com/560355 389 {
381 if (!result) 390 switch (result) {
391 case DispatchEventResult::NotCanceled:
392 return WebInputEventResult::NotHandled;
393 case DispatchEventResult::CanceledByEventHandler:
394 return WebInputEventResult::HandledApplication;
395 case DispatchEventResult::CanceledByDefaultEventHandler:
396 return WebInputEventResult::HandledSystem;
397 case DispatchEventResult::CanceledBeforeDispatch:
382 return WebInputEventResult::HandledSuppressed; 398 return WebInputEventResult::HandledSuppressed;
383 return WebInputEventResult::NotHandled; 399 }
384 } 400 }
385 401
386 void EventHandler::nodeWillBeRemoved(Node& nodeToBeRemoved) 402 void EventHandler::nodeWillBeRemoved(Node& nodeToBeRemoved)
387 { 403 {
388 if (nodeToBeRemoved.containsIncludingShadowDOM(m_clickNode.get())) { 404 if (nodeToBeRemoved.containsIncludingShadowDOM(m_clickNode.get())) {
389 // We don't dispatch click events if the mousedown node is removed 405 // We don't dispatch click events if the mousedown node is removed
390 // before a mouseup event. It is compatible with IE and Firefox. 406 // before a mouseup event. It is compatible with IE and Firefox.
391 m_clickNode = nullptr; 407 m_clickNode = nullptr;
392 } 408 }
393 } 409 }
(...skipping 947 matching lines...) Expand 10 before | Expand all | Expand 10 after
1341 // Both m_clickNode and mev.innerNode() don't need to be updated 1357 // Both m_clickNode and mev.innerNode() don't need to be updated
1342 // because commonAncestor() will exit early if their documents are diffe rent. 1358 // because commonAncestor() will exit early if their documents are diffe rent.
1343 m_clickNode->updateDistribution(); 1359 m_clickNode->updateDistribution();
1344 if (Node* clickTargetNode = mev.innerNode()->commonAncestor( 1360 if (Node* clickTargetNode = mev.innerNode()->commonAncestor(
1345 *m_clickNode, parentForClickEvent)) { 1361 *m_clickNode, parentForClickEvent)) {
1346 1362
1347 // Dispatch mouseup directly w/o calling updateMouseEventTargetNode 1363 // Dispatch mouseup directly w/o calling updateMouseEventTargetNode
1348 // because the mouseup dispatch above has already updated it 1364 // because the mouseup dispatch above has already updated it
1349 // correctly. Moreover, clickTargetNode is different from 1365 // correctly. Moreover, clickTargetNode is different from
1350 // mev.innerNode at drag-release. 1366 // mev.innerNode at drag-release.
1351 if (clickTargetNode->dispatchMouseEvent(mouseEvent, 1367 clickEventResult = toWebInputEventResult(clickTargetNode->dispatchMo useEvent(mouseEvent,
1352 EventTypeNames::click, m_clickCount)) { 1368 EventTypeNames::click, m_clickCount));
1353 clickEventResult = WebInputEventResult::HandledApplication;
1354 }
1355 } 1369 }
1356 } 1370 }
1357 1371
1358 if (m_resizeScrollableArea) { 1372 if (m_resizeScrollableArea) {
1359 m_resizeScrollableArea->setInResizeMode(false); 1373 m_resizeScrollableArea->setInResizeMode(false);
1360 m_resizeScrollableArea = nullptr; 1374 m_resizeScrollableArea = nullptr;
1361 } 1375 }
1362 1376
1363 if (eventResult == WebInputEventResult::NotHandled) 1377 if (eventResult == WebInputEventResult::NotHandled)
1364 eventResult = handleMouseReleaseEvent(mev); 1378 eventResult = handleMouseReleaseEvent(mev);
(...skipping 11 matching lines...) Expand all
1376 if (!view) 1390 if (!view)
1377 return WebInputEventResult::NotHandled; 1391 return WebInputEventResult::NotHandled;
1378 1392
1379 RefPtrWillBeRawPtr<DragEvent> me = DragEvent::create(eventType, 1393 RefPtrWillBeRawPtr<DragEvent> me = DragEvent::create(eventType,
1380 true, true, m_frame->document()->domWindow(), 1394 true, true, m_frame->document()->domWindow(),
1381 0, event.globalPosition().x(), event.globalPosition().y(), event.positio n().x(), event.position().y(), 1395 0, event.globalPosition().x(), event.globalPosition().y(), event.positio n().x(), event.position().y(),
1382 event.movementDelta().x(), event.movementDelta().y(), 1396 event.movementDelta().x(), event.movementDelta().y(),
1383 event.modifiers(), 1397 event.modifiers(),
1384 0, MouseEvent::platformModifiersToButtons(event.modifiers()), nullptr, e vent.timestamp(), dataTransfer, event.syntheticEventType()); 1398 0, MouseEvent::platformModifiersToButtons(event.modifiers()), nullptr, e vent.timestamp(), dataTransfer, event.syntheticEventType());
1385 1399
1386 bool dispatchResult = dragTarget->dispatchEvent(me.get()); 1400 return toWebInputEventResult(dragTarget->dispatchEvent(me.get()));
1387 return eventToEventResult(me, dispatchResult);
1388 } 1401 }
1389 1402
1390 static bool targetIsFrame(Node* target, LocalFrame*& frame) 1403 static bool targetIsFrame(Node* target, LocalFrame*& frame)
1391 { 1404 {
1392 if (!isHTMLFrameElementBase(target)) 1405 if (!isHTMLFrameElementBase(target))
1393 return false; 1406 return false;
1394 1407
1395 // Cross-process drag and drop is not yet supported. 1408 // Cross-process drag and drop is not yet supported.
1396 if (toHTMLFrameElementBase(target)->contentFrame() && !toHTMLFrameElementBas e(target)->contentFrame()->isLocalFrame()) 1409 if (toHTMLFrameElementBase(target)->contentFrame() && !toHTMLFrameElementBas e(target)->contentFrame()->isLocalFrame())
1397 return false; 1410 return false;
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
1614 m_nodeUnderMouse, mouseEvent, m_frame->document()->domWindow()); 1627 m_nodeUnderMouse, mouseEvent, m_frame->document()->domWindow());
1615 } 1628 }
1616 1629
1617 WebInputEventResult EventHandler::dispatchMouseEvent(const AtomicString& eventTy pe, Node* targetNode, int clickCount, const PlatformMouseEvent& mouseEvent) 1630 WebInputEventResult EventHandler::dispatchMouseEvent(const AtomicString& eventTy pe, Node* targetNode, int clickCount, const PlatformMouseEvent& mouseEvent)
1618 { 1631 {
1619 updateMouseEventTargetNode(targetNode, mouseEvent); 1632 updateMouseEventTargetNode(targetNode, mouseEvent);
1620 if (!m_nodeUnderMouse) 1633 if (!m_nodeUnderMouse)
1621 return WebInputEventResult::NotHandled; 1634 return WebInputEventResult::NotHandled;
1622 1635
1623 RefPtrWillBeRawPtr<MouseEvent> event = MouseEvent::create(eventType, m_nodeU nderMouse->document().domWindow(), mouseEvent, clickCount, nullptr); 1636 RefPtrWillBeRawPtr<MouseEvent> event = MouseEvent::create(eventType, m_nodeU nderMouse->document().domWindow(), mouseEvent, clickCount, nullptr);
1624 bool dispatchResult = m_nodeUnderMouse->dispatchEvent(event); 1637 return toWebInputEventResult(m_nodeUnderMouse->dispatchEvent(event));
1625 return eventToEventResult(event, dispatchResult);
1626 } 1638 }
1627 1639
1628 // TODO(mustaq): Make PE drive ME dispatch & bookkeeping in EventHandler. 1640 // TODO(mustaq): Make PE drive ME dispatch & bookkeeping in EventHandler.
1629 WebInputEventResult EventHandler::updatePointerTargetAndDispatchEvents(const Ato micString& mouseEventType, Node* targetNode, int clickCount, const PlatformMouse Event& mouseEvent) 1641 WebInputEventResult EventHandler::updatePointerTargetAndDispatchEvents(const Ato micString& mouseEventType, Node* targetNode, int clickCount, const PlatformMouse Event& mouseEvent)
1630 { 1642 {
1631 ASSERT(mouseEventType == EventTypeNames::mousedown 1643 ASSERT(mouseEventType == EventTypeNames::mousedown
1632 || mouseEventType == EventTypeNames::mousemove 1644 || mouseEventType == EventTypeNames::mousemove
1633 || mouseEventType == EventTypeNames::mouseup); 1645 || mouseEventType == EventTypeNames::mouseup);
1634 1646
1635 updateMouseEventTargetNode(targetNode, mouseEvent); 1647 updateMouseEventTargetNode(targetNode, mouseEvent);
1636 if (!m_nodeUnderMouse) 1648 if (!m_nodeUnderMouse)
1637 return WebInputEventResult::NotHandled; 1649 return WebInputEventResult::NotHandled;
1638 1650
1639 WebInputEventResult result = m_pointerEventManager.sendMousePointerEvent( 1651 return m_pointerEventManager.sendMousePointerEvent(
1640 m_nodeUnderMouse, mouseEventType, clickCount, mouseEvent, nullptr, 1652 m_nodeUnderMouse, mouseEventType, clickCount, mouseEvent, nullptr,
1641 m_frame->document()->domWindow()); 1653 m_frame->document()->domWindow());
1642
1643 return result;
1644 } 1654 }
1645 1655
1646 WebInputEventResult EventHandler::handleMouseFocus(const MouseEventWithHitTestRe sults& targetedEvent, InputDeviceCapabilities* sourceCapabilities) 1656 WebInputEventResult EventHandler::handleMouseFocus(const MouseEventWithHitTestRe sults& targetedEvent, InputDeviceCapabilities* sourceCapabilities)
1647 { 1657 {
1648 // If clicking on a frame scrollbar, do not mess up with content focus. 1658 // If clicking on a frame scrollbar, do not mess up with content focus.
1649 if (targetedEvent.hitTestResult().scrollbar() && m_frame->contentLayoutObjec t()) { 1659 if (targetedEvent.hitTestResult().scrollbar() && m_frame->contentLayoutObjec t()) {
1650 if (targetedEvent.hitTestResult().scrollbar()->scrollableArea() == m_fra me->contentLayoutObject()->scrollableArea()) 1660 if (targetedEvent.hitTestResult().scrollbar()->scrollableArea() == m_fra me->contentLayoutObject()->scrollableArea())
1651 return WebInputEventResult::NotHandled; 1661 return WebInputEventResult::NotHandled;
1652 } 1662 }
1653 1663
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
1801 if (Widget* widget = toLayoutPart(target)->widget()) { 1811 if (Widget* widget = toLayoutPart(target)->widget()) {
1802 WebInputEventResult result = passWheelEventToWidget(event, *widg et); 1812 WebInputEventResult result = passWheelEventToWidget(event, *widg et);
1803 if (result != WebInputEventResult::NotHandled) { 1813 if (result != WebInputEventResult::NotHandled) {
1804 setFrameWasScrolledByUser(); 1814 setFrameWasScrolledByUser();
1805 return result; 1815 return result;
1806 } 1816 }
1807 } 1817 }
1808 } 1818 }
1809 1819
1810 RefPtrWillBeRawPtr<Event> domEvent = WheelEvent::create(event, node->doc ument().domWindow()); 1820 RefPtrWillBeRawPtr<Event> domEvent = WheelEvent::create(event, node->doc ument().domWindow());
1811 if (!node->dispatchEvent(domEvent)) { 1821 DispatchEventResult domEventResult = node->dispatchEvent(domEvent);
1822 if (domEventResult != DispatchEventResult::NotCanceled) {
1812 setFrameWasScrolledByUser(); 1823 setFrameWasScrolledByUser();
1813 return eventToEventResult(domEvent, false); 1824 return toWebInputEventResult(domEventResult);
1814 } 1825 }
1815 } 1826 }
1816 1827
1817 // We do another check on the frame view because the event handler can run 1828 // We do another check on the frame view because the event handler can run
1818 // JS which results in the frame getting destroyed. 1829 // JS which results in the frame getting destroyed.
1819 view = m_frame->view(); 1830 view = m_frame->view();
1820 if (!view) 1831 if (!view)
1821 return WebInputEventResult::NotHandled; 1832 return WebInputEventResult::NotHandled;
1822 1833
1823 // Wheel events which do not scroll are used to trigger zooming. 1834 // Wheel events which do not scroll are used to trigger zooming.
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
1933 if (scrollbar) { 1944 if (scrollbar) {
1934 bool eventSwallowed = scrollbar->gestureEvent(gestureEvent); 1945 bool eventSwallowed = scrollbar->gestureEvent(gestureEvent);
1935 if (gestureEvent.type() == PlatformEvent::GestureTapDown && eventSwallow ed) 1946 if (gestureEvent.type() == PlatformEvent::GestureTapDown && eventSwallow ed)
1936 m_scrollbarHandlingScrollGesture = scrollbar; 1947 m_scrollbarHandlingScrollGesture = scrollbar;
1937 if (eventSwallowed) 1948 if (eventSwallowed)
1938 return WebInputEventResult::HandledSuppressed; 1949 return WebInputEventResult::HandledSuppressed;
1939 } 1950 }
1940 1951
1941 if (eventTarget) { 1952 if (eventTarget) {
1942 RefPtrWillBeRawPtr<GestureEvent> gestureDomEvent = GestureEvent::create( eventTarget->document().domWindow(), gestureEvent); 1953 RefPtrWillBeRawPtr<GestureEvent> gestureDomEvent = GestureEvent::create( eventTarget->document().domWindow(), gestureEvent);
1943 // TODO(dtapuska): dispatchEvent is inverted for Gesture Events 1954 if (gestureDomEvent.get()) {
1944 // crbug.com/560357 1955 DispatchEventResult gestureDomEventResult = eventTarget->dispatchEve nt(gestureDomEvent);
1945 if (gestureDomEvent.get() && eventTarget->dispatchEvent(gestureDomEvent) ) 1956 if (gestureDomEventResult != DispatchEventResult::NotCanceled)
1946 return eventToEventResult(gestureDomEvent, false); 1957 return toWebInputEventResultWithStrictAsserts(gestureDomEventRes ult);
1958 }
1947 } 1959 }
1948 1960
1949 switch (gestureEvent.type()) { 1961 switch (gestureEvent.type()) {
1950 case PlatformEvent::GestureTap: 1962 case PlatformEvent::GestureTap:
1951 return handleGestureTap(targetedEvent); 1963 return handleGestureTap(targetedEvent);
1952 case PlatformEvent::GestureShowPress: 1964 case PlatformEvent::GestureShowPress:
1953 return handleGestureShowPress(); 1965 return handleGestureShowPress();
1954 case PlatformEvent::GestureLongPress: 1966 case PlatformEvent::GestureLongPress:
1955 return handleGestureLongPress(targetedEvent); 1967 return handleGestureLongPress(targetedEvent);
1956 case PlatformEvent::GestureLongTap: 1968 case PlatformEvent::GestureLongTap:
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
2012 } 2024 }
2013 if (eventSwallowed) 2025 if (eventSwallowed)
2014 return WebInputEventResult::HandledSuppressed; 2026 return WebInputEventResult::HandledSuppressed;
2015 } 2027 }
2016 2028
2017 if (eventTarget) { 2029 if (eventTarget) {
2018 if (handleScrollGestureOnResizer(eventTarget.get(), gestureEvent)) 2030 if (handleScrollGestureOnResizer(eventTarget.get(), gestureEvent))
2019 return WebInputEventResult::HandledSuppressed; 2031 return WebInputEventResult::HandledSuppressed;
2020 2032
2021 RefPtrWillBeRawPtr<GestureEvent> gestureDomEvent = GestureEvent::create( eventTarget->document().domWindow(), gestureEvent); 2033 RefPtrWillBeRawPtr<GestureEvent> gestureDomEvent = GestureEvent::create( eventTarget->document().domWindow(), gestureEvent);
2022 // TODO(dtapuska): dispatchEvent is inverted for Gesture Events 2034 if (gestureDomEvent.get()) {
2023 // crbug.com/560357 2035 DispatchEventResult gestureDomEventResult = eventTarget->dispatchEve nt(gestureDomEvent);
2024 if (gestureDomEvent.get() && eventTarget->dispatchEvent(gestureDomEvent) ) 2036 if (gestureDomEventResult != DispatchEventResult::NotCanceled)
2025 return eventToEventResult(gestureDomEvent, false); 2037 return toWebInputEventResultWithStrictAsserts(gestureDomEventRes ult);
2038 }
2026 } 2039 }
2027 2040
2028 switch (gestureEvent.type()) { 2041 switch (gestureEvent.type()) {
2029 case PlatformEvent::GestureScrollBegin: 2042 case PlatformEvent::GestureScrollBegin:
2030 return handleGestureScrollBegin(gestureEvent); 2043 return handleGestureScrollBegin(gestureEvent);
2031 case PlatformEvent::GestureScrollUpdate: 2044 case PlatformEvent::GestureScrollUpdate:
2032 return handleGestureScrollUpdate(gestureEvent); 2045 return handleGestureScrollUpdate(gestureEvent);
2033 case PlatformEvent::GestureScrollEnd: 2046 case PlatformEvent::GestureScrollEnd:
2034 return handleGestureScrollEnd(gestureEvent); 2047 return handleGestureScrollEnd(gestureEvent);
2035 case PlatformEvent::GestureFlingStart: 2048 case PlatformEvent::GestureFlingStart:
(...skipping 1051 matching lines...) Expand 10 before | Expand all | Expand 10 after
3087 // On Windows, WebKit explicitly calls handleAccessKey() instead of dispatch ing a keypress event for WM_SYSCHAR messages. 3100 // On Windows, WebKit explicitly calls handleAccessKey() instead of dispatch ing a keypress event for WM_SYSCHAR messages.
3088 // Other platforms currently match either Mac or Windows behavior, depending on whether they send combined KeyDown events. 3101 // Other platforms currently match either Mac or Windows behavior, depending on whether they send combined KeyDown events.
3089 bool matchedAnAccessKey = false; 3102 bool matchedAnAccessKey = false;
3090 if (initialKeyEvent.type() == PlatformEvent::KeyDown) 3103 if (initialKeyEvent.type() == PlatformEvent::KeyDown)
3091 matchedAnAccessKey = handleAccessKey(initialKeyEvent); 3104 matchedAnAccessKey = handleAccessKey(initialKeyEvent);
3092 3105
3093 // FIXME: it would be fair to let an input method handle KeyUp events before DOM dispatch. 3106 // FIXME: it would be fair to let an input method handle KeyUp events before DOM dispatch.
3094 if (initialKeyEvent.type() == PlatformEvent::KeyUp || initialKeyEvent.type() == PlatformEvent::Char) { 3107 if (initialKeyEvent.type() == PlatformEvent::KeyUp || initialKeyEvent.type() == PlatformEvent::Char) {
3095 RefPtrWillBeRawPtr<KeyboardEvent> domEvent = KeyboardEvent::create(initi alKeyEvent, m_frame->document()->domWindow()); 3108 RefPtrWillBeRawPtr<KeyboardEvent> domEvent = KeyboardEvent::create(initi alKeyEvent, m_frame->document()->domWindow());
3096 3109
3097 bool dispatchResult = node->dispatchEvent(domEvent); 3110 return toWebInputEventResult(node->dispatchEvent(domEvent));
3098 return eventToEventResult(domEvent, dispatchResult);
3099 } 3111 }
3100 3112
3101 PlatformKeyboardEvent keyDownEvent = initialKeyEvent; 3113 PlatformKeyboardEvent keyDownEvent = initialKeyEvent;
3102 if (keyDownEvent.type() != PlatformEvent::RawKeyDown) 3114 if (keyDownEvent.type() != PlatformEvent::RawKeyDown)
3103 keyDownEvent.disambiguateKeyDownEvent(PlatformEvent::RawKeyDown); 3115 keyDownEvent.disambiguateKeyDownEvent(PlatformEvent::RawKeyDown);
3104 RefPtrWillBeRawPtr<KeyboardEvent> keydown = KeyboardEvent::create(keyDownEve nt, m_frame->document()->domWindow()); 3116 RefPtrWillBeRawPtr<KeyboardEvent> keydown = KeyboardEvent::create(keyDownEve nt, m_frame->document()->domWindow());
3105 if (matchedAnAccessKey) 3117 if (matchedAnAccessKey)
3106 keydown->setDefaultPrevented(true); 3118 keydown->setDefaultPrevented(true);
3107 keydown->setTarget(node); 3119 keydown->setTarget(node);
3108 3120
3109 if (initialKeyEvent.type() == PlatformEvent::RawKeyDown) { 3121 DispatchEventResult dispatchResult = node->dispatchEvent(keydown);
3110 if (!node->dispatchEvent(keydown)) 3122 if (dispatchResult != DispatchEventResult::NotCanceled)
3111 return eventToEventResult(keydown, false); 3123 return toWebInputEventResult(dispatchResult);
3112 // If frame changed as a result of keydown dispatch, then return true to avoid sending a subsequent keypress message to the new frame.
3113 bool changedFocusedFrame = m_frame->page() && m_frame != m_frame->page() ->focusController().focusedOrMainFrame();
3114 if (changedFocusedFrame)
3115 return WebInputEventResult::HandledSystem;
3116 return WebInputEventResult::NotHandled;
3117 }
3118
3119 if (!node->dispatchEvent(keydown))
3120 return eventToEventResult(keydown, false);
3121 // If frame changed as a result of keydown dispatch, then return early to av oid sending a subsequent keypress message to the new frame. 3124 // If frame changed as a result of keydown dispatch, then return early to av oid sending a subsequent keypress message to the new frame.
3122 bool changedFocusedFrame = m_frame->page() && m_frame != m_frame->page()->fo cusController().focusedOrMainFrame(); 3125 bool changedFocusedFrame = m_frame->page() && m_frame != m_frame->page()->fo cusController().focusedOrMainFrame();
3123 if (changedFocusedFrame) 3126 if (changedFocusedFrame)
3124 return WebInputEventResult::HandledSystem; 3127 return WebInputEventResult::HandledSystem;
3125 3128
3129 if (initialKeyEvent.type() == PlatformEvent::RawKeyDown)
3130 return WebInputEventResult::NotHandled;
3131
3126 // Focus may have changed during keydown handling, so refetch node. 3132 // Focus may have changed during keydown handling, so refetch node.
3127 // But if we are dispatching a fake backward compatibility keypress, then we pretend that the keypress happened on the original node. 3133 // But if we are dispatching a fake backward compatibility keypress, then we pretend that the keypress happened on the original node.
3128 node = eventTargetNodeForDocument(m_frame->document()); 3134 node = eventTargetNodeForDocument(m_frame->document());
3129 if (!node) 3135 if (!node)
3130 return WebInputEventResult::NotHandled; 3136 return WebInputEventResult::NotHandled;
3131 3137
3132 PlatformKeyboardEvent keyPressEvent = initialKeyEvent; 3138 PlatformKeyboardEvent keyPressEvent = initialKeyEvent;
3133 keyPressEvent.disambiguateKeyDownEvent(PlatformEvent::Char); 3139 keyPressEvent.disambiguateKeyDownEvent(PlatformEvent::Char);
3134 if (keyPressEvent.text().isEmpty()) 3140 if (keyPressEvent.text().isEmpty())
3135 return WebInputEventResult::NotHandled; 3141 return WebInputEventResult::NotHandled;
3136 RefPtrWillBeRawPtr<KeyboardEvent> keypress = KeyboardEvent::create(keyPressE vent, m_frame->document()->domWindow()); 3142 RefPtrWillBeRawPtr<KeyboardEvent> keypress = KeyboardEvent::create(keyPressE vent, m_frame->document()->domWindow());
3137 keypress->setTarget(node); 3143 keypress->setTarget(node);
3138 bool dispatchResult = node->dispatchEvent(keypress); 3144 return toWebInputEventResult(node->dispatchEvent(keypress));
3139 return eventToEventResult(keypress, dispatchResult);
3140 } 3145 }
3141 3146
3142 static WebFocusType focusDirectionForKey(const AtomicString& keyIdentifier) 3147 static WebFocusType focusDirectionForKey(const AtomicString& keyIdentifier)
3143 { 3148 {
3144 DEFINE_STATIC_LOCAL(AtomicString, Down, ("Down", AtomicString::ConstructFrom Literal)); 3149 DEFINE_STATIC_LOCAL(AtomicString, Down, ("Down", AtomicString::ConstructFrom Literal));
3145 DEFINE_STATIC_LOCAL(AtomicString, Up, ("Up", AtomicString::ConstructFromLite ral)); 3150 DEFINE_STATIC_LOCAL(AtomicString, Up, ("Up", AtomicString::ConstructFromLite ral));
3146 DEFINE_STATIC_LOCAL(AtomicString, Left, ("Left", AtomicString::ConstructFrom Literal)); 3151 DEFINE_STATIC_LOCAL(AtomicString, Left, ("Left", AtomicString::ConstructFrom Literal));
3147 DEFINE_STATIC_LOCAL(AtomicString, Right, ("Right", AtomicString::ConstructFr omLiteral)); 3152 DEFINE_STATIC_LOCAL(AtomicString, Right, ("Right", AtomicString::ConstructFr omLiteral));
3148 3153
3149 WebFocusType retVal = WebFocusTypeNone; 3154 WebFocusType retVal = WebFocusTypeNone;
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after
3703 continue; 3708 continue;
3704 3709
3705 const AtomicString& eventName(touchEventNameForTouchPointState(static_ca st<PlatformTouchPoint::State>(state))); 3710 const AtomicString& eventName(touchEventNameForTouchPointState(static_ca st<PlatformTouchPoint::State>(state)));
3706 for (const auto& eventTarget : changedTouches[state].m_targets) { 3711 for (const auto& eventTarget : changedTouches[state].m_targets) {
3707 EventTarget* touchEventTarget = eventTarget.get(); 3712 EventTarget* touchEventTarget = eventTarget.get();
3708 RefPtrWillBeRawPtr<TouchEvent> touchEvent = TouchEvent::create( 3713 RefPtrWillBeRawPtr<TouchEvent> touchEvent = TouchEvent::create(
3709 touches.get(), touchesByTarget.get(touchEventTarget), changedTou ches[state].m_touches.get(), 3714 touches.get(), touchesByTarget.get(touchEventTarget), changedTou ches[state].m_touches.get(),
3710 eventName, touchEventTarget->toNode()->document().domWindow(), 3715 eventName, touchEventTarget->toNode()->document().domWindow(),
3711 event.modifiers(), event.cancelable(), event.causesScrollingIfUn canceled(), event.timestamp()); 3716 event.modifiers(), event.cancelable(), event.causesScrollingIfUn canceled(), event.timestamp());
3712 3717
3713 bool dispatchResult = touchEventTarget->dispatchEvent(touchEvent.get ()); 3718 eventResult = mergeEventResult(eventResult, toWebInputEventResult(to uchEventTarget->dispatchEvent(touchEvent.get())));
3714 eventResult = mergeEventResult(eventResult, eventToEventResult(touch Event, dispatchResult));
3715 } 3719 }
3716 } 3720 }
3717 3721
3718 return eventResult; 3722 return eventResult;
3719 } 3723 }
3720 3724
3721 WebInputEventResult EventHandler::handleTouchEvent(const PlatformTouchEvent& eve nt) 3725 WebInputEventResult EventHandler::handleTouchEvent(const PlatformTouchEvent& eve nt)
3722 { 3726 {
3723 TRACE_EVENT0("blink", "EventHandler::handleTouchEvent"); 3727 TRACE_EVENT0("blink", "EventHandler::handleTouchEvent");
3724 3728
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
3976 PlatformEvent::Modifiers EventHandler::accessKeyModifiers() 3980 PlatformEvent::Modifiers EventHandler::accessKeyModifiers()
3977 { 3981 {
3978 #if OS(MACOSX) 3982 #if OS(MACOSX)
3979 return static_cast<PlatformEvent::Modifiers>(PlatformEvent::CtrlKey | Platfo rmEvent::AltKey); 3983 return static_cast<PlatformEvent::Modifiers>(PlatformEvent::CtrlKey | Platfo rmEvent::AltKey);
3980 #else 3984 #else
3981 return PlatformEvent::AltKey; 3985 return PlatformEvent::AltKey;
3982 #endif 3986 #endif
3983 } 3987 }
3984 3988
3985 } // namespace blink 3989 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698