Chromium Code Reviews| Index: cc/animation/scroll_offset_animations.cc |
| diff --git a/cc/animation/scroll_offset_animations.cc b/cc/animation/scroll_offset_animations.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..f55b041625dc81894202c3df9fa1edbd8d535c6f |
| --- /dev/null |
| +++ b/cc/animation/scroll_offset_animations.cc |
| @@ -0,0 +1,47 @@ |
| +// Copyright 2016 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/animation/scroll_offset_animations.h" |
| + |
| +#include "cc/animation/animation_host.h" |
| + |
| +namespace cc { |
| + |
| +ScrollOffsetAnimationUpdate::ScrollOffsetAnimationUpdate(Type type, |
| + ElementId element_id) |
| + : type_(type), element_id_(element_id) {} |
| + |
| +ScrollOffsetAnimations::ScrollOffsetAnimations(AnimationHost* animation_host) |
| + : animation_host_(animation_host) {} |
| + |
| +ScrollOffsetAnimations::~ScrollOffsetAnimations() {} |
| + |
| +void ScrollOffsetAnimations::AddUpdate(ScrollOffsetAnimationUpdate update) { |
| + queue_.push_back(update); |
| + animation_host_->SetNeedsCommit(); |
| +} |
| + |
| +bool ScrollOffsetAnimations::HasUpdatesForTesting() const { |
| + return !queue_.empty(); |
| +} |
| + |
| +void ScrollOffsetAnimations::PushPropertiesTo( |
| + ScrollOffsetAnimationsImpl* animations, |
| + base::TimeTicks frame_monotonic_time) { |
| + if (!animations) |
|
loyso (OOO)
2016/05/11 06:25:45
DCHECK maybe?
ymalik
2016/05/12 22:31:25
Done.
|
| + return; |
| + if (queue_.empty()) |
| + return; |
| + |
| + for (auto& update : queue_) { |
| + switch (update.type_) { |
| + case ScrollOffsetAnimationUpdate::Type::SCROLL_OFFSET_CHANGED: |
| + animations->ScrollAnimationApplyAdjustment( |
| + update.element_id_, update.adjustment_, frame_monotonic_time); |
| + } |
| + } |
| + queue_.clear(); |
| +} |
| + |
| +} // namespace cc |