scroll_state.cc 810 B

12345678910111213141516171819202122232425262728293031323334
  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. #include "cc/input/scroll_state.h"
  5. #include <utility>
  6. #include "cc/trees/scroll_node.h"
  7. namespace cc {
  8. ScrollState::ScrollState(ScrollStateData data) : data_(data) {}
  9. ScrollState::ScrollState(const ScrollState& other) = default;
  10. ScrollState::~ScrollState() = default;
  11. void ScrollState::ConsumeDelta(double x, double y) {
  12. data_.delta_x -= x;
  13. data_.delta_y -= y;
  14. if (x || y)
  15. data_.delta_consumed_for_scroll_sequence = true;
  16. }
  17. gfx::Vector2dF ScrollState::DeltaOrHint() const {
  18. if (is_beginning())
  19. return gfx::Vector2dF(delta_x_hint(), delta_y_hint());
  20. return gfx::Vector2dF(delta_x(), delta_y());
  21. }
  22. } // namespace cc