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

Unified Diff: ui/compositor/overscroll/ui_input_handler.cc

Issue 2197503002: Route Scroll events through a cc::InputHandler Base URL: https://chromium.googlesource.com/chromium/src.git@20160728-MacViews-ScrollWheelAsScrollEvent
Patch Set: Abandon DeliverInputForBeginFrame: will not help fix the header row Created 4 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/compositor/overscroll/ui_input_handler.h ('k') | ui/compositor/overscroll/ui_scroll_input_manager.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/compositor/overscroll/ui_input_handler.cc
diff --git a/ui/compositor/overscroll/ui_input_handler.cc b/ui/compositor/overscroll/ui_input_handler.cc
new file mode 100644
index 0000000000000000000000000000000000000000..93ac9bd874840f49610de5b0f59e0563303d5e9c
--- /dev/null
+++ b/ui/compositor/overscroll/ui_input_handler.cc
@@ -0,0 +1,77 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/compositor/overscroll/ui_input_handler.h"
+
+#include "base/logging.h"
+#include "cc/trees/layer_tree_impl.h"
+#include "cc/trees/scroll_node.h"
+#include "ui/events/event.h"
+
+namespace ui {
+
+namespace {
+
+// Creates a cc::ScrollState from a ui::ScrollEvent, populating fields general
+// to all event phases. Take care not to put deltas on beginning/end updates,
+// since InputHandler will DCHECK if they're present.
+cc::ScrollState CreateScrollState(const ScrollEvent& scroll, bool is_end) {
+ cc::ScrollStateData scroll_state_data;
+ scroll_state_data.position_x = scroll.x();
+ scroll_state_data.position_y = scroll.y();
+ if (!is_end) {
+ scroll_state_data.delta_x = -scroll.x_offset_ordinal();
+ scroll_state_data.delta_y = -scroll.y_offset_ordinal();
+ }
+ scroll_state_data.is_in_inertial_phase =
+ scroll.momentum_phase() == EventMomentumPhase::INERTIAL_UPDATE;
+ scroll_state_data.is_ending = is_end;
+ return cc::ScrollState(scroll_state_data);
+}
+
+} // namespace
+
+UIInputHandler::UIInputHandler(
+ const base::WeakPtr<cc::InputHandler>& input_handler)
+ : input_handler_(input_handler.get()) {
+ input_handler_->BindToClient(this);
+}
+
+UIInputHandler::~UIInputHandler() {
+ DCHECK(!input_handler_);
+}
+
+void UIInputHandler::WillShutdown() {
+ input_handler_ = nullptr;
+}
+
+void UIInputHandler::Animate(base::TimeTicks time) {}
+
+void UIInputHandler::MainThreadHasStoppedFlinging() {}
+
+void UIInputHandler::ReconcileElasticOverscrollAndRootScroll() {}
+
+void UIInputHandler::UpdateRootLayerStateForSynchronousInputHandler(
+ const gfx::ScrollOffset& total_scroll_offset,
+ const gfx::ScrollOffset& max_scroll_offset,
+ const gfx::SizeF& scrollable_size,
+ float page_scale_factor,
+ float min_page_scale_factor,
+ float max_page_scale_factor) {}
+
+void UIInputHandler::DeliverInputForBeginFrame() {}
+
+void UIInputHandler::HandleScrollUpdate(const ScrollEvent& scroll,
+ cc::ElementId element) {
+ cc::ScrollState scroll_state = CreateScrollState(scroll, false);
+ scroll_state.data()->set_current_native_scrolling_element(element);
+ input_handler_->ScrollBy(&scroll_state);
+}
+
+void UIInputHandler::HandleScrollEnd(const ScrollEvent& scroll) {
+ cc::ScrollState scroll_state = CreateScrollState(scroll, true);
+ input_handler_->ScrollEnd(&scroll_state);
+}
+
+} // namespace ui
« no previous file with comments | « ui/compositor/overscroll/ui_input_handler.h ('k') | ui/compositor/overscroll/ui_scroll_input_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698