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

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: 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
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..21efcffff6a79edc2f3fe3deaea69c1dfb085ab6 100644
--- a/cc/animation/scroll_offset_animations.cc
+++ b/cc/animation/scroll_offset_animations.cc
@@ -8,38 +8,59 @@
namespace cc {
-ScrollOffsetAnimationUpdate::ScrollOffsetAnimationUpdate(Type type,
- ElementId element_id)
- : type_(type), element_id_(element_id) {}
+ScrollOffsetAnimationUpdate::ScrollOffsetAnimationUpdate(ElementId element_id)
+ : element_id_(element_id) {}
ajuma 2016/05/24 23:25:09 takeover_ needs to be initialized here
ymalik 2016/05/25 16:09:05 Thanks! Done.
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_.insert(std::make_pair(element_id, update));
skobes 2016/05/24 23:50:50 Hmm, I think unordered_map::insert will not replac
ymalik 2016/05/25 16:09:05 Good catch. Done!
+ animation_host_->SetNeedsCommit();
+}
+
+void ScrollOffsetAnimations::AddTakeoverUpdate(ElementId element_id) {
+ DCHECK(element_id);
+ ScrollOffsetAnimationUpdate update = GetUpdateForElementId(element_id);
+ update.takeover_ = true;
+ element_to_update_map_.insert(std::make_pair(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

Powered by Google App Engine
This is Rietveld 408576698