OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/animation_host.h" | 5 #include "cc/animation/animation_host.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 element_animations->PushPropertiesTo(std::move(element_animations_impl)); | 210 element_animations->PushPropertiesTo(std::move(element_animations_impl)); |
211 } | 211 } |
212 | 212 |
213 // Update the impl-only scroll offset animations. | 213 // Update the impl-only scroll offset animations. |
214 scroll_offset_animations_->PushPropertiesTo( | 214 scroll_offset_animations_->PushPropertiesTo( |
215 host_impl->scroll_offset_animations_impl_.get()); | 215 host_impl->scroll_offset_animations_impl_.get()); |
216 } | 216 } |
217 | 217 |
218 scoped_refptr<ElementAnimations> | 218 scoped_refptr<ElementAnimations> |
219 AnimationHost::GetElementAnimationsForElementId(ElementId element_id) const { | 219 AnimationHost::GetElementAnimationsForElementId(ElementId element_id) const { |
220 if (!element_id) | 220 DCHECK(element_id); |
221 return nullptr; | |
222 auto iter = element_to_animations_map_.find(element_id); | 221 auto iter = element_to_animations_map_.find(element_id); |
223 return iter == element_to_animations_map_.end() ? nullptr : iter->second; | 222 return iter == element_to_animations_map_.end() ? nullptr : iter->second; |
224 } | 223 } |
225 | 224 |
226 void AnimationHost::SetSupportsScrollAnimations( | 225 void AnimationHost::SetSupportsScrollAnimations( |
227 bool supports_scroll_animations) { | 226 bool supports_scroll_animations) { |
228 supports_scroll_animations_ = supports_scroll_animations; | 227 supports_scroll_animations_ = supports_scroll_animations; |
229 } | 228 } |
230 | 229 |
231 bool AnimationHost::SupportsScrollAnimations() const { | 230 bool AnimationHost::SupportsScrollAnimations() const { |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 } | 276 } |
278 | 277 |
279 std::unique_ptr<AnimationEvents> AnimationHost::CreateEvents() { | 278 std::unique_ptr<AnimationEvents> AnimationHost::CreateEvents() { |
280 return base::WrapUnique(new AnimationEvents()); | 279 return base::WrapUnique(new AnimationEvents()); |
281 } | 280 } |
282 | 281 |
283 void AnimationHost::SetAnimationEvents( | 282 void AnimationHost::SetAnimationEvents( |
284 std::unique_ptr<AnimationEvents> events) { | 283 std::unique_ptr<AnimationEvents> events) { |
285 for (size_t event_index = 0; event_index < events->events_.size(); | 284 for (size_t event_index = 0; event_index < events->events_.size(); |
286 ++event_index) { | 285 ++event_index) { |
287 ElementId element_id = events->events_[event_index].element_id; | 286 int event_layer_id = events->events_[event_index].element_id; |
288 | 287 |
289 // Use the map of all ElementAnimations, not just active ones, since | 288 // Use the map of all ElementAnimations, not just active ones, since |
290 // non-active ElementAnimations may still receive events for impl-only | 289 // non-active ElementAnimations may still receive events for impl-only |
291 // animations. | 290 // animations. |
292 const ElementToAnimationsMap& all_element_animations = | 291 const ElementToAnimationsMap& all_element_animations = |
293 element_to_animations_map_; | 292 element_to_animations_map_; |
294 auto iter = all_element_animations.find(element_id); | 293 auto iter = all_element_animations.find(event_layer_id); |
295 if (iter != all_element_animations.end()) { | 294 if (iter != all_element_animations.end()) { |
296 switch (events->events_[event_index].type) { | 295 switch (events->events_[event_index].type) { |
297 case AnimationEvent::STARTED: | 296 case AnimationEvent::STARTED: |
298 (*iter).second->NotifyAnimationStarted(events->events_[event_index]); | 297 (*iter).second->NotifyAnimationStarted(events->events_[event_index]); |
299 break; | 298 break; |
300 | 299 |
301 case AnimationEvent::FINISHED: | 300 case AnimationEvent::FINISHED: |
302 (*iter).second->NotifyAnimationFinished(events->events_[event_index]); | 301 (*iter).second->NotifyAnimationFinished(events->events_[event_index]); |
303 break; | 302 break; |
304 | 303 |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
549 const AnimationHost::ElementToAnimationsMap& | 548 const AnimationHost::ElementToAnimationsMap& |
550 AnimationHost::all_element_animations_for_testing() const { | 549 AnimationHost::all_element_animations_for_testing() const { |
551 return element_to_animations_map_; | 550 return element_to_animations_map_; |
552 } | 551 } |
553 | 552 |
554 void AnimationHost::OnAnimationWaitingForDeletion() { | 553 void AnimationHost::OnAnimationWaitingForDeletion() { |
555 animation_waiting_for_deletion_ = true; | 554 animation_waiting_for_deletion_ = true; |
556 } | 555 } |
557 | 556 |
558 } // namespace cc | 557 } // namespace cc |
OLD | NEW |