summaryrefslogtreecommitdiffstats
path: root/cc/input/scroll_state_data.h
blob: 63fbe437ed138660ed352e14cd340fd1c86169d4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// 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_DATA_H_
#define CC_INPUT_SCROLL_STATE_DATA_H_

#include <stdint.h>

#include <list>

#include "cc/base/cc_export.h"
#include "cc/trees/property_tree.h"

namespace cc {

class CC_EXPORT ScrollStateData {
 public:
  ScrollStateData();
  ScrollStateData(const ScrollStateData& other);

  // Scroll delta in viewport coordinates (DIP).
  double delta_x;
  double delta_y;
  // Scroll position in viewport coordinates (DIP).
  int start_position_x;
  int start_position_y;
  // Scroll velocity in DIP/seconds.
  double velocity_x;
  double velocity_y;

  bool is_beginning;
  bool is_in_inertial_phase;
  bool is_ending;

  bool should_propagate;
  bool from_user_input;

  // 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;
  // Minimum amount this input device can scroll.
  double delta_granularity;

  // TODO(tdresser): ScrollState shouldn't need to keep track of whether or not
  // this ScrollState object has caused a scroll. Ideally, any native scroller
  // consuming delta has caused a scroll. Currently, there are some cases where
  // we consume delta without scrolling, such as in
  // |Viewport::AdjustOverscroll|. Once these cases are fixed, we should get rid
  // of |caused_scroll_*_|. See crbug.com/510045 for details.
  bool caused_scroll_x;
  bool caused_scroll_y;

  ScrollNode* current_native_scrolling_node() const;
  void set_current_native_scrolling_node(
      ScrollNode* current_native_scrolling_node);
  uint64_t current_native_scrolling_element() const;
  void set_current_native_scrolling_element(uint64_t element_id);

 private:
  // Only one of current_native_scrolling_node_ and
  // current_native_scrolling_element_ may be non-null at a time. Whenever
  // possible, we should store the scroll node.

  // The last scroll node to respond to a scroll, or null if none exists.
  ScrollNode* current_native_scrolling_node_;
  // The id of the last native element to respond to a scroll, or 0 if none
  // exists.
  uint64_t current_native_scrolling_element_;
};

}  // namespace cc

#endif  // CC_INPUT_SCROLL_STATE_DATA_H_