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

Side by Side Diff: ui/compositor/overscroll/ui_input_handler.cc

Issue 2194833002: Overscroll and Elasticity for views::ScrollView Base URL: https://chromium.googlesource.com/chromium/src.git@20160728-MacViews-RouteThroughInputHandler
Patch Set: Restore functionality and fix bugs \o/ Created 4 years, 1 month 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
« no previous file with comments | « ui/compositor/overscroll/ui_input_handler.h ('k') | ui/events/blink/input_handler_proxy.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/compositor/overscroll/ui_input_handler.h" 5 #include "ui/compositor/overscroll/ui_input_handler.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "cc/trees/layer_tree_impl.h" 8 #include "cc/trees/layer_tree_impl.h"
9 #include "cc/trees/scroll_node.h" 9 #include "cc/trees/scroll_node.h"
10 #include "ui/events/event.h" 10 #include "ui/events/event.h"
(...skipping 28 matching lines...) Expand all
39 } 39 }
40 40
41 UIInputHandler::~UIInputHandler() { 41 UIInputHandler::~UIInputHandler() {
42 DCHECK(!input_handler_); 42 DCHECK(!input_handler_);
43 } 43 }
44 44
45 void UIInputHandler::WillShutdown() { 45 void UIInputHandler::WillShutdown() {
46 input_handler_ = nullptr; 46 input_handler_ = nullptr;
47 } 47 }
48 48
49 void UIInputHandler::Animate(base::TimeTicks time) {} 49 void UIInputHandler::Animate(base::TimeTicks time) {
50 scroll_elasticity_controller_.Animate(time);
51 }
50 52
51 void UIInputHandler::MainThreadHasStoppedFlinging() {} 53 void UIInputHandler::MainThreadHasStoppedFlinging() {}
52 54
53 void UIInputHandler::ReconcileElasticOverscrollAndRootScroll() {} 55 void UIInputHandler::ReconcileElasticOverscrollAndRootScroll() {
56 scroll_elasticity_controller_.ReconcileStretchAndScroll();
57 }
54 58
55 void UIInputHandler::UpdateRootLayerStateForSynchronousInputHandler( 59 void UIInputHandler::UpdateRootLayerStateForSynchronousInputHandler(
56 const gfx::ScrollOffset& total_scroll_offset, 60 const gfx::ScrollOffset& total_scroll_offset,
57 const gfx::ScrollOffset& max_scroll_offset, 61 const gfx::ScrollOffset& max_scroll_offset,
58 const gfx::SizeF& scrollable_size, 62 const gfx::SizeF& scrollable_size,
59 float page_scale_factor, 63 float page_scale_factor,
60 float min_page_scale_factor, 64 float min_page_scale_factor,
61 float max_page_scale_factor) {} 65 float max_page_scale_factor) {}
62 66
63 void UIInputHandler::HandleScrollUpdate(const ScrollEvent& scroll, 67 void UIInputHandler::HandleScrollUpdate(const ScrollEvent& scroll,
64 cc::ElementId element) { 68 cc::ElementId element) {
65 cc::ScrollState scroll_state = CreateScrollState(scroll, false); 69 cc::ScrollState scroll_state = CreateScrollState(scroll, false);
66 scroll_state.data()->set_current_native_scrolling_element(element); 70 scroll_state.data()->set_current_native_scrolling_element(element);
67 input_handler_->ScrollBy(&scroll_state); 71 cc::InputHandlerScrollResult result = input_handler_->ScrollBy(&scroll_state);
72
73 base::WeakPtr<cc::ScrollElasticityHelper> overscroll_helper =
74 input_handler_->ScrollElasticityHelperForScrollingLayer();
75 if (!overscroll_helper)
76 return; // E.g., the scrolling layer doesn't support overscroll.
77
78 scroll_elasticity_controller_.SetActiveHelper(overscroll_helper);
79
80 gfx::Vector2dF event_delta(scroll_state.delta_x(), scroll_state.delta_y());
81 bool begin = scroll.momentum_phase() == EventMomentumPhase::MAY_BEGIN;
82 bool momentum_begin = event_delta.IsZero() &&
83 scroll.momentum_phase() == EventMomentumPhase::INERTIAL_UPDATE;
84
85 scroll_elasticity_controller_.ObserveRealScrollBegin(momentum_begin, begin);
86 scroll_elasticity_controller_.ObserveScrollUpdate(
87 event_delta, result.unused_scroll_delta, scroll.time_stamp(),
88 scroll_state.is_in_inertial_phase());
68 } 89 }
69 90
70 void UIInputHandler::HandleScrollEnd(const ScrollEvent& scroll) { 91 void UIInputHandler::HandleScrollEnd(const ScrollEvent& scroll) {
71 cc::ScrollState scroll_state = CreateScrollState(scroll, true); 92 cc::ScrollState scroll_state = CreateScrollState(scroll, true);
72 input_handler_->ScrollEnd(&scroll_state); 93 input_handler_->ScrollEnd(&scroll_state);
94 scroll_elasticity_controller_.ObserveRealScrollEnd(scroll.time_stamp());
73 } 95 }
74 96
75 } // namespace ui 97 } // namespace ui
OLDNEW
« no previous file with comments | « ui/compositor/overscroll/ui_input_handler.h ('k') | ui/events/blink/input_handler_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698