Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(299)

Side by Side Diff: cc/animation/scroll_offset_animations.cc

Issue 2006103004: Send takeover msg from MT to CC using the animation path. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: jbroman nits Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/animation/scroll_offset_animations.h ('k') | cc/layers/layer_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/animation/scroll_offset_animations.h" 5 #include "cc/animation/scroll_offset_animations.h"
6 6
7 #include "cc/animation/animation_host.h" 7 #include "cc/animation/animation_host.h"
8 8
9 namespace cc { 9 namespace cc {
10 10
11 ScrollOffsetAnimationUpdate::ScrollOffsetAnimationUpdate(Type type, 11 ScrollOffsetAnimationUpdate::ScrollOffsetAnimationUpdate() {}
12 ElementId element_id) 12
13 : type_(type), element_id_(element_id) {} 13 ScrollOffsetAnimationUpdate::ScrollOffsetAnimationUpdate(ElementId element_id)
14 : element_id_(element_id), takeover_(false) {}
14 15
15 ScrollOffsetAnimations::ScrollOffsetAnimations(AnimationHost* animation_host) 16 ScrollOffsetAnimations::ScrollOffsetAnimations(AnimationHost* animation_host)
16 : animation_host_(animation_host) {} 17 : animation_host_(animation_host) {}
17 18
18 ScrollOffsetAnimations::~ScrollOffsetAnimations() {} 19 ScrollOffsetAnimations::~ScrollOffsetAnimations() {}
19 20
20 void ScrollOffsetAnimations::AddUpdate(ScrollOffsetAnimationUpdate update) { 21 ScrollOffsetAnimationUpdate ScrollOffsetAnimations::GetUpdateForElementId(
21 queue_.push_back(update); 22 ElementId element_id) const {
23 DCHECK(element_id);
24 auto iter = element_to_update_map_.find(element_id);
25 return iter == element_to_update_map_.end()
26 ? ScrollOffsetAnimationUpdate(element_id)
27 : iter->second;
28 }
29
30 void ScrollOffsetAnimations::AddAdjustmentUpdate(ElementId element_id,
31 gfx::Vector2dF adjustment) {
32 DCHECK(element_id);
33 ScrollOffsetAnimationUpdate update = GetUpdateForElementId(element_id);
34 update.adjustment_ += adjustment;
35 element_to_update_map_[element_id] = update;
36 animation_host_->SetNeedsCommit();
37 }
38
39 void ScrollOffsetAnimations::AddTakeoverUpdate(ElementId element_id) {
40 DCHECK(element_id);
41 ScrollOffsetAnimationUpdate update = GetUpdateForElementId(element_id);
42 update.takeover_ = true;
43 element_to_update_map_[element_id] = update;
22 animation_host_->SetNeedsCommit(); 44 animation_host_->SetNeedsCommit();
23 } 45 }
24 46
25 bool ScrollOffsetAnimations::HasUpdatesForTesting() const { 47 bool ScrollOffsetAnimations::HasUpdatesForTesting() const {
26 return !queue_.empty(); 48 return !element_to_update_map_.empty();
27 } 49 }
28 50
29 void ScrollOffsetAnimations::PushPropertiesTo( 51 void ScrollOffsetAnimations::PushPropertiesTo(
30 ScrollOffsetAnimationsImpl* animations) { 52 ScrollOffsetAnimationsImpl* animations) {
31 DCHECK(animations); 53 DCHECK(animations);
32 if (queue_.empty()) 54 if (element_to_update_map_.empty())
33 return; 55 return;
34 56
35 for (auto& update : queue_) { 57 for (auto& kv : element_to_update_map_) {
36 switch (update.type_) { 58 const auto& update = kv.second;
37 case ScrollOffsetAnimationUpdate::Type::SCROLL_OFFSET_CHANGED: 59 if (update.takeover_)
38 animations->ScrollAnimationApplyAdjustment(update.element_id_, 60 animations->ScrollAnimationAbort(true /*needs_completion*/);
39 update.adjustment_); 61 else
40 } 62 animations->ScrollAnimationApplyAdjustment(update.element_id_,
63 update.adjustment_);
41 } 64 }
42 queue_.clear(); 65 element_to_update_map_.clear();
43 } 66 }
44 67
45 } // namespace cc 68 } // namespace cc
OLDNEW
« no previous file with comments | « cc/animation/scroll_offset_animations.h ('k') | cc/layers/layer_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698