| 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_scroll_input_manager.h" |
| 6 |
| 7 #include "base/logging.h" |
| 8 #include "ui/compositor/overscroll/ui_input_handler.h" |
| 9 #include "ui/events/event.h" |
| 10 |
| 11 namespace ui { |
| 12 |
| 13 UIScrollInputManager::UIScrollInputManager( |
| 14 const base::WeakPtr<cc::InputHandler>& input_handler) |
| 15 : input_wrapper_(new UIInputHandler(input_handler)) {} |
| 16 |
| 17 UIScrollInputManager::~UIScrollInputManager() {} |
| 18 |
| 19 bool UIScrollInputManager::OnScrollEvent(const ScrollEvent& event) { |
| 20 // Decide whether to HandleScrollBegin() based only on whether the |
| 21 // InputHandler last handled an "End" (i.e. do not use properties on |event|). |
| 22 // This is because, on Mac, an event ending the non-fling portion of a scroll |
| 23 // can't be distinguished from an event ending a scroll that won't fling. So, |
| 24 // when handling the fling portion, HandleScrollBegin() must be invoked, even |
| 25 // though |event| will not be a "begin" phase. |
| 26 if (!scrolling_layer_) |
| 27 scrolling_layer_ = input_wrapper_->HandleScrollBegin(event); |
| 28 if (!scrolling_layer_) |
| 29 return false; |
| 30 |
| 31 input_wrapper_->HandleScrollUpdate(event, scrolling_layer_); |
| 32 if (event.momentum_phase() == EventMomentumPhase::END) { |
| 33 input_wrapper_->HandleScrollEnd(event); |
| 34 scrolling_layer_ = cc::ElementId(); |
| 35 } |
| 36 return true; |
| 37 } |
| 38 |
| 39 } // namespace ui |
| OLD | NEW |