| 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 838 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 849 Vector<IntRect> goodTargets; | 849 Vector<IntRect> goodTargets; |
| 850 HeapVector<Member<Node>> highlightNodes; | 850 HeapVector<Member<Node>> highlightNodes; |
| 851 findGoodTouchTargets(boundingBox, mainFrameImpl()->frame(), | 851 findGoodTouchTargets(boundingBox, mainFrameImpl()->frame(), |
| 852 goodTargets, highlightNodes); | 852 goodTargets, highlightNodes); |
| 853 // FIXME: replace touch adjustment code when numberOfGoodTargets == 1? | 853 // FIXME: replace touch adjustment code when numberOfGoodTargets == 1? |
| 854 // Single candidate case is currently handled by: | 854 // Single candidate case is currently handled by: |
| 855 // https://bugs.webkit.org/show_bug.cgi?id=85101 | 855 // https://bugs.webkit.org/show_bug.cgi?id=85101 |
| 856 if (goodTargets.size() >= 2 && m_client && | 856 if (goodTargets.size() >= 2 && m_client && |
| 857 m_client->didTapMultipleTargets(visualViewportOffset, boundingBox, | 857 m_client->didTapMultipleTargets(visualViewportOffset, boundingBox, |
| 858 goodTargets)) { | 858 goodTargets)) { |
| 859 // Stash the position of the node that would've been used absent |
| 860 // disambiguation, for UMA purposes. |
| 861 m_lastTapDisambiguationBestCandidatePosition = |
| 862 targetedEvent.hitTestResult().roundedPointInMainFrame() - |
| 863 roundedIntSize(targetedEvent.hitTestResult().localPoint()); |
| 864 |
| 859 enableTapHighlights(highlightNodes); | 865 enableTapHighlights(highlightNodes); |
| 860 for (size_t i = 0; i < m_linkHighlights.size(); ++i) | 866 for (size_t i = 0; i < m_linkHighlights.size(); ++i) |
| 861 m_linkHighlights[i]->startHighlightAnimationIfNeeded(); | 867 m_linkHighlights[i]->startHighlightAnimationIfNeeded(); |
| 862 eventResult = WebInputEventResult::HandledSystem; | 868 eventResult = WebInputEventResult::HandledSystem; |
| 863 eventCancelled = true; | 869 eventCancelled = true; |
| 864 break; | 870 break; |
| 865 } | 871 } |
| 866 } | 872 } |
| 867 } | 873 } |
| 868 | 874 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 924 eventResult = mainFrameImpl()->frame()->eventHandler().handleGestureEvent( | 930 eventResult = mainFrameImpl()->frame()->eventHandler().handleGestureEvent( |
| 925 targetedEvent); | 931 targetedEvent); |
| 926 break; | 932 break; |
| 927 } | 933 } |
| 928 default: { NOTREACHED(); } | 934 default: { NOTREACHED(); } |
| 929 } | 935 } |
| 930 m_client->didHandleGestureEvent(event, eventCancelled); | 936 m_client->didHandleGestureEvent(event, eventCancelled); |
| 931 return eventResult; | 937 return eventResult; |
| 932 } | 938 } |
| 933 | 939 |
| 940 namespace { |
| 941 // This enum is used to back a histogram, and should therefore be treated as |
| 942 // append-only. |
| 943 enum TapDisambiguationResult { |
| 944 UmaTapDisambiguationOther = 0, |
| 945 UmaTapDisambiguationBackButton = 1, |
| 946 UmaTapDisambiguationTappedOutside = 2, |
| 947 UmaTapDisambiguationTappedInsideDeprecated = 3, |
| 948 UmaTapDisambiguationTappedInsideSameNode = 4, |
| 949 UmaTapDisambiguationTappedInsideDifferentNode = 5, |
| 950 UmaTapDisambiguationCount = 6, |
| 951 }; |
| 952 |
| 953 void RecordTapDisambiguation(TapDisambiguationResult result) { |
| 954 UMA_HISTOGRAM_ENUMERATION("Touchscreen.TapDisambiguation", result, |
| 955 UmaTapDisambiguationCount); |
| 956 } |
| 957 |
| 958 } // namespace |
| 959 |
| 960 void WebViewImpl::resolveTapDisambiguation(double timestampSeconds, |
| 961 WebPoint tapViewportOffset, |
| 962 bool isLongPress) { |
| 963 WebGestureEvent event( |
| 964 isLongPress ? WebInputEvent::GestureLongPress : WebInputEvent::GestureTap, |
| 965 WebInputEvent::NoModifiers, timestampSeconds); |
| 966 |
| 967 event.x = tapViewportOffset.x; |
| 968 event.y = tapViewportOffset.y; |
| 969 event.sourceDevice = blink::WebGestureDeviceTouchscreen; |
| 970 |
| 971 { |
| 972 // Compute UMA stat about whether the node selected by disambiguation UI was |
| 973 // different from the one preferred by the regular hit-testing + adjustment |
| 974 // logic. |
| 975 WebGestureEvent scaledEvent = |
| 976 TransformWebGestureEvent(mainFrameImpl()->frameView(), event); |
| 977 GestureEventWithHitTestResults targetedEvent = |
| 978 m_page->deprecatedLocalMainFrame()->eventHandler().targetGestureEvent( |
| 979 scaledEvent); |
| 980 WebPoint nodePosition = |
| 981 targetedEvent.hitTestResult().roundedPointInMainFrame() - |
| 982 roundedIntSize(targetedEvent.hitTestResult().localPoint()); |
| 983 TapDisambiguationResult result = |
| 984 (nodePosition == m_lastTapDisambiguationBestCandidatePosition) |
| 985 ? UmaTapDisambiguationTappedInsideSameNode |
| 986 : UmaTapDisambiguationTappedInsideDifferentNode; |
| 987 RecordTapDisambiguation(result); |
| 988 } |
| 989 |
| 990 handleGestureEvent(event); |
| 991 } |
| 992 |
| 934 WebInputEventResult WebViewImpl::handleSyntheticWheelFromTouchpadPinchEvent( | 993 WebInputEventResult WebViewImpl::handleSyntheticWheelFromTouchpadPinchEvent( |
| 935 const WebGestureEvent& pinchEvent) { | 994 const WebGestureEvent& pinchEvent) { |
| 936 DCHECK_EQ(pinchEvent.type(), WebInputEvent::GesturePinchUpdate); | 995 DCHECK_EQ(pinchEvent.type(), WebInputEvent::GesturePinchUpdate); |
| 937 | 996 |
| 938 // For pinch gesture events, match typical trackpad behavior on Windows by | 997 // For pinch gesture events, match typical trackpad behavior on Windows by |
| 939 // sending fake wheel events with the ctrl modifier set when we see trackpad | 998 // sending fake wheel events with the ctrl modifier set when we see trackpad |
| 940 // pinch gestures. Ideally we'd someday get a platform 'pinch' event and | 999 // pinch gestures. Ideally we'd someday get a platform 'pinch' event and |
| 941 // send that instead. | 1000 // send that instead. |
| 942 WebMouseWheelEvent wheelEvent( | 1001 WebMouseWheelEvent wheelEvent( |
| 943 WebInputEvent::MouseWheel, | 1002 WebInputEvent::MouseWheel, |
| (...skipping 3233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4177 if (focusedFrame->localFrameRoot() != mainFrameImpl()->frame()) | 4236 if (focusedFrame->localFrameRoot() != mainFrameImpl()->frame()) |
| 4178 return nullptr; | 4237 return nullptr; |
| 4179 return focusedFrame; | 4238 return focusedFrame; |
| 4180 } | 4239 } |
| 4181 | 4240 |
| 4182 LocalFrame* WebViewImpl::focusedLocalFrameAvailableForIme() const { | 4241 LocalFrame* WebViewImpl::focusedLocalFrameAvailableForIme() const { |
| 4183 return m_imeAcceptEvents ? focusedLocalFrameInWidget() : nullptr; | 4242 return m_imeAcceptEvents ? focusedLocalFrameInWidget() : nullptr; |
| 4184 } | 4243 } |
| 4185 | 4244 |
| 4186 } // namespace blink | 4245 } // namespace blink |
| OLD | NEW |