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

Unified 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, 7 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/animation/scroll_offset_animations.cc
diff --git a/cc/animation/scroll_offset_animations.cc b/cc/animation/scroll_offset_animations.cc
index 1dcda6060bb7643a7c156d727c9f19d5814b61b4..04cf954c6f27ad286dafc83fb3f076a9c81c338c 100644
--- a/cc/animation/scroll_offset_animations.cc
+++ b/cc/animation/scroll_offset_animations.cc
@@ -8,38 +8,61 @@
namespace cc {
-ScrollOffsetAnimationUpdate::ScrollOffsetAnimationUpdate(Type type,
- ElementId element_id)
- : type_(type), element_id_(element_id) {}
+ScrollOffsetAnimationUpdate::ScrollOffsetAnimationUpdate() {}
+
+ScrollOffsetAnimationUpdate::ScrollOffsetAnimationUpdate(ElementId element_id)
+ : element_id_(element_id), takeover_(false) {}
ScrollOffsetAnimations::ScrollOffsetAnimations(AnimationHost* animation_host)
: animation_host_(animation_host) {}
ScrollOffsetAnimations::~ScrollOffsetAnimations() {}
-void ScrollOffsetAnimations::AddUpdate(ScrollOffsetAnimationUpdate update) {
- queue_.push_back(update);
+ScrollOffsetAnimationUpdate ScrollOffsetAnimations::GetUpdateForElementId(
+ ElementId element_id) const {
+ DCHECK(element_id);
+ auto iter = element_to_update_map_.find(element_id);
+ return iter == element_to_update_map_.end()
+ ? ScrollOffsetAnimationUpdate(element_id)
+ : iter->second;
+}
+
+void ScrollOffsetAnimations::AddAdjustmentUpdate(ElementId element_id,
+ gfx::Vector2dF adjustment) {
+ DCHECK(element_id);
+ ScrollOffsetAnimationUpdate update = GetUpdateForElementId(element_id);
+ update.adjustment_ += adjustment;
+ element_to_update_map_[element_id] = update;
+ animation_host_->SetNeedsCommit();
+}
+
+void ScrollOffsetAnimations::AddTakeoverUpdate(ElementId element_id) {
+ DCHECK(element_id);
+ ScrollOffsetAnimationUpdate update = GetUpdateForElementId(element_id);
+ update.takeover_ = true;
+ element_to_update_map_[element_id] = update;
animation_host_->SetNeedsCommit();
}
bool ScrollOffsetAnimations::HasUpdatesForTesting() const {
- return !queue_.empty();
+ return !element_to_update_map_.empty();
}
void ScrollOffsetAnimations::PushPropertiesTo(
ScrollOffsetAnimationsImpl* animations) {
DCHECK(animations);
- if (queue_.empty())
+ if (element_to_update_map_.empty())
return;
- for (auto& update : queue_) {
- switch (update.type_) {
- case ScrollOffsetAnimationUpdate::Type::SCROLL_OFFSET_CHANGED:
- animations->ScrollAnimationApplyAdjustment(update.element_id_,
- update.adjustment_);
- }
+ for (auto& kv : element_to_update_map_) {
+ const auto& update = kv.second;
+ if (update.takeover_)
+ animations->ScrollAnimationAbort(true /*needs_completion*/);
+ else
+ animations->ScrollAnimationApplyAdjustment(update.element_id_,
+ update.adjustment_);
}
- queue_.clear();
+ element_to_update_map_.clear();
}
} // namespace cc
« 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