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 "base/logging.h" | |
| 7 #include "content/browser/renderer_host/overscroll_controller_delegate.h" | 8 #include "content/browser/renderer_host/overscroll_controller_delegate.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" | |
| 11 | 10 |
| 12 using WebKit::WebInputEvent; | 11 using WebKit::WebInputEvent; |
| 13 | 12 |
| 14 namespace content { | 13 namespace content { |
| 15 | 14 |
| 16 OverscrollController::OverscrollController( | 15 OverscrollController::OverscrollController() |
| 17 RenderWidgetHostImpl* render_widget_host) | 16 : overscroll_mode_(OVERSCROLL_NONE), |
| 18 : render_widget_host_(render_widget_host), | |
| 19 overscroll_mode_(OVERSCROLL_NONE), | |
| 20 scroll_state_(STATE_UNKNOWN), | 17 scroll_state_(STATE_UNKNOWN), |
| 21 overscroll_delta_x_(0.f), | 18 overscroll_delta_x_(0.f), |
| 22 overscroll_delta_y_(0.f), | 19 overscroll_delta_y_(0.f), |
| 23 delegate_(NULL) { | 20 delegate_(NULL) { |
| 24 } | 21 } |
| 25 | 22 |
| 26 OverscrollController::~OverscrollController() { | 23 OverscrollController::~OverscrollController() { |
| 27 } | 24 } |
| 28 | 25 |
| 29 OverscrollController::Disposition OverscrollController::DispatchEvent( | 26 OverscrollController::Disposition OverscrollController::DispatchEvent( |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 138 if (overscroll_mode_ == OVERSCROLL_NONE) | 135 if (overscroll_mode_ == OVERSCROLL_NONE) |
| 139 return false; | 136 return false; |
| 140 | 137 |
| 141 // Complete the overscroll gesture if there was a mouse move or a scroll-end | 138 // Complete the overscroll gesture if there was a mouse move or a scroll-end |
| 142 // after the threshold. | 139 // after the threshold. |
| 143 if (event.type != WebKit::WebInputEvent::MouseMove && | 140 if (event.type != WebKit::WebInputEvent::MouseMove && |
| 144 event.type != WebKit::WebInputEvent::GestureScrollEnd && | 141 event.type != WebKit::WebInputEvent::GestureScrollEnd && |
| 145 event.type != WebKit::WebInputEvent::GestureFlingStart) | 142 event.type != WebKit::WebInputEvent::GestureFlingStart) |
| 146 return false; | 143 return false; |
| 147 | 144 |
| 148 RenderWidgetHostView* view = render_widget_host_->GetView(); | 145 if (!delegate_) |
|
jdduke (slow)
2013/10/21 19:56:53
Are there cases where we want to process overscrol
sadrul
2013/10/21 23:28:35
There shouldn't be such cases. This can probably b
jdduke (slow)
2013/10/22 15:15:58
Done.
| |
| 149 if (!view->IsShowing()) | |
| 150 return false; | 146 return false; |
| 151 | 147 |
| 152 const gfx::Rect& bounds = view->GetViewBounds(); | 148 gfx::Rect bounds = delegate_->GetVisibleBounds(); |
| 153 if (bounds.IsEmpty()) | 149 if (bounds.IsEmpty()) |
| 154 return false; | 150 return false; |
| 155 | 151 |
| 156 if (event.type == WebKit::WebInputEvent::GestureFlingStart) { | 152 if (event.type == WebKit::WebInputEvent::GestureFlingStart) { |
| 157 // Check to see if the fling is in the same direction of the overscroll. | 153 // Check to see if the fling is in the same direction of the overscroll. |
| 158 const WebKit::WebGestureEvent gesture = | 154 const WebKit::WebGestureEvent gesture = |
| 159 static_cast<const WebKit::WebGestureEvent&>(event); | 155 static_cast<const WebKit::WebGestureEvent&>(event); |
| 160 switch (overscroll_mode_) { | 156 switch (overscroll_mode_) { |
| 161 case OVERSCROLL_EAST: | 157 case OVERSCROLL_EAST: |
| 162 if (gesture.data.flingStart.velocityX < 0) | 158 if (gesture.data.flingStart.velocityX < 0) |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 356 overscroll_mode_ = mode; | 352 overscroll_mode_ = mode; |
| 357 if (overscroll_mode_ == OVERSCROLL_NONE) | 353 if (overscroll_mode_ == OVERSCROLL_NONE) |
| 358 overscroll_delta_x_ = overscroll_delta_y_ = 0.f; | 354 overscroll_delta_x_ = overscroll_delta_y_ = 0.f; |
| 359 else | 355 else |
| 360 scroll_state_ = STATE_OVERSCROLLING; | 356 scroll_state_ = STATE_OVERSCROLLING; |
| 361 if (delegate_) | 357 if (delegate_) |
| 362 delegate_->OnOverscrollModeChange(old_mode, overscroll_mode_); | 358 delegate_->OnOverscrollModeChange(old_mode, overscroll_mode_); |
| 363 } | 359 } |
| 364 | 360 |
| 365 } // namespace content | 361 } // namespace content |
| OLD | NEW |