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

Unified Diff: cc/input/scroll_state.h

Issue 1215183004: Arrange compositor scrolling into scroll customization format (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix windows compile. Created 5 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: cc/input/scroll_state.h
diff --git a/cc/input/scroll_state.h b/cc/input/scroll_state.h
new file mode 100644
index 0000000000000000000000000000000000000000..16202b13fd5774bd3c6a520e680e3c76f59a45af
--- /dev/null
+++ b/cc/input/scroll_state.h
@@ -0,0 +1,93 @@
+// Copyright 2015 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.
+
+#ifndef CC_INPUT_SCROLL_STATE_H_
+#define CC_INPUT_SCROLL_STATE_H_
+
+#include <list>
+
+#include "cc/base/cc_export.h"
+
+namespace cc {
+
+class LayerImpl;
+
+// ScrollState is based on the proposal for scroll customization in blink, found
+// here: https://goo.gl/1ipTpP.
+class CC_EXPORT ScrollState {
+ public:
+ ScrollState(double delta_x,
+ double delta_y,
+ int start_position_x,
+ int start_position_y,
+ bool in_inertial_phase,
+ bool should_propagate,
+ bool delta_consumed_for_scroll_sequence,
+ bool is_direct_manipulation);
+ ~ScrollState();
+
+ // Reduce deltas by x, y.
+ void ConsumeDelta(double x, double y);
+ // Pops the first layer off of |scroll_chain_| and calls
+ // |DistributeScroll| on it.
+ void DistributeToScrollChainDescendant();
+ // Positive when scrolling left.
+ double delta_x() const { return delta_x_; }
+ // Positive when scrolling up.
+ double delta_y() const { return delta_y_; }
+ // The location the scroll started at. For touch, the starting
+ // position of the finger. For mouse, the location of the cursor.
+ int start_position_x() const { return start_position_x_; }
+ int start_position_y() const { return start_position_y_; }
+
+ // True for events dispatched after the users's gesture has finished.
+ bool in_inertial_phase() const { return in_inertial_phase_; }
+ // True if this scroll is allowed to bubble upwards.
+ bool should_propagate() const { return should_propagate_; }
+ // True if the user interacts directly with the screen, e.g., via touch.
+ bool is_direct_manipulation() const { return is_direct_manipulation_; }
+
+ void set_scroll_chain(const std::list<LayerImpl*>& scroll_chain) {
+ scroll_chain_ = scroll_chain;
+ }
+
+ void set_current_native_scrolling_layer(LayerImpl* layer) {
+ current_native_scrolling_layer_ = layer;
+ }
+
+ LayerImpl* current_native_scrolling_layer() const {
+ return current_native_scrolling_layer_;
+ }
+
+ bool delta_consumed_for_scroll_sequence() const {
+ return delta_consumed_for_scroll_sequence_;
+ }
+
+ bool FullyConsumed() const { return !delta_x_ && !delta_y_; }
+
+ private:
+ ScrollState();
+ double delta_x_;
+ double delta_y_;
+ double start_position_x_;
+ double start_position_y_;
+
+ bool in_inertial_phase_;
+ bool should_propagate_;
+
+ // The last layer to respond to a scroll, or null if none exists.
+ LayerImpl* current_native_scrolling_layer_;
+ // Whether the scroll sequence has had any delta consumed, in the
+ // current frame, or any child frames.
+ bool delta_consumed_for_scroll_sequence_;
+ // True if the user interacts directly with the display, e.g., via
+ // touch.
+ bool is_direct_manipulation_;
+
+ std::list<LayerImpl*> scroll_chain_;
Ian Vollick 2015/07/09 14:03:55 I'm a little nervous about the LayerImpl pointers
tdresser 2015/07/09 16:07:45 We'll absolutely want to introduce a layer of abst
Ian Vollick 2015/07/09 16:46:51 Please put a TODO here, then, and link to the scro
tdresser 2015/07/16 14:04:49 Done.
+};
+
+} // namespace cc
+
+#endif // CC_INPUT_SCROLL_STATE_H_
« no previous file with comments | « cc/cc_tests.gyp ('k') | cc/input/scroll_state.cc » ('j') | cc/trees/layer_tree_host_impl.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698