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

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

Issue 2479123003: WIP Add getCoalescedEvents API using vector of WebInputEvents (Closed)
Patch Set: Creating CoalescedWebInputEvent 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 952 matching lines...) Expand 10 before | Expand all | Expand 10 after
963 // - magnitude roughly matches wheels: f(2) > 25 && f(2) < 100 963 // - magnitude roughly matches wheels: f(2) > 25 && f(2) < 100
964 // - a formula that's relatively easy to use from JavaScript 964 // - a formula that's relatively easy to use from JavaScript
965 // Note that 'wheel' event deltaY values have their sign inverted. So to 965 // Note that 'wheel' event deltaY values have their sign inverted. So to
966 // convert a wheel deltaY back to a scale use Math.exp(-deltaY/100). 966 // convert a wheel deltaY back to a scale use Math.exp(-deltaY/100).
967 DCHECK_GT(pinchEvent.data.pinchUpdate.scale, 0); 967 DCHECK_GT(pinchEvent.data.pinchUpdate.scale, 0);
968 wheelEvent.deltaY = 100.0f * log(pinchEvent.data.pinchUpdate.scale); 968 wheelEvent.deltaY = 100.0f * log(pinchEvent.data.pinchUpdate.scale);
969 wheelEvent.hasPreciseScrollingDeltas = true; 969 wheelEvent.hasPreciseScrollingDeltas = true;
970 wheelEvent.wheelTicksX = 0; 970 wheelEvent.wheelTicksX = 0;
971 wheelEvent.wheelTicksY = pinchEvent.data.pinchUpdate.scale > 1 ? 1 : -1; 971 wheelEvent.wheelTicksY = pinchEvent.data.pinchUpdate.scale > 1 ? 1 : -1;
972 972
973 return handleInputEvent(wheelEvent); 973 return handleInputEvent(CoalescedWebInputEvent(wheelEvent));
974 } 974 }
975 975
976 void WebViewImpl::transferActiveWheelFlingAnimation( 976 void WebViewImpl::transferActiveWheelFlingAnimation(
977 const WebActiveWheelFlingParameters& parameters) { 977 const WebActiveWheelFlingParameters& parameters) {
978 TRACE_EVENT0("blink", "WebViewImpl::transferActiveWheelFlingAnimation"); 978 TRACE_EVENT0("blink", "WebViewImpl::transferActiveWheelFlingAnimation");
979 DCHECK(!m_gestureAnimation); 979 DCHECK(!m_gestureAnimation);
980 m_positionOnFlingStart = parameters.point; 980 m_positionOnFlingStart = parameters.point;
981 m_globalPositionOnFlingStart = parameters.globalPoint; 981 m_globalPositionOnFlingStart = parameters.globalPoint;
982 m_flingModifier = parameters.modifiers; 982 m_flingModifier = parameters.modifiers;
983 std::unique_ptr<WebGestureCurve> curve = 983 std::unique_ptr<WebGestureCurve> curve =
(...skipping 1126 matching lines...) Expand 10 before | Expand all | Expand 10 after
2110 bool WebViewImpl::hasVerticalScrollbar() { 2110 bool WebViewImpl::hasVerticalScrollbar() {
2111 return mainFrameImpl() 2111 return mainFrameImpl()
2112 ->frameView() 2112 ->frameView()
2113 ->layoutViewportScrollableArea() 2113 ->layoutViewportScrollableArea()
2114 ->verticalScrollbar(); 2114 ->verticalScrollbar();
2115 } 2115 }
2116 2116
2117 const WebInputEvent* WebViewImpl::m_currentInputEvent = nullptr; 2117 const WebInputEvent* WebViewImpl::m_currentInputEvent = nullptr;
2118 2118
2119 WebInputEventResult WebViewImpl::handleInputEvent( 2119 WebInputEventResult WebViewImpl::handleInputEvent(
2120 const WebInputEvent& inputEvent) { 2120 const CoalescedWebInputEvent& coalescedEvent) {
2121 const WebInputEvent& inputEvent = coalescedEvent.event();
2121 // TODO(dcheng): The fact that this is getting called when there is no local 2122 // TODO(dcheng): The fact that this is getting called when there is no local
2122 // main frame is problematic and probably indicates a bug in the input event 2123 // main frame is problematic and probably indicates a bug in the input event
2123 // routing code. 2124 // routing code.
2124 if (!mainFrameImpl()) 2125 if (!mainFrameImpl())
2125 return WebInputEventResult::NotHandled; 2126 return WebInputEventResult::NotHandled;
2126 2127
2127 WebAutofillClient* autofillClient = mainFrameImpl()->autofillClient(); 2128 WebAutofillClient* autofillClient = mainFrameImpl()->autofillClient();
2128 UserGestureNotifier notifier(this); 2129 UserGestureNotifier notifier(this);
2129 // On the first input event since page load, |notifier| instructs the 2130 // On the first input event since page load, |notifier| instructs the
2130 // autofill client to unblock values of password input fields of any forms 2131 // autofill client to unblock values of password input fields of any forms
(...skipping 13 matching lines...) Expand all
2144 WebInputEvent::GetName(inputEvent.type)); 2145 WebInputEvent::GetName(inputEvent.type));
2145 // If we've started a drag and drop operation, ignore input events until 2146 // If we've started a drag and drop operation, ignore input events until
2146 // we're done. 2147 // we're done.
2147 if (m_doingDragAndDrop) 2148 if (m_doingDragAndDrop)
2148 return WebInputEventResult::HandledSuppressed; 2149 return WebInputEventResult::HandledSuppressed;
2149 2150
2150 if (m_devToolsEmulator->handleInputEvent(inputEvent)) 2151 if (m_devToolsEmulator->handleInputEvent(inputEvent))
2151 return WebInputEventResult::HandledSuppressed; 2152 return WebInputEventResult::HandledSuppressed;
2152 2153
2153 if (InspectorOverlay* overlay = inspectorOverlay()) { 2154 if (InspectorOverlay* overlay = inspectorOverlay()) {
2154 if (overlay->handleInputEvent(inputEvent)) 2155 if (overlay->handleInputEvent(coalescedEvent))
2155 return WebInputEventResult::HandledSuppressed; 2156 return WebInputEventResult::HandledSuppressed;
2156 } 2157 }
2157 2158
2158 // Report the event to be NOT processed by WebKit, so that the browser can 2159 // Report the event to be NOT processed by WebKit, so that the browser can
2159 // handle it appropriately. 2160 // handle it appropriately.
2160 if (m_ignoreInputEvents) 2161 if (m_ignoreInputEvents)
2161 return WebInputEventResult::NotHandled; 2162 return WebInputEventResult::NotHandled;
2162 2163
2163 AutoReset<const WebInputEvent*> currentEventChange(&m_currentInputEvent, 2164 AutoReset<const WebInputEvent*> currentEventChange(&m_currentInputEvent,
2164 &inputEvent); 2165 &inputEvent);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
2213 node->dispatchMouseEvent( 2214 node->dispatchMouseEvent(
2214 PlatformMouseEventBuilder( 2215 PlatformMouseEventBuilder(
2215 mainFrameImpl()->frameView(), 2216 mainFrameImpl()->frameView(),
2216 static_cast<const WebMouseEvent&>(inputEvent)), 2217 static_cast<const WebMouseEvent&>(inputEvent)),
2217 eventType, static_cast<const WebMouseEvent&>(inputEvent).clickCount); 2218 eventType, static_cast<const WebMouseEvent&>(inputEvent).clickCount);
2218 return WebInputEventResult::HandledSystem; 2219 return WebInputEventResult::HandledSystem;
2219 } 2220 }
2220 2221
2221 // FIXME: This should take in the intended frame, not the local frame root. 2222 // FIXME: This should take in the intended frame, not the local frame root.
2222 WebInputEventResult result = PageWidgetDelegate::handleInputEvent( 2223 WebInputEventResult result = PageWidgetDelegate::handleInputEvent(
2223 *this, inputEvent, mainFrameImpl()->frame()); 2224 *this, coalescedEvents, mainFrameImpl()->frame());
2224 if (result != WebInputEventResult::NotHandled) 2225 if (result != WebInputEventResult::NotHandled)
2225 return result; 2226 return result;
2226 2227
2227 // Unhandled pinch events should adjust the scale. 2228 // Unhandled pinch events should adjust the scale.
2228 if (inputEvent.type == WebInputEvent::GesturePinchUpdate) { 2229 if (inputEvent.type == WebInputEvent::GesturePinchUpdate) {
2229 const WebGestureEvent& pinchEvent = 2230 const WebGestureEvent& pinchEvent =
2230 static_cast<const WebGestureEvent&>(inputEvent); 2231 static_cast<const WebGestureEvent&>(inputEvent);
2231 2232
2232 // For touchpad gestures synthesize a Windows-like wheel event 2233 // For touchpad gestures synthesize a Windows-like wheel event
2233 // to send to any handlers that may exist. Not necessary for touchscreen 2234 // to send to any handlers that may exist. Not necessary for touchscreen
(...skipping 1990 matching lines...) Expand 10 before | Expand all | Expand 10 after
4224 if (focusedFrame->localFrameRoot() != mainFrameImpl()->frame()) 4225 if (focusedFrame->localFrameRoot() != mainFrameImpl()->frame())
4225 return nullptr; 4226 return nullptr;
4226 return focusedFrame; 4227 return focusedFrame;
4227 } 4228 }
4228 4229
4229 LocalFrame* WebViewImpl::focusedLocalFrameAvailableForIme() const { 4230 LocalFrame* WebViewImpl::focusedLocalFrameAvailableForIme() const {
4230 return m_imeAcceptEvents ? focusedLocalFrameInWidget() : nullptr; 4231 return m_imeAcceptEvents ? focusedLocalFrameInWidget() : nullptr;
4231 } 4232 }
4232 4233
4233 } // namespace blink 4234 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698