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