| 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 697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 708 | 708 |
| 709 // Special handling for slow-path fling gestures. | 709 // Special handling for slow-path fling gestures. |
| 710 switch (event.type()) { | 710 switch (event.type()) { |
| 711 case WebInputEvent::GestureFlingStart: { | 711 case WebInputEvent::GestureFlingStart: { |
| 712 if (mainFrameImpl() | 712 if (mainFrameImpl() |
| 713 ->frame() | 713 ->frame() |
| 714 ->eventHandler() | 714 ->eventHandler() |
| 715 .isScrollbarHandlingGestures()) | 715 .isScrollbarHandlingGestures()) |
| 716 break; | 716 break; |
| 717 endActiveFlingAnimation(); | 717 endActiveFlingAnimation(); |
| 718 m_client->cancelScheduledContentIntents(); | |
| 719 m_positionOnFlingStart = WebPoint(event.x, event.y); | 718 m_positionOnFlingStart = WebPoint(event.x, event.y); |
| 720 m_globalPositionOnFlingStart = WebPoint(event.globalX, event.globalY); | 719 m_globalPositionOnFlingStart = WebPoint(event.globalX, event.globalY); |
| 721 m_flingModifier = event.modifiers(); | 720 m_flingModifier = event.modifiers(); |
| 722 m_flingSourceDevice = event.sourceDevice; | 721 m_flingSourceDevice = event.sourceDevice; |
| 723 DCHECK_NE(m_flingSourceDevice, WebGestureDeviceUninitialized); | 722 DCHECK_NE(m_flingSourceDevice, WebGestureDeviceUninitialized); |
| 724 std::unique_ptr<WebGestureCurve> flingCurve = | 723 std::unique_ptr<WebGestureCurve> flingCurve = |
| 725 WTF::wrapUnique(Platform::current()->createFlingAnimationCurve( | 724 WTF::wrapUnique(Platform::current()->createFlingAnimationCurve( |
| 726 event.sourceDevice, | 725 event.sourceDevice, |
| 727 WebFloatPoint(event.data.flingStart.velocityX, | 726 WebFloatPoint(event.data.flingStart.velocityX, |
| 728 event.data.flingStart.velocityY), | 727 event.data.flingStart.velocityY), |
| (...skipping 28 matching lines...) Expand all Loading... |
| 757 | 756 |
| 758 WebGestureEvent scaledEvent = | 757 WebGestureEvent scaledEvent = |
| 759 TransformWebGestureEvent(mainFrameImpl()->frameView(), event); | 758 TransformWebGestureEvent(mainFrameImpl()->frameView(), event); |
| 760 | 759 |
| 761 // Special handling for double tap and scroll events as we don't want to | 760 // Special handling for double tap and scroll events as we don't want to |
| 762 // hit test for them. | 761 // hit test for them. |
| 763 switch (event.type()) { | 762 switch (event.type()) { |
| 764 case WebInputEvent::GestureDoubleTap: | 763 case WebInputEvent::GestureDoubleTap: |
| 765 if (m_webSettings->doubleTapToZoomEnabled() && | 764 if (m_webSettings->doubleTapToZoomEnabled() && |
| 766 minimumPageScaleFactor() != maximumPageScaleFactor()) { | 765 minimumPageScaleFactor() != maximumPageScaleFactor()) { |
| 767 m_client->cancelScheduledContentIntents(); | |
| 768 animateDoubleTapZoom( | 766 animateDoubleTapZoom( |
| 769 flooredIntPoint(scaledEvent.positionInRootFrame())); | 767 flooredIntPoint(scaledEvent.positionInRootFrame())); |
| 770 } | 768 } |
| 771 // GestureDoubleTap is currently only used by Android for zooming. For | 769 // GestureDoubleTap is currently only used by Android for zooming. For |
| 772 // WebCore, GestureTap with tap count = 2 is used instead. So we drop | 770 // WebCore, GestureTap with tap count = 2 is used instead. So we drop |
| 773 // GestureDoubleTap here. | 771 // GestureDoubleTap here. |
| 774 eventResult = WebInputEventResult::HandledSystem; | 772 eventResult = WebInputEventResult::HandledSystem; |
| 775 m_client->didHandleGestureEvent(event, eventCancelled); | 773 m_client->didHandleGestureEvent(event, eventCancelled); |
| 776 return eventResult; | 774 return eventResult; |
| 777 case WebInputEvent::GestureScrollBegin: | 775 case WebInputEvent::GestureScrollBegin: |
| 778 m_client->cancelScheduledContentIntents(); | |
| 779 case WebInputEvent::GestureScrollEnd: | 776 case WebInputEvent::GestureScrollEnd: |
| 780 case WebInputEvent::GestureScrollUpdate: | 777 case WebInputEvent::GestureScrollUpdate: |
| 781 case WebInputEvent::GestureFlingStart: | 778 case WebInputEvent::GestureFlingStart: |
| 782 // Scrolling-related gesture events invoke EventHandler recursively for | 779 // Scrolling-related gesture events invoke EventHandler recursively for |
| 783 // each frame down the chain, doing a single-frame hit-test per frame. | 780 // each frame down the chain, doing a single-frame hit-test per frame. |
| 784 // This matches handleWheelEvent. Perhaps we could simplify things by | 781 // This matches handleWheelEvent. Perhaps we could simplify things by |
| 785 // rewriting scroll handling to work inner frame out, and then unify with | 782 // rewriting scroll handling to work inner frame out, and then unify with |
| 786 // other gesture events. | 783 // other gesture events. |
| 787 eventResult = | 784 eventResult = |
| 788 mainFrameImpl()->frame()->eventHandler().handleGestureScrollEvent( | 785 mainFrameImpl()->frame()->eventHandler().handleGestureScrollEvent( |
| (...skipping 26 matching lines...) Expand all Loading... |
| 815 case WebInputEvent::GestureLongPress: | 812 case WebInputEvent::GestureLongPress: |
| 816 for (size_t i = 0; i < m_linkHighlights.size(); ++i) | 813 for (size_t i = 0; i < m_linkHighlights.size(); ++i) |
| 817 m_linkHighlights[i]->startHighlightAnimationIfNeeded(); | 814 m_linkHighlights[i]->startHighlightAnimationIfNeeded(); |
| 818 break; | 815 break; |
| 819 default: | 816 default: |
| 820 break; | 817 break; |
| 821 } | 818 } |
| 822 | 819 |
| 823 switch (event.type()) { | 820 switch (event.type()) { |
| 824 case WebInputEvent::GestureTap: { | 821 case WebInputEvent::GestureTap: { |
| 825 m_client->cancelScheduledContentIntents(); | |
| 826 if (detectContentOnTouch(targetedEvent)) { | |
| 827 eventResult = WebInputEventResult::HandledSystem; | |
| 828 break; | |
| 829 } | |
| 830 | |
| 831 // Don't trigger a disambiguation popup on sites designed for mobile | 822 // Don't trigger a disambiguation popup on sites designed for mobile |
| 832 // devices. Instead, assume that the page has been designed with big | 823 // devices. Instead, assume that the page has been designed with big |
| 833 // enough buttons and links. Don't trigger a disambiguation popup when | 824 // enough buttons and links. Don't trigger a disambiguation popup when |
| 834 // screencasting, since it's implemented outside of compositor pipeline | 825 // screencasting, since it's implemented outside of compositor pipeline |
| 835 // and is not being screencasted itself. This leads to bad user | 826 // and is not being screencasted itself. This leads to bad user |
| 836 // experience. | 827 // experience. |
| 837 WebDevToolsAgentImpl* devTools = mainFrameDevToolsAgentImpl(); | 828 WebDevToolsAgentImpl* devTools = mainFrameDevToolsAgentImpl(); |
| 838 VisualViewport& visualViewport = page()->visualViewport(); | 829 VisualViewport& visualViewport = page()->visualViewport(); |
| 839 bool screencastEnabled = devTools && devTools->screencastEnabled(); | 830 bool screencastEnabled = devTools && devTools->screencastEnabled(); |
| 840 if (event.data.tap.width > 0 && | 831 if (event.data.tap.width > 0 && |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 887 } | 878 } |
| 888 m_lastHiddenPagePopup = nullptr; | 879 m_lastHiddenPagePopup = nullptr; |
| 889 break; | 880 break; |
| 890 } | 881 } |
| 891 case WebInputEvent::GestureTwoFingerTap: | 882 case WebInputEvent::GestureTwoFingerTap: |
| 892 case WebInputEvent::GestureLongPress: | 883 case WebInputEvent::GestureLongPress: |
| 893 case WebInputEvent::GestureLongTap: { | 884 case WebInputEvent::GestureLongTap: { |
| 894 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) | 885 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) |
| 895 break; | 886 break; |
| 896 | 887 |
| 897 m_client->cancelScheduledContentIntents(); | |
| 898 m_page->contextMenuController().clearContextMenu(); | 888 m_page->contextMenuController().clearContextMenu(); |
| 899 { | 889 { |
| 900 ContextMenuAllowedScope scope; | 890 ContextMenuAllowedScope scope; |
| 901 eventResult = | 891 eventResult = |
| 902 mainFrameImpl()->frame()->eventHandler().handleGestureEvent( | 892 mainFrameImpl()->frame()->eventHandler().handleGestureEvent( |
| 903 targetedEvent); | 893 targetedEvent); |
| 904 } | 894 } |
| 905 | 895 |
| 906 break; | 896 break; |
| 907 } | 897 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 919 targetedEvent); | 909 targetedEvent); |
| 920 break; | 910 break; |
| 921 } | 911 } |
| 922 case WebInputEvent::GestureTapCancel: { | 912 case WebInputEvent::GestureTapCancel: { |
| 923 m_lastHiddenPagePopup = nullptr; | 913 m_lastHiddenPagePopup = nullptr; |
| 924 eventResult = mainFrameImpl()->frame()->eventHandler().handleGestureEvent( | 914 eventResult = mainFrameImpl()->frame()->eventHandler().handleGestureEvent( |
| 925 targetedEvent); | 915 targetedEvent); |
| 926 break; | 916 break; |
| 927 } | 917 } |
| 928 case WebInputEvent::GestureShowPress: { | 918 case WebInputEvent::GestureShowPress: { |
| 929 m_client->cancelScheduledContentIntents(); | |
| 930 eventResult = mainFrameImpl()->frame()->eventHandler().handleGestureEvent( | 919 eventResult = mainFrameImpl()->frame()->eventHandler().handleGestureEvent( |
| 931 targetedEvent); | 920 targetedEvent); |
| 932 break; | 921 break; |
| 933 } | 922 } |
| 934 case WebInputEvent::GestureTapUnconfirmed: { | 923 case WebInputEvent::GestureTapUnconfirmed: { |
| 935 eventResult = mainFrameImpl()->frame()->eventHandler().handleGestureEvent( | 924 eventResult = mainFrameImpl()->frame()->eventHandler().handleGestureEvent( |
| 936 targetedEvent); | 925 targetedEvent); |
| 937 break; | 926 break; |
| 938 } | 927 } |
| 939 default: { NOTREACHED(); } | 928 default: { NOTREACHED(); } |
| (...skipping 3163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4103 if (!m_visualViewportContainerLayer) | 4092 if (!m_visualViewportContainerLayer) |
| 4104 return; | 4093 return; |
| 4105 | 4094 |
| 4106 // When the device emulation transform is updated, to avoid incorrect | 4095 // When the device emulation transform is updated, to avoid incorrect |
| 4107 // scales and fuzzy raster from the compositor, force all content to | 4096 // scales and fuzzy raster from the compositor, force all content to |
| 4108 // pick ideal raster scales. | 4097 // pick ideal raster scales. |
| 4109 m_visualViewportContainerLayer->setTransform(m_deviceEmulationTransform); | 4098 m_visualViewportContainerLayer->setTransform(m_deviceEmulationTransform); |
| 4110 m_layerTreeView->forceRecalculateRasterScales(); | 4099 m_layerTreeView->forceRecalculateRasterScales(); |
| 4111 } | 4100 } |
| 4112 | 4101 |
| 4113 bool WebViewImpl::detectContentOnTouch( | |
| 4114 const GestureEventWithHitTestResults& targetedEvent) { | |
| 4115 if (!m_page->mainFrame()->isLocalFrame()) | |
| 4116 return false; | |
| 4117 | |
| 4118 // Need a local copy of the hit test as | |
| 4119 // setToShadowHostIfInUserAgentShadowRoot() will modify it. | |
| 4120 HitTestResult touchHit = targetedEvent.hitTestResult(); | |
| 4121 touchHit.setToShadowHostIfInRestrictedShadowRoot(); | |
| 4122 | |
| 4123 if (touchHit.isContentEditable()) | |
| 4124 return false; | |
| 4125 | |
| 4126 Node* node = touchHit.innerNode(); | |
| 4127 if (!node || !node->isTextNode()) | |
| 4128 return false; | |
| 4129 | |
| 4130 // Ignore when tapping on links or nodes listening to click events, unless | |
| 4131 // the click event is on the body element, in which case it's unlikely that | |
| 4132 // the original node itself was intended to be clickable. | |
| 4133 for (; node && !isHTMLBodyElement(*node); | |
| 4134 node = LayoutTreeBuilderTraversal::parent(*node)) { | |
| 4135 if (node->isLink() || node->willRespondToTouchEvents() || | |
| 4136 node->willRespondToMouseClickEvents()) | |
| 4137 return false; | |
| 4138 } | |
| 4139 | |
| 4140 WebURL intent = m_client->detectContentIntentAt(touchHit); | |
| 4141 if (!intent.isValid()) | |
| 4142 return false; | |
| 4143 | |
| 4144 // This code is called directly after hit test code, with no user code | |
| 4145 // running in between, thus it is assumed that the frame pointer is non-null. | |
| 4146 bool isMainFrame = node ? node->document().frame()->isMainFrame() : true; | |
| 4147 m_client->scheduleContentIntent(intent, isMainFrame); | |
| 4148 return true; | |
| 4149 } | |
| 4150 | |
| 4151 WebViewScheduler* WebViewImpl::scheduler() const { | 4102 WebViewScheduler* WebViewImpl::scheduler() const { |
| 4152 return m_scheduler.get(); | 4103 return m_scheduler.get(); |
| 4153 } | 4104 } |
| 4154 | 4105 |
| 4155 void WebViewImpl::setVisibilityState(WebPageVisibilityState visibilityState, | 4106 void WebViewImpl::setVisibilityState(WebPageVisibilityState visibilityState, |
| 4156 bool isInitialState) { | 4107 bool isInitialState) { |
| 4157 DCHECK(visibilityState == WebPageVisibilityStateVisible || | 4108 DCHECK(visibilityState == WebPageVisibilityStateVisible || |
| 4158 visibilityState == WebPageVisibilityStateHidden || | 4109 visibilityState == WebPageVisibilityStateHidden || |
| 4159 visibilityState == WebPageVisibilityStatePrerender); | 4110 visibilityState == WebPageVisibilityStatePrerender); |
| 4160 | 4111 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4233 if (focusedFrame->localFrameRoot() != mainFrameImpl()->frame()) | 4184 if (focusedFrame->localFrameRoot() != mainFrameImpl()->frame()) |
| 4234 return nullptr; | 4185 return nullptr; |
| 4235 return focusedFrame; | 4186 return focusedFrame; |
| 4236 } | 4187 } |
| 4237 | 4188 |
| 4238 LocalFrame* WebViewImpl::focusedLocalFrameAvailableForIme() const { | 4189 LocalFrame* WebViewImpl::focusedLocalFrameAvailableForIme() const { |
| 4239 return m_imeAcceptEvents ? focusedLocalFrameInWidget() : nullptr; | 4190 return m_imeAcceptEvents ? focusedLocalFrameInWidget() : nullptr; |
| 4240 } | 4191 } |
| 4241 | 4192 |
| 4242 } // namespace blink | 4193 } // namespace blink |
| OLD | NEW |