| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2014 Google Inc. All rights reserved. | 2 * Copyright (C) 2014 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 | 303 |
| 304 WebRect damagedRect(0, 0, m_size.width, m_size.height); | 304 WebRect damagedRect(0, 0, m_size.width, m_size.height); |
| 305 view->invalidateRect(damagedRect); | 305 view->invalidateRect(damagedRect); |
| 306 } | 306 } |
| 307 | 307 |
| 308 const WebInputEvent* WebFrameWidgetImpl::m_currentInputEvent = nullptr; | 308 const WebInputEvent* WebFrameWidgetImpl::m_currentInputEvent = nullptr; |
| 309 | 309 |
| 310 WebInputEventResult WebFrameWidgetImpl::handleInputEvent( | 310 WebInputEventResult WebFrameWidgetImpl::handleInputEvent( |
| 311 const WebInputEvent& inputEvent) { | 311 const WebInputEvent& inputEvent) { |
| 312 TRACE_EVENT1("input", "WebFrameWidgetImpl::handleInputEvent", "type", | 312 TRACE_EVENT1("input", "WebFrameWidgetImpl::handleInputEvent", "type", |
| 313 WebInputEvent::GetName(inputEvent.type)); | 313 WebInputEvent::GetName(inputEvent.type())); |
| 314 | 314 |
| 315 // If a drag-and-drop operation is in progress, ignore input events. | 315 // If a drag-and-drop operation is in progress, ignore input events. |
| 316 if (m_doingDragAndDrop) | 316 if (m_doingDragAndDrop) |
| 317 return WebInputEventResult::HandledSuppressed; | 317 return WebInputEventResult::HandledSuppressed; |
| 318 | 318 |
| 319 // Don't handle events once we've started shutting down. | 319 // Don't handle events once we've started shutting down. |
| 320 if (!page()) | 320 if (!page()) |
| 321 return WebInputEventResult::NotHandled; | 321 return WebInputEventResult::NotHandled; |
| 322 | 322 |
| 323 if (InspectorOverlay* overlay = inspectorOverlay()) { | 323 if (InspectorOverlay* overlay = inspectorOverlay()) { |
| 324 if (overlay->handleInputEvent(inputEvent)) | 324 if (overlay->handleInputEvent(inputEvent)) |
| 325 return WebInputEventResult::HandledSuppressed; | 325 return WebInputEventResult::HandledSuppressed; |
| 326 } | 326 } |
| 327 | 327 |
| 328 // Report the event to be NOT processed by WebKit, so that the browser can | 328 // Report the event to be NOT processed by WebKit, so that the browser can |
| 329 // handle it appropriately. | 329 // handle it appropriately. |
| 330 if (ignoreInputEvents()) | 330 if (ignoreInputEvents()) |
| 331 return WebInputEventResult::NotHandled; | 331 return WebInputEventResult::NotHandled; |
| 332 | 332 |
| 333 // FIXME: pass event to m_localRoot's WebDevToolsAgentImpl once available. | 333 // FIXME: pass event to m_localRoot's WebDevToolsAgentImpl once available. |
| 334 | 334 |
| 335 AutoReset<const WebInputEvent*> currentEventChange(&m_currentInputEvent, | 335 AutoReset<const WebInputEvent*> currentEventChange(&m_currentInputEvent, |
| 336 &inputEvent); | 336 &inputEvent); |
| 337 | 337 |
| 338 if (m_mouseCaptureNode && WebInputEvent::isMouseEventType(inputEvent.type)) { | 338 if (m_mouseCaptureNode && |
| 339 TRACE_EVENT1("input", "captured mouse event", "type", inputEvent.type); | 339 WebInputEvent::isMouseEventType(inputEvent.type())) { |
| 340 TRACE_EVENT1("input", "captured mouse event", "type", inputEvent.type()); |
| 340 // Save m_mouseCaptureNode since mouseCaptureLost() will clear it. | 341 // Save m_mouseCaptureNode since mouseCaptureLost() will clear it. |
| 341 Node* node = m_mouseCaptureNode; | 342 Node* node = m_mouseCaptureNode; |
| 342 | 343 |
| 343 // Not all platforms call mouseCaptureLost() directly. | 344 // Not all platforms call mouseCaptureLost() directly. |
| 344 if (inputEvent.type == WebInputEvent::MouseUp) | 345 if (inputEvent.type() == WebInputEvent::MouseUp) |
| 345 mouseCaptureLost(); | 346 mouseCaptureLost(); |
| 346 | 347 |
| 347 std::unique_ptr<UserGestureIndicator> gestureIndicator; | 348 std::unique_ptr<UserGestureIndicator> gestureIndicator; |
| 348 | 349 |
| 349 AtomicString eventType; | 350 AtomicString eventType; |
| 350 switch (inputEvent.type) { | 351 switch (inputEvent.type()) { |
| 351 case WebInputEvent::MouseMove: | 352 case WebInputEvent::MouseMove: |
| 352 eventType = EventTypeNames::mousemove; | 353 eventType = EventTypeNames::mousemove; |
| 353 break; | 354 break; |
| 354 case WebInputEvent::MouseLeave: | 355 case WebInputEvent::MouseLeave: |
| 355 eventType = EventTypeNames::mouseout; | 356 eventType = EventTypeNames::mouseout; |
| 356 break; | 357 break; |
| 357 case WebInputEvent::MouseDown: | 358 case WebInputEvent::MouseDown: |
| 358 eventType = EventTypeNames::mousedown; | 359 eventType = EventTypeNames::mousedown; |
| 359 gestureIndicator = WTF::wrapUnique( | 360 gestureIndicator = WTF::wrapUnique( |
| 360 new UserGestureIndicator(DocumentUserGestureToken::create( | 361 new UserGestureIndicator(DocumentUserGestureToken::create( |
| (...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 742 | 743 |
| 743 if (event.button == WebMouseEvent::Button::Left && m_mouseCaptureNode) | 744 if (event.button == WebMouseEvent::Button::Left && m_mouseCaptureNode) |
| 744 m_mouseCaptureGestureToken = | 745 m_mouseCaptureGestureToken = |
| 745 mainFrame.eventHandler().takeLastMouseDownGestureToken(); | 746 mainFrame.eventHandler().takeLastMouseDownGestureToken(); |
| 746 | 747 |
| 747 // Dispatch the contextmenu event regardless of if the click was swallowed. | 748 // Dispatch the contextmenu event regardless of if the click was swallowed. |
| 748 if (!page()->settings().getShowContextMenuOnMouseUp()) { | 749 if (!page()->settings().getShowContextMenuOnMouseUp()) { |
| 749 #if OS(MACOSX) | 750 #if OS(MACOSX) |
| 750 if (event.button == WebMouseEvent::Button::Right || | 751 if (event.button == WebMouseEvent::Button::Right || |
| 751 (event.button == WebMouseEvent::Button::Left && | 752 (event.button == WebMouseEvent::Button::Left && |
| 752 event.modifiers & WebMouseEvent::ControlKey)) | 753 event.modifiers() & WebMouseEvent::ControlKey)) |
| 753 mouseContextMenu(event); | 754 mouseContextMenu(event); |
| 754 #else | 755 #else |
| 755 if (event.button == WebMouseEvent::Button::Right) | 756 if (event.button == WebMouseEvent::Button::Right) |
| 756 mouseContextMenu(event); | 757 mouseContextMenu(event); |
| 757 #endif | 758 #endif |
| 758 } | 759 } |
| 759 } | 760 } |
| 760 | 761 |
| 761 void WebFrameWidgetImpl::mouseContextMenu(const WebMouseEvent& event) { | 762 void WebFrameWidgetImpl::mouseContextMenu(const WebMouseEvent& event) { |
| 762 page()->contextMenuController().clearContextMenu(); | 763 page()->contextMenuController().clearContextMenu(); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 807 WebInputEventResult WebFrameWidgetImpl::handleMouseWheel( | 808 WebInputEventResult WebFrameWidgetImpl::handleMouseWheel( |
| 808 LocalFrame& mainFrame, | 809 LocalFrame& mainFrame, |
| 809 const WebMouseWheelEvent& event) { | 810 const WebMouseWheelEvent& event) { |
| 810 return PageWidgetEventHandler::handleMouseWheel(mainFrame, event); | 811 return PageWidgetEventHandler::handleMouseWheel(mainFrame, event); |
| 811 } | 812 } |
| 812 | 813 |
| 813 WebInputEventResult WebFrameWidgetImpl::handleGestureEvent( | 814 WebInputEventResult WebFrameWidgetImpl::handleGestureEvent( |
| 814 const WebGestureEvent& event) { | 815 const WebGestureEvent& event) { |
| 815 WebInputEventResult eventResult = WebInputEventResult::NotHandled; | 816 WebInputEventResult eventResult = WebInputEventResult::NotHandled; |
| 816 bool eventCancelled = false; | 817 bool eventCancelled = false; |
| 817 switch (event.type) { | 818 switch (event.type()) { |
| 818 case WebInputEvent::GestureScrollBegin: | 819 case WebInputEvent::GestureScrollBegin: |
| 819 case WebInputEvent::GestureScrollEnd: | 820 case WebInputEvent::GestureScrollEnd: |
| 820 case WebInputEvent::GestureScrollUpdate: | 821 case WebInputEvent::GestureScrollUpdate: |
| 821 case WebInputEvent::GestureTap: | 822 case WebInputEvent::GestureTap: |
| 822 case WebInputEvent::GestureTapUnconfirmed: | 823 case WebInputEvent::GestureTapUnconfirmed: |
| 823 case WebInputEvent::GestureTapDown: | 824 case WebInputEvent::GestureTapDown: |
| 824 case WebInputEvent::GestureShowPress: | 825 case WebInputEvent::GestureShowPress: |
| 825 case WebInputEvent::GestureTapCancel: | 826 case WebInputEvent::GestureTapCancel: |
| 826 case WebInputEvent::GestureDoubleTap: | 827 case WebInputEvent::GestureDoubleTap: |
| 827 case WebInputEvent::GestureTwoFingerTap: | 828 case WebInputEvent::GestureTwoFingerTap: |
| 828 case WebInputEvent::GestureLongPress: | 829 case WebInputEvent::GestureLongPress: |
| 829 case WebInputEvent::GestureLongTap: | 830 case WebInputEvent::GestureLongTap: |
| 830 break; | 831 break; |
| 831 case WebInputEvent::GestureFlingStart: | 832 case WebInputEvent::GestureFlingStart: |
| 832 case WebInputEvent::GestureFlingCancel: | 833 case WebInputEvent::GestureFlingCancel: |
| 833 m_client->didHandleGestureEvent(event, eventCancelled); | 834 m_client->didHandleGestureEvent(event, eventCancelled); |
| 834 return WebInputEventResult::NotHandled; | 835 return WebInputEventResult::NotHandled; |
| 835 default: | 836 default: |
| 836 NOTREACHED(); | 837 NOTREACHED(); |
| 837 } | 838 } |
| 838 LocalFrame* frame = m_localRoot->frame(); | 839 LocalFrame* frame = m_localRoot->frame(); |
| 839 WebGestureEvent scaledEvent = TransformWebGestureEvent(frame->view(), event); | 840 WebGestureEvent scaledEvent = TransformWebGestureEvent(frame->view(), event); |
| 840 eventResult = frame->eventHandler().handleGestureEvent(scaledEvent); | 841 eventResult = frame->eventHandler().handleGestureEvent(scaledEvent); |
| 841 m_client->didHandleGestureEvent(event, eventCancelled); | 842 m_client->didHandleGestureEvent(event, eventCancelled); |
| 842 return eventResult; | 843 return eventResult; |
| 843 } | 844 } |
| 844 | 845 |
| 845 WebInputEventResult WebFrameWidgetImpl::handleKeyEvent( | 846 WebInputEventResult WebFrameWidgetImpl::handleKeyEvent( |
| 846 const WebKeyboardEvent& event) { | 847 const WebKeyboardEvent& event) { |
| 847 DCHECK((event.type == WebInputEvent::RawKeyDown) || | 848 DCHECK((event.type() == WebInputEvent::RawKeyDown) || |
| 848 (event.type == WebInputEvent::KeyDown) || | 849 (event.type() == WebInputEvent::KeyDown) || |
| 849 (event.type == WebInputEvent::KeyUp)); | 850 (event.type() == WebInputEvent::KeyUp)); |
| 850 | 851 |
| 851 // Please refer to the comments explaining the m_suppressNextKeypressEvent | 852 // Please refer to the comments explaining the m_suppressNextKeypressEvent |
| 852 // member. | 853 // member. |
| 853 // The m_suppressNextKeypressEvent is set if the KeyDown is handled by | 854 // The m_suppressNextKeypressEvent is set if the KeyDown is handled by |
| 854 // Webkit. A keyDown event is typically associated with a keyPress(char) | 855 // Webkit. A keyDown event is typically associated with a keyPress(char) |
| 855 // event and a keyUp event. We reset this flag here as this is a new keyDown | 856 // event and a keyUp event. We reset this flag here as this is a new keyDown |
| 856 // event. | 857 // event. |
| 857 m_suppressNextKeypressEvent = false; | 858 m_suppressNextKeypressEvent = false; |
| 858 | 859 |
| 859 Frame* focusedFrame = focusedCoreFrame(); | 860 Frame* focusedFrame = focusedCoreFrame(); |
| 860 if (focusedFrame && focusedFrame->isRemoteFrame()) { | 861 if (focusedFrame && focusedFrame->isRemoteFrame()) { |
| 861 WebRemoteFrameImpl* webFrame = | 862 WebRemoteFrameImpl* webFrame = |
| 862 WebRemoteFrameImpl::fromFrame(*toRemoteFrame(focusedFrame)); | 863 WebRemoteFrameImpl::fromFrame(*toRemoteFrame(focusedFrame)); |
| 863 webFrame->client()->forwardInputEvent(&event); | 864 webFrame->client()->forwardInputEvent(&event); |
| 864 return WebInputEventResult::HandledSystem; | 865 return WebInputEventResult::HandledSystem; |
| 865 } | 866 } |
| 866 | 867 |
| 867 if (!focusedFrame || !focusedFrame->isLocalFrame()) | 868 if (!focusedFrame || !focusedFrame->isLocalFrame()) |
| 868 return WebInputEventResult::NotHandled; | 869 return WebInputEventResult::NotHandled; |
| 869 | 870 |
| 870 LocalFrame* frame = toLocalFrame(focusedFrame); | 871 LocalFrame* frame = toLocalFrame(focusedFrame); |
| 871 | 872 |
| 872 WebInputEventResult result = frame->eventHandler().keyEvent(event); | 873 WebInputEventResult result = frame->eventHandler().keyEvent(event); |
| 873 if (result != WebInputEventResult::NotHandled) { | 874 if (result != WebInputEventResult::NotHandled) { |
| 874 if (WebInputEvent::RawKeyDown == event.type) { | 875 if (WebInputEvent::RawKeyDown == event.type()) { |
| 875 // Suppress the next keypress event unless the focused node is a plugin | 876 // Suppress the next keypress event unless the focused node is a plugin |
| 876 // node. (Flash needs these keypress events to handle non-US keyboards.) | 877 // node. (Flash needs these keypress events to handle non-US keyboards.) |
| 877 Element* element = focusedElement(); | 878 Element* element = focusedElement(); |
| 878 if (!element || !element->layoutObject() || | 879 if (!element || !element->layoutObject() || |
| 879 !element->layoutObject()->isEmbeddedObject()) | 880 !element->layoutObject()->isEmbeddedObject()) |
| 880 m_suppressNextKeypressEvent = true; | 881 m_suppressNextKeypressEvent = true; |
| 881 } | 882 } |
| 882 return result; | 883 return result; |
| 883 } | 884 } |
| 884 | 885 |
| 885 #if !OS(MACOSX) | 886 #if !OS(MACOSX) |
| 886 const WebInputEvent::Type contextMenuKeyTriggeringEventType = | 887 const WebInputEvent::Type contextMenuKeyTriggeringEventType = |
| 887 #if OS(WIN) | 888 #if OS(WIN) |
| 888 WebInputEvent::KeyUp; | 889 WebInputEvent::KeyUp; |
| 889 #else | 890 #else |
| 890 WebInputEvent::RawKeyDown; | 891 WebInputEvent::RawKeyDown; |
| 891 #endif | 892 #endif |
| 892 const WebInputEvent::Type shiftF10TriggeringEventType = | 893 const WebInputEvent::Type shiftF10TriggeringEventType = |
| 893 WebInputEvent::RawKeyDown; | 894 WebInputEvent::RawKeyDown; |
| 894 | 895 |
| 895 bool isUnmodifiedMenuKey = | 896 bool isUnmodifiedMenuKey = |
| 896 !(event.modifiers & WebInputEvent::InputModifiers) && | 897 !(event.modifiers() & WebInputEvent::InputModifiers) && |
| 897 event.windowsKeyCode == VKEY_APPS; | 898 event.windowsKeyCode == VKEY_APPS; |
| 898 bool isShiftF10 = (event.modifiers & WebInputEvent::InputModifiers) == | 899 bool isShiftF10 = (event.modifiers() & WebInputEvent::InputModifiers) == |
| 899 WebInputEvent::ShiftKey && | 900 WebInputEvent::ShiftKey && |
| 900 event.windowsKeyCode == VKEY_F10; | 901 event.windowsKeyCode == VKEY_F10; |
| 901 if ((isUnmodifiedMenuKey && | 902 if ((isUnmodifiedMenuKey && |
| 902 event.type == contextMenuKeyTriggeringEventType) || | 903 event.type() == contextMenuKeyTriggeringEventType) || |
| 903 (isShiftF10 && event.type == shiftF10TriggeringEventType)) { | 904 (isShiftF10 && event.type() == shiftF10TriggeringEventType)) { |
| 904 view()->sendContextMenuEvent(event); | 905 view()->sendContextMenuEvent(event); |
| 905 return WebInputEventResult::HandledSystem; | 906 return WebInputEventResult::HandledSystem; |
| 906 } | 907 } |
| 907 #endif // !OS(MACOSX) | 908 #endif // !OS(MACOSX) |
| 908 | 909 |
| 909 return WebInputEventResult::NotHandled; | 910 return WebInputEventResult::NotHandled; |
| 910 } | 911 } |
| 911 | 912 |
| 912 WebInputEventResult WebFrameWidgetImpl::handleCharEvent( | 913 WebInputEventResult WebFrameWidgetImpl::handleCharEvent( |
| 913 const WebKeyboardEvent& event) { | 914 const WebKeyboardEvent& event) { |
| 914 DCHECK_EQ(event.type, WebInputEvent::Char); | 915 DCHECK_EQ(event.type(), WebInputEvent::Char); |
| 915 | 916 |
| 916 // Please refer to the comments explaining the m_suppressNextKeypressEvent | 917 // Please refer to the comments explaining the m_suppressNextKeypressEvent |
| 917 // member. The m_suppressNextKeypressEvent is set if the KeyDown is | 918 // member. The m_suppressNextKeypressEvent is set if the KeyDown is |
| 918 // handled by Webkit. A keyDown event is typically associated with a | 919 // handled by Webkit. A keyDown event is typically associated with a |
| 919 // keyPress(char) event and a keyUp event. We reset this flag here as it | 920 // keyPress(char) event and a keyUp event. We reset this flag here as it |
| 920 // only applies to the current keyPress event. | 921 // only applies to the current keyPress event. |
| 921 bool suppress = m_suppressNextKeypressEvent; | 922 bool suppress = m_suppressNextKeypressEvent; |
| 922 m_suppressNextKeypressEvent = false; | 923 m_suppressNextKeypressEvent = false; |
| 923 | 924 |
| 924 LocalFrame* frame = toLocalFrame(focusedCoreFrame()); | 925 LocalFrame* frame = toLocalFrame(focusedCoreFrame()); |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1120 return nullptr; | 1121 return nullptr; |
| 1121 } | 1122 } |
| 1122 | 1123 |
| 1123 LocalFrame* WebFrameWidgetImpl::focusedLocalFrameAvailableForIme() const { | 1124 LocalFrame* WebFrameWidgetImpl::focusedLocalFrameAvailableForIme() const { |
| 1124 if (!m_imeAcceptEvents) | 1125 if (!m_imeAcceptEvents) |
| 1125 return nullptr; | 1126 return nullptr; |
| 1126 return focusedLocalFrameInWidget(); | 1127 return focusedLocalFrameInWidget(); |
| 1127 } | 1128 } |
| 1128 | 1129 |
| 1129 } // namespace blink | 1130 } // namespace blink |
| OLD | NEW |