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

Side by Side Diff: content/browser/renderer_host/overscroll_controller.cc

Issue 291003002: Move OverscrollController to RenderWidgetHostViewAura (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: DCHECK_GE Created 6 years, 6 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 // 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/command_line.h" 7 #include "base/command_line.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "content/browser/renderer_host/overscroll_controller_delegate.h" 9 #include "content/browser/renderer_host/overscroll_controller_delegate.h"
10 #include "content/public/browser/overscroll_configuration.h" 10 #include "content/public/browser/overscroll_configuration.h"
(...skipping 16 matching lines...) Expand all
27 : overscroll_mode_(OVERSCROLL_NONE), 27 : overscroll_mode_(OVERSCROLL_NONE),
28 scroll_state_(STATE_UNKNOWN), 28 scroll_state_(STATE_UNKNOWN),
29 overscroll_delta_x_(0.f), 29 overscroll_delta_x_(0.f),
30 overscroll_delta_y_(0.f), 30 overscroll_delta_y_(0.f),
31 delegate_(NULL) { 31 delegate_(NULL) {
32 } 32 }
33 33
34 OverscrollController::~OverscrollController() { 34 OverscrollController::~OverscrollController() {
35 } 35 }
36 36
37 OverscrollController::Disposition OverscrollController::DispatchEvent( 37 bool OverscrollController::WillHandleEvent(const blink::WebInputEvent& event) {
38 const blink::WebInputEvent& event,
39 const ui::LatencyInfo& latency_info) {
40 if (scroll_state_ != STATE_UNKNOWN) { 38 if (scroll_state_ != STATE_UNKNOWN) {
41 switch (event.type) { 39 switch (event.type) {
42 case blink::WebInputEvent::GestureScrollEnd: 40 case blink::WebInputEvent::GestureScrollEnd:
43 case blink::WebInputEvent::GestureFlingStart: 41 case blink::WebInputEvent::GestureFlingStart:
44 scroll_state_ = STATE_UNKNOWN; 42 scroll_state_ = STATE_UNKNOWN;
45 break; 43 break;
46 44
47 case blink::WebInputEvent::MouseWheel: { 45 case blink::WebInputEvent::MouseWheel: {
48 const blink::WebMouseWheelEvent& wheel = 46 const blink::WebMouseWheelEvent& wheel =
49 static_cast<const blink::WebMouseWheelEvent&>(event); 47 static_cast<const blink::WebMouseWheelEvent&>(event);
(...skipping 10 matching lines...) Expand all
60 blink::WebInputEvent::isKeyboardEventType(event.type)) { 58 blink::WebInputEvent::isKeyboardEventType(event.type)) {
61 scroll_state_ = STATE_UNKNOWN; 59 scroll_state_ = STATE_UNKNOWN;
62 } 60 }
63 break; 61 break;
64 } 62 }
65 } 63 }
66 64
67 if (DispatchEventCompletesAction(event)) { 65 if (DispatchEventCompletesAction(event)) {
68 CompleteAction(); 66 CompleteAction();
69 67
70 // If the overscroll was caused by touch-scrolling, then the gesture event 68 // Let the event be dispatched to the renderer.
71 // that completes the action needs to be sent to the renderer, because the 69 return false;
72 // touch-scrolls maintain state in the renderer side (in the compositor, for
73 // example), and the event that completes this action needs to be sent to
74 // the renderer so that those states can be updated/reset appropriately.
75 if (blink::WebInputEvent::isGestureEventType(event.type)) {
76 // A gesture-event isn't sent to the GestureEventQueue when overscroll is
77 // in progress. So dispatch the event through the RenderWidgetHost so that
78 // it can reach the GestureEventQueue.
79 return SHOULD_FORWARD_TO_GESTURE_QUEUE;
80 }
81
82 return SHOULD_FORWARD_TO_RENDERER;
83 } 70 }
84 71
85 if (overscroll_mode_ != OVERSCROLL_NONE && DispatchEventResetsState(event)) { 72 if (overscroll_mode_ != OVERSCROLL_NONE && DispatchEventResetsState(event)) {
86 SetOverscrollMode(OVERSCROLL_NONE); 73 SetOverscrollMode(OVERSCROLL_NONE);
87 if (blink::WebInputEvent::isGestureEventType(event.type)) {
88 // A gesture-event isn't sent to the GestureEventQueue when overscroll is
89 // in progress. So dispatch the event through the RenderWidgetHost so that
90 // it can reach the GestureEventQueue.
91 return SHOULD_FORWARD_TO_GESTURE_QUEUE;
92 }
93 74
94 // Let the event be dispatched to the renderer. 75 // Let the event be dispatched to the renderer.
95 return SHOULD_FORWARD_TO_RENDERER; 76 return false;
96 } 77 }
97 78
98 if (overscroll_mode_ != OVERSCROLL_NONE) { 79 if (overscroll_mode_ != OVERSCROLL_NONE) {
99 // Consume the event only if it updates the overscroll state. 80 // Consume the event only if it updates the overscroll state.
100 if (ProcessEventForOverscroll(event)) 81 if (ProcessEventForOverscroll(event))
101 return CONSUMED; 82 return true;
102 } 83 }
103 84
104 return SHOULD_FORWARD_TO_RENDERER; 85 return false;
105 } 86 }
106 87
107 void OverscrollController::ReceivedEventACK(const blink::WebInputEvent& event, 88 void OverscrollController::ReceivedEventACK(const blink::WebInputEvent& event,
108 bool processed) { 89 bool processed) {
109 if (processed) { 90 if (processed) {
110 // If a scroll event is consumed by the page, i.e. some content on the page 91 // If a scroll event is consumed by the page, i.e. some content on the page
111 // has been scrolled, then there is not going to be an overscroll gesture, 92 // has been scrolled, then there is not going to be an overscroll gesture,
112 // until the current scroll ends, and a new scroll gesture starts. 93 // until the current scroll ends, and a new scroll gesture starts.
113 if (scroll_state_ == STATE_UNKNOWN && 94 if (scroll_state_ == STATE_UNKNOWN &&
114 (event.type == blink::WebInputEvent::MouseWheel || 95 (event.type == blink::WebInputEvent::MouseWheel ||
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 overscroll_mode_ = mode; 350 overscroll_mode_ = mode;
370 if (overscroll_mode_ == OVERSCROLL_NONE) 351 if (overscroll_mode_ == OVERSCROLL_NONE)
371 overscroll_delta_x_ = overscroll_delta_y_ = 0.f; 352 overscroll_delta_x_ = overscroll_delta_y_ = 0.f;
372 else 353 else
373 scroll_state_ = STATE_OVERSCROLLING; 354 scroll_state_ = STATE_OVERSCROLLING;
374 if (delegate_) 355 if (delegate_)
375 delegate_->OnOverscrollModeChange(old_mode, overscroll_mode_); 356 delegate_->OnOverscrollModeChange(old_mode, overscroll_mode_);
376 } 357 }
377 358
378 } // namespace content 359 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/overscroll_controller.h ('k') | content/browser/renderer_host/render_widget_host_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698