scroll_state_data.h 3.2 KB

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