| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "content/renderer/gpu/input_handler_proxy.h" | 5 #include "content/renderer/gpu/input_handler_proxy.h" |
| 6 | 6 |
| 7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "content/renderer/gpu/input_handler_proxy_client.h" | 10 #include "content/renderer/gpu/input_handler_proxy_client.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 namespace content { | 53 namespace content { |
| 54 | 54 |
| 55 InputHandlerProxy::InputHandlerProxy(cc::InputHandler* input_handler) | 55 InputHandlerProxy::InputHandlerProxy(cc::InputHandler* input_handler) |
| 56 : client_(NULL), | 56 : client_(NULL), |
| 57 input_handler_(input_handler), | 57 input_handler_(input_handler), |
| 58 #ifndef NDEBUG | 58 #ifndef NDEBUG |
| 59 expect_scroll_update_end_(false), | 59 expect_scroll_update_end_(false), |
| 60 expect_pinch_update_end_(false), | 60 expect_pinch_update_end_(false), |
| 61 #endif | 61 #endif |
| 62 gesture_scroll_on_impl_thread_(false), | 62 gesture_scroll_on_impl_thread_(false), |
| 63 gesture_scroll_on_main_thread_(false), |
| 63 gesture_pinch_on_impl_thread_(false), | 64 gesture_pinch_on_impl_thread_(false), |
| 64 fling_may_be_active_on_main_thread_(false), | 65 fling_may_be_active_on_main_thread_(false), |
| 65 fling_overscrolled_horizontally_(false), | 66 fling_overscrolled_horizontally_(false), |
| 66 fling_overscrolled_vertically_(false) { | 67 fling_overscrolled_vertically_(false) { |
| 67 input_handler_->BindToClient(this); | 68 input_handler_->BindToClient(this); |
| 68 } | 69 } |
| 69 | 70 |
| 70 InputHandlerProxy::~InputHandlerProxy() {} | 71 InputHandlerProxy::~InputHandlerProxy() {} |
| 71 | 72 |
| 72 void InputHandlerProxy::WillShutdown() { | 73 void InputHandlerProxy::WillShutdown() { |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 const WebGestureEvent& gesture_event = | 144 const WebGestureEvent& gesture_event = |
| 144 *static_cast<const WebGestureEvent*>(&event); | 145 *static_cast<const WebGestureEvent*>(&event); |
| 145 cc::InputHandler::ScrollStatus scroll_status = input_handler_->ScrollBegin( | 146 cc::InputHandler::ScrollStatus scroll_status = input_handler_->ScrollBegin( |
| 146 gfx::Point(gesture_event.x, gesture_event.y), | 147 gfx::Point(gesture_event.x, gesture_event.y), |
| 147 cc::InputHandler::Gesture); | 148 cc::InputHandler::Gesture); |
| 148 switch (scroll_status) { | 149 switch (scroll_status) { |
| 149 case cc::InputHandler::ScrollStarted: | 150 case cc::InputHandler::ScrollStarted: |
| 150 gesture_scroll_on_impl_thread_ = true; | 151 gesture_scroll_on_impl_thread_ = true; |
| 151 return DID_HANDLE; | 152 return DID_HANDLE; |
| 152 case cc::InputHandler::ScrollOnMainThread: | 153 case cc::InputHandler::ScrollOnMainThread: |
| 154 gesture_scroll_on_main_thread_ = true; |
| 153 return DID_NOT_HANDLE; | 155 return DID_NOT_HANDLE; |
| 154 case cc::InputHandler::ScrollIgnored: | 156 case cc::InputHandler::ScrollIgnored: |
| 155 return DROP_EVENT; | 157 return DROP_EVENT; |
| 156 } | 158 } |
| 157 } else if (event.type == WebInputEvent::GestureScrollUpdate) { | 159 } else if (event.type == WebInputEvent::GestureScrollUpdate) { |
| 158 #ifndef NDEBUG | 160 #ifndef NDEBUG |
| 159 DCHECK(expect_scroll_update_end_); | 161 DCHECK(expect_scroll_update_end_); |
| 160 #endif | 162 #endif |
| 161 | 163 |
| 164 if (gesture_scroll_on_main_thread_) |
| 165 return DID_NOT_HANDLE; |
| 166 |
| 162 if (!gesture_scroll_on_impl_thread_ && !gesture_pinch_on_impl_thread_) | 167 if (!gesture_scroll_on_impl_thread_ && !gesture_pinch_on_impl_thread_) |
| 163 return DID_NOT_HANDLE; | 168 return DROP_EVENT; |
| 164 | 169 |
| 165 const WebGestureEvent& gesture_event = | 170 const WebGestureEvent& gesture_event = |
| 166 *static_cast<const WebGestureEvent*>(&event); | 171 *static_cast<const WebGestureEvent*>(&event); |
| 167 bool did_scroll = input_handler_->ScrollBy( | 172 bool did_scroll = input_handler_->ScrollBy( |
| 168 gfx::Point(gesture_event.x, gesture_event.y), | 173 gfx::Point(gesture_event.x, gesture_event.y), |
| 169 gfx::Vector2dF(-gesture_event.data.scrollUpdate.deltaX, | 174 gfx::Vector2dF(-gesture_event.data.scrollUpdate.deltaX, |
| 170 -gesture_event.data.scrollUpdate.deltaY)); | 175 -gesture_event.data.scrollUpdate.deltaY)); |
| 171 return did_scroll ? DID_HANDLE : DROP_EVENT; | 176 return did_scroll ? DID_HANDLE : DROP_EVENT; |
| 172 } else if (event.type == WebInputEvent::GestureScrollEnd) { | 177 } else if (event.type == WebInputEvent::GestureScrollEnd) { |
| 173 #ifndef NDEBUG | 178 #ifndef NDEBUG |
| 174 DCHECK(expect_scroll_update_end_); | 179 DCHECK(expect_scroll_update_end_); |
| 175 expect_scroll_update_end_ = false; | 180 expect_scroll_update_end_ = false; |
| 176 #endif | 181 #endif |
| 177 input_handler_->ScrollEnd(); | 182 input_handler_->ScrollEnd(); |
| 178 | 183 |
| 184 if (gesture_scroll_on_main_thread_) { |
| 185 gesture_scroll_on_main_thread_ = false; |
| 186 return DID_NOT_HANDLE; |
| 187 } |
| 188 |
| 179 if (!gesture_scroll_on_impl_thread_) | 189 if (!gesture_scroll_on_impl_thread_) |
| 180 return DID_NOT_HANDLE; | 190 return DROP_EVENT; |
| 181 | 191 |
| 182 gesture_scroll_on_impl_thread_ = false; | 192 gesture_scroll_on_impl_thread_ = false; |
| 183 return DID_HANDLE; | 193 return DID_HANDLE; |
| 184 } else if (event.type == WebInputEvent::GesturePinchBegin) { | 194 } else if (event.type == WebInputEvent::GesturePinchBegin) { |
| 185 #ifndef NDEBUG | 195 #ifndef NDEBUG |
| 186 DCHECK(!expect_pinch_update_end_); | 196 DCHECK(!expect_pinch_update_end_); |
| 187 expect_pinch_update_end_ = true; | 197 expect_pinch_update_end_ = true; |
| 188 #endif | 198 #endif |
| 189 input_handler_->PinchGestureBegin(); | 199 input_handler_->PinchGestureBegin(); |
| 190 gesture_pinch_on_impl_thread_ = true; | 200 gesture_pinch_on_impl_thread_ = true; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 InputHandlerProxy::EventDisposition | 247 InputHandlerProxy::EventDisposition |
| 238 InputHandlerProxy::HandleGestureFling( | 248 InputHandlerProxy::HandleGestureFling( |
| 239 const WebGestureEvent& gesture_event) { | 249 const WebGestureEvent& gesture_event) { |
| 240 cc::InputHandler::ScrollStatus scroll_status; | 250 cc::InputHandler::ScrollStatus scroll_status; |
| 241 | 251 |
| 242 if (gesture_event.sourceDevice == WebGestureEvent::Touchpad) { | 252 if (gesture_event.sourceDevice == WebGestureEvent::Touchpad) { |
| 243 scroll_status = input_handler_->ScrollBegin( | 253 scroll_status = input_handler_->ScrollBegin( |
| 244 gfx::Point(gesture_event.x, gesture_event.y), | 254 gfx::Point(gesture_event.x, gesture_event.y), |
| 245 cc::InputHandler::NonBubblingGesture); | 255 cc::InputHandler::NonBubblingGesture); |
| 246 } else { | 256 } else { |
| 247 if (!gesture_scroll_on_impl_thread_) | 257 if (gesture_scroll_on_main_thread_) |
| 248 scroll_status = cc::InputHandler::ScrollOnMainThread; | 258 scroll_status = cc::InputHandler::ScrollOnMainThread; |
| 249 else | 259 else |
| 250 scroll_status = input_handler_->FlingScrollBegin(); | 260 scroll_status = input_handler_->FlingScrollBegin(); |
| 251 } | 261 } |
| 252 | 262 |
| 253 #ifndef NDEBUG | 263 #ifndef NDEBUG |
| 254 expect_scroll_update_end_ = false; | 264 expect_scroll_update_end_ = false; |
| 255 #endif | 265 #endif |
| 256 | 266 |
| 257 switch (scroll_status) { | 267 switch (scroll_status) { |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 453 TRACE_EVENT2("renderer", | 463 TRACE_EVENT2("renderer", |
| 454 "InputHandlerProxy::notifyCurrentFlingVelocity", | 464 "InputHandlerProxy::notifyCurrentFlingVelocity", |
| 455 "vx", | 465 "vx", |
| 456 velocity.width, | 466 velocity.width, |
| 457 "vy", | 467 "vy", |
| 458 velocity.height); | 468 velocity.height); |
| 459 input_handler_->NotifyCurrentFlingVelocity(ToClientScrollIncrement(velocity)); | 469 input_handler_->NotifyCurrentFlingVelocity(ToClientScrollIncrement(velocity)); |
| 460 } | 470 } |
| 461 | 471 |
| 462 } // namespace content | 472 } // namespace content |
| OLD | NEW |