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

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: Add back the EventDispatchResult enum 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::eventDispatchResultToWebInputEventResult(
371 PassRefPtrWillBeRawPtr<Event> event, bool result) 371 EventTarget::DispatchEventResult result)
372 { 372 {
373 if (event->defaultPrevented()) 373 static_assert(static_cast<int>(WebInputEventResult::NotHandled) == static_ca st<int>(EventTarget::DispatchEventResult::NotHandled), "WebInputEventResult does not match EventTarget::DispatchEventResult");
374 return WebInputEventResult::HandledApplication; 374 static_assert(static_cast<int>(WebInputEventResult::HandledApplication) == s tatic_cast<int>(EventTarget::DispatchEventResult::HandledApplication), "WebInput EventResult does not match EventTarget::DispatchEventResult");
375 if (event->defaultHandled()) 375 static_assert(static_cast<int>(WebInputEventResult::HandledSystem) == static _cast<int>(EventTarget::DispatchEventResult::HandledSystem), "WebInputEventResul t does not match EventTarget::DispatchEventResult");
376 return WebInputEventResult::HandledSystem; 376 static_assert(static_cast<int>(WebInputEventResult::HandledSuppressed) == st atic_cast<int>(EventTarget::DispatchEventResult::HandledSuppressed), "WebInputEv entResult does not match EventTarget::DispatchEventResult");
377 377 return static_cast<WebInputEventResult>(static_cast<int>(result));
378 // TODO(dtapuska): There are cases in the code where dispatchEvent
379 // returns false (indicated handled) but event is not marked
380 // as default handled or default prevented. crbug.com/560355
381 if (!result)
382 return WebInputEventResult::HandledSuppressed;
383 return WebInputEventResult::NotHandled;
384 } 378 }
385 379
386 void EventHandler::nodeWillBeRemoved(Node& nodeToBeRemoved) 380 void EventHandler::nodeWillBeRemoved(Node& nodeToBeRemoved)
387 { 381 {
388 if (nodeToBeRemoved.containsIncludingShadowDOM(m_clickNode.get())) { 382 if (nodeToBeRemoved.containsIncludingShadowDOM(m_clickNode.get())) {
389 // We don't dispatch click events if the mousedown node is removed 383 // We don't dispatch click events if the mousedown node is removed
390 // before a mouseup event. It is compatible with IE and Firefox. 384 // before a mouseup event. It is compatible with IE and Firefox.
391 m_clickNode = nullptr; 385 m_clickNode = nullptr;
392 } 386 }
393 } 387 }
(...skipping 945 matching lines...) Expand 10 before | Expand all | Expand 10 after
1339 // Both m_clickNode and mev.innerNode() don't need to be updated 1333 // Both m_clickNode and mev.innerNode() don't need to be updated
1340 // because commonAncestor() will exit early if their documents are diffe rent. 1334 // because commonAncestor() will exit early if their documents are diffe rent.
1341 m_clickNode->updateDistribution(); 1335 m_clickNode->updateDistribution();
1342 if (Node* clickTargetNode = mev.innerNode()->commonAncestor( 1336 if (Node* clickTargetNode = mev.innerNode()->commonAncestor(
1343 *m_clickNode, parentForClickEvent)) { 1337 *m_clickNode, parentForClickEvent)) {
1344 1338
1345 // Dispatch mouseup directly w/o calling updateMouseEventTargetNode 1339 // Dispatch mouseup directly w/o calling updateMouseEventTargetNode
1346 // because the mouseup dispatch above has already updated it 1340 // because the mouseup dispatch above has already updated it
1347 // correctly. Moreover, clickTargetNode is different from 1341 // correctly. Moreover, clickTargetNode is different from
1348 // mev.innerNode at drag-release. 1342 // mev.innerNode at drag-release.
1349 if (clickTargetNode->dispatchMouseEvent(mouseEvent, 1343 clickEventResult = eventDispatchResultToWebInputEventResult(clickTar getNode->dispatchMouseEvent(mouseEvent,
1350 EventTypeNames::click, m_clickCount)) { 1344 EventTypeNames::click, m_clickCount));
1351 clickEventResult = WebInputEventResult::HandledApplication;
1352 }
1353 } 1345 }
1354 } 1346 }
1355 1347
1356 if (m_resizeScrollableArea) { 1348 if (m_resizeScrollableArea) {
1357 m_resizeScrollableArea->setInResizeMode(false); 1349 m_resizeScrollableArea->setInResizeMode(false);
1358 m_resizeScrollableArea = nullptr; 1350 m_resizeScrollableArea = nullptr;
1359 } 1351 }
1360 1352
1361 if (eventResult == WebInputEventResult::NotHandled) 1353 if (eventResult == WebInputEventResult::NotHandled)
1362 eventResult = handleMouseReleaseEvent(mev); 1354 eventResult = handleMouseReleaseEvent(mev);
(...skipping 11 matching lines...) Expand all
1374 if (!view) 1366 if (!view)
1375 return WebInputEventResult::NotHandled; 1367 return WebInputEventResult::NotHandled;
1376 1368
1377 RefPtrWillBeRawPtr<DragEvent> me = DragEvent::create(eventType, 1369 RefPtrWillBeRawPtr<DragEvent> me = DragEvent::create(eventType,
1378 true, true, m_frame->document()->domWindow(), 1370 true, true, m_frame->document()->domWindow(),
1379 0, event.globalPosition().x(), event.globalPosition().y(), event.positio n().x(), event.position().y(), 1371 0, event.globalPosition().x(), event.globalPosition().y(), event.positio n().x(), event.position().y(),
1380 event.movementDelta().x(), event.movementDelta().y(), 1372 event.movementDelta().x(), event.movementDelta().y(),
1381 event.modifiers(), 1373 event.modifiers(),
1382 0, MouseEvent::platformModifiersToButtons(event.modifiers()), nullptr, e vent.timestamp(), dataTransfer, event.syntheticEventType()); 1374 0, MouseEvent::platformModifiersToButtons(event.modifiers()), nullptr, e vent.timestamp(), dataTransfer, event.syntheticEventType());
1383 1375
1384 bool dispatchResult = dragTarget->dispatchEvent(me.get()); 1376 return eventDispatchResultToWebInputEventResult(dragTarget->dispatchEvent(me .get()));
1385 return eventToEventResult(me, dispatchResult);
1386 } 1377 }
1387 1378
1388 static bool targetIsFrame(Node* target, LocalFrame*& frame) 1379 static bool targetIsFrame(Node* target, LocalFrame*& frame)
1389 { 1380 {
1390 if (!isHTMLFrameElementBase(target)) 1381 if (!isHTMLFrameElementBase(target))
1391 return false; 1382 return false;
1392 1383
1393 // Cross-process drag and drop is not yet supported. 1384 // Cross-process drag and drop is not yet supported.
1394 if (toHTMLFrameElementBase(target)->contentFrame() && !toHTMLFrameElementBas e(target)->contentFrame()->isLocalFrame()) 1385 if (toHTMLFrameElementBase(target)->contentFrame() && !toHTMLFrameElementBas e(target)->contentFrame()->isLocalFrame())
1395 return false; 1386 return false;
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
1612 m_nodeUnderMouse, mouseEvent, m_frame->document()->domWindow()); 1603 m_nodeUnderMouse, mouseEvent, m_frame->document()->domWindow());
1613 } 1604 }
1614 1605
1615 WebInputEventResult EventHandler::dispatchMouseEvent(const AtomicString& eventTy pe, Node* targetNode, int clickCount, const PlatformMouseEvent& mouseEvent) 1606 WebInputEventResult EventHandler::dispatchMouseEvent(const AtomicString& eventTy pe, Node* targetNode, int clickCount, const PlatformMouseEvent& mouseEvent)
1616 { 1607 {
1617 updateMouseEventTargetNode(targetNode, mouseEvent); 1608 updateMouseEventTargetNode(targetNode, mouseEvent);
1618 if (!m_nodeUnderMouse) 1609 if (!m_nodeUnderMouse)
1619 return WebInputEventResult::NotHandled; 1610 return WebInputEventResult::NotHandled;
1620 1611
1621 RefPtrWillBeRawPtr<MouseEvent> event = MouseEvent::create(eventType, m_nodeU nderMouse->document().domWindow(), mouseEvent, clickCount, nullptr); 1612 RefPtrWillBeRawPtr<MouseEvent> event = MouseEvent::create(eventType, m_nodeU nderMouse->document().domWindow(), mouseEvent, clickCount, nullptr);
1622 bool dispatchResult = m_nodeUnderMouse->dispatchEvent(event); 1613 return eventDispatchResultToWebInputEventResult(m_nodeUnderMouse->dispatchEv ent(event));
1623 return eventToEventResult(event, dispatchResult);
1624 } 1614 }
1625 1615
1626 // TODO(mustaq): Make PE drive ME dispatch & bookkeeping in EventHandler. 1616 // TODO(mustaq): Make PE drive ME dispatch & bookkeeping in EventHandler.
1627 WebInputEventResult EventHandler::updatePointerTargetAndDispatchEvents(const Ato micString& mouseEventType, Node* targetNode, int clickCount, const PlatformMouse Event& mouseEvent) 1617 WebInputEventResult EventHandler::updatePointerTargetAndDispatchEvents(const Ato micString& mouseEventType, Node* targetNode, int clickCount, const PlatformMouse Event& mouseEvent)
1628 { 1618 {
1629 ASSERT(mouseEventType == EventTypeNames::mousedown 1619 ASSERT(mouseEventType == EventTypeNames::mousedown
1630 || mouseEventType == EventTypeNames::mousemove 1620 || mouseEventType == EventTypeNames::mousemove
1631 || mouseEventType == EventTypeNames::mouseup); 1621 || mouseEventType == EventTypeNames::mouseup);
1632 1622
1633 updateMouseEventTargetNode(targetNode, mouseEvent); 1623 updateMouseEventTargetNode(targetNode, mouseEvent);
1634 if (!m_nodeUnderMouse) 1624 if (!m_nodeUnderMouse)
1635 return WebInputEventResult::NotHandled; 1625 return WebInputEventResult::NotHandled;
1636 1626
1637 WebInputEventResult result = m_pointerEventManager.sendMousePointerEvent( 1627 return m_pointerEventManager.sendMousePointerEvent(
1638 m_nodeUnderMouse, mouseEventType, clickCount, mouseEvent, nullptr, 1628 m_nodeUnderMouse, mouseEventType, clickCount, mouseEvent, nullptr,
1639 m_frame->document()->domWindow()); 1629 m_frame->document()->domWindow());
1640
1641 return result;
1642 } 1630 }
1643 1631
1644 WebInputEventResult EventHandler::handleMouseFocus(const MouseEventWithHitTestRe sults& targetedEvent, InputDeviceCapabilities* sourceCapabilities) 1632 WebInputEventResult EventHandler::handleMouseFocus(const MouseEventWithHitTestRe sults& targetedEvent, InputDeviceCapabilities* sourceCapabilities)
1645 { 1633 {
1646 // If clicking on a frame scrollbar, do not mess up with content focus. 1634 // If clicking on a frame scrollbar, do not mess up with content focus.
1647 if (targetedEvent.hitTestResult().scrollbar() && m_frame->contentLayoutObjec t()) { 1635 if (targetedEvent.hitTestResult().scrollbar() && m_frame->contentLayoutObjec t()) {
1648 if (targetedEvent.hitTestResult().scrollbar()->scrollableArea() == m_fra me->contentLayoutObject()->scrollableArea()) 1636 if (targetedEvent.hitTestResult().scrollbar()->scrollableArea() == m_fra me->contentLayoutObject()->scrollableArea())
1649 return WebInputEventResult::NotHandled; 1637 return WebInputEventResult::NotHandled;
1650 } 1638 }
1651 1639
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
1799 if (Widget* widget = toLayoutPart(target)->widget()) { 1787 if (Widget* widget = toLayoutPart(target)->widget()) {
1800 WebInputEventResult result = passWheelEventToWidget(event, *widg et); 1788 WebInputEventResult result = passWheelEventToWidget(event, *widg et);
1801 if (result != WebInputEventResult::NotHandled) { 1789 if (result != WebInputEventResult::NotHandled) {
1802 setFrameWasScrolledByUser(); 1790 setFrameWasScrolledByUser();
1803 return result; 1791 return result;
1804 } 1792 }
1805 } 1793 }
1806 } 1794 }
1807 1795
1808 RefPtrWillBeRawPtr<Event> domEvent = WheelEvent::create(event, node->doc ument().domWindow()); 1796 RefPtrWillBeRawPtr<Event> domEvent = WheelEvent::create(event, node->doc ument().domWindow());
1809 if (!node->dispatchEvent(domEvent)) { 1797 EventTarget::DispatchEventResult domEventResult = node->dispatchEvent(do mEvent);
1798 if (domEventResult != EventTarget::DispatchEventResult::NotHandled) {
1810 setFrameWasScrolledByUser(); 1799 setFrameWasScrolledByUser();
1811 return eventToEventResult(domEvent, false); 1800 return eventDispatchResultToWebInputEventResult(domEventResult);
1812 } 1801 }
1813 } 1802 }
1814 1803
1815 // We do another check on the frame view because the event handler can run 1804 // We do another check on the frame view because the event handler can run
1816 // JS which results in the frame getting destroyed. 1805 // JS which results in the frame getting destroyed.
1817 view = m_frame->view(); 1806 view = m_frame->view();
1818 if (!view) 1807 if (!view)
1819 return WebInputEventResult::NotHandled; 1808 return WebInputEventResult::NotHandled;
1820 1809
1821 // Wheel events which do not scroll are used to trigger zooming. 1810 // Wheel events which do not scroll are used to trigger zooming.
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
1931 if (scrollbar) { 1920 if (scrollbar) {
1932 bool eventSwallowed = scrollbar->gestureEvent(gestureEvent); 1921 bool eventSwallowed = scrollbar->gestureEvent(gestureEvent);
1933 if (gestureEvent.type() == PlatformEvent::GestureTapDown && eventSwallow ed) 1922 if (gestureEvent.type() == PlatformEvent::GestureTapDown && eventSwallow ed)
1934 m_scrollbarHandlingScrollGesture = scrollbar; 1923 m_scrollbarHandlingScrollGesture = scrollbar;
1935 if (eventSwallowed) 1924 if (eventSwallowed)
1936 return WebInputEventResult::HandledSuppressed; 1925 return WebInputEventResult::HandledSuppressed;
1937 } 1926 }
1938 1927
1939 if (eventTarget) { 1928 if (eventTarget) {
1940 RefPtrWillBeRawPtr<GestureEvent> gestureDomEvent = GestureEvent::create( eventTarget->document().domWindow(), gestureEvent); 1929 RefPtrWillBeRawPtr<GestureEvent> gestureDomEvent = GestureEvent::create( eventTarget->document().domWindow(), gestureEvent);
1941 // TODO(dtapuska): dispatchEvent is inverted for Gesture Events 1930 if (gestureDomEvent.get()) {
1942 // crbug.com/560357 1931 EventTarget::DispatchEventResult gestureDomEventResult = eventTarget ->dispatchEvent(gestureDomEvent);
Rick Byers 2016/02/22 15:16:14 There used to be an ASSERT in the GestureEventDisp
dtapuska 2016/02/23 19:14:40 Done; I rolled this into a method.
1943 if (gestureDomEvent.get() && eventTarget->dispatchEvent(gestureDomEvent) ) 1932 if (gestureDomEventResult != EventTarget::DispatchEventResult::NotHa ndled)
1944 return eventToEventResult(gestureDomEvent, false); 1933 return eventDispatchResultToWebInputEventResult(gestureDomEventR esult);
1934 }
1945 } 1935 }
1946 1936
1947 switch (gestureEvent.type()) { 1937 switch (gestureEvent.type()) {
1948 case PlatformEvent::GestureTap: 1938 case PlatformEvent::GestureTap:
1949 return handleGestureTap(targetedEvent); 1939 return handleGestureTap(targetedEvent);
1950 case PlatformEvent::GestureShowPress: 1940 case PlatformEvent::GestureShowPress:
1951 return handleGestureShowPress(); 1941 return handleGestureShowPress();
1952 case PlatformEvent::GestureLongPress: 1942 case PlatformEvent::GestureLongPress:
1953 return handleGestureLongPress(targetedEvent); 1943 return handleGestureLongPress(targetedEvent);
1954 case PlatformEvent::GestureLongTap: 1944 case PlatformEvent::GestureLongTap:
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
2010 } 2000 }
2011 if (eventSwallowed) 2001 if (eventSwallowed)
2012 return WebInputEventResult::HandledSuppressed; 2002 return WebInputEventResult::HandledSuppressed;
2013 } 2003 }
2014 2004
2015 if (eventTarget) { 2005 if (eventTarget) {
2016 if (handleScrollGestureOnResizer(eventTarget.get(), gestureEvent)) 2006 if (handleScrollGestureOnResizer(eventTarget.get(), gestureEvent))
2017 return WebInputEventResult::HandledSuppressed; 2007 return WebInputEventResult::HandledSuppressed;
2018 2008
2019 RefPtrWillBeRawPtr<GestureEvent> gestureDomEvent = GestureEvent::create( eventTarget->document().domWindow(), gestureEvent); 2009 RefPtrWillBeRawPtr<GestureEvent> gestureDomEvent = GestureEvent::create( eventTarget->document().domWindow(), gestureEvent);
2020 // TODO(dtapuska): dispatchEvent is inverted for Gesture Events 2010 if (gestureDomEvent.get()) {
2021 // crbug.com/560357 2011 EventTarget::DispatchEventResult gestureDomEventResult = eventTarget ->dispatchEvent(gestureDomEvent);
2022 if (gestureDomEvent.get() && eventTarget->dispatchEvent(gestureDomEvent) ) 2012 if (gestureDomEventResult != EventTarget::DispatchEventResult::NotHa ndled)
2023 return eventToEventResult(gestureDomEvent, false); 2013 return eventDispatchResultToWebInputEventResult(gestureDomEventR esult);
2014 }
2024 } 2015 }
2025 2016
2026 switch (gestureEvent.type()) { 2017 switch (gestureEvent.type()) {
2027 case PlatformEvent::GestureScrollBegin: 2018 case PlatformEvent::GestureScrollBegin:
2028 return handleGestureScrollBegin(gestureEvent); 2019 return handleGestureScrollBegin(gestureEvent);
2029 case PlatformEvent::GestureScrollUpdate: 2020 case PlatformEvent::GestureScrollUpdate:
2030 return handleGestureScrollUpdate(gestureEvent); 2021 return handleGestureScrollUpdate(gestureEvent);
2031 case PlatformEvent::GestureScrollEnd: 2022 case PlatformEvent::GestureScrollEnd:
2032 return handleGestureScrollEnd(gestureEvent); 2023 return handleGestureScrollEnd(gestureEvent);
2033 case PlatformEvent::GestureFlingStart: 2024 case PlatformEvent::GestureFlingStart:
(...skipping 1051 matching lines...) Expand 10 before | Expand all | Expand 10 after
3085 // On Windows, WebKit explicitly calls handleAccessKey() instead of dispatch ing a keypress event for WM_SYSCHAR messages. 3076 // On Windows, WebKit explicitly calls handleAccessKey() instead of dispatch ing a keypress event for WM_SYSCHAR messages.
3086 // Other platforms currently match either Mac or Windows behavior, depending on whether they send combined KeyDown events. 3077 // Other platforms currently match either Mac or Windows behavior, depending on whether they send combined KeyDown events.
3087 bool matchedAnAccessKey = false; 3078 bool matchedAnAccessKey = false;
3088 if (initialKeyEvent.type() == PlatformEvent::KeyDown) 3079 if (initialKeyEvent.type() == PlatformEvent::KeyDown)
3089 matchedAnAccessKey = handleAccessKey(initialKeyEvent); 3080 matchedAnAccessKey = handleAccessKey(initialKeyEvent);
3090 3081
3091 // FIXME: it would be fair to let an input method handle KeyUp events before DOM dispatch. 3082 // FIXME: it would be fair to let an input method handle KeyUp events before DOM dispatch.
3092 if (initialKeyEvent.type() == PlatformEvent::KeyUp || initialKeyEvent.type() == PlatformEvent::Char) { 3083 if (initialKeyEvent.type() == PlatformEvent::KeyUp || initialKeyEvent.type() == PlatformEvent::Char) {
3093 RefPtrWillBeRawPtr<KeyboardEvent> domEvent = KeyboardEvent::create(initi alKeyEvent, m_frame->document()->domWindow()); 3084 RefPtrWillBeRawPtr<KeyboardEvent> domEvent = KeyboardEvent::create(initi alKeyEvent, m_frame->document()->domWindow());
3094 3085
3095 bool dispatchResult = node->dispatchEvent(domEvent); 3086 return eventDispatchResultToWebInputEventResult(node->dispatchEvent(domE vent));
3096 return eventToEventResult(domEvent, dispatchResult);
3097 } 3087 }
3098 3088
3099 PlatformKeyboardEvent keyDownEvent = initialKeyEvent; 3089 PlatformKeyboardEvent keyDownEvent = initialKeyEvent;
3100 if (keyDownEvent.type() != PlatformEvent::RawKeyDown) 3090 if (keyDownEvent.type() != PlatformEvent::RawKeyDown)
3101 keyDownEvent.disambiguateKeyDownEvent(PlatformEvent::RawKeyDown); 3091 keyDownEvent.disambiguateKeyDownEvent(PlatformEvent::RawKeyDown);
3102 RefPtrWillBeRawPtr<KeyboardEvent> keydown = KeyboardEvent::create(keyDownEve nt, m_frame->document()->domWindow()); 3092 RefPtrWillBeRawPtr<KeyboardEvent> keydown = KeyboardEvent::create(keyDownEve nt, m_frame->document()->domWindow());
3103 if (matchedAnAccessKey) 3093 if (matchedAnAccessKey)
3104 keydown->setDefaultPrevented(true); 3094 keydown->setDefaultPrevented(true);
3105 keydown->setTarget(node); 3095 keydown->setTarget(node);
3106 3096
3107 if (initialKeyEvent.type() == PlatformEvent::RawKeyDown) { 3097 EventTarget::DispatchEventResult dispatchResult = node->dispatchEvent(keydow n);
3108 if (!node->dispatchEvent(keydown)) 3098 if (dispatchResult != EventTarget::DispatchEventResult::NotHandled)
3109 return eventToEventResult(keydown, false); 3099 return eventDispatchResultToWebInputEventResult(dispatchResult);
3110 // If frame changed as a result of keydown dispatch, then return true to avoid sending a subsequent keypress message to the new frame.
3111 bool changedFocusedFrame = m_frame->page() && m_frame != m_frame->page() ->focusController().focusedOrMainFrame();
3112 if (changedFocusedFrame)
3113 return WebInputEventResult::HandledSystem;
3114 return WebInputEventResult::NotHandled;
3115 }
3116
3117 if (!node->dispatchEvent(keydown))
3118 return eventToEventResult(keydown, false);
3119 // If frame changed as a result of keydown dispatch, then return early to av oid sending a subsequent keypress message to the new frame. 3100 // If frame changed as a result of keydown dispatch, then return early to av oid sending a subsequent keypress message to the new frame.
3120 bool changedFocusedFrame = m_frame->page() && m_frame != m_frame->page()->fo cusController().focusedOrMainFrame(); 3101 bool changedFocusedFrame = m_frame->page() && m_frame != m_frame->page()->fo cusController().focusedOrMainFrame();
3121 if (changedFocusedFrame) 3102 if (changedFocusedFrame)
3122 return WebInputEventResult::HandledSystem; 3103 return WebInputEventResult::HandledSystem;
3123 3104
3105 if (initialKeyEvent.type() == PlatformEvent::RawKeyDown)
3106 return WebInputEventResult::NotHandled;
3107
3124 // Focus may have changed during keydown handling, so refetch node. 3108 // Focus may have changed during keydown handling, so refetch node.
3125 // But if we are dispatching a fake backward compatibility keypress, then we pretend that the keypress happened on the original node. 3109 // But if we are dispatching a fake backward compatibility keypress, then we pretend that the keypress happened on the original node.
3126 node = eventTargetNodeForDocument(m_frame->document()); 3110 node = eventTargetNodeForDocument(m_frame->document());
3127 if (!node) 3111 if (!node)
3128 return WebInputEventResult::NotHandled; 3112 return WebInputEventResult::NotHandled;
3129 3113
3130 PlatformKeyboardEvent keyPressEvent = initialKeyEvent; 3114 PlatformKeyboardEvent keyPressEvent = initialKeyEvent;
3131 keyPressEvent.disambiguateKeyDownEvent(PlatformEvent::Char); 3115 keyPressEvent.disambiguateKeyDownEvent(PlatformEvent::Char);
3132 if (keyPressEvent.text().isEmpty()) 3116 if (keyPressEvent.text().isEmpty())
3133 return WebInputEventResult::NotHandled; 3117 return WebInputEventResult::NotHandled;
3134 RefPtrWillBeRawPtr<KeyboardEvent> keypress = KeyboardEvent::create(keyPressE vent, m_frame->document()->domWindow()); 3118 RefPtrWillBeRawPtr<KeyboardEvent> keypress = KeyboardEvent::create(keyPressE vent, m_frame->document()->domWindow());
3135 keypress->setTarget(node); 3119 keypress->setTarget(node);
3136 bool dispatchResult = node->dispatchEvent(keypress); 3120 return eventDispatchResultToWebInputEventResult(node->dispatchEvent(keypress ));
3137 return eventToEventResult(keypress, dispatchResult);
3138 } 3121 }
3139 3122
3140 static WebFocusType focusDirectionForKey(const AtomicString& keyIdentifier) 3123 static WebFocusType focusDirectionForKey(const AtomicString& keyIdentifier)
3141 { 3124 {
3142 DEFINE_STATIC_LOCAL(AtomicString, Down, ("Down", AtomicString::ConstructFrom Literal)); 3125 DEFINE_STATIC_LOCAL(AtomicString, Down, ("Down", AtomicString::ConstructFrom Literal));
3143 DEFINE_STATIC_LOCAL(AtomicString, Up, ("Up", AtomicString::ConstructFromLite ral)); 3126 DEFINE_STATIC_LOCAL(AtomicString, Up, ("Up", AtomicString::ConstructFromLite ral));
3144 DEFINE_STATIC_LOCAL(AtomicString, Left, ("Left", AtomicString::ConstructFrom Literal)); 3127 DEFINE_STATIC_LOCAL(AtomicString, Left, ("Left", AtomicString::ConstructFrom Literal));
3145 DEFINE_STATIC_LOCAL(AtomicString, Right, ("Right", AtomicString::ConstructFr omLiteral)); 3128 DEFINE_STATIC_LOCAL(AtomicString, Right, ("Right", AtomicString::ConstructFr omLiteral));
3146 3129
3147 WebFocusType retVal = WebFocusTypeNone; 3130 WebFocusType retVal = WebFocusTypeNone;
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after
3701 continue; 3684 continue;
3702 3685
3703 const AtomicString& eventName(touchEventNameForTouchPointState(static_ca st<PlatformTouchPoint::State>(state))); 3686 const AtomicString& eventName(touchEventNameForTouchPointState(static_ca st<PlatformTouchPoint::State>(state)));
3704 for (const auto& eventTarget : changedTouches[state].m_targets) { 3687 for (const auto& eventTarget : changedTouches[state].m_targets) {
3705 EventTarget* touchEventTarget = eventTarget.get(); 3688 EventTarget* touchEventTarget = eventTarget.get();
3706 RefPtrWillBeRawPtr<TouchEvent> touchEvent = TouchEvent::create( 3689 RefPtrWillBeRawPtr<TouchEvent> touchEvent = TouchEvent::create(
3707 touches.get(), touchesByTarget.get(touchEventTarget), changedTou ches[state].m_touches.get(), 3690 touches.get(), touchesByTarget.get(touchEventTarget), changedTou ches[state].m_touches.get(),
3708 eventName, touchEventTarget->toNode()->document().domWindow(), 3691 eventName, touchEventTarget->toNode()->document().domWindow(),
3709 event.modifiers(), event.cancelable(), event.causesScrollingIfUn canceled(), event.timestamp()); 3692 event.modifiers(), event.cancelable(), event.causesScrollingIfUn canceled(), event.timestamp());
3710 3693
3711 bool dispatchResult = touchEventTarget->dispatchEvent(touchEvent.get ()); 3694 eventResult = mergeEventResult(eventResult, eventDispatchResultToWeb InputEventResult(touchEventTarget->dispatchEvent(touchEvent.get())));
3712 eventResult = mergeEventResult(eventResult, eventToEventResult(touch Event, dispatchResult));
3713 } 3695 }
3714 } 3696 }
3715 3697
3716 return eventResult; 3698 return eventResult;
3717 } 3699 }
3718 3700
3719 WebInputEventResult EventHandler::handleTouchEvent(const PlatformTouchEvent& eve nt) 3701 WebInputEventResult EventHandler::handleTouchEvent(const PlatformTouchEvent& eve nt)
3720 { 3702 {
3721 TRACE_EVENT0("blink", "EventHandler::handleTouchEvent"); 3703 TRACE_EVENT0("blink", "EventHandler::handleTouchEvent");
3722 3704
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
3974 PlatformEvent::Modifiers EventHandler::accessKeyModifiers() 3956 PlatformEvent::Modifiers EventHandler::accessKeyModifiers()
3975 { 3957 {
3976 #if OS(MACOSX) 3958 #if OS(MACOSX)
3977 return static_cast<PlatformEvent::Modifiers>(PlatformEvent::CtrlKey | Platfo rmEvent::AltKey); 3959 return static_cast<PlatformEvent::Modifiers>(PlatformEvent::CtrlKey | Platfo rmEvent::AltKey);
3978 #else 3960 #else
3979 return PlatformEvent::AltKey; 3961 return PlatformEvent::AltKey;
3980 #endif 3962 #endif
3981 } 3963 }
3982 3964
3983 } // namespace blink 3965 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698