| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/events/blink/input_handler_proxy.h" | 5 #include "ui/events/blink/input_handler_proxy.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| 11 #include "base/auto_reset.h" | 11 #include "base/auto_reset.h" |
| 12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "base/location.h" | 13 #include "base/location.h" |
| 14 #include "base/logging.h" | 14 #include "base/logging.h" |
| 15 #include "base/metrics/histogram_macros.h" | 15 #include "base/metrics/histogram_macros.h" |
| 16 #include "base/single_thread_task_runner.h" | 16 #include "base/single_thread_task_runner.h" |
| 17 #include "base/threading/thread_task_runner_handle.h" | 17 #include "base/threading/thread_task_runner_handle.h" |
| 18 #include "base/trace_event/trace_event.h" | 18 #include "base/trace_event/trace_event.h" |
| 19 #include "cc/input/main_thread_scrolling_reason.h" | 19 #include "cc/input/main_thread_scrolling_reason.h" |
| 20 #include "third_party/WebKit/public/platform/WebInputEvent.h" | 20 #include "third_party/WebKit/public/platform/WebInputEvent.h" |
| 21 #include "ui/events/blink/did_overscroll_params.h" | 21 #include "ui/events/blink/did_overscroll_params.h" |
| 22 #include "ui/events/blink/input_handler_proxy_client.h" | 22 #include "ui/events/blink/input_handler_proxy_client.h" |
| 23 #include "ui/events/blink/input_scroll_elasticity_controller.h" | 23 #include "ui/events/blink/input_scroll_elasticity_controller.h" |
| 24 #include "ui/events/blink/web_input_event_traits.h" |
| 24 #include "ui/events/latency_info.h" | 25 #include "ui/events/latency_info.h" |
| 25 #include "ui/gfx/geometry/point_conversions.h" | 26 #include "ui/gfx/geometry/point_conversions.h" |
| 26 | 27 |
| 27 using blink::WebFloatPoint; | 28 using blink::WebFloatPoint; |
| 28 using blink::WebFloatSize; | 29 using blink::WebFloatSize; |
| 29 using blink::WebGestureEvent; | 30 using blink::WebGestureEvent; |
| 30 using blink::WebInputEvent; | 31 using blink::WebInputEvent; |
| 31 using blink::WebMouseEvent; | 32 using blink::WebMouseEvent; |
| 32 using blink::WebMouseWheelEvent; | 33 using blink::WebMouseWheelEvent; |
| 33 using blink::WebPoint; | 34 using blink::WebPoint; |
| (...skipping 1189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1223 input_handler_->SetNeedsAnimateInput(); | 1224 input_handler_->SetNeedsAnimateInput(); |
| 1224 } | 1225 } |
| 1225 | 1226 |
| 1226 bool InputHandlerProxy::TouchpadFlingScroll( | 1227 bool InputHandlerProxy::TouchpadFlingScroll( |
| 1227 const WebFloatSize& increment) { | 1228 const WebFloatSize& increment) { |
| 1228 InputHandlerProxy::EventDisposition disposition; | 1229 InputHandlerProxy::EventDisposition disposition; |
| 1229 cc::EventListenerProperties properties = | 1230 cc::EventListenerProperties properties = |
| 1230 input_handler_->GetEventListenerProperties( | 1231 input_handler_->GetEventListenerProperties( |
| 1231 cc::EventListenerClass::kMouseWheel); | 1232 cc::EventListenerClass::kMouseWheel); |
| 1232 switch (properties) { | 1233 switch (properties) { |
| 1233 case cc::EventListenerProperties::kPassive: | |
| 1234 disposition = DID_HANDLE_NON_BLOCKING; | |
| 1235 break; | |
| 1236 case cc::EventListenerProperties::kBlocking: | 1234 case cc::EventListenerProperties::kBlocking: |
| 1237 disposition = DID_NOT_HANDLE; | 1235 disposition = DID_NOT_HANDLE; |
| 1238 break; | 1236 break; |
| 1237 case cc::EventListenerProperties::kPassive: |
| 1239 case cc::EventListenerProperties::kNone: { | 1238 case cc::EventListenerProperties::kNone: { |
| 1240 WebMouseWheelEvent synthetic_wheel; | 1239 WebMouseWheelEvent synthetic_wheel; |
| 1241 synthetic_wheel.type = WebInputEvent::MouseWheel; | 1240 synthetic_wheel.type = WebInputEvent::MouseWheel; |
| 1242 synthetic_wheel.timeStampSeconds = InSecondsF(base::TimeTicks::Now()); | 1241 synthetic_wheel.timeStampSeconds = InSecondsF(base::TimeTicks::Now()); |
| 1243 synthetic_wheel.deltaX = increment.width; | 1242 synthetic_wheel.deltaX = increment.width; |
| 1244 synthetic_wheel.deltaY = increment.height; | 1243 synthetic_wheel.deltaY = increment.height; |
| 1245 synthetic_wheel.hasPreciseScrollingDeltas = true; | 1244 synthetic_wheel.hasPreciseScrollingDeltas = true; |
| 1246 synthetic_wheel.x = fling_parameters_.point.x; | 1245 synthetic_wheel.x = fling_parameters_.point.x; |
| 1247 synthetic_wheel.y = fling_parameters_.point.y; | 1246 synthetic_wheel.y = fling_parameters_.point.y; |
| 1248 synthetic_wheel.globalX = fling_parameters_.globalPoint.x; | 1247 synthetic_wheel.globalX = fling_parameters_.globalPoint.x; |
| 1249 synthetic_wheel.globalY = fling_parameters_.globalPoint.y; | 1248 synthetic_wheel.globalY = fling_parameters_.globalPoint.y; |
| 1250 synthetic_wheel.modifiers = fling_parameters_.modifiers; | 1249 synthetic_wheel.modifiers = fling_parameters_.modifiers; |
| 1251 | 1250 |
| 1252 disposition = ScrollByMouseWheel(synthetic_wheel); | 1251 disposition = ScrollByMouseWheel(synthetic_wheel); |
| 1252 |
| 1253 // Send the event over to the main thread. |
| 1254 if (disposition == DID_HANDLE_NON_BLOCKING) { |
| 1255 client_->DispatchNonBlockingEventToMainThread( |
| 1256 ui::WebInputEventTraits::Clone(synthetic_wheel)); |
| 1257 } |
| 1253 break; | 1258 break; |
| 1254 } | 1259 } |
| 1255 default: | 1260 default: |
| 1256 NOTREACHED(); | 1261 NOTREACHED(); |
| 1257 return false; | 1262 return false; |
| 1258 } | 1263 } |
| 1259 | 1264 |
| 1260 switch (disposition) { | 1265 switch (disposition) { |
| 1261 case DID_HANDLE: | 1266 case DID_HANDLE: |
| 1267 case DID_HANDLE_NON_BLOCKING: |
| 1262 return true; | 1268 return true; |
| 1263 case DROP_EVENT: | 1269 case DROP_EVENT: |
| 1264 break; | 1270 break; |
| 1265 case DID_HANDLE_NON_BLOCKING: | |
| 1266 // TODO(dtapuska): Process the fling on the compositor thread | |
| 1267 // but post the events to the main thread; for now just pass it to the | |
| 1268 // main thread. | |
| 1269 case DID_NOT_HANDLE: | 1271 case DID_NOT_HANDLE: |
| 1270 TRACE_EVENT_INSTANT0("input", | 1272 TRACE_EVENT_INSTANT0("input", |
| 1271 "InputHandlerProxy::scrollBy::AbortFling", | 1273 "InputHandlerProxy::scrollBy::AbortFling", |
| 1272 TRACE_EVENT_SCOPE_THREAD); | 1274 TRACE_EVENT_SCOPE_THREAD); |
| 1273 // If we got a DID_NOT_HANDLE, that means we need to deliver wheels on the | 1275 // If we got a DID_NOT_HANDLE, that means we need to deliver wheels on the |
| 1274 // main thread. In this case we need to schedule a commit and transfer the | 1276 // main thread. In this case we need to schedule a commit and transfer the |
| 1275 // fling curve over to the main thread and run the rest of the wheels from | 1277 // fling curve over to the main thread and run the rest of the wheels from |
| 1276 // there. This can happen when flinging a page that contains a scrollable | 1278 // there. This can happen when flinging a page that contains a scrollable |
| 1277 // subarea that we can't scroll on the thread if the fling starts outside | 1279 // subarea that we can't scroll on the thread if the fling starts outside |
| 1278 // the subarea but then is flung "under" the pointer. | 1280 // the subarea but then is flung "under" the pointer. |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1362 // is made asynchronously, to minimize divergence between main thread and | 1364 // is made asynchronously, to minimize divergence between main thread and |
| 1363 // impl thread event handling paths. | 1365 // impl thread event handling paths. |
| 1364 base::ThreadTaskRunnerHandle::Get()->PostTask( | 1366 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 1365 FROM_HERE, | 1367 FROM_HERE, |
| 1366 base::Bind(&InputScrollElasticityController::ObserveGestureEventAndResult, | 1368 base::Bind(&InputScrollElasticityController::ObserveGestureEventAndResult, |
| 1367 scroll_elasticity_controller_->GetWeakPtr(), gesture_event, | 1369 scroll_elasticity_controller_->GetWeakPtr(), gesture_event, |
| 1368 scroll_result)); | 1370 scroll_result)); |
| 1369 } | 1371 } |
| 1370 | 1372 |
| 1371 } // namespace ui | 1373 } // namespace ui |
| OLD | NEW |