| 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 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 | 317 |
| 318 WebRect damagedRect(0, 0, m_size.width, m_size.height); | 318 WebRect damagedRect(0, 0, m_size.width, m_size.height); |
| 319 view->invalidateRect(damagedRect); | 319 view->invalidateRect(damagedRect); |
| 320 } | 320 } |
| 321 | 321 |
| 322 const WebInputEvent* WebFrameWidgetImpl::m_currentInputEvent = nullptr; | 322 const WebInputEvent* WebFrameWidgetImpl::m_currentInputEvent = nullptr; |
| 323 | 323 |
| 324 WebInputEventResult WebFrameWidgetImpl::handleInputEvent( | 324 WebInputEventResult WebFrameWidgetImpl::handleInputEvent( |
| 325 const WebInputEvent& inputEvent) { | 325 const WebInputEvent& inputEvent) { |
| 326 TRACE_EVENT1("input", "WebFrameWidgetImpl::handleInputEvent", "type", | 326 TRACE_EVENT1("input", "WebFrameWidgetImpl::handleInputEvent", "type", |
| 327 WebInputEvent::GetName(inputEvent.type)); | 327 WebInputEvent::GetName(inputEvent.type())); |
| 328 | 328 |
| 329 // If a drag-and-drop operation is in progress, ignore input events. | 329 // If a drag-and-drop operation is in progress, ignore input events. |
| 330 if (m_doingDragAndDrop) | 330 if (m_doingDragAndDrop) |
| 331 return WebInputEventResult::HandledSuppressed; | 331 return WebInputEventResult::HandledSuppressed; |
| 332 | 332 |
| 333 // Don't handle events once we've started shutting down. | 333 // Don't handle events once we've started shutting down. |
| 334 if (!page()) | 334 if (!page()) |
| 335 return WebInputEventResult::NotHandled; | 335 return WebInputEventResult::NotHandled; |
| 336 | 336 |
| 337 if (InspectorOverlay* overlay = inspectorOverlay()) { | 337 if (InspectorOverlay* overlay = inspectorOverlay()) { |
| 338 if (overlay->handleInputEvent(inputEvent)) | 338 if (overlay->handleInputEvent(inputEvent)) |
| 339 return WebInputEventResult::HandledSuppressed; | 339 return WebInputEventResult::HandledSuppressed; |
| 340 } | 340 } |
| 341 | 341 |
| 342 // Report the event to be NOT processed by WebKit, so that the browser can | 342 // Report the event to be NOT processed by WebKit, so that the browser can |
| 343 // handle it appropriately. | 343 // handle it appropriately. |
| 344 if (m_ignoreInputEvents) | 344 if (m_ignoreInputEvents) |
| 345 return WebInputEventResult::NotHandled; | 345 return WebInputEventResult::NotHandled; |
| 346 | 346 |
| 347 // FIXME: pass event to m_localRoot's WebDevToolsAgentImpl once available. | 347 // FIXME: pass event to m_localRoot's WebDevToolsAgentImpl once available. |
| 348 | 348 |
| 349 AutoReset<const WebInputEvent*> currentEventChange(&m_currentInputEvent, | 349 AutoReset<const WebInputEvent*> currentEventChange(&m_currentInputEvent, |
| 350 &inputEvent); | 350 &inputEvent); |
| 351 | 351 |
| 352 if (m_mouseCaptureNode && WebInputEvent::isMouseEventType(inputEvent.type)) { | 352 if (m_mouseCaptureNode && |
| 353 TRACE_EVENT1("input", "captured mouse event", "type", inputEvent.type); | 353 WebInputEvent::isMouseEventType(inputEvent.type())) { |
| 354 TRACE_EVENT1("input", "captured mouse event", "type", inputEvent.type()); |
| 354 // Save m_mouseCaptureNode since mouseCaptureLost() will clear it. | 355 // Save m_mouseCaptureNode since mouseCaptureLost() will clear it. |
| 355 Node* node = m_mouseCaptureNode; | 356 Node* node = m_mouseCaptureNode; |
| 356 | 357 |
| 357 // Not all platforms call mouseCaptureLost() directly. | 358 // Not all platforms call mouseCaptureLost() directly. |
| 358 if (inputEvent.type == WebInputEvent::MouseUp) | 359 if (inputEvent.type() == WebInputEvent::MouseUp) |
| 359 mouseCaptureLost(); | 360 mouseCaptureLost(); |
| 360 | 361 |
| 361 std::unique_ptr<UserGestureIndicator> gestureIndicator; | 362 std::unique_ptr<UserGestureIndicator> gestureIndicator; |
| 362 | 363 |
| 363 AtomicString eventType; | 364 AtomicString eventType; |
| 364 switch (inputEvent.type) { | 365 switch (inputEvent.type()) { |
| 365 case WebInputEvent::MouseMove: | 366 case WebInputEvent::MouseMove: |
| 366 eventType = EventTypeNames::mousemove; | 367 eventType = EventTypeNames::mousemove; |
| 367 break; | 368 break; |
| 368 case WebInputEvent::MouseLeave: | 369 case WebInputEvent::MouseLeave: |
| 369 eventType = EventTypeNames::mouseout; | 370 eventType = EventTypeNames::mouseout; |
| 370 break; | 371 break; |
| 371 case WebInputEvent::MouseDown: | 372 case WebInputEvent::MouseDown: |
| 372 eventType = EventTypeNames::mousedown; | 373 eventType = EventTypeNames::mousedown; |
| 373 gestureIndicator = WTF::wrapUnique( | 374 gestureIndicator = WTF::wrapUnique( |
| 374 new UserGestureIndicator(DocumentUserGestureToken::create( | 375 new UserGestureIndicator(DocumentUserGestureToken::create( |
| (...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 834 WebInputEventResult WebFrameWidgetImpl::handleMouseWheel( | 835 WebInputEventResult WebFrameWidgetImpl::handleMouseWheel( |
| 835 LocalFrame& mainFrame, | 836 LocalFrame& mainFrame, |
| 836 const WebMouseWheelEvent& event) { | 837 const WebMouseWheelEvent& event) { |
| 837 return PageWidgetEventHandler::handleMouseWheel(mainFrame, event); | 838 return PageWidgetEventHandler::handleMouseWheel(mainFrame, event); |
| 838 } | 839 } |
| 839 | 840 |
| 840 WebInputEventResult WebFrameWidgetImpl::handleGestureEvent( | 841 WebInputEventResult WebFrameWidgetImpl::handleGestureEvent( |
| 841 const WebGestureEvent& event) { | 842 const WebGestureEvent& event) { |
| 842 WebInputEventResult eventResult = WebInputEventResult::NotHandled; | 843 WebInputEventResult eventResult = WebInputEventResult::NotHandled; |
| 843 bool eventCancelled = false; | 844 bool eventCancelled = false; |
| 844 switch (event.type) { | 845 switch (event.type()) { |
| 845 case WebInputEvent::GestureScrollBegin: | 846 case WebInputEvent::GestureScrollBegin: |
| 846 case WebInputEvent::GestureScrollEnd: | 847 case WebInputEvent::GestureScrollEnd: |
| 847 case WebInputEvent::GestureScrollUpdate: | 848 case WebInputEvent::GestureScrollUpdate: |
| 848 case WebInputEvent::GestureTap: | 849 case WebInputEvent::GestureTap: |
| 849 case WebInputEvent::GestureTapUnconfirmed: | 850 case WebInputEvent::GestureTapUnconfirmed: |
| 850 case WebInputEvent::GestureTapDown: | 851 case WebInputEvent::GestureTapDown: |
| 851 case WebInputEvent::GestureShowPress: | 852 case WebInputEvent::GestureShowPress: |
| 852 case WebInputEvent::GestureTapCancel: | 853 case WebInputEvent::GestureTapCancel: |
| 853 case WebInputEvent::GestureDoubleTap: | 854 case WebInputEvent::GestureDoubleTap: |
| 854 case WebInputEvent::GestureTwoFingerTap: | 855 case WebInputEvent::GestureTwoFingerTap: |
| 855 case WebInputEvent::GestureLongPress: | 856 case WebInputEvent::GestureLongPress: |
| 856 case WebInputEvent::GestureLongTap: | 857 case WebInputEvent::GestureLongTap: |
| 857 break; | 858 break; |
| 858 case WebInputEvent::GestureFlingStart: | 859 case WebInputEvent::GestureFlingStart: |
| 859 case WebInputEvent::GestureFlingCancel: | 860 case WebInputEvent::GestureFlingCancel: |
| 860 m_client->didHandleGestureEvent(event, eventCancelled); | 861 m_client->didHandleGestureEvent(event, eventCancelled); |
| 861 return WebInputEventResult::NotHandled; | 862 return WebInputEventResult::NotHandled; |
| 862 default: | 863 default: |
| 863 NOTREACHED(); | 864 NOTREACHED(); |
| 864 } | 865 } |
| 865 LocalFrame* frame = m_localRoot->frame(); | 866 LocalFrame* frame = m_localRoot->frame(); |
| 866 eventResult = frame->eventHandler().handleGestureEvent( | 867 eventResult = frame->eventHandler().handleGestureEvent( |
| 867 PlatformGestureEventBuilder(frame->view(), event)); | 868 PlatformGestureEventBuilder(frame->view(), event)); |
| 868 m_client->didHandleGestureEvent(event, eventCancelled); | 869 m_client->didHandleGestureEvent(event, eventCancelled); |
| 869 return eventResult; | 870 return eventResult; |
| 870 } | 871 } |
| 871 | 872 |
| 872 WebInputEventResult WebFrameWidgetImpl::handleKeyEvent( | 873 WebInputEventResult WebFrameWidgetImpl::handleKeyEvent( |
| 873 const WebKeyboardEvent& event) { | 874 const WebKeyboardEvent& event) { |
| 874 DCHECK((event.type == WebInputEvent::RawKeyDown) || | 875 DCHECK((event.type() == WebInputEvent::RawKeyDown) || |
| 875 (event.type == WebInputEvent::KeyDown) || | 876 (event.type() == WebInputEvent::KeyDown) || |
| 876 (event.type == WebInputEvent::KeyUp)); | 877 (event.type() == WebInputEvent::KeyUp)); |
| 877 | 878 |
| 878 // Please refer to the comments explaining the m_suppressNextKeypressEvent | 879 // Please refer to the comments explaining the m_suppressNextKeypressEvent |
| 879 // member. | 880 // member. |
| 880 // The m_suppressNextKeypressEvent is set if the KeyDown is handled by | 881 // The m_suppressNextKeypressEvent is set if the KeyDown is handled by |
| 881 // Webkit. A keyDown event is typically associated with a keyPress(char) | 882 // Webkit. A keyDown event is typically associated with a keyPress(char) |
| 882 // event and a keyUp event. We reset this flag here as this is a new keyDown | 883 // event and a keyUp event. We reset this flag here as this is a new keyDown |
| 883 // event. | 884 // event. |
| 884 m_suppressNextKeypressEvent = false; | 885 m_suppressNextKeypressEvent = false; |
| 885 | 886 |
| 886 Frame* focusedFrame = focusedCoreFrame(); | 887 Frame* focusedFrame = focusedCoreFrame(); |
| 887 if (focusedFrame && focusedFrame->isRemoteFrame()) { | 888 if (focusedFrame && focusedFrame->isRemoteFrame()) { |
| 888 WebRemoteFrameImpl* webFrame = | 889 WebRemoteFrameImpl* webFrame = |
| 889 WebRemoteFrameImpl::fromFrame(*toRemoteFrame(focusedFrame)); | 890 WebRemoteFrameImpl::fromFrame(*toRemoteFrame(focusedFrame)); |
| 890 webFrame->client()->forwardInputEvent(&event); | 891 webFrame->client()->forwardInputEvent(&event); |
| 891 return WebInputEventResult::HandledSystem; | 892 return WebInputEventResult::HandledSystem; |
| 892 } | 893 } |
| 893 | 894 |
| 894 if (!focusedFrame || !focusedFrame->isLocalFrame()) | 895 if (!focusedFrame || !focusedFrame->isLocalFrame()) |
| 895 return WebInputEventResult::NotHandled; | 896 return WebInputEventResult::NotHandled; |
| 896 | 897 |
| 897 LocalFrame* frame = toLocalFrame(focusedFrame); | 898 LocalFrame* frame = toLocalFrame(focusedFrame); |
| 898 | 899 |
| 899 WebInputEventResult result = frame->eventHandler().keyEvent(event); | 900 WebInputEventResult result = frame->eventHandler().keyEvent(event); |
| 900 if (result != WebInputEventResult::NotHandled) { | 901 if (result != WebInputEventResult::NotHandled) { |
| 901 if (WebInputEvent::RawKeyDown == event.type) { | 902 if (WebInputEvent::RawKeyDown == event.type()) { |
| 902 // Suppress the next keypress event unless the focused node is a plugin | 903 // Suppress the next keypress event unless the focused node is a plugin |
| 903 // node. (Flash needs these keypress events to handle non-US keyboards.) | 904 // node. (Flash needs these keypress events to handle non-US keyboards.) |
| 904 Element* element = focusedElement(); | 905 Element* element = focusedElement(); |
| 905 if (!element || !element->layoutObject() || | 906 if (!element || !element->layoutObject() || |
| 906 !element->layoutObject()->isEmbeddedObject()) | 907 !element->layoutObject()->isEmbeddedObject()) |
| 907 m_suppressNextKeypressEvent = true; | 908 m_suppressNextKeypressEvent = true; |
| 908 } | 909 } |
| 909 return result; | 910 return result; |
| 910 } | 911 } |
| 911 | 912 |
| 912 #if !OS(MACOSX) | 913 #if !OS(MACOSX) |
| 913 const WebInputEvent::Type contextMenuKeyTriggeringEventType = | 914 const WebInputEvent::Type contextMenuKeyTriggeringEventType = |
| 914 #if OS(WIN) | 915 #if OS(WIN) |
| 915 WebInputEvent::KeyUp; | 916 WebInputEvent::KeyUp; |
| 916 #else | 917 #else |
| 917 WebInputEvent::RawKeyDown; | 918 WebInputEvent::RawKeyDown; |
| 918 #endif | 919 #endif |
| 919 const WebInputEvent::Type shiftF10TriggeringEventType = | 920 const WebInputEvent::Type shiftF10TriggeringEventType = |
| 920 WebInputEvent::RawKeyDown; | 921 WebInputEvent::RawKeyDown; |
| 921 | 922 |
| 922 bool isUnmodifiedMenuKey = | 923 bool isUnmodifiedMenuKey = |
| 923 !(event.modifiers & WebInputEvent::InputModifiers) && | 924 !(event.modifiers() & WebInputEvent::InputModifiers) && |
| 924 event.windowsKeyCode == VKEY_APPS; | 925 event.windowsKeyCode == VKEY_APPS; |
| 925 bool isShiftF10 = (event.modifiers & WebInputEvent::InputModifiers) == | 926 bool isShiftF10 = (event.modifiers() & WebInputEvent::InputModifiers) == |
| 926 WebInputEvent::ShiftKey && | 927 WebInputEvent::ShiftKey && |
| 927 event.windowsKeyCode == VKEY_F10; | 928 event.windowsKeyCode == VKEY_F10; |
| 928 if ((isUnmodifiedMenuKey && | 929 if ((isUnmodifiedMenuKey && |
| 929 event.type == contextMenuKeyTriggeringEventType) || | 930 event.type() == contextMenuKeyTriggeringEventType) || |
| 930 (isShiftF10 && event.type == shiftF10TriggeringEventType)) { | 931 (isShiftF10 && event.type() == shiftF10TriggeringEventType)) { |
| 931 view()->sendContextMenuEvent(event); | 932 view()->sendContextMenuEvent(event); |
| 932 return WebInputEventResult::HandledSystem; | 933 return WebInputEventResult::HandledSystem; |
| 933 } | 934 } |
| 934 #endif // !OS(MACOSX) | 935 #endif // !OS(MACOSX) |
| 935 | 936 |
| 936 return WebInputEventResult::NotHandled; | 937 return WebInputEventResult::NotHandled; |
| 937 } | 938 } |
| 938 | 939 |
| 939 WebInputEventResult WebFrameWidgetImpl::handleCharEvent( | 940 WebInputEventResult WebFrameWidgetImpl::handleCharEvent( |
| 940 const WebKeyboardEvent& event) { | 941 const WebKeyboardEvent& event) { |
| 941 DCHECK_EQ(event.type, WebInputEvent::Char); | 942 DCHECK_EQ(event.type(), WebInputEvent::Char); |
| 942 | 943 |
| 943 // Please refer to the comments explaining the m_suppressNextKeypressEvent | 944 // Please refer to the comments explaining the m_suppressNextKeypressEvent |
| 944 // member. The m_suppressNextKeypressEvent is set if the KeyDown is | 945 // member. The m_suppressNextKeypressEvent is set if the KeyDown is |
| 945 // handled by Webkit. A keyDown event is typically associated with a | 946 // handled by Webkit. A keyDown event is typically associated with a |
| 946 // keyPress(char) event and a keyUp event. We reset this flag here as it | 947 // keyPress(char) event and a keyUp event. We reset this flag here as it |
| 947 // only applies to the current keyPress event. | 948 // only applies to the current keyPress event. |
| 948 bool suppress = m_suppressNextKeypressEvent; | 949 bool suppress = m_suppressNextKeypressEvent; |
| 949 m_suppressNextKeypressEvent = false; | 950 m_suppressNextKeypressEvent = false; |
| 950 | 951 |
| 951 LocalFrame* frame = toLocalFrame(focusedCoreFrame()); | 952 LocalFrame* frame = toLocalFrame(focusedCoreFrame()); |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1150 return nullptr; | 1151 return nullptr; |
| 1151 } | 1152 } |
| 1152 | 1153 |
| 1153 LocalFrame* WebFrameWidgetImpl::focusedLocalFrameAvailableForIme() const { | 1154 LocalFrame* WebFrameWidgetImpl::focusedLocalFrameAvailableForIme() const { |
| 1154 if (!m_imeAcceptEvents) | 1155 if (!m_imeAcceptEvents) |
| 1155 return nullptr; | 1156 return nullptr; |
| 1156 return focusedLocalFrameInWidget(); | 1157 return focusedLocalFrameInWidget(); |
| 1157 } | 1158 } |
| 1158 | 1159 |
| 1159 } // namespace blink | 1160 } // namespace blink |
| OLD | NEW |