| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "ui/compositor/overscroll/ui_input_handler.h" |
| 6 |
| 7 #include "base/logging.h" |
| 8 #include "cc/trees/layer_tree_impl.h" |
| 9 #include "cc/trees/scroll_node.h" |
| 10 #include "ui/events/event.h" |
| 11 |
| 12 namespace ui { |
| 13 |
| 14 namespace { |
| 15 |
| 16 // Creates a cc::ScrollState from a ui::ScrollEvent, populating fields general |
| 17 // to all event phases. Take care not to put deltas on beginning/end updates, |
| 18 // since InputHandler will DCHECK if they're present. |
| 19 cc::ScrollState CreateScrollState(const ScrollEvent& scroll, bool is_end) { |
| 20 cc::ScrollStateData scroll_state_data; |
| 21 scroll_state_data.position_x = scroll.x(); |
| 22 scroll_state_data.position_y = scroll.y(); |
| 23 if (!is_end) { |
| 24 scroll_state_data.delta_x = -scroll.x_offset_ordinal(); |
| 25 scroll_state_data.delta_y = -scroll.y_offset_ordinal(); |
| 26 } |
| 27 scroll_state_data.is_in_inertial_phase = |
| 28 scroll.momentum_phase() == EventMomentumPhase::INERTIAL_UPDATE; |
| 29 scroll_state_data.is_ending = is_end; |
| 30 return cc::ScrollState(scroll_state_data); |
| 31 } |
| 32 |
| 33 } // namespace |
| 34 |
| 35 UIInputHandler::UIInputHandler( |
| 36 const base::WeakPtr<cc::InputHandler>& input_handler) |
| 37 : input_handler_(input_handler.get()) { |
| 38 input_handler_->BindToClient(this); |
| 39 } |
| 40 |
| 41 UIInputHandler::~UIInputHandler() { |
| 42 DCHECK(!input_handler_); |
| 43 } |
| 44 |
| 45 void UIInputHandler::WillShutdown() { |
| 46 input_handler_ = nullptr; |
| 47 } |
| 48 |
| 49 void UIInputHandler::Animate(base::TimeTicks time) {} |
| 50 |
| 51 void UIInputHandler::MainThreadHasStoppedFlinging() {} |
| 52 |
| 53 void UIInputHandler::ReconcileElasticOverscrollAndRootScroll() {} |
| 54 |
| 55 void UIInputHandler::UpdateRootLayerStateForSynchronousInputHandler( |
| 56 const gfx::ScrollOffset& total_scroll_offset, |
| 57 const gfx::ScrollOffset& max_scroll_offset, |
| 58 const gfx::SizeF& scrollable_size, |
| 59 float page_scale_factor, |
| 60 float min_page_scale_factor, |
| 61 float max_page_scale_factor) {} |
| 62 |
| 63 void UIInputHandler::DeliverInputForBeginFrame() {} |
| 64 |
| 65 void UIInputHandler::HandleScrollUpdate(const ScrollEvent& scroll, |
| 66 cc::ElementId element) { |
| 67 cc::ScrollState scroll_state = CreateScrollState(scroll, false); |
| 68 scroll_state.data()->set_current_native_scrolling_element(element); |
| 69 input_handler_->ScrollBy(&scroll_state); |
| 70 } |
| 71 |
| 72 void UIInputHandler::HandleScrollEnd(const ScrollEvent& scroll) { |
| 73 cc::ScrollState scroll_state = CreateScrollState(scroll, true); |
| 74 input_handler_->ScrollEnd(&scroll_state); |
| 75 } |
| 76 |
| 77 } // namespace ui |
| OLD | NEW |