Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/browser/renderer_host/overscroll_controller.h" | 5 #include "content/browser/renderer_host/overscroll_controller.h" |
| 6 | 6 |
| 7 #include "content/browser/renderer_host/overscroll_controller_delegate.h" | 7 #include "content/browser/renderer_host/overscroll_controller_delegate.h" |
| 8 #include "content/browser/renderer_host/render_widget_host_impl.h" | 8 #include "content/browser/renderer_host/render_widget_host_impl.h" |
| 9 #include "content/public/browser/overscroll_configuration.h" | 9 #include "content/public/browser/overscroll_configuration.h" |
| 10 #include "content/public/browser/render_widget_host_view.h" | 10 #include "content/public/browser/render_widget_host_view.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 57 } | 57 } |
| 58 | 58 |
| 59 if (DispatchEventCompletesAction(event)) { | 59 if (DispatchEventCompletesAction(event)) { |
| 60 CompleteAction(); | 60 CompleteAction(); |
| 61 | 61 |
| 62 // If the overscroll was caused by touch-scrolling, then the gesture event | 62 // If the overscroll was caused by touch-scrolling, then the gesture event |
| 63 // that completes the action needs to be sent to the renderer, because the | 63 // that completes the action needs to be sent to the renderer, because the |
| 64 // touch-scrolls maintain state in the renderer side (in the compositor, for | 64 // touch-scrolls maintain state in the renderer side (in the compositor, for |
| 65 // example), and the event that completes this action needs to be sent to | 65 // example), and the event that completes this action needs to be sent to |
| 66 // the renderer so that those states can be updated/reset appropriately. | 66 // the renderer so that those states can be updated/reset appropriately. |
| 67 // Send the event through the host when appropriate. | 67 if (WebKit::WebInputEvent::isGestureEventType(event.type)) { |
| 68 if (ShouldForwardToHost(event)) { | |
| 69 const WebKit::WebGestureEvent& gevent = | 68 const WebKit::WebGestureEvent& gevent = |
| 70 static_cast<const WebKit::WebGestureEvent&>(event); | 69 static_cast<const WebKit::WebGestureEvent&>(event); |
| 71 return render_widget_host_->ShouldForwardGestureEvent( | 70 return render_widget_host_->ShouldForwardGestureEvent( |
| 72 GestureEventWithLatencyInfo(gevent, latency_info)); | 71 GestureEventWithLatencyInfo(gevent, latency_info)); |
| 73 } | 72 } |
| 74 | 73 |
| 75 return false; | 74 return false; |
| 76 } | 75 } |
| 77 | 76 |
| 78 if (overscroll_mode_ != OVERSCROLL_NONE && DispatchEventResetsState(event)) { | 77 if (overscroll_mode_ != OVERSCROLL_NONE && DispatchEventResetsState(event)) { |
| 79 SetOverscrollMode(OVERSCROLL_NONE); | 78 SetOverscrollMode(OVERSCROLL_NONE); |
| 80 // The overscroll gesture status is being reset. If the event is a | 79 // The overscroll gesture status is being reset. If the event is a |
| 81 // gesture event (from either touchscreen or trackpad), then make sure the | 80 // gesture event (from either touchscreen or trackpad), then make sure the |
| 82 // host gets the event first (if it didn't already process it). | 81 // host gets the event first. |
| 83 if (ShouldForwardToHost(event)) { | 82 if (WebKit::WebInputEvent::isGestureEventType(event.type)) { |
| 84 const WebKit::WebGestureEvent& gevent = | 83 const WebKit::WebGestureEvent& gevent = |
| 85 static_cast<const WebKit::WebGestureEvent&>(event); | 84 static_cast<const WebKit::WebGestureEvent&>(event); |
| 86 return render_widget_host_->ShouldForwardGestureEvent( | 85 return render_widget_host_->ShouldForwardGestureEvent( |
| 87 GestureEventWithLatencyInfo(gevent, latency_info)); | 86 GestureEventWithLatencyInfo(gevent, latency_info)); |
| 88 } | 87 } |
| 89 | 88 |
| 90 // Let the event be dispatched to the renderer. | 89 // Let the event be dispatched to the renderer. |
|
aelias_OOO_until_Jul13
2013/09/03 02:24:10
I don't think the OverscrollController should be m
| |
| 91 return true; | 90 return true; |
| 92 } | 91 } |
| 93 | 92 |
| 94 if (overscroll_mode_ != OVERSCROLL_NONE) { | 93 if (overscroll_mode_ != OVERSCROLL_NONE) { |
| 95 // Consume the event and update overscroll state when in the middle of the | 94 // Consume the event and update overscroll state when in the middle of the |
| 96 // overscroll gesture. | 95 // overscroll gesture. |
| 97 ProcessEventForOverscroll(event); | 96 ProcessEventForOverscroll(event); |
| 98 | 97 |
| 99 if (event.type == WebKit::WebInputEvent::TouchEnd || | 98 if (event.type == WebKit::WebInputEvent::TouchEnd || |
| 100 event.type == WebKit::WebInputEvent::TouchCancel || | 99 event.type == WebKit::WebInputEvent::TouchCancel || |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 360 OverscrollMode old_mode = overscroll_mode_; | 359 OverscrollMode old_mode = overscroll_mode_; |
| 361 overscroll_mode_ = mode; | 360 overscroll_mode_ = mode; |
| 362 if (overscroll_mode_ == OVERSCROLL_NONE) | 361 if (overscroll_mode_ == OVERSCROLL_NONE) |
| 363 overscroll_delta_x_ = overscroll_delta_y_ = 0.f; | 362 overscroll_delta_x_ = overscroll_delta_y_ = 0.f; |
| 364 else | 363 else |
| 365 scroll_state_ = STATE_OVERSCROLLING; | 364 scroll_state_ = STATE_OVERSCROLLING; |
| 366 if (delegate_) | 365 if (delegate_) |
| 367 delegate_->OnOverscrollModeChange(old_mode, overscroll_mode_); | 366 delegate_->OnOverscrollModeChange(old_mode, overscroll_mode_); |
| 368 } | 367 } |
| 369 | 368 |
| 370 bool OverscrollController::ShouldForwardToHost( | |
| 371 const WebKit::WebInputEvent& event) const { | |
| 372 if (!WebKit::WebInputEvent::isGestureEventType(event.type)) | |
| 373 return false; | |
| 374 | |
| 375 // If the RenderWidgetHost already processed this event, then the event must | |
| 376 // not be sent again. | |
| 377 return !render_widget_host_->HasQueuedGestureEvents(); | |
| 378 } | |
| 379 | |
| 380 } // namespace content | 369 } // namespace content |
| OLD | NEW |