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

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

Issue 2621303004: Keep track of coalesced events in main thread event queue (Closed)
Patch Set: Keep coalesced events in main thread event queue unittests Created 3 years, 11 months 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 943 matching lines...) Expand 10 before | Expand all | Expand 10 after
954 // - magnitude roughly matches wheels: f(2) > 25 && f(2) < 100 954 // - magnitude roughly matches wheels: f(2) > 25 && f(2) < 100
955 // - a formula that's relatively easy to use from JavaScript 955 // - a formula that's relatively easy to use from JavaScript
956 // Note that 'wheel' event deltaY values have their sign inverted. So to 956 // Note that 'wheel' event deltaY values have their sign inverted. So to
957 // convert a wheel deltaY back to a scale use Math.exp(-deltaY/100). 957 // convert a wheel deltaY back to a scale use Math.exp(-deltaY/100).
958 DCHECK_GT(pinchEvent.data.pinchUpdate.scale, 0); 958 DCHECK_GT(pinchEvent.data.pinchUpdate.scale, 0);
959 wheelEvent.deltaY = 100.0f * log(pinchEvent.data.pinchUpdate.scale); 959 wheelEvent.deltaY = 100.0f * log(pinchEvent.data.pinchUpdate.scale);
960 wheelEvent.hasPreciseScrollingDeltas = true; 960 wheelEvent.hasPreciseScrollingDeltas = true;
961 wheelEvent.wheelTicksX = 0; 961 wheelEvent.wheelTicksX = 0;
962 wheelEvent.wheelTicksY = pinchEvent.data.pinchUpdate.scale > 1 ? 1 : -1; 962 wheelEvent.wheelTicksY = pinchEvent.data.pinchUpdate.scale > 1 ? 1 : -1;
963 963
964 return handleInputEvent(wheelEvent); 964 return handleInputEvent(blink::WebCoalescedInputEvent(wheelEvent));
965 } 965 }
966 966
967 void WebViewImpl::transferActiveWheelFlingAnimation( 967 void WebViewImpl::transferActiveWheelFlingAnimation(
968 const WebActiveWheelFlingParameters& parameters) { 968 const WebActiveWheelFlingParameters& parameters) {
969 TRACE_EVENT0("blink", "WebViewImpl::transferActiveWheelFlingAnimation"); 969 TRACE_EVENT0("blink", "WebViewImpl::transferActiveWheelFlingAnimation");
970 DCHECK(!m_gestureAnimation); 970 DCHECK(!m_gestureAnimation);
971 m_positionOnFlingStart = parameters.point; 971 m_positionOnFlingStart = parameters.point;
972 m_globalPositionOnFlingStart = parameters.globalPoint; 972 m_globalPositionOnFlingStart = parameters.globalPoint;
973 m_flingModifier = parameters.modifiers; 973 m_flingModifier = parameters.modifiers;
974 std::unique_ptr<WebGestureCurve> curve = 974 std::unique_ptr<WebGestureCurve> curve =
(...skipping 1127 matching lines...) Expand 10 before | Expand all | Expand 10 after
2102 bool WebViewImpl::hasVerticalScrollbar() { 2102 bool WebViewImpl::hasVerticalScrollbar() {
2103 return mainFrameImpl() 2103 return mainFrameImpl()
2104 ->frameView() 2104 ->frameView()
2105 ->layoutViewportScrollableArea() 2105 ->layoutViewportScrollableArea()
2106 ->verticalScrollbar(); 2106 ->verticalScrollbar();
2107 } 2107 }
2108 2108
2109 const WebInputEvent* WebViewImpl::m_currentInputEvent = nullptr; 2109 const WebInputEvent* WebViewImpl::m_currentInputEvent = nullptr;
2110 2110
2111 WebInputEventResult WebViewImpl::handleInputEvent( 2111 WebInputEventResult WebViewImpl::handleInputEvent(
2112 const WebInputEvent& inputEvent) { 2112 const WebCoalescedInputEvent& coalescedEvent) {
2113 const WebInputEvent& inputEvent = coalescedEvent.event();
2113 // TODO(dcheng): The fact that this is getting called when there is no local 2114 // TODO(dcheng): The fact that this is getting called when there is no local
2114 // main frame is problematic and probably indicates a bug in the input event 2115 // main frame is problematic and probably indicates a bug in the input event
2115 // routing code. 2116 // routing code.
2116 if (!mainFrameImpl()) 2117 if (!mainFrameImpl())
2117 return WebInputEventResult::NotHandled; 2118 return WebInputEventResult::NotHandled;
2118 2119
2119 WebAutofillClient* autofillClient = mainFrameImpl()->autofillClient(); 2120 WebAutofillClient* autofillClient = mainFrameImpl()->autofillClient();
2120 UserGestureNotifier notifier(this); 2121 UserGestureNotifier notifier(this);
2121 // On the first input event since page load, |notifier| instructs the 2122 // On the first input event since page load, |notifier| instructs the
2122 // autofill client to unblock values of password input fields of any forms 2123 // autofill client to unblock values of password input fields of any forms
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
2206 node->dispatchMouseEvent( 2207 node->dispatchMouseEvent(
2207 PlatformMouseEventBuilder( 2208 PlatformMouseEventBuilder(
2208 mainFrameImpl()->frameView(), 2209 mainFrameImpl()->frameView(),
2209 static_cast<const WebMouseEvent&>(inputEvent)), 2210 static_cast<const WebMouseEvent&>(inputEvent)),
2210 eventType, static_cast<const WebMouseEvent&>(inputEvent).clickCount); 2211 eventType, static_cast<const WebMouseEvent&>(inputEvent).clickCount);
2211 return WebInputEventResult::HandledSystem; 2212 return WebInputEventResult::HandledSystem;
2212 } 2213 }
2213 2214
2214 // FIXME: This should take in the intended frame, not the local frame root. 2215 // FIXME: This should take in the intended frame, not the local frame root.
2215 WebInputEventResult result = PageWidgetDelegate::handleInputEvent( 2216 WebInputEventResult result = PageWidgetDelegate::handleInputEvent(
2216 *this, WebCoalescedInputEvent(inputEvent), mainFrameImpl()->frame()); 2217 *this, coalescedEvent, mainFrameImpl()->frame());
2217 if (result != WebInputEventResult::NotHandled) 2218 if (result != WebInputEventResult::NotHandled)
2218 return result; 2219 return result;
2219 2220
2220 // Unhandled pinch events should adjust the scale. 2221 // Unhandled pinch events should adjust the scale.
2221 if (inputEvent.type() == WebInputEvent::GesturePinchUpdate) { 2222 if (inputEvent.type() == WebInputEvent::GesturePinchUpdate) {
2222 const WebGestureEvent& pinchEvent = 2223 const WebGestureEvent& pinchEvent =
2223 static_cast<const WebGestureEvent&>(inputEvent); 2224 static_cast<const WebGestureEvent&>(inputEvent);
2224 2225
2225 // For touchpad gestures synthesize a Windows-like wheel event 2226 // For touchpad gestures synthesize a Windows-like wheel event
2226 // to send to any handlers that may exist. Not necessary for touchscreen 2227 // to send to any handlers that may exist. Not necessary for touchscreen
(...skipping 1964 matching lines...) Expand 10 before | Expand all | Expand 10 after
4191 if (focusedFrame->localFrameRoot() != mainFrameImpl()->frame()) 4192 if (focusedFrame->localFrameRoot() != mainFrameImpl()->frame())
4192 return nullptr; 4193 return nullptr;
4193 return focusedFrame; 4194 return focusedFrame;
4194 } 4195 }
4195 4196
4196 LocalFrame* WebViewImpl::focusedLocalFrameAvailableForIme() const { 4197 LocalFrame* WebViewImpl::focusedLocalFrameAvailableForIme() const {
4197 return m_imeAcceptEvents ? focusedLocalFrameInWidget() : nullptr; 4198 return m_imeAcceptEvents ? focusedLocalFrameInWidget() : nullptr;
4198 } 4199 }
4199 4200
4200 } // namespace blink 4201 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698