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

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

Issue 2479123003: WIP Add getCoalescedEvents API using vector of WebInputEvents (Closed)
Patch Set: Created 4 years, 1 month 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 964 matching lines...) Expand 10 before | Expand all | Expand 10 after
975 // - magnitude roughly matches wheels: f(2) > 25 && f(2) < 100 975 // - magnitude roughly matches wheels: f(2) > 25 && f(2) < 100
976 // - a formula that's relatively easy to use from JavaScript 976 // - a formula that's relatively easy to use from JavaScript
977 // Note that 'wheel' event deltaY values have their sign inverted. So to 977 // Note that 'wheel' event deltaY values have their sign inverted. So to
978 // convert a wheel deltaY back to a scale use Math.exp(-deltaY/100). 978 // convert a wheel deltaY back to a scale use Math.exp(-deltaY/100).
979 DCHECK_GT(pinchEvent.data.pinchUpdate.scale, 0); 979 DCHECK_GT(pinchEvent.data.pinchUpdate.scale, 0);
980 wheelEvent.deltaY = 100.0f * log(pinchEvent.data.pinchUpdate.scale); 980 wheelEvent.deltaY = 100.0f * log(pinchEvent.data.pinchUpdate.scale);
981 wheelEvent.hasPreciseScrollingDeltas = true; 981 wheelEvent.hasPreciseScrollingDeltas = true;
982 wheelEvent.wheelTicksX = 0; 982 wheelEvent.wheelTicksX = 0;
983 wheelEvent.wheelTicksY = pinchEvent.data.pinchUpdate.scale > 1 ? 1 : -1; 983 wheelEvent.wheelTicksY = pinchEvent.data.pinchUpdate.scale > 1 ? 1 : -1;
984 984
985 return handleInputEvent(wheelEvent); 985 return handleInputEvent(wheelEvent, std::vector<const WebInputEvent*>());
986 } 986 }
987 987
988 void WebViewImpl::transferActiveWheelFlingAnimation( 988 void WebViewImpl::transferActiveWheelFlingAnimation(
989 const WebActiveWheelFlingParameters& parameters) { 989 const WebActiveWheelFlingParameters& parameters) {
990 TRACE_EVENT0("blink", "WebViewImpl::transferActiveWheelFlingAnimation"); 990 TRACE_EVENT0("blink", "WebViewImpl::transferActiveWheelFlingAnimation");
991 DCHECK(!m_gestureAnimation); 991 DCHECK(!m_gestureAnimation);
992 m_positionOnFlingStart = parameters.point; 992 m_positionOnFlingStart = parameters.point;
993 m_globalPositionOnFlingStart = parameters.globalPoint; 993 m_globalPositionOnFlingStart = parameters.globalPoint;
994 m_flingModifier = parameters.modifiers; 994 m_flingModifier = parameters.modifiers;
995 std::unique_ptr<WebGestureCurve> curve = 995 std::unique_ptr<WebGestureCurve> curve =
(...skipping 1104 matching lines...) Expand 10 before | Expand all | Expand 10 after
2100 return mainFrameImpl()->frameView()->horizontalScrollbar(); 2100 return mainFrameImpl()->frameView()->horizontalScrollbar();
2101 } 2101 }
2102 2102
2103 bool WebViewImpl::hasVerticalScrollbar() { 2103 bool WebViewImpl::hasVerticalScrollbar() {
2104 return mainFrameImpl()->frameView()->verticalScrollbar(); 2104 return mainFrameImpl()->frameView()->verticalScrollbar();
2105 } 2105 }
2106 2106
2107 const WebInputEvent* WebViewImpl::m_currentInputEvent = nullptr; 2107 const WebInputEvent* WebViewImpl::m_currentInputEvent = nullptr;
2108 2108
2109 WebInputEventResult WebViewImpl::handleInputEvent( 2109 WebInputEventResult WebViewImpl::handleInputEvent(
2110 const WebInputEvent& inputEvent) { 2110 const WebInputEvent& inputEvent,
2111 const std::vector<const WebInputEvent*>& webCoalescedEvents) {
2111 // TODO(dcheng): The fact that this is getting called when there is no local 2112 // TODO(dcheng): The fact that this is getting called when there is no local
2112 // main frame is problematic and probably indicates a bug in the input event 2113 // main frame is problematic and probably indicates a bug in the input event
2113 // routing code. 2114 // routing code.
2114 if (!mainFrameImpl()) 2115 if (!mainFrameImpl())
2115 return WebInputEventResult::NotHandled; 2116 return WebInputEventResult::NotHandled;
2116 2117
2117 WebAutofillClient* autofillClient = mainFrameImpl()->autofillClient(); 2118 WebAutofillClient* autofillClient = mainFrameImpl()->autofillClient();
2118 UserGestureNotifier notifier(mainFrameImpl(), &m_userGestureObserved); 2119 UserGestureNotifier notifier(mainFrameImpl(), &m_userGestureObserved);
2119 // On the first input event since page load, |notifier| instructs the 2120 // On the first input event since page load, |notifier| instructs the
2120 // autofill client to unblock values of password input fields of any forms 2121 // autofill client to unblock values of password input fields of any forms
(...skipping 13 matching lines...) Expand all
2134 WebInputEvent::GetName(inputEvent.type)); 2135 WebInputEvent::GetName(inputEvent.type));
2135 // If we've started a drag and drop operation, ignore input events until 2136 // If we've started a drag and drop operation, ignore input events until
2136 // we're done. 2137 // we're done.
2137 if (m_doingDragAndDrop) 2138 if (m_doingDragAndDrop)
2138 return WebInputEventResult::HandledSuppressed; 2139 return WebInputEventResult::HandledSuppressed;
2139 2140
2140 if (m_devToolsEmulator->handleInputEvent(inputEvent)) 2141 if (m_devToolsEmulator->handleInputEvent(inputEvent))
2141 return WebInputEventResult::HandledSuppressed; 2142 return WebInputEventResult::HandledSuppressed;
2142 2143
2143 if (InspectorOverlay* overlay = inspectorOverlay()) { 2144 if (InspectorOverlay* overlay = inspectorOverlay()) {
2144 if (overlay->handleInputEvent(inputEvent)) 2145 if (overlay->handleInputEvent(inputEvent, webCoalescedEvents))
2145 return WebInputEventResult::HandledSuppressed; 2146 return WebInputEventResult::HandledSuppressed;
2146 } 2147 }
2147 2148
2148 // Report the event to be NOT processed by WebKit, so that the browser can 2149 // Report the event to be NOT processed by WebKit, so that the browser can
2149 // handle it appropriately. 2150 // handle it appropriately.
2150 if (m_ignoreInputEvents) 2151 if (m_ignoreInputEvents)
2151 return WebInputEventResult::NotHandled; 2152 return WebInputEventResult::NotHandled;
2152 2153
2153 AutoReset<const WebInputEvent*> currentEventChange(&m_currentInputEvent, 2154 AutoReset<const WebInputEvent*> currentEventChange(&m_currentInputEvent,
2154 &inputEvent); 2155 &inputEvent);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
2203 node->dispatchMouseEvent( 2204 node->dispatchMouseEvent(
2204 PlatformMouseEventBuilder( 2205 PlatformMouseEventBuilder(
2205 mainFrameImpl()->frameView(), 2206 mainFrameImpl()->frameView(),
2206 static_cast<const WebMouseEvent&>(inputEvent)), 2207 static_cast<const WebMouseEvent&>(inputEvent)),
2207 eventType, static_cast<const WebMouseEvent&>(inputEvent).clickCount); 2208 eventType, static_cast<const WebMouseEvent&>(inputEvent).clickCount);
2208 return WebInputEventResult::HandledSystem; 2209 return WebInputEventResult::HandledSystem;
2209 } 2210 }
2210 2211
2211 // FIXME: This should take in the intended frame, not the local frame root. 2212 // FIXME: This should take in the intended frame, not the local frame root.
2212 WebInputEventResult result = PageWidgetDelegate::handleInputEvent( 2213 WebInputEventResult result = PageWidgetDelegate::handleInputEvent(
2213 *this, inputEvent, mainFrameImpl()->frame()); 2214 *this, inputEvent, webCoalescedEvents, mainFrameImpl()->frame());
2214 if (result != WebInputEventResult::NotHandled) 2215 if (result != WebInputEventResult::NotHandled)
2215 return result; 2216 return result;
2216 2217
2217 // Unhandled pinch events should adjust the scale. 2218 // Unhandled pinch events should adjust the scale.
2218 if (inputEvent.type == WebInputEvent::GesturePinchUpdate) { 2219 if (inputEvent.type == WebInputEvent::GesturePinchUpdate) {
2219 const WebGestureEvent& pinchEvent = 2220 const WebGestureEvent& pinchEvent =
2220 static_cast<const WebGestureEvent&>(inputEvent); 2221 static_cast<const WebGestureEvent&>(inputEvent);
2221 2222
2222 // For touchpad gestures synthesize a Windows-like wheel event 2223 // For touchpad gestures synthesize a Windows-like wheel event
2223 // to send to any handlers that may exist. Not necessary for touchscreen 2224 // to send to any handlers that may exist. Not necessary for touchscreen
(...skipping 2219 matching lines...) Expand 10 before | Expand all | Expand 10 after
4443 if (focusedFrame->localFrameRoot() != mainFrameImpl()->frame()) 4444 if (focusedFrame->localFrameRoot() != mainFrameImpl()->frame())
4444 return nullptr; 4445 return nullptr;
4445 return focusedFrame; 4446 return focusedFrame;
4446 } 4447 }
4447 4448
4448 LocalFrame* WebViewImpl::focusedLocalFrameAvailableForIme() const { 4449 LocalFrame* WebViewImpl::focusedLocalFrameAvailableForIme() const {
4449 return m_imeAcceptEvents ? focusedLocalFrameInWidget() : nullptr; 4450 return m_imeAcceptEvents ? focusedLocalFrameInWidget() : nullptr;
4450 } 4451 }
4451 4452
4452 } // namespace blink 4453 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698