| OLD | NEW |
| 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 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 : iter->second; | 27 : iter->second; |
| 28 } | 28 } |
| 29 | 29 |
| 30 void ScrollOffsetAnimations::AddAdjustmentUpdate(ElementId element_id, | 30 void ScrollOffsetAnimations::AddAdjustmentUpdate(ElementId element_id, |
| 31 gfx::Vector2dF adjustment) { | 31 gfx::Vector2dF adjustment) { |
| 32 DCHECK(element_id); | 32 DCHECK(element_id); |
| 33 ScrollOffsetAnimationUpdate update = GetUpdateForElementId(element_id); | 33 ScrollOffsetAnimationUpdate update = GetUpdateForElementId(element_id); |
| 34 update.adjustment_ += adjustment; | 34 update.adjustment_ += adjustment; |
| 35 element_to_update_map_[element_id] = update; | 35 element_to_update_map_[element_id] = update; |
| 36 animation_host_->SetNeedsCommit(); | 36 animation_host_->SetNeedsCommit(); |
| 37 animation_host_->SetNeedsPushProperties(); |
| 37 } | 38 } |
| 38 | 39 |
| 39 void ScrollOffsetAnimations::AddTakeoverUpdate(ElementId element_id) { | 40 void ScrollOffsetAnimations::AddTakeoverUpdate(ElementId element_id) { |
| 40 DCHECK(element_id); | 41 DCHECK(element_id); |
| 41 ScrollOffsetAnimationUpdate update = GetUpdateForElementId(element_id); | 42 ScrollOffsetAnimationUpdate update = GetUpdateForElementId(element_id); |
| 42 update.takeover_ = true; | 43 update.takeover_ = true; |
| 43 element_to_update_map_[element_id] = update; | 44 element_to_update_map_[element_id] = update; |
| 44 animation_host_->SetNeedsCommit(); | 45 animation_host_->SetNeedsCommit(); |
| 46 animation_host_->SetNeedsPushProperties(); |
| 45 } | 47 } |
| 46 | 48 |
| 47 bool ScrollOffsetAnimations::HasUpdatesForTesting() const { | 49 bool ScrollOffsetAnimations::HasUpdatesForTesting() const { |
| 48 return !element_to_update_map_.empty(); | 50 return !element_to_update_map_.empty(); |
| 49 } | 51 } |
| 50 | 52 |
| 51 void ScrollOffsetAnimations::PushPropertiesTo( | 53 void ScrollOffsetAnimations::PushPropertiesTo( |
| 52 ScrollOffsetAnimationsImpl* animations) { | 54 ScrollOffsetAnimationsImpl* animations) { |
| 53 DCHECK(animations); | 55 DCHECK(animations); |
| 54 if (element_to_update_map_.empty()) | 56 if (element_to_update_map_.empty()) |
| 55 return; | 57 return; |
| 56 | 58 |
| 57 for (auto& kv : element_to_update_map_) { | 59 for (auto& kv : element_to_update_map_) { |
| 58 const auto& update = kv.second; | 60 const auto& update = kv.second; |
| 59 if (update.takeover_) | 61 if (update.takeover_) |
| 60 animations->ScrollAnimationAbort(true /*needs_completion*/); | 62 animations->ScrollAnimationAbort(true /*needs_completion*/); |
| 61 else | 63 else |
| 62 animations->ScrollAnimationApplyAdjustment(update.element_id_, | 64 animations->ScrollAnimationApplyAdjustment(update.element_id_, |
| 63 update.adjustment_); | 65 update.adjustment_); |
| 64 } | 66 } |
| 65 element_to_update_map_.clear(); | 67 element_to_update_map_.clear(); |
| 66 } | 68 } |
| 67 | 69 |
| 68 } // namespace cc | 70 } // namespace cc |
| OLD | NEW |