Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(42)

Side by Side Diff: third_party/WebKit/Source/web/WebViewImpl.cpp

Issue 2539283002: Remove PlatformGestureEvent in favour of using WebGestureEvent (Closed)
Patch Set: Rebase and fix comments Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 #include "modules/accessibility/AXObjectCacheImpl.h" 91 #include "modules/accessibility/AXObjectCacheImpl.h"
92 #include "modules/credentialmanager/CredentialManagerClient.h" 92 #include "modules/credentialmanager/CredentialManagerClient.h"
93 #include "modules/encryptedmedia/MediaKeysController.h" 93 #include "modules/encryptedmedia/MediaKeysController.h"
94 #include "modules/storage/StorageNamespaceController.h" 94 #include "modules/storage/StorageNamespaceController.h"
95 #include "modules/webgl/WebGLRenderingContext.h" 95 #include "modules/webgl/WebGLRenderingContext.h"
96 #include "platform/ContextMenu.h" 96 #include "platform/ContextMenu.h"
97 #include "platform/ContextMenuItem.h" 97 #include "platform/ContextMenuItem.h"
98 #include "platform/Cursor.h" 98 #include "platform/Cursor.h"
99 #include "platform/Histogram.h" 99 #include "platform/Histogram.h"
100 #include "platform/KeyboardCodes.h" 100 #include "platform/KeyboardCodes.h"
101 #include "platform/PlatformGestureEvent.h"
102 #include "platform/PlatformMouseEvent.h" 101 #include "platform/PlatformMouseEvent.h"
103 #include "platform/RuntimeEnabledFeatures.h" 102 #include "platform/RuntimeEnabledFeatures.h"
104 #include "platform/UserGestureIndicator.h" 103 #include "platform/UserGestureIndicator.h"
105 #include "platform/exported/WebActiveGestureAnimation.h" 104 #include "platform/exported/WebActiveGestureAnimation.h"
106 #include "platform/fonts/FontCache.h" 105 #include "platform/fonts/FontCache.h"
107 #include "platform/geometry/FloatRect.h" 106 #include "platform/geometry/FloatRect.h"
108 #include "platform/graphics/Color.h" 107 #include "platform/graphics/Color.h"
109 #include "platform/graphics/CompositorMutatorClient.h" 108 #include "platform/graphics/CompositorMutatorClient.h"
110 #include "platform/graphics/FirstPaintInvalidationTracking.h" 109 #include "platform/graphics/FirstPaintInvalidationTracking.h"
111 #include "platform/graphics/GraphicsContext.h" 110 #include "platform/graphics/GraphicsContext.h"
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after
721 event.sourceDevice, 720 event.sourceDevice,
722 WebFloatPoint(event.data.flingStart.velocityX, 721 WebFloatPoint(event.data.flingStart.velocityX,
723 event.data.flingStart.velocityY), 722 event.data.flingStart.velocityY),
724 WebSize())); 723 WebSize()));
725 DCHECK(flingCurve); 724 DCHECK(flingCurve);
726 m_gestureAnimation = WebActiveGestureAnimation::createAtAnimationStart( 725 m_gestureAnimation = WebActiveGestureAnimation::createAtAnimationStart(
727 std::move(flingCurve), this); 726 std::move(flingCurve), this);
728 mainFrameImpl()->frameWidget()->scheduleAnimation(); 727 mainFrameImpl()->frameWidget()->scheduleAnimation();
729 eventResult = WebInputEventResult::HandledSystem; 728 eventResult = WebInputEventResult::HandledSystem;
730 729
730 WebGestureEvent scaledEvent =
731 ScaleWebGestureEvent(mainFrameImpl()->frameView(), event);
majidvp 2016/12/15 17:40:46 One thing that we are going to miss when we remove
dtapuska 2016/12/15 21:29:39 I've adjusted the framescale to be zero based whic
majidvp 2016/12/15 21:45:36 Neat trick.
731 // Plugins may need to see GestureFlingStart to balance 732 // Plugins may need to see GestureFlingStart to balance
732 // GestureScrollBegin (since the former replaces GestureScrollEnd when 733 // GestureScrollBegin (since the former replaces GestureScrollEnd when
733 // transitioning to a fling). 734 // transitioning to a fling).
734 PlatformGestureEventBuilder platformEvent(mainFrameImpl()->frameView(),
735 event);
736 // TODO(dtapuska): Why isn't the response used? 735 // TODO(dtapuska): Why isn't the response used?
737 mainFrameImpl()->frame()->eventHandler().handleGestureScrollEvent( 736 mainFrameImpl()->frame()->eventHandler().handleGestureScrollEvent(
738 platformEvent); 737 scaledEvent);
739 738
740 m_client->didHandleGestureEvent(event, eventCancelled); 739 m_client->didHandleGestureEvent(event, eventCancelled);
741 return WebInputEventResult::HandledSystem; 740 return WebInputEventResult::HandledSystem;
742 } 741 }
743 case WebInputEvent::GestureFlingCancel: 742 case WebInputEvent::GestureFlingCancel:
744 if (endActiveFlingAnimation()) 743 if (endActiveFlingAnimation())
745 eventResult = WebInputEventResult::HandledSuppressed; 744 eventResult = WebInputEventResult::HandledSuppressed;
746 745
747 m_client->didHandleGestureEvent(event, eventCancelled); 746 m_client->didHandleGestureEvent(event, eventCancelled);
748 return eventResult; 747 return eventResult;
749 default: 748 default:
750 break; 749 break;
751 } 750 }
752 751
753 PlatformGestureEventBuilder platformEvent(mainFrameImpl()->frameView(), 752 WebGestureEvent scaledEvent =
754 event); 753 ScaleWebGestureEvent(mainFrameImpl()->frameView(), event);
755 754
756 // Special handling for double tap and scroll events as we don't want to 755 // Special handling for double tap and scroll events as we don't want to
757 // hit test for them. 756 // hit test for them.
758 switch (event.type) { 757 switch (event.type) {
759 case WebInputEvent::GestureDoubleTap: 758 case WebInputEvent::GestureDoubleTap:
760 if (m_webSettings->doubleTapToZoomEnabled() && 759 if (m_webSettings->doubleTapToZoomEnabled() &&
761 minimumPageScaleFactor() != maximumPageScaleFactor()) { 760 minimumPageScaleFactor() != maximumPageScaleFactor()) {
762 m_client->cancelScheduledContentIntents(); 761 m_client->cancelScheduledContentIntents();
763 animateDoubleTapZoom(platformEvent.position()); 762 animateDoubleTapZoom(
763 flooredIntPoint(scaledEvent.positionInRootFrame()));
764 } 764 }
765 // GestureDoubleTap is currently only used by Android for zooming. For 765 // GestureDoubleTap is currently only used by Android for zooming. For
766 // WebCore, GestureTap with tap count = 2 is used instead. So we drop 766 // WebCore, GestureTap with tap count = 2 is used instead. So we drop
767 // GestureDoubleTap here. 767 // GestureDoubleTap here.
768 eventResult = WebInputEventResult::HandledSystem; 768 eventResult = WebInputEventResult::HandledSystem;
769 m_client->didHandleGestureEvent(event, eventCancelled); 769 m_client->didHandleGestureEvent(event, eventCancelled);
770 return eventResult; 770 return eventResult;
771 case WebInputEvent::GestureScrollBegin: 771 case WebInputEvent::GestureScrollBegin:
772 m_client->cancelScheduledContentIntents(); 772 m_client->cancelScheduledContentIntents();
773 case WebInputEvent::GestureScrollEnd: 773 case WebInputEvent::GestureScrollEnd:
774 case WebInputEvent::GestureScrollUpdate: 774 case WebInputEvent::GestureScrollUpdate:
775 case WebInputEvent::GestureFlingStart: 775 case WebInputEvent::GestureFlingStart:
776 // Scrolling-related gesture events invoke EventHandler recursively for 776 // Scrolling-related gesture events invoke EventHandler recursively for
777 // each frame down the chain, doing a single-frame hit-test per frame. 777 // each frame down the chain, doing a single-frame hit-test per frame.
778 // This matches handleWheelEvent. Perhaps we could simplify things by 778 // This matches handleWheelEvent. Perhaps we could simplify things by
779 // rewriting scroll handling to work inner frame out, and then unify with 779 // rewriting scroll handling to work inner frame out, and then unify with
780 // other gesture events. 780 // other gesture events.
781 eventResult = 781 eventResult =
782 mainFrameImpl()->frame()->eventHandler().handleGestureScrollEvent( 782 mainFrameImpl()->frame()->eventHandler().handleGestureScrollEvent(
783 platformEvent); 783 scaledEvent);
784 m_client->didHandleGestureEvent(event, eventCancelled); 784 m_client->didHandleGestureEvent(event, eventCancelled);
785 return eventResult; 785 return eventResult;
786 case WebInputEvent::GesturePinchBegin: 786 case WebInputEvent::GesturePinchBegin:
787 case WebInputEvent::GesturePinchEnd: 787 case WebInputEvent::GesturePinchEnd:
788 case WebInputEvent::GesturePinchUpdate: 788 case WebInputEvent::GesturePinchUpdate:
789 return WebInputEventResult::NotHandled; 789 return WebInputEventResult::NotHandled;
790 default: 790 default:
791 break; 791 break;
792 } 792 }
793 793
794 // Hit test across all frames and do touch adjustment as necessary for the 794 // Hit test across all frames and do touch adjustment as necessary for the
795 // event type. 795 // event type.
796 GestureEventWithHitTestResults targetedEvent = 796 GestureEventWithHitTestResults targetedEvent =
797 m_page->deprecatedLocalMainFrame()->eventHandler().targetGestureEvent( 797 m_page->deprecatedLocalMainFrame()->eventHandler().targetGestureEvent(
798 platformEvent); 798 scaledEvent);
799 799
800 // Handle link highlighting outside the main switch to avoid getting lost in 800 // Handle link highlighting outside the main switch to avoid getting lost in
801 // the complicated set of cases handled below. 801 // the complicated set of cases handled below.
802 switch (event.type) { 802 switch (event.type) {
803 case WebInputEvent::GestureShowPress: 803 case WebInputEvent::GestureShowPress:
804 // Queue a highlight animation, then hand off to regular handler. 804 // Queue a highlight animation, then hand off to regular handler.
805 enableTapHighlightAtPoint(targetedEvent); 805 enableTapHighlightAtPoint(targetedEvent);
806 break; 806 break;
807 case WebInputEvent::GestureTapCancel: 807 case WebInputEvent::GestureTapCancel:
808 case WebInputEvent::GestureTap: 808 case WebInputEvent::GestureTap:
(...skipping 1141 matching lines...) Expand 10 before | Expand all | Expand 10 after
1950 1950
1951 // Create synthetic wheel events as necessary for fling. 1951 // Create synthetic wheel events as necessary for fling.
1952 if (m_gestureAnimation) { 1952 if (m_gestureAnimation) {
1953 if (m_gestureAnimation->animate(lastFrameTimeMonotonic)) 1953 if (m_gestureAnimation->animate(lastFrameTimeMonotonic))
1954 mainFrameImpl()->frameWidget()->scheduleAnimation(); 1954 mainFrameImpl()->frameWidget()->scheduleAnimation();
1955 else { 1955 else {
1956 DCHECK_NE(m_flingSourceDevice, WebGestureDeviceUninitialized); 1956 DCHECK_NE(m_flingSourceDevice, WebGestureDeviceUninitialized);
1957 WebGestureDevice lastFlingSourceDevice = m_flingSourceDevice; 1957 WebGestureDevice lastFlingSourceDevice = m_flingSourceDevice;
1958 endActiveFlingAnimation(); 1958 endActiveFlingAnimation();
1959 1959
1960 PlatformGestureEvent endScrollEvent( 1960 WebGestureEvent endScrollEvent = createGestureScrollEventFromFling(
1961 PlatformEvent::GestureScrollEnd, m_positionOnFlingStart, 1961 WebInputEvent::GestureScrollEnd, lastFlingSourceDevice);
1962 m_globalPositionOnFlingStart, IntSize(), TimeTicks(),
1963 PlatformEvent::NoModifiers,
1964 lastFlingSourceDevice == WebGestureDeviceTouchpad
1965 ? PlatformGestureSourceTouchpad
1966 : PlatformGestureSourceTouchscreen);
1967 endScrollEvent.setScrollGestureData(0, 0, ScrollByPrecisePixel, 0, 0,
1968 ScrollInertialPhaseMomentum, false,
1969 -1 /* null plugin id */);
1970
1971 mainFrameImpl()->frame()->eventHandler().handleGestureScrollEnd( 1962 mainFrameImpl()->frame()->eventHandler().handleGestureScrollEnd(
1972 endScrollEvent); 1963 endScrollEvent);
1973 } 1964 }
1974 } 1965 }
1975 1966
1976 if (!mainFrameImpl()) 1967 if (!mainFrameImpl())
1977 return; 1968 return;
1978 1969
1979 m_lastFrameTimeMonotonic = lastFrameTimeMonotonic; 1970 m_lastFrameTimeMonotonic = lastFrameTimeMonotonic;
1980 1971
(...skipping 1820 matching lines...) Expand 10 before | Expand all | Expand 10 after
3801 WebGestureEvent tapEvent; 3792 WebGestureEvent tapEvent;
3802 tapEvent.x = tapPointWindowPos.x; 3793 tapEvent.x = tapPointWindowPos.x;
3803 tapEvent.y = tapPointWindowPos.y; 3794 tapEvent.y = tapPointWindowPos.y;
3804 tapEvent.type = WebInputEvent::GestureTap; 3795 tapEvent.type = WebInputEvent::GestureTap;
3805 // GestureTap is only ever from a touchscreen. 3796 // GestureTap is only ever from a touchscreen.
3806 tapEvent.sourceDevice = WebGestureDeviceTouchscreen; 3797 tapEvent.sourceDevice = WebGestureDeviceTouchscreen;
3807 tapEvent.data.tap.tapCount = 1; 3798 tapEvent.data.tap.tapCount = 1;
3808 tapEvent.data.tap.width = tapArea.width; 3799 tapEvent.data.tap.width = tapArea.width;
3809 tapEvent.data.tap.height = tapArea.height; 3800 tapEvent.data.tap.height = tapArea.height;
3810 3801
3811 PlatformGestureEventBuilder platformEvent(mainFrameImpl()->frameView(), 3802 WebGestureEvent scaledEvent =
3812 tapEvent); 3803 ScaleWebGestureEvent(mainFrameImpl()->frameView(), tapEvent);
3813 3804
3814 HitTestResult result = 3805 HitTestResult result =
3815 m_page->deprecatedLocalMainFrame() 3806 m_page->deprecatedLocalMainFrame()
3816 ->eventHandler() 3807 ->eventHandler()
3817 .hitTestResultForGestureEvent( 3808 .hitTestResultForGestureEvent(
3818 platformEvent, HitTestRequest::ReadOnly | HitTestRequest::Active) 3809 scaledEvent, HitTestRequest::ReadOnly | HitTestRequest::Active)
3819 .hitTestResult(); 3810 .hitTestResult();
3820 3811
3821 result.setToShadowHostIfInUserAgentShadowRoot(); 3812 result.setToShadowHostIfInUserAgentShadowRoot();
3822 return result; 3813 return result;
3823 } 3814 }
3824 3815
3825 void WebViewImpl::setTabsToLinks(bool enable) { 3816 void WebViewImpl::setTabsToLinks(bool enable) {
3826 m_tabsToLinks = enable; 3817 m_tabsToLinks = enable;
3827 } 3818 }
3828 3819
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
4214 if (focusedFrame->localFrameRoot() != mainFrameImpl()->frame()) 4205 if (focusedFrame->localFrameRoot() != mainFrameImpl()->frame())
4215 return nullptr; 4206 return nullptr;
4216 return focusedFrame; 4207 return focusedFrame;
4217 } 4208 }
4218 4209
4219 LocalFrame* WebViewImpl::focusedLocalFrameAvailableForIme() const { 4210 LocalFrame* WebViewImpl::focusedLocalFrameAvailableForIme() const {
4220 return m_imeAcceptEvents ? focusedLocalFrameInWidget() : nullptr; 4211 return m_imeAcceptEvents ? focusedLocalFrameInWidget() : nullptr;
4221 } 4212 }
4222 4213
4223 } // namespace blink 4214 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698