| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2011, 2012 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 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 630 PageWidgetEventHandler::handleMouseUp(mainFrame, event); | 630 PageWidgetEventHandler::handleMouseUp(mainFrame, event); |
| 631 | 631 |
| 632 if (page()->settings().showContextMenuOnMouseUp()) { | 632 if (page()->settings().showContextMenuOnMouseUp()) { |
| 633 // Dispatch the contextmenu event regardless of if the click was swallow
ed. | 633 // Dispatch the contextmenu event regardless of if the click was swallow
ed. |
| 634 // On Mac/Linux, we handle it on mouse down, not up. | 634 // On Mac/Linux, we handle it on mouse down, not up. |
| 635 if (event.button == WebMouseEvent::ButtonRight) | 635 if (event.button == WebMouseEvent::ButtonRight) |
| 636 mouseContextMenu(event); | 636 mouseContextMenu(event); |
| 637 } | 637 } |
| 638 } | 638 } |
| 639 | 639 |
| 640 bool WebViewImpl::handleMouseWheel(LocalFrame& mainFrame, const WebMouseWheelEve
nt& event) | 640 WebInputEventResult WebViewImpl::handleMouseWheel(LocalFrame& mainFrame, const W
ebMouseWheelEvent& event) |
| 641 { | 641 { |
| 642 hidePopups(); | 642 hidePopups(); |
| 643 return PageWidgetEventHandler::handleMouseWheel(mainFrame, event); | 643 return PageWidgetEventHandler::handleMouseWheel(mainFrame, event); |
| 644 } | 644 } |
| 645 | 645 |
| 646 bool WebViewImpl::scrollBy(const WebFloatSize& delta, const WebFloatSize& veloci
ty) | 646 bool WebViewImpl::scrollBy(const WebFloatSize& delta, const WebFloatSize& veloci
ty) |
| 647 { | 647 { |
| 648 ASSERT(m_flingSourceDevice != WebGestureDeviceUninitialized); | 648 ASSERT(m_flingSourceDevice != WebGestureDeviceUninitialized); |
| 649 if (m_flingSourceDevice == WebGestureDeviceTouchpad) { | 649 if (m_flingSourceDevice == WebGestureDeviceTouchpad) { |
| 650 WebMouseWheelEvent syntheticWheel; | 650 WebMouseWheelEvent syntheticWheel; |
| 651 const float tickDivisor = WheelEvent::TickMultiplier; | 651 const float tickDivisor = WheelEvent::TickMultiplier; |
| 652 | 652 |
| 653 syntheticWheel.deltaX = delta.width; | 653 syntheticWheel.deltaX = delta.width; |
| 654 syntheticWheel.deltaY = delta.height; | 654 syntheticWheel.deltaY = delta.height; |
| 655 syntheticWheel.wheelTicksX = delta.width / tickDivisor; | 655 syntheticWheel.wheelTicksX = delta.width / tickDivisor; |
| 656 syntheticWheel.wheelTicksY = delta.height / tickDivisor; | 656 syntheticWheel.wheelTicksY = delta.height / tickDivisor; |
| 657 syntheticWheel.hasPreciseScrollingDeltas = true; | 657 syntheticWheel.hasPreciseScrollingDeltas = true; |
| 658 syntheticWheel.x = m_positionOnFlingStart.x; | 658 syntheticWheel.x = m_positionOnFlingStart.x; |
| 659 syntheticWheel.y = m_positionOnFlingStart.y; | 659 syntheticWheel.y = m_positionOnFlingStart.y; |
| 660 syntheticWheel.globalX = m_globalPositionOnFlingStart.x; | 660 syntheticWheel.globalX = m_globalPositionOnFlingStart.x; |
| 661 syntheticWheel.globalY = m_globalPositionOnFlingStart.y; | 661 syntheticWheel.globalY = m_globalPositionOnFlingStart.y; |
| 662 syntheticWheel.modifiers = m_flingModifier; | 662 syntheticWheel.modifiers = m_flingModifier; |
| 663 | 663 |
| 664 if (m_page && m_page->mainFrame() && m_page->mainFrame()->isLocalFrame()
&& m_page->deprecatedLocalMainFrame()->view()) | 664 if (m_page && m_page->mainFrame() && m_page->mainFrame()->isLocalFrame()
&& m_page->deprecatedLocalMainFrame()->view()) |
| 665 return handleMouseWheel(*m_page->deprecatedLocalMainFrame(), synthet
icWheel); | 665 return handleMouseWheel(*m_page->deprecatedLocalMainFrame(), synthet
icWheel) != WebInputEventResult::NotHandled; |
| 666 } else { | 666 } else { |
| 667 WebGestureEvent syntheticGestureEvent; | 667 WebGestureEvent syntheticGestureEvent; |
| 668 | 668 |
| 669 syntheticGestureEvent.type = WebInputEvent::GestureScrollUpdate; | 669 syntheticGestureEvent.type = WebInputEvent::GestureScrollUpdate; |
| 670 syntheticGestureEvent.data.scrollUpdate.preventPropagation = true; | 670 syntheticGestureEvent.data.scrollUpdate.preventPropagation = true; |
| 671 syntheticGestureEvent.data.scrollUpdate.deltaX = delta.width; | 671 syntheticGestureEvent.data.scrollUpdate.deltaX = delta.width; |
| 672 syntheticGestureEvent.data.scrollUpdate.deltaY = delta.height; | 672 syntheticGestureEvent.data.scrollUpdate.deltaY = delta.height; |
| 673 syntheticGestureEvent.data.scrollUpdate.velocityX = velocity.width; | 673 syntheticGestureEvent.data.scrollUpdate.velocityX = velocity.width; |
| 674 syntheticGestureEvent.data.scrollUpdate.velocityY = velocity.height; | 674 syntheticGestureEvent.data.scrollUpdate.velocityY = velocity.height; |
| 675 syntheticGestureEvent.x = m_positionOnFlingStart.x; | 675 syntheticGestureEvent.x = m_positionOnFlingStart.x; |
| 676 syntheticGestureEvent.y = m_positionOnFlingStart.y; | 676 syntheticGestureEvent.y = m_positionOnFlingStart.y; |
| 677 syntheticGestureEvent.globalX = m_globalPositionOnFlingStart.x; | 677 syntheticGestureEvent.globalX = m_globalPositionOnFlingStart.x; |
| 678 syntheticGestureEvent.globalY = m_globalPositionOnFlingStart.y; | 678 syntheticGestureEvent.globalY = m_globalPositionOnFlingStart.y; |
| 679 syntheticGestureEvent.modifiers = m_flingModifier; | 679 syntheticGestureEvent.modifiers = m_flingModifier; |
| 680 syntheticGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; | 680 syntheticGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; |
| 681 syntheticGestureEvent.data.scrollUpdate.inertial = true; | 681 syntheticGestureEvent.data.scrollUpdate.inertial = true; |
| 682 | 682 |
| 683 if (m_page && m_page->mainFrame() && m_page->mainFrame()->isLocalFrame()
&& m_page->deprecatedLocalMainFrame()->view()) | 683 if (m_page && m_page->mainFrame() && m_page->mainFrame()->isLocalFrame()
&& m_page->deprecatedLocalMainFrame()->view()) |
| 684 return handleGestureEvent(syntheticGestureEvent); | 684 return handleGestureEvent(syntheticGestureEvent) != WebInputEventRes
ult::NotHandled; |
| 685 } | 685 } |
| 686 return false; | 686 return false; |
| 687 } | 687 } |
| 688 | 688 |
| 689 bool WebViewImpl::handleGestureEvent(const WebGestureEvent& event) | 689 WebInputEventResult WebViewImpl::handleGestureEvent(const WebGestureEvent& event
) |
| 690 { | 690 { |
| 691 if (!m_client) | 691 if (!m_client) |
| 692 return false; | 692 return WebInputEventResult::NotHandled; |
| 693 | 693 |
| 694 bool eventSwallowed = false; | 694 WebInputEventResult eventSwallowed = WebInputEventResult::NotHandled; |
| 695 bool eventCancelled = false; // for disambiguation | 695 bool eventCancelled = false; // for disambiguation |
| 696 | 696 |
| 697 // Special handling for slow-path fling gestures. | 697 // Special handling for slow-path fling gestures. |
| 698 switch (event.type) { | 698 switch (event.type) { |
| 699 case WebInputEvent::GestureFlingStart: { | 699 case WebInputEvent::GestureFlingStart: { |
| 700 if (mainFrameImpl()->frame()->eventHandler().isScrollbarHandlingGestures
()) | 700 if (mainFrameImpl()->frame()->eventHandler().isScrollbarHandlingGestures
()) |
| 701 break; | 701 break; |
| 702 endActiveFlingAnimation(); | 702 endActiveFlingAnimation(); |
| 703 m_client->cancelScheduledContentIntents(); | 703 m_client->cancelScheduledContentIntents(); |
| 704 m_positionOnFlingStart = WebPoint(event.x, event.y); | 704 m_positionOnFlingStart = WebPoint(event.x, event.y); |
| 705 m_globalPositionOnFlingStart = WebPoint(event.globalX, event.globalY); | 705 m_globalPositionOnFlingStart = WebPoint(event.globalX, event.globalY); |
| 706 m_flingModifier = event.modifiers; | 706 m_flingModifier = event.modifiers; |
| 707 m_flingSourceDevice = event.sourceDevice; | 707 m_flingSourceDevice = event.sourceDevice; |
| 708 ASSERT(m_flingSourceDevice != WebGestureDeviceUninitialized); | 708 ASSERT(m_flingSourceDevice != WebGestureDeviceUninitialized); |
| 709 OwnPtr<WebGestureCurve> flingCurve = adoptPtr(Platform::current()->creat
eFlingAnimationCurve(event.sourceDevice, WebFloatPoint(event.data.flingStart.vel
ocityX, event.data.flingStart.velocityY), WebSize())); | 709 OwnPtr<WebGestureCurve> flingCurve = adoptPtr(Platform::current()->creat
eFlingAnimationCurve(event.sourceDevice, WebFloatPoint(event.data.flingStart.vel
ocityX, event.data.flingStart.velocityY), WebSize())); |
| 710 ASSERT(flingCurve); | 710 ASSERT(flingCurve); |
| 711 m_gestureAnimation = WebActiveGestureAnimation::createAtAnimationStart(f
lingCurve.release(), this); | 711 m_gestureAnimation = WebActiveGestureAnimation::createAtAnimationStart(f
lingCurve.release(), this); |
| 712 scheduleAnimation(); | 712 scheduleAnimation(); |
| 713 eventSwallowed = true; | 713 eventSwallowed = WebInputEventResult::HandledDefaultHandler; |
| 714 | 714 |
| 715 // Plugins may need to see GestureFlingStart to balance | 715 // Plugins may need to see GestureFlingStart to balance |
| 716 // GestureScrollBegin (since the former replaces GestureScrollEnd when | 716 // GestureScrollBegin (since the former replaces GestureScrollEnd when |
| 717 // transitioning to a fling). | 717 // transitioning to a fling). |
| 718 PlatformGestureEventBuilder platformEvent(mainFrameImpl()->frameView(),
event); | 718 PlatformGestureEventBuilder platformEvent(mainFrameImpl()->frameView(),
event); |
| 719 mainFrameImpl()->frame()->eventHandler().handleGestureScrollEvent(platfo
rmEvent); | 719 mainFrameImpl()->frame()->eventHandler().handleGestureScrollEvent(platfo
rmEvent); |
| 720 | 720 |
| 721 m_client->didHandleGestureEvent(event, eventCancelled); | 721 m_client->didHandleGestureEvent(event, eventCancelled); |
| 722 return eventSwallowed; | 722 return eventSwallowed; |
| 723 } | 723 } |
| 724 case WebInputEvent::GestureFlingCancel: | 724 case WebInputEvent::GestureFlingCancel: |
| 725 if (endActiveFlingAnimation()) | 725 if (endActiveFlingAnimation()) |
| 726 eventSwallowed = true; | 726 eventSwallowed = WebInputEventResult::HandledDefaultHandler; |
| 727 | 727 |
| 728 m_client->didHandleGestureEvent(event, eventCancelled); | 728 m_client->didHandleGestureEvent(event, eventCancelled); |
| 729 return eventSwallowed; | 729 return eventSwallowed; |
| 730 default: | 730 default: |
| 731 break; | 731 break; |
| 732 } | 732 } |
| 733 | 733 |
| 734 PlatformGestureEventBuilder platformEvent(mainFrameImpl()->frameView(), even
t); | 734 PlatformGestureEventBuilder platformEvent(mainFrameImpl()->frameView(), even
t); |
| 735 | 735 |
| 736 // Special handling for double tap and scroll events as we don't want to | 736 // Special handling for double tap and scroll events as we don't want to |
| 737 // hit test for them. | 737 // hit test for them. |
| 738 switch (event.type) { | 738 switch (event.type) { |
| 739 case WebInputEvent::GestureDoubleTap: | 739 case WebInputEvent::GestureDoubleTap: |
| 740 if (m_webSettings->doubleTapToZoomEnabled() && minimumPageScaleFactor()
!= maximumPageScaleFactor()) { | 740 if (m_webSettings->doubleTapToZoomEnabled() && minimumPageScaleFactor()
!= maximumPageScaleFactor()) { |
| 741 m_client->cancelScheduledContentIntents(); | 741 m_client->cancelScheduledContentIntents(); |
| 742 animateDoubleTapZoom(platformEvent.position()); | 742 animateDoubleTapZoom(platformEvent.position()); |
| 743 } | 743 } |
| 744 // GestureDoubleTap is currently only used by Android for zooming. For W
ebCore, | 744 // GestureDoubleTap is currently only used by Android for zooming. For W
ebCore, |
| 745 // GestureTap with tap count = 2 is used instead. So we drop GestureDoub
leTap here. | 745 // GestureTap with tap count = 2 is used instead. So we drop GestureDoub
leTap here. |
| 746 eventSwallowed = true; | 746 eventSwallowed = WebInputEventResult::HandledDefaultHandler; |
| 747 m_client->didHandleGestureEvent(event, eventCancelled); | 747 m_client->didHandleGestureEvent(event, eventCancelled); |
| 748 return eventSwallowed; | 748 return eventSwallowed; |
| 749 case WebInputEvent::GestureScrollBegin: | 749 case WebInputEvent::GestureScrollBegin: |
| 750 m_client->cancelScheduledContentIntents(); | 750 m_client->cancelScheduledContentIntents(); |
| 751 case WebInputEvent::GestureScrollEnd: | 751 case WebInputEvent::GestureScrollEnd: |
| 752 case WebInputEvent::GestureScrollUpdate: | 752 case WebInputEvent::GestureScrollUpdate: |
| 753 case WebInputEvent::GestureFlingStart: | 753 case WebInputEvent::GestureFlingStart: |
| 754 // Scrolling-related gesture events invoke EventHandler recursively for
each frame down | 754 // Scrolling-related gesture events invoke EventHandler recursively for
each frame down |
| 755 // the chain, doing a single-frame hit-test per frame. This matches hand
leWheelEvent. | 755 // the chain, doing a single-frame hit-test per frame. This matches hand
leWheelEvent. |
| 756 // Perhaps we could simplify things by rewriting scroll handling to work
inner frame | 756 // Perhaps we could simplify things by rewriting scroll handling to work
inner frame |
| 757 // out, and then unify with other gesture events. | 757 // out, and then unify with other gesture events. |
| 758 eventSwallowed = mainFrameImpl()->frame()->eventHandler().handleGestureS
crollEvent(platformEvent); | 758 eventSwallowed = mainFrameImpl()->frame()->eventHandler().handleGestureS
crollEvent(platformEvent); |
| 759 m_client->didHandleGestureEvent(event, eventCancelled); | 759 m_client->didHandleGestureEvent(event, eventCancelled); |
| 760 return eventSwallowed; | 760 return eventSwallowed; |
| 761 case WebInputEvent::GesturePinchBegin: | 761 case WebInputEvent::GesturePinchBegin: |
| 762 case WebInputEvent::GesturePinchEnd: | 762 case WebInputEvent::GesturePinchEnd: |
| 763 case WebInputEvent::GesturePinchUpdate: | 763 case WebInputEvent::GesturePinchUpdate: |
| 764 return false; | 764 return WebInputEventResult::NotHandled; |
| 765 default: | 765 default: |
| 766 break; | 766 break; |
| 767 } | 767 } |
| 768 | 768 |
| 769 // Hit test across all frames and do touch adjustment as necessary for the e
vent type. | 769 // Hit test across all frames and do touch adjustment as necessary for the e
vent type. |
| 770 GestureEventWithHitTestResults targetedEvent = | 770 GestureEventWithHitTestResults targetedEvent = |
| 771 m_page->deprecatedLocalMainFrame()->eventHandler().targetGestureEvent(pl
atformEvent); | 771 m_page->deprecatedLocalMainFrame()->eventHandler().targetGestureEvent(pl
atformEvent); |
| 772 | 772 |
| 773 // Handle link highlighting outside the main switch to avoid getting lost in
the | 773 // Handle link highlighting outside the main switch to avoid getting lost in
the |
| 774 // complicated set of cases handled below. | 774 // complicated set of cases handled below. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 791 case WebInputEvent::GestureTap: { | 791 case WebInputEvent::GestureTap: { |
| 792 // If there is a popup open, close it as the user is clicking on the pag
e | 792 // If there is a popup open, close it as the user is clicking on the pag
e |
| 793 // (outside of the popup). We also save it so we can prevent a tap on an | 793 // (outside of the popup). We also save it so we can prevent a tap on an |
| 794 // element from immediately reopening the same popup. | 794 // element from immediately reopening the same popup. |
| 795 RefPtr<WebPagePopupImpl> pagePopup = m_pagePopup; | 795 RefPtr<WebPagePopupImpl> pagePopup = m_pagePopup; |
| 796 hidePopups(); | 796 hidePopups(); |
| 797 ASSERT(!m_pagePopup); | 797 ASSERT(!m_pagePopup); |
| 798 | 798 |
| 799 m_client->cancelScheduledContentIntents(); | 799 m_client->cancelScheduledContentIntents(); |
| 800 if (detectContentOnTouch(targetedEvent)) { | 800 if (detectContentOnTouch(targetedEvent)) { |
| 801 eventSwallowed = true; | 801 eventSwallowed = WebInputEventResult::HandledDefaultHandler; |
| 802 break; | 802 break; |
| 803 } | 803 } |
| 804 | 804 |
| 805 // Don't trigger a disambiguation popup on sites designed for mobile dev
ices. | 805 // Don't trigger a disambiguation popup on sites designed for mobile dev
ices. |
| 806 // Instead, assume that the page has been designed with big enough butto
ns and links. | 806 // Instead, assume that the page has been designed with big enough butto
ns and links. |
| 807 // Don't trigger a disambiguation popup when screencasting, since it's i
mplemented outside of | 807 // Don't trigger a disambiguation popup when screencasting, since it's i
mplemented outside of |
| 808 // compositor pipeline and is not being screencasted itself. This leads
to bad user experience. | 808 // compositor pipeline and is not being screencasted itself. This leads
to bad user experience. |
| 809 WebDevToolsAgentImpl* devTools = mainFrameDevToolsAgentImpl(); | 809 WebDevToolsAgentImpl* devTools = mainFrameDevToolsAgentImpl(); |
| 810 VisualViewport& visualViewport = page()->frameHost().visualViewport(); | 810 VisualViewport& visualViewport = page()->frameHost().visualViewport(); |
| 811 bool screencastEnabled = devTools && devTools->screencastEnabled(); | 811 bool screencastEnabled = devTools && devTools->screencastEnabled(); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 825 WillBeHeapVector<RawPtrWillBeMember<Node>> highlightNodes; | 825 WillBeHeapVector<RawPtrWillBeMember<Node>> highlightNodes; |
| 826 findGoodTouchTargets(boundingBox, mainFrameImpl()->frame(), good
Targets, highlightNodes); | 826 findGoodTouchTargets(boundingBox, mainFrameImpl()->frame(), good
Targets, highlightNodes); |
| 827 // FIXME: replace touch adjustment code when numberOfGoodTargets
== 1? | 827 // FIXME: replace touch adjustment code when numberOfGoodTargets
== 1? |
| 828 // Single candidate case is currently handled by: https://bugs.w
ebkit.org/show_bug.cgi?id=85101 | 828 // Single candidate case is currently handled by: https://bugs.w
ebkit.org/show_bug.cgi?id=85101 |
| 829 if (goodTargets.size() >= 2 && m_client | 829 if (goodTargets.size() >= 2 && m_client |
| 830 && m_client->didTapMultipleTargets(visualViewportOffset, bou
ndingBox, goodTargets)) { | 830 && m_client->didTapMultipleTargets(visualViewportOffset, bou
ndingBox, goodTargets)) { |
| 831 | 831 |
| 832 enableTapHighlights(highlightNodes); | 832 enableTapHighlights(highlightNodes); |
| 833 for (size_t i = 0; i < m_linkHighlights.size(); ++i) | 833 for (size_t i = 0; i < m_linkHighlights.size(); ++i) |
| 834 m_linkHighlights[i]->startHighlightAnimationIfNeeded(); | 834 m_linkHighlights[i]->startHighlightAnimationIfNeeded(); |
| 835 eventSwallowed = true; | 835 eventSwallowed = WebInputEventResult::HandledDefaultHandler; |
| 836 eventCancelled = true; | 836 eventCancelled = true; |
| 837 break; | 837 break; |
| 838 } | 838 } |
| 839 } | 839 } |
| 840 } | 840 } |
| 841 | 841 |
| 842 eventSwallowed = mainFrameImpl()->frame()->eventHandler().handleGestureE
vent(targetedEvent); | 842 eventSwallowed = mainFrameImpl()->frame()->eventHandler().handleGestureE
vent(targetedEvent); |
| 843 | 843 |
| 844 if (m_pagePopup && pagePopup && m_pagePopup->hasSamePopupClient(pagePopu
p.get())) { | 844 if (m_pagePopup && pagePopup && m_pagePopup->hasSamePopupClient(pagePopu
p.get())) { |
| 845 // The tap triggered a page popup that is the same as the one we jus
t closed. | 845 // The tap triggered a page popup that is the same as the one we jus
t closed. |
| (...skipping 25 matching lines...) Expand all Loading... |
| 871 eventSwallowed = mainFrameImpl()->frame()->eventHandler().handleGestureE
vent(targetedEvent); | 871 eventSwallowed = mainFrameImpl()->frame()->eventHandler().handleGestureE
vent(targetedEvent); |
| 872 break; | 872 break; |
| 873 } | 873 } |
| 874 default: | 874 default: |
| 875 ASSERT_NOT_REACHED(); | 875 ASSERT_NOT_REACHED(); |
| 876 } | 876 } |
| 877 m_client->didHandleGestureEvent(event, eventCancelled); | 877 m_client->didHandleGestureEvent(event, eventCancelled); |
| 878 return eventSwallowed; | 878 return eventSwallowed; |
| 879 } | 879 } |
| 880 | 880 |
| 881 bool WebViewImpl::handleSyntheticWheelFromTouchpadPinchEvent(const WebGestureEve
nt& pinchEvent) | 881 WebInputEventResult WebViewImpl::handleSyntheticWheelFromTouchpadPinchEvent(cons
t WebGestureEvent& pinchEvent) |
| 882 { | 882 { |
| 883 ASSERT(pinchEvent.type == WebInputEvent::GesturePinchUpdate); | 883 ASSERT(pinchEvent.type == WebInputEvent::GesturePinchUpdate); |
| 884 | 884 |
| 885 // Touchscreen pinch events should not reach Blink. | 885 // Touchscreen pinch events should not reach Blink. |
| 886 ASSERT(pinchEvent.sourceDevice == WebGestureDeviceTouchpad); | 886 ASSERT(pinchEvent.sourceDevice == WebGestureDeviceTouchpad); |
| 887 | 887 |
| 888 // For pinch gesture events, match typical trackpad behavior on Windows by s
ending fake | 888 // For pinch gesture events, match typical trackpad behavior on Windows by s
ending fake |
| 889 // wheel events with the ctrl modifier set when we see trackpad pinch gestur
es. Ideally | 889 // wheel events with the ctrl modifier set when we see trackpad pinch gestur
es. Ideally |
| 890 // we'd someday get a platform 'pinch' event and send that instead. | 890 // we'd someday get a platform 'pinch' event and send that instead. |
| 891 WebMouseWheelEvent wheelEvent; | 891 WebMouseWheelEvent wheelEvent; |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1020 } | 1020 } |
| 1021 | 1021 |
| 1022 void WebViewImpl::acceptLanguagesChanged() | 1022 void WebViewImpl::acceptLanguagesChanged() |
| 1023 { | 1023 { |
| 1024 if (!page()) | 1024 if (!page()) |
| 1025 return; | 1025 return; |
| 1026 | 1026 |
| 1027 page()->acceptLanguagesChanged(); | 1027 page()->acceptLanguagesChanged(); |
| 1028 } | 1028 } |
| 1029 | 1029 |
| 1030 bool WebViewImpl::handleKeyEvent(const WebKeyboardEvent& event) | 1030 WebInputEventResult WebViewImpl::handleKeyEvent(const WebKeyboardEvent& event) |
| 1031 { | 1031 { |
| 1032 ASSERT((event.type == WebInputEvent::RawKeyDown) | 1032 ASSERT((event.type == WebInputEvent::RawKeyDown) |
| 1033 || (event.type == WebInputEvent::KeyDown) | 1033 || (event.type == WebInputEvent::KeyDown) |
| 1034 || (event.type == WebInputEvent::KeyUp)); | 1034 || (event.type == WebInputEvent::KeyUp)); |
| 1035 TRACE_EVENT2("input", "WebViewImpl::handleKeyEvent", | 1035 TRACE_EVENT2("input", "WebViewImpl::handleKeyEvent", |
| 1036 "type", inputTypeToName(event.type), | 1036 "type", inputTypeToName(event.type), |
| 1037 "text", String(event.text).utf8()); | 1037 "text", String(event.text).utf8()); |
| 1038 | 1038 |
| 1039 // Halt an in-progress fling on a key event. | 1039 // Halt an in-progress fling on a key event. |
| 1040 endActiveFlingAnimation(); | 1040 endActiveFlingAnimation(); |
| 1041 | 1041 |
| 1042 // Please refer to the comments explaining the m_suppressNextKeypressEvent | 1042 // Please refer to the comments explaining the m_suppressNextKeypressEvent |
| 1043 // member. | 1043 // member. |
| 1044 // The m_suppressNextKeypressEvent is set if the KeyDown is handled by | 1044 // The m_suppressNextKeypressEvent is set if the KeyDown is handled by |
| 1045 // Webkit. A keyDown event is typically associated with a keyPress(char) | 1045 // Webkit. A keyDown event is typically associated with a keyPress(char) |
| 1046 // event and a keyUp event. We reset this flag here as this is a new keyDown | 1046 // event and a keyUp event. We reset this flag here as this is a new keyDown |
| 1047 // event. | 1047 // event. |
| 1048 m_suppressNextKeypressEvent = false; | 1048 m_suppressNextKeypressEvent = false; |
| 1049 | 1049 |
| 1050 // If there is a popup, it should be the one processing the event, not the | 1050 // If there is a popup, it should be the one processing the event, not the |
| 1051 // page. | 1051 // page. |
| 1052 if (m_pagePopup) { | 1052 if (m_pagePopup) { |
| 1053 m_pagePopup->handleKeyEvent(PlatformKeyboardEventBuilder(event)); | 1053 m_pagePopup->handleKeyEvent(PlatformKeyboardEventBuilder(event)); |
| 1054 // We need to ignore the next Char event after this otherwise pressing | 1054 // We need to ignore the next Char event after this otherwise pressing |
| 1055 // enter when selecting an item in the popup will go to the page. | 1055 // enter when selecting an item in the popup will go to the page. |
| 1056 if (WebInputEvent::RawKeyDown == event.type) | 1056 if (WebInputEvent::RawKeyDown == event.type) |
| 1057 m_suppressNextKeypressEvent = true; | 1057 m_suppressNextKeypressEvent = true; |
| 1058 return true; | 1058 return WebInputEventResult::HandledDefaultHandler; |
| 1059 } | 1059 } |
| 1060 | 1060 |
| 1061 RefPtrWillBeRawPtr<Frame> focusedFrame = focusedCoreFrame(); | 1061 RefPtrWillBeRawPtr<Frame> focusedFrame = focusedCoreFrame(); |
| 1062 if (focusedFrame && focusedFrame->isRemoteFrame()) { | 1062 if (focusedFrame && focusedFrame->isRemoteFrame()) { |
| 1063 WebRemoteFrameImpl* webFrame = WebRemoteFrameImpl::fromFrame(*toRemoteFr
ame(focusedFrame.get())); | 1063 WebRemoteFrameImpl* webFrame = WebRemoteFrameImpl::fromFrame(*toRemoteFr
ame(focusedFrame.get())); |
| 1064 webFrame->client()->forwardInputEvent(&event); | 1064 webFrame->client()->forwardInputEvent(&event); |
| 1065 return true; | 1065 return WebInputEventResult::HandledDefaultHandler; |
| 1066 } | 1066 } |
| 1067 | 1067 |
| 1068 if (!focusedFrame || !focusedFrame->isLocalFrame()) | 1068 if (!focusedFrame || !focusedFrame->isLocalFrame()) |
| 1069 return false; | 1069 return WebInputEventResult::NotHandled; |
| 1070 | 1070 |
| 1071 LocalFrame* frame = toLocalFrame(focusedFrame.get()); | 1071 LocalFrame* frame = toLocalFrame(focusedFrame.get()); |
| 1072 | 1072 |
| 1073 PlatformKeyboardEventBuilder evt(event); | 1073 PlatformKeyboardEventBuilder evt(event); |
| 1074 | 1074 |
| 1075 if (frame->eventHandler().keyEvent(evt)) { | 1075 WebInputEventResult result = frame->eventHandler().keyEvent(evt); |
| 1076 if (result != WebInputEventResult::NotHandled) { |
| 1076 if (WebInputEvent::RawKeyDown == event.type) { | 1077 if (WebInputEvent::RawKeyDown == event.type) { |
| 1077 // Suppress the next keypress event unless the focused node is a plu
gin node. | 1078 // Suppress the next keypress event unless the focused node is a plu
gin node. |
| 1078 // (Flash needs these keypress events to handle non-US keyboards.) | 1079 // (Flash needs these keypress events to handle non-US keyboards.) |
| 1079 Element* element = focusedElement(); | 1080 Element* element = focusedElement(); |
| 1080 if (element && element->layoutObject() && element->layoutObject()->i
sEmbeddedObject()) { | 1081 if (element && element->layoutObject() && element->layoutObject()->i
sEmbeddedObject()) { |
| 1081 if (event.windowsKeyCode == VKEY_TAB) { | 1082 if (event.windowsKeyCode == VKEY_TAB) { |
| 1082 // If the plugin supports keyboard focus then we should not
send a tab keypress event. | 1083 // If the plugin supports keyboard focus then we should not
send a tab keypress event. |
| 1083 Widget* widget = toLayoutPart(element->layoutObject())->widg
et(); | 1084 Widget* widget = toLayoutPart(element->layoutObject())->widg
et(); |
| 1084 if (widget && widget->isPluginContainer()) { | 1085 if (widget && widget->isPluginContainer()) { |
| 1085 WebPluginContainerImpl* plugin = toWebPluginContainerImp
l(widget); | 1086 WebPluginContainerImpl* plugin = toWebPluginContainerImp
l(widget); |
| 1086 if (plugin && plugin->supportsKeyboardFocus()) | 1087 if (plugin && plugin->supportsKeyboardFocus()) |
| 1087 m_suppressNextKeypressEvent = true; | 1088 m_suppressNextKeypressEvent = true; |
| 1088 } | 1089 } |
| 1089 } | 1090 } |
| 1090 } else { | 1091 } else { |
| 1091 m_suppressNextKeypressEvent = true; | 1092 m_suppressNextKeypressEvent = true; |
| 1092 } | 1093 } |
| 1093 } | 1094 } |
| 1094 return true; | 1095 return result; |
| 1095 } | 1096 } |
| 1096 | 1097 |
| 1097 #if !OS(MACOSX) | 1098 #if !OS(MACOSX) |
| 1098 const WebInputEvent::Type contextMenuTriggeringEventType = | 1099 const WebInputEvent::Type contextMenuTriggeringEventType = |
| 1099 #if OS(WIN) | 1100 #if OS(WIN) |
| 1100 WebInputEvent::KeyUp; | 1101 WebInputEvent::KeyUp; |
| 1101 #else | 1102 #else |
| 1102 WebInputEvent::RawKeyDown; | 1103 WebInputEvent::RawKeyDown; |
| 1103 #endif | 1104 #endif |
| 1104 | 1105 |
| 1105 bool isUnmodifiedMenuKey = !(event.modifiers & WebInputEvent::InputModifiers
) && event.windowsKeyCode == VKEY_APPS; | 1106 bool isUnmodifiedMenuKey = !(event.modifiers & WebInputEvent::InputModifiers
) && event.windowsKeyCode == VKEY_APPS; |
| 1106 bool isShiftF10 = event.modifiers == WebInputEvent::ShiftKey && event.window
sKeyCode == VKEY_F10; | 1107 bool isShiftF10 = event.modifiers == WebInputEvent::ShiftKey && event.window
sKeyCode == VKEY_F10; |
| 1107 if ((isUnmodifiedMenuKey || isShiftF10) && event.type == contextMenuTriggeri
ngEventType) { | 1108 if ((isUnmodifiedMenuKey || isShiftF10) && event.type == contextMenuTriggeri
ngEventType) { |
| 1108 sendContextMenuEvent(event); | 1109 sendContextMenuEvent(event); |
| 1109 return true; | 1110 return WebInputEventResult::HandledDefaultHandler; |
| 1110 } | 1111 } |
| 1111 #endif // !OS(MACOSX) | 1112 #endif // !OS(MACOSX) |
| 1112 | 1113 |
| 1113 return keyEventDefault(event); | 1114 if (keyEventDefault(event)) |
| 1115 return WebInputEventResult::HandledDefaultHandler; |
| 1116 return WebInputEventResult::NotHandled; |
| 1114 } | 1117 } |
| 1115 | 1118 |
| 1116 bool WebViewImpl::handleCharEvent(const WebKeyboardEvent& event) | 1119 WebInputEventResult WebViewImpl::handleCharEvent(const WebKeyboardEvent& event) |
| 1117 { | 1120 { |
| 1118 ASSERT(event.type == WebInputEvent::Char); | 1121 ASSERT(event.type == WebInputEvent::Char); |
| 1119 TRACE_EVENT1("input", "WebViewImpl::handleCharEvent", | 1122 TRACE_EVENT1("input", "WebViewImpl::handleCharEvent", |
| 1120 "text", String(event.text).utf8()); | 1123 "text", String(event.text).utf8()); |
| 1121 | 1124 |
| 1122 // Please refer to the comments explaining the m_suppressNextKeypressEvent | 1125 // Please refer to the comments explaining the m_suppressNextKeypressEvent |
| 1123 // member. The m_suppressNextKeypressEvent is set if the KeyDown is | 1126 // member. The m_suppressNextKeypressEvent is set if the KeyDown is |
| 1124 // handled by Webkit. A keyDown event is typically associated with a | 1127 // handled by Webkit. A keyDown event is typically associated with a |
| 1125 // keyPress(char) event and a keyUp event. We reset this flag here as it | 1128 // keyPress(char) event and a keyUp event. We reset this flag here as it |
| 1126 // only applies to the current keyPress event. | 1129 // only applies to the current keyPress event. |
| 1127 bool suppress = m_suppressNextKeypressEvent; | 1130 bool suppress = m_suppressNextKeypressEvent; |
| 1128 m_suppressNextKeypressEvent = false; | 1131 m_suppressNextKeypressEvent = false; |
| 1129 | 1132 |
| 1130 // If there is a popup, it should be the one processing the event, not the | 1133 // If there is a popup, it should be the one processing the event, not the |
| 1131 // page. | 1134 // page. |
| 1132 if (m_pagePopup) | 1135 if (m_pagePopup) |
| 1133 return m_pagePopup->handleKeyEvent(PlatformKeyboardEventBuilder(event)); | 1136 return m_pagePopup->handleKeyEvent(PlatformKeyboardEventBuilder(event)); |
| 1134 | 1137 |
| 1135 LocalFrame* frame = toLocalFrame(focusedCoreFrame()); | 1138 LocalFrame* frame = toLocalFrame(focusedCoreFrame()); |
| 1136 if (!frame) | 1139 if (!frame) |
| 1137 return suppress; | 1140 return suppress ? WebInputEventResult::HandledDefaultHandler : WebInputE
ventResult::NotHandled; |
| 1138 | 1141 |
| 1139 EventHandler& handler = frame->eventHandler(); | 1142 EventHandler& handler = frame->eventHandler(); |
| 1140 | 1143 |
| 1141 PlatformKeyboardEventBuilder evt(event); | 1144 PlatformKeyboardEventBuilder evt(event); |
| 1142 if (!evt.isCharacterKey()) | 1145 if (!evt.isCharacterKey()) |
| 1143 return true; | 1146 return WebInputEventResult::HandledDefaultHandler; |
| 1144 | 1147 |
| 1145 // Accesskeys are triggered by char events and can't be suppressed. | 1148 // Accesskeys are triggered by char events and can't be suppressed. |
| 1146 if (handler.handleAccessKey(evt)) | 1149 if (handler.handleAccessKey(evt)) |
| 1147 return true; | 1150 return WebInputEventResult::HandledDefaultHandler; |
| 1148 | 1151 |
| 1149 // Safari 3.1 does not pass off windows system key messages (WM_SYSCHAR) to | 1152 // Safari 3.1 does not pass off windows system key messages (WM_SYSCHAR) to |
| 1150 // the eventHandler::keyEvent. We mimic this behavior on all platforms since | 1153 // the eventHandler::keyEvent. We mimic this behavior on all platforms since |
| 1151 // for now we are converting other platform's key events to windows key | 1154 // for now we are converting other platform's key events to windows key |
| 1152 // events. | 1155 // events. |
| 1153 if (evt.isSystemKey()) | 1156 if (evt.isSystemKey()) |
| 1154 return false; | 1157 return WebInputEventResult::NotHandled; |
| 1155 | 1158 |
| 1156 if (!suppress && !handler.keyEvent(evt)) | 1159 if (suppress) |
| 1157 return keyEventDefault(event); | 1160 return WebInputEventResult::HandledDefaultHandler; |
| 1158 | 1161 |
| 1159 return true; | 1162 WebInputEventResult result = handler.keyEvent(evt); |
| 1163 if (result != WebInputEventResult::NotHandled) |
| 1164 return result; |
| 1165 if (keyEventDefault(event)) |
| 1166 return WebInputEventResult::HandledDefaultHandler; |
| 1167 |
| 1168 return WebInputEventResult::NotHandled; |
| 1160 } | 1169 } |
| 1161 | 1170 |
| 1162 WebRect WebViewImpl::computeBlockBound(const WebPoint& pointInRootFrame, bool ig
noreClipping) | 1171 WebRect WebViewImpl::computeBlockBound(const WebPoint& pointInRootFrame, bool ig
noreClipping) |
| 1163 { | 1172 { |
| 1164 if (!mainFrameImpl()) | 1173 if (!mainFrameImpl()) |
| 1165 return WebRect(); | 1174 return WebRect(); |
| 1166 | 1175 |
| 1167 // Use the point-based hit test to find the node. | 1176 // Use the point-based hit test to find the node. |
| 1168 IntPoint point = mainFrameImpl()->frameView()->rootFrameToContents(IntPoint(
pointInRootFrame.x, pointInRootFrame.y)); | 1177 IntPoint point = mainFrameImpl()->frameView()->rootFrameToContents(IntPoint(
pointInRootFrame.x, pointInRootFrame.y)); |
| 1169 HitTestRequest::HitTestRequestType hitType = HitTestRequest::ReadOnly | HitT
estRequest::Active | (ignoreClipping ? HitTestRequest::IgnoreClipping : 0); | 1178 HitTestRequest::HitTestRequestType hitType = HitTestRequest::ReadOnly | HitT
estRequest::Active | (ignoreClipping ? HitTestRequest::IgnoreClipping : 0); |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1477 } | 1486 } |
| 1478 | 1487 |
| 1479 bool WebViewImpl::hasTouchEventHandlersAt(const WebPoint& point) | 1488 bool WebViewImpl::hasTouchEventHandlersAt(const WebPoint& point) |
| 1480 { | 1489 { |
| 1481 // FIXME: Implement this. Note that the point must be divided by pageScaleFa
ctor. | 1490 // FIXME: Implement this. Note that the point must be divided by pageScaleFa
ctor. |
| 1482 return true; | 1491 return true; |
| 1483 } | 1492 } |
| 1484 | 1493 |
| 1485 #if !OS(MACOSX) | 1494 #if !OS(MACOSX) |
| 1486 // Mac has no way to open a context menu based on a keyboard event. | 1495 // Mac has no way to open a context menu based on a keyboard event. |
| 1487 bool WebViewImpl::sendContextMenuEvent(const WebKeyboardEvent& event) | 1496 WebInputEventResult WebViewImpl::sendContextMenuEvent(const WebKeyboardEvent& ev
ent) |
| 1488 { | 1497 { |
| 1489 // The contextMenuController() holds onto the last context menu that was | 1498 // The contextMenuController() holds onto the last context menu that was |
| 1490 // popped up on the page until a new one is created. We need to clear | 1499 // popped up on the page until a new one is created. We need to clear |
| 1491 // this menu before propagating the event through the DOM so that we can | 1500 // this menu before propagating the event through the DOM so that we can |
| 1492 // detect if we create a new menu for this event, since we won't create | 1501 // detect if we create a new menu for this event, since we won't create |
| 1493 // a new menu if the DOM swallows the event and the defaultEventHandler does | 1502 // a new menu if the DOM swallows the event and the defaultEventHandler does |
| 1494 // not run. | 1503 // not run. |
| 1495 page()->contextMenuController().clearContextMenu(); | 1504 page()->contextMenuController().clearContextMenu(); |
| 1496 | 1505 |
| 1497 bool handled; | |
| 1498 { | 1506 { |
| 1499 ContextMenuAllowedScope scope; | 1507 ContextMenuAllowedScope scope; |
| 1500 Frame* focusedFrame = page()->focusController().focusedOrMainFrame(); | 1508 Frame* focusedFrame = page()->focusController().focusedOrMainFrame(); |
| 1501 if (!focusedFrame->isLocalFrame()) | 1509 if (!focusedFrame->isLocalFrame()) |
| 1502 return false; | 1510 return WebInputEventResult::NotHandled; |
| 1503 handled = toLocalFrame(focusedFrame)->eventHandler().sendContextMenuEven
tForKey(nullptr); | 1511 return toLocalFrame(focusedFrame)->eventHandler().sendContextMenuEventFo
rKey(nullptr); |
| 1504 } | 1512 } |
| 1505 return handled; | |
| 1506 } | 1513 } |
| 1507 #endif | 1514 #endif |
| 1508 | 1515 |
| 1509 void WebViewImpl::showContextMenuAtPoint(float x, float y, PassRefPtrWillBeRawPt
r<ContextMenuProvider> menuProvider) | 1516 void WebViewImpl::showContextMenuAtPoint(float x, float y, PassRefPtrWillBeRawPt
r<ContextMenuProvider> menuProvider) |
| 1510 { | 1517 { |
| 1511 if (!page()->mainFrame()->isLocalFrame()) | 1518 if (!page()->mainFrame()->isLocalFrame()) |
| 1512 return; | 1519 return; |
| 1513 { | 1520 { |
| 1514 ContextMenuAllowedScope scope; | 1521 ContextMenuAllowedScope scope; |
| 1515 page()->contextMenuController().clearContextMenu(); | 1522 page()->contextMenuController().clearContextMenu(); |
| (...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2031 return mainFrameImpl()->frameView()->horizontalScrollbar(); | 2038 return mainFrameImpl()->frameView()->horizontalScrollbar(); |
| 2032 } | 2039 } |
| 2033 | 2040 |
| 2034 bool WebViewImpl::hasVerticalScrollbar() | 2041 bool WebViewImpl::hasVerticalScrollbar() |
| 2035 { | 2042 { |
| 2036 return mainFrameImpl()->frameView()->verticalScrollbar(); | 2043 return mainFrameImpl()->frameView()->verticalScrollbar(); |
| 2037 } | 2044 } |
| 2038 | 2045 |
| 2039 const WebInputEvent* WebViewImpl::m_currentInputEvent = nullptr; | 2046 const WebInputEvent* WebViewImpl::m_currentInputEvent = nullptr; |
| 2040 | 2047 |
| 2041 bool WebViewImpl::handleInputEvent(const WebInputEvent& inputEvent) | 2048 WebInputEventResult WebViewImpl::handleInputEvent(const WebInputEvent& inputEven
t) |
| 2042 { | 2049 { |
| 2043 // TODO(dcheng): The fact that this is getting called when there is no local | 2050 // TODO(dcheng): The fact that this is getting called when there is no local |
| 2044 // main frame is problematic and probably indicates a bug in the input event | 2051 // main frame is problematic and probably indicates a bug in the input event |
| 2045 // routing code. | 2052 // routing code. |
| 2046 if (!mainFrameImpl()) | 2053 if (!mainFrameImpl()) |
| 2047 return false; | 2054 return WebInputEventResult::NotHandled; |
| 2048 | 2055 |
| 2049 WebAutofillClient* autofillClient = mainFrameImpl()->autofillClient(); | 2056 WebAutofillClient* autofillClient = mainFrameImpl()->autofillClient(); |
| 2050 UserGestureNotifier notifier(autofillClient, &m_userGestureObserved); | 2057 UserGestureNotifier notifier(autofillClient, &m_userGestureObserved); |
| 2051 // On the first input event since page load, |notifier| instructs the | 2058 // On the first input event since page load, |notifier| instructs the |
| 2052 // autofill client to unblock values of password input fields of any forms | 2059 // autofill client to unblock values of password input fields of any forms |
| 2053 // on the page. There is a single input event, GestureTap, which can both | 2060 // on the page. There is a single input event, GestureTap, which can both |
| 2054 // be the first event after page load, and cause a form submission. In that | 2061 // be the first event after page load, and cause a form submission. In that |
| 2055 // case, the form submission happens before the autofill client is told | 2062 // case, the form submission happens before the autofill client is told |
| 2056 // to unblock the password values, and so the password values are not | 2063 // to unblock the password values, and so the password values are not |
| 2057 // submitted. To avoid that, GestureTap is handled explicitly: | 2064 // submitted. To avoid that, GestureTap is handled explicitly: |
| 2058 if (inputEvent.type == WebInputEvent::GestureTap && autofillClient) { | 2065 if (inputEvent.type == WebInputEvent::GestureTap && autofillClient) { |
| 2059 m_userGestureObserved = true; | 2066 m_userGestureObserved = true; |
| 2060 autofillClient->firstUserGestureObserved(); | 2067 autofillClient->firstUserGestureObserved(); |
| 2061 } | 2068 } |
| 2062 | 2069 |
| 2063 page()->frameHost().visualViewport().startTrackingPinchStats(); | 2070 page()->frameHost().visualViewport().startTrackingPinchStats(); |
| 2064 | 2071 |
| 2065 TRACE_EVENT1("input", "WebViewImpl::handleInputEvent", "type", inputTypeToNa
me(inputEvent.type)); | 2072 TRACE_EVENT1("input", "WebViewImpl::handleInputEvent", "type", inputTypeToNa
me(inputEvent.type)); |
| 2066 // If we've started a drag and drop operation, ignore input events until | 2073 // If we've started a drag and drop operation, ignore input events until |
| 2067 // we're done. | 2074 // we're done. |
| 2068 if (m_doingDragAndDrop) | 2075 if (m_doingDragAndDrop) |
| 2069 return true; | 2076 return WebInputEventResult::HandledDefaultHandler; |
| 2070 | 2077 |
| 2071 if (m_devToolsEmulator->handleInputEvent(inputEvent)) | 2078 if (m_devToolsEmulator->handleInputEvent(inputEvent)) |
| 2072 return true; | 2079 return WebInputEventResult::HandledDefaultHandler; |
| 2073 | 2080 |
| 2074 if (InspectorOverlay* overlay = inspectorOverlay()) { | 2081 if (InspectorOverlay* overlay = inspectorOverlay()) { |
| 2075 if (overlay->handleInputEvent(inputEvent)) | 2082 if (overlay->handleInputEvent(inputEvent)) |
| 2076 return true; | 2083 return WebInputEventResult::HandledDefaultHandler; |
| 2077 } | 2084 } |
| 2078 | 2085 |
| 2079 if (inputEvent.modifiers & WebInputEvent::IsTouchAccessibility | 2086 if (inputEvent.modifiers & WebInputEvent::IsTouchAccessibility |
| 2080 && WebInputEvent::isMouseEventType(inputEvent.type)) { | 2087 && WebInputEvent::isMouseEventType(inputEvent.type)) { |
| 2081 PlatformMouseEventBuilder pme(mainFrameImpl()->frameView(), static_cast<
const WebMouseEvent&>(inputEvent)); | 2088 PlatformMouseEventBuilder pme(mainFrameImpl()->frameView(), static_cast<
const WebMouseEvent&>(inputEvent)); |
| 2082 | 2089 |
| 2083 // Find the right target frame. See issue 1186900. | 2090 // Find the right target frame. See issue 1186900. |
| 2084 HitTestResult result = hitTestResultForRootFramePos(pme.position()); | 2091 HitTestResult result = hitTestResultForRootFramePos(pme.position()); |
| 2085 Frame* targetFrame; | 2092 Frame* targetFrame; |
| 2086 if (result.innerNodeOrImageMapImage()) | 2093 if (result.innerNodeOrImageMapImage()) |
| 2087 targetFrame = result.innerNodeOrImageMapImage()->document().frame(); | 2094 targetFrame = result.innerNodeOrImageMapImage()->document().frame(); |
| 2088 else | 2095 else |
| 2089 targetFrame = m_page->focusController().focusedOrMainFrame(); | 2096 targetFrame = m_page->focusController().focusedOrMainFrame(); |
| 2090 | 2097 |
| 2091 if (targetFrame->isLocalFrame()) { | 2098 if (targetFrame->isLocalFrame()) { |
| 2092 LocalFrame* targetLocalFrame = toLocalFrame(targetFrame); | 2099 LocalFrame* targetLocalFrame = toLocalFrame(targetFrame); |
| 2093 Document* document = targetLocalFrame->document(); | 2100 Document* document = targetLocalFrame->document(); |
| 2094 if (document) { | 2101 if (document) { |
| 2095 AXObjectCache* cache = document->existingAXObjectCache(); | 2102 AXObjectCache* cache = document->existingAXObjectCache(); |
| 2096 if (cache) | 2103 if (cache) |
| 2097 cache->onTouchAccessibilityHover(pme.position()); | 2104 cache->onTouchAccessibilityHover(pme.position()); |
| 2098 } | 2105 } |
| 2099 } | 2106 } |
| 2100 } | 2107 } |
| 2101 | 2108 |
| 2102 // Report the event to be NOT processed by WebKit, so that the browser can h
andle it appropriately. | 2109 // Report the event to be NOT processed by WebKit, so that the browser can h
andle it appropriately. |
| 2103 if (m_ignoreInputEvents) | 2110 if (m_ignoreInputEvents) |
| 2104 return false; | 2111 return WebInputEventResult::NotHandled; |
| 2105 | 2112 |
| 2106 TemporaryChange<const WebInputEvent*> currentEventChange(m_currentInputEvent
, &inputEvent); | 2113 TemporaryChange<const WebInputEvent*> currentEventChange(m_currentInputEvent
, &inputEvent); |
| 2107 UIEventWithKeyState::clearNewTabModifierSetFromIsolatedWorld(); | 2114 UIEventWithKeyState::clearNewTabModifierSetFromIsolatedWorld(); |
| 2108 | 2115 |
| 2109 if (isPointerLocked() && WebInputEvent::isMouseEventType(inputEvent.type)) { | 2116 if (isPointerLocked() && WebInputEvent::isMouseEventType(inputEvent.type)) { |
| 2110 pointerLockMouseEvent(inputEvent); | 2117 pointerLockMouseEvent(inputEvent); |
| 2111 return true; | 2118 return WebInputEventResult::HandledDefaultHandler; |
| 2112 } | 2119 } |
| 2113 | 2120 |
| 2114 if (m_mouseCaptureNode && WebInputEvent::isMouseEventType(inputEvent.type))
{ | 2121 if (m_mouseCaptureNode && WebInputEvent::isMouseEventType(inputEvent.type))
{ |
| 2115 TRACE_EVENT1("input", "captured mouse event", "type", inputEvent.type); | 2122 TRACE_EVENT1("input", "captured mouse event", "type", inputEvent.type); |
| 2116 // Save m_mouseCaptureNode since mouseCaptureLost() will clear it. | 2123 // Save m_mouseCaptureNode since mouseCaptureLost() will clear it. |
| 2117 RefPtrWillBeRawPtr<Node> node = m_mouseCaptureNode; | 2124 RefPtrWillBeRawPtr<Node> node = m_mouseCaptureNode; |
| 2118 | 2125 |
| 2119 // Not all platforms call mouseCaptureLost() directly. | 2126 // Not all platforms call mouseCaptureLost() directly. |
| 2120 if (inputEvent.type == WebInputEvent::MouseUp) | 2127 if (inputEvent.type == WebInputEvent::MouseUp) |
| 2121 mouseCaptureLost(); | 2128 mouseCaptureLost(); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 2139 eventType = EventTypeNames::mouseup; | 2146 eventType = EventTypeNames::mouseup; |
| 2140 gestureIndicator = adoptPtr(new UserGestureIndicator(m_mouseCaptureG
estureToken.release())); | 2147 gestureIndicator = adoptPtr(new UserGestureIndicator(m_mouseCaptureG
estureToken.release())); |
| 2141 break; | 2148 break; |
| 2142 default: | 2149 default: |
| 2143 ASSERT_NOT_REACHED(); | 2150 ASSERT_NOT_REACHED(); |
| 2144 } | 2151 } |
| 2145 | 2152 |
| 2146 node->dispatchMouseEvent( | 2153 node->dispatchMouseEvent( |
| 2147 PlatformMouseEventBuilder(mainFrameImpl()->frameView(), static_cast<
const WebMouseEvent&>(inputEvent)), | 2154 PlatformMouseEventBuilder(mainFrameImpl()->frameView(), static_cast<
const WebMouseEvent&>(inputEvent)), |
| 2148 eventType, static_cast<const WebMouseEvent&>(inputEvent).clickCount)
; | 2155 eventType, static_cast<const WebMouseEvent&>(inputEvent).clickCount)
; |
| 2149 return true; | 2156 return WebInputEventResult::HandledDefaultHandler; |
| 2150 } | 2157 } |
| 2151 | 2158 |
| 2152 // FIXME: This should take in the intended frame, not the local frame root. | 2159 // FIXME: This should take in the intended frame, not the local frame root. |
| 2153 if (PageWidgetDelegate::handleInputEvent(*this, inputEvent, mainFrameImpl()-
>frame())) | 2160 WebInputEventResult result = PageWidgetDelegate::handleInputEvent(*this, inp
utEvent, mainFrameImpl()->frame()); |
| 2154 return true; | 2161 if (result != WebInputEventResult::NotHandled) |
| 2162 return result; |
| 2155 | 2163 |
| 2156 // Unhandled touchpad gesture pinch events synthesize mouse wheel events. | 2164 // Unhandled touchpad gesture pinch events synthesize mouse wheel events. |
| 2157 if (inputEvent.type == WebInputEvent::GesturePinchUpdate) { | 2165 if (inputEvent.type == WebInputEvent::GesturePinchUpdate) { |
| 2158 const WebGestureEvent& pinchEvent = static_cast<const WebGestureEvent&>(
inputEvent); | 2166 const WebGestureEvent& pinchEvent = static_cast<const WebGestureEvent&>(
inputEvent); |
| 2159 | 2167 |
| 2160 // First, synthesize a Windows-like wheel event to send to any handlers
that may exist. | 2168 // First, synthesize a Windows-like wheel event to send to any handlers
that may exist. |
| 2161 if (handleSyntheticWheelFromTouchpadPinchEvent(pinchEvent)) | 2169 result = handleSyntheticWheelFromTouchpadPinchEvent(pinchEvent); |
| 2162 return true; | 2170 if (result != WebInputEventResult::NotHandled) |
| 2171 return result; |
| 2163 | 2172 |
| 2164 if (pinchEvent.data.pinchUpdate.zoomDisabled) | 2173 if (pinchEvent.data.pinchUpdate.zoomDisabled) |
| 2165 return false; | 2174 return WebInputEventResult::NotHandled; |
| 2166 | 2175 |
| 2167 if (page()->frameHost().visualViewport().magnifyScaleAroundAnchor(pinchE
vent.data.pinchUpdate.scale, FloatPoint(pinchEvent.x, pinchEvent.y))) | 2176 if (page()->frameHost().visualViewport().magnifyScaleAroundAnchor(pinchE
vent.data.pinchUpdate.scale, FloatPoint(pinchEvent.x, pinchEvent.y))) |
| 2168 return true; | 2177 return WebInputEventResult::HandledDefaultHandler; |
| 2169 } | 2178 } |
| 2170 | 2179 |
| 2171 return false; | 2180 return WebInputEventResult::NotHandled; |
| 2172 } | 2181 } |
| 2173 | 2182 |
| 2174 void WebViewImpl::setCursorVisibilityState(bool isVisible) | 2183 void WebViewImpl::setCursorVisibilityState(bool isVisible) |
| 2175 { | 2184 { |
| 2176 if (m_page) | 2185 if (m_page) |
| 2177 m_page->setIsCursorVisible(isVisible); | 2186 m_page->setIsCursorVisible(isVisible); |
| 2178 } | 2187 } |
| 2179 | 2188 |
| 2180 void WebViewImpl::mouseCaptureLost() | 2189 void WebViewImpl::mouseCaptureLost() |
| 2181 { | 2190 { |
| (...skipping 2276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4458 if (m_pageColorOverlay) | 4467 if (m_pageColorOverlay) |
| 4459 m_pageColorOverlay->update(); | 4468 m_pageColorOverlay->update(); |
| 4460 if (InspectorOverlay* overlay = inspectorOverlay()) { | 4469 if (InspectorOverlay* overlay = inspectorOverlay()) { |
| 4461 PageOverlay* inspectorPageOverlay = overlay->pageOverlay(); | 4470 PageOverlay* inspectorPageOverlay = overlay->pageOverlay(); |
| 4462 if (inspectorPageOverlay) | 4471 if (inspectorPageOverlay) |
| 4463 inspectorPageOverlay->update(); | 4472 inspectorPageOverlay->update(); |
| 4464 } | 4473 } |
| 4465 } | 4474 } |
| 4466 | 4475 |
| 4467 } // namespace blink | 4476 } // namespace blink |
| OLD | NEW |