summaryrefslogtreecommitdiffstats
path: root/cc/input/scroll_state.cc
blob: 419b5904363ea02be74552f7a0ece21d7b441560 (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
// 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.

#include "cc/input/scroll_state.h"

#include <utility>

#include "cc/layers/layer_impl.h"

namespace cc {

ScrollState::ScrollState(double delta_x,
                         double delta_y,
                         int start_position_x,
                         int start_position_y,
                         double velocity_x,
                         double velocity_y,
                         bool is_beginning,
                         bool is_in_inertial_phase,
                         bool is_ending,
                         bool should_propagate,
                         bool delta_consumed_for_scroll_sequence,
                         bool is_direct_manipulation)
    : data_(delta_x,
            delta_y,
            start_position_x,
            start_position_y,
            velocity_x,
            velocity_y,
            is_beginning,
            is_in_inertial_phase,
            is_ending,
            should_propagate,
            delta_consumed_for_scroll_sequence,
            is_direct_manipulation) {}

ScrollState::ScrollState(ScrollStateData data) : data_(data) {}

ScrollState::~ScrollState() {}

void ScrollState::ConsumeDelta(double x, double y) {
  data_.delta_x -= x;
  data_.delta_y -= y;

  if (x || y)
    data_.delta_consumed_for_scroll_sequence = true;
}

void ScrollState::DistributeToScrollChainDescendant() {
  if (!scroll_chain_.empty()) {
    LayerImpl* next = scroll_chain_.front();
    scroll_chain_.pop_front();
    next->DistributeScroll(this);
  }
}

}  // namespace cc