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 3 // found in the LICENSE file. 4 5 #ifndef CC_INPUT_SCROLL_STATE_DATA_H_ 6 #define CC_INPUT_SCROLL_STATE_DATA_H_ 7 8 #include <stdint.h> 9 10 #include <list> 11 12 #include "cc/cc_export.h" 13 #include "cc/trees/property_tree.h" 14 #include "ui/events/types/scroll_types.h" 15 16 namespace cc { 17 18 class CC_EXPORT ScrollStateData { 19 public: 20 ScrollStateData(); 21 ScrollStateData(const ScrollStateData& other); 22 23 // Scroll delta in viewport coordinates (DIP). 24 double delta_x; 25 double delta_y; 26 // Scroll delta hint in viewport coordinates (DIP). 27 // Delta hints are equal to deltas of the first gesture scroll update event in 28 // a scroll sequence and are used for hittesting. 29 double delta_x_hint; 30 double delta_y_hint; 31 // Pointer (i.e. cursor/touch point) position in viewport coordinates (DIP). 32 int position_x; 33 int position_y; 34 // Scroll velocity in DIP/seconds. 35 double velocity_x; 36 double velocity_y; 37 38 bool is_beginning; 39 bool is_in_inertial_phase; 40 bool is_ending; 41 42 bool from_user_input; 43 44 // Whether the scroll sequence has had any delta consumed, in the 45 // current frame, or any child frames. 46 bool delta_consumed_for_scroll_sequence; 47 // True if the user interacts directly with the display, e.g., via 48 // touch. 49 bool is_direct_manipulation; 50 51 // Granularity units for the scroll delta. 52 ui::ScrollGranularity delta_granularity; 53 54 // TODO(tdresser): ScrollState shouldn't need to keep track of whether or not 55 // this ScrollState object has caused a scroll. Ideally, any native scroller 56 // consuming delta has caused a scroll. Currently, there are some cases where 57 // we consume delta without scrolling, such as in 58 // |Viewport::AdjustOverscroll|. Once these cases are fixed, we should get rid 59 // of |caused_scroll_*_|. See crbug.com/510045 for details. 60 bool caused_scroll_x; 61 bool caused_scroll_y; 62 63 // Track if the scroll_chain has been cut by overscroll_behavior, in 64 // order to properly handle overscroll-effects. 65 // TODO(sunyunjia): overscroll should be handled at the top of scroll_chain, 66 // as implemented at blink side. This field should be removed after it's 67 // resolved. crbug.com/755164. 68 bool is_scroll_chain_cut; 69 70 ElementId current_native_scrolling_element() const; 71 void set_current_native_scrolling_element(ElementId element_id); 72 73 // Used in scroll unification to specify that a scroll state has been hit 74 // tested on the main thread. If this is true, the hit test result will be 75 // placed in the current_native_scrolling_element_. 76 bool is_main_thread_hit_tested; 77 78 private: 79 // The id of the last native element to respond to a scroll, or 0 if none 80 // exists. 81 // TODO(bokan): In the compositor, this is now only used as an override to 82 // scroller targeting. I.e. we'll latch scrolling to the specified 83 // element_id. It will be renamed to a better name (target_element_id?) when 84 // the main thread is also converted. 85 ElementId current_native_scrolling_element_; 86 }; 87 88 } // namespace cc 89 90 #endif // CC_INPUT_SCROLL_STATE_DATA_H_ 91