| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #ifndef CC_INPUT_SCROLL_STATE_H_ | 5 #ifndef CC_INPUT_SCROLL_STATE_H_ |
| 6 #define CC_INPUT_SCROLL_STATE_H_ | 6 #define CC_INPUT_SCROLL_STATE_H_ |
| 7 | 7 |
| 8 #include <list> | 8 #include <list> |
| 9 | 9 |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "cc/base/cc_export.h" | 11 #include "cc/base/cc_export.h" |
| 12 #include "cc/input/scroll_state_data.h" | 12 #include "cc/input/scroll_state_data.h" |
| 13 #include "ui/gfx/geometry/point.h" | 13 #include "ui/gfx/geometry/point.h" |
| 14 #include "ui/gfx/geometry/vector2d.h" | 14 #include "ui/gfx/geometry/vector2d.h" |
| 15 | 15 |
| 16 namespace cc { | 16 namespace cc { |
| 17 | 17 |
| 18 class LayerImpl; | 18 class LayerImpl; |
| 19 | 19 |
| 20 // ScrollState is based on the proposal for scroll customization in blink, found | 20 // ScrollState is based on the proposal for scroll customization in blink, found |
| 21 // here: https://goo.gl/1ipTpP. | 21 // here: https://goo.gl/1ipTpP. |
| 22 class CC_EXPORT ScrollState { | 22 class CC_EXPORT ScrollState { |
| 23 public: | 23 public: |
| 24 static scoped_ptr<ScrollState> Create(const gfx::Vector2dF& scroll_delta, | |
| 25 const gfx::Point& viewport_point, | |
| 26 const gfx::Vector2dF& scroll_velocity, | |
| 27 bool is_beginning, | |
| 28 bool is_in_inertial_phase, | |
| 29 bool is_ending) { | |
| 30 return make_scoped_ptr(new ScrollState( | |
| 31 scroll_delta.x(), scroll_delta.y(), viewport_point.x(), | |
| 32 viewport_point.y(), scroll_velocity.x(), scroll_velocity.y(), | |
| 33 is_beginning, is_in_inertial_phase, is_ending)); | |
| 34 } | |
| 35 | |
| 36 ScrollState(double delta_x, | |
| 37 double delta_y, | |
| 38 int start_position_x, | |
| 39 int start_position_y, | |
| 40 double velocity_x, | |
| 41 double velocity_y, | |
| 42 bool is_beginning, | |
| 43 bool is_in_inertial_phase, | |
| 44 bool is_ending, | |
| 45 bool should_propagate = false, | |
| 46 bool delta_consumed_for_scroll_sequence = false, | |
| 47 bool is_direct_manipulation = false); | |
| 48 explicit ScrollState(ScrollStateData data); | 24 explicit ScrollState(ScrollStateData data); |
| 49 ~ScrollState(); | 25 ~ScrollState(); |
| 50 | 26 |
| 51 // Reduce deltas by x, y. | 27 // Reduce deltas by x, y. |
| 52 void ConsumeDelta(double x, double y); | 28 void ConsumeDelta(double x, double y); |
| 53 // Pops the first layer off of |scroll_chain_| and calls | 29 // Pops the first layer off of |scroll_chain_| and calls |
| 54 // |DistributeScroll| on it. | 30 // |DistributeScroll| on it. |
| 55 void DistributeToScrollChainDescendant(); | 31 void DistributeToScrollChainDescendant(); |
| 56 // Positive when scrolling left. | 32 // Positive when scrolling left. |
| 57 double delta_x() const { return data_.delta_x; } | 33 double delta_x() const { return data_.delta_x; } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 82 bool is_direct_manipulation() const { return data_.is_direct_manipulation; } | 58 bool is_direct_manipulation() const { return data_.is_direct_manipulation; } |
| 83 void set_is_direct_manipulation(bool is_direct_manipulation) { | 59 void set_is_direct_manipulation(bool is_direct_manipulation) { |
| 84 data_.is_direct_manipulation = is_direct_manipulation; | 60 data_.is_direct_manipulation = is_direct_manipulation; |
| 85 } | 61 } |
| 86 | 62 |
| 87 void set_scroll_chain(const std::list<LayerImpl*>& scroll_chain) { | 63 void set_scroll_chain(const std::list<LayerImpl*>& scroll_chain) { |
| 88 scroll_chain_ = scroll_chain; | 64 scroll_chain_ = scroll_chain; |
| 89 } | 65 } |
| 90 | 66 |
| 91 void set_current_native_scrolling_layer(LayerImpl* layer) { | 67 void set_current_native_scrolling_layer(LayerImpl* layer) { |
| 92 data_.current_native_scrolling_layer = layer; | 68 data_.set_current_native_scrolling_layer(layer); |
| 93 } | 69 } |
| 94 | 70 |
| 95 LayerImpl* current_native_scrolling_layer() const { | 71 LayerImpl* current_native_scrolling_layer() const { |
| 96 return data_.current_native_scrolling_layer; | 72 return data_.current_native_scrolling_layer(); |
| 97 } | 73 } |
| 98 | 74 |
| 99 bool delta_consumed_for_scroll_sequence() const { | 75 bool delta_consumed_for_scroll_sequence() const { |
| 100 return data_.delta_consumed_for_scroll_sequence; | 76 return data_.delta_consumed_for_scroll_sequence; |
| 101 } | 77 } |
| 102 void set_delta_consumed_for_scroll_sequence(bool delta_consumed) { | 78 void set_delta_consumed_for_scroll_sequence(bool delta_consumed) { |
| 103 data_.delta_consumed_for_scroll_sequence = delta_consumed; | 79 data_.delta_consumed_for_scroll_sequence = delta_consumed; |
| 104 } | 80 } |
| 105 | 81 |
| 106 bool FullyConsumed() const { return !data_.delta_x && !data_.delta_y; } | 82 bool FullyConsumed() const { return !data_.delta_x && !data_.delta_y; } |
| 107 | 83 |
| 108 void set_caused_scroll(bool x, bool y) { | 84 void set_caused_scroll(bool x, bool y) { |
| 109 data_.caused_scroll_x |= x; | 85 data_.caused_scroll_x |= x; |
| 110 data_.caused_scroll_y |= y; | 86 data_.caused_scroll_y |= y; |
| 111 } | 87 } |
| 112 | 88 |
| 113 bool caused_scroll_x() const { return data_.caused_scroll_x; } | 89 bool caused_scroll_x() const { return data_.caused_scroll_x; } |
| 114 bool caused_scroll_y() const { return data_.caused_scroll_y; } | 90 bool caused_scroll_y() const { return data_.caused_scroll_y; } |
| 115 | 91 |
| 116 ScrollStateData* data() { return &data_; } | 92 ScrollStateData* data() { return &data_; } |
| 117 | 93 |
| 118 private: | 94 private: |
| 119 ScrollStateData data_; | 95 ScrollStateData data_; |
| 120 std::list<LayerImpl*> scroll_chain_; | 96 std::list<LayerImpl*> scroll_chain_; |
| 121 }; | 97 }; |
| 122 | 98 |
| 123 } // namespace cc | 99 } // namespace cc |
| 124 | 100 |
| 125 #endif // CC_INPUT_SCROLL_STATE_H_ | 101 #endif // CC_INPUT_SCROLL_STATE_H_ |
| OLD | NEW |