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 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 element_animations->PushPropertiesTo(std::move(element_animations_impl)); | 228 element_animations->PushPropertiesTo(std::move(element_animations_impl)); |
229 } | 229 } |
230 | 230 |
231 // Update the impl-only scroll offset animations. | 231 // Update the impl-only scroll offset animations. |
232 scroll_offset_animations_->PushPropertiesTo( | 232 scroll_offset_animations_->PushPropertiesTo( |
233 host_impl->scroll_offset_animations_impl_.get()); | 233 host_impl->scroll_offset_animations_impl_.get()); |
234 } | 234 } |
235 | 235 |
236 scoped_refptr<ElementAnimations> | 236 scoped_refptr<ElementAnimations> |
237 AnimationHost::GetElementAnimationsForElementId(ElementId element_id) const { | 237 AnimationHost::GetElementAnimationsForElementId(ElementId element_id) const { |
238 DCHECK(element_id); | 238 if (!element_id) |
| 239 return nullptr; |
239 auto iter = element_to_animations_map_.find(element_id); | 240 auto iter = element_to_animations_map_.find(element_id); |
240 return iter == element_to_animations_map_.end() ? nullptr : iter->second; | 241 return iter == element_to_animations_map_.end() ? nullptr : iter->second; |
241 } | 242 } |
242 | 243 |
243 void AnimationHost::SetSupportsScrollAnimations( | 244 void AnimationHost::SetSupportsScrollAnimations( |
244 bool supports_scroll_animations) { | 245 bool supports_scroll_animations) { |
245 supports_scroll_animations_ = supports_scroll_animations; | 246 supports_scroll_animations_ = supports_scroll_animations; |
246 } | 247 } |
247 | 248 |
248 bool AnimationHost::SupportsScrollAnimations() const { | 249 bool AnimationHost::SupportsScrollAnimations() const { |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 } | 295 } |
295 | 296 |
296 std::unique_ptr<AnimationEvents> AnimationHost::CreateEvents() { | 297 std::unique_ptr<AnimationEvents> AnimationHost::CreateEvents() { |
297 return base::WrapUnique(new AnimationEvents()); | 298 return base::WrapUnique(new AnimationEvents()); |
298 } | 299 } |
299 | 300 |
300 void AnimationHost::SetAnimationEvents( | 301 void AnimationHost::SetAnimationEvents( |
301 std::unique_ptr<AnimationEvents> events) { | 302 std::unique_ptr<AnimationEvents> events) { |
302 for (size_t event_index = 0; event_index < events->events_.size(); | 303 for (size_t event_index = 0; event_index < events->events_.size(); |
303 ++event_index) { | 304 ++event_index) { |
304 int event_layer_id = events->events_[event_index].element_id; | 305 ElementId element_id = events->events_[event_index].element_id; |
305 | 306 |
306 // Use the map of all ElementAnimations, not just active ones, since | 307 // Use the map of all ElementAnimations, not just active ones, since |
307 // non-active ElementAnimations may still receive events for impl-only | 308 // non-active ElementAnimations may still receive events for impl-only |
308 // animations. | 309 // animations. |
309 const ElementToAnimationsMap& all_element_animations = | 310 const ElementToAnimationsMap& all_element_animations = |
310 element_to_animations_map_; | 311 element_to_animations_map_; |
311 auto iter = all_element_animations.find(event_layer_id); | 312 auto iter = all_element_animations.find(element_id); |
312 if (iter != all_element_animations.end()) { | 313 if (iter != all_element_animations.end()) { |
313 switch (events->events_[event_index].type) { | 314 switch (events->events_[event_index].type) { |
314 case AnimationEvent::STARTED: | 315 case AnimationEvent::STARTED: |
315 (*iter).second->NotifyAnimationStarted(events->events_[event_index]); | 316 (*iter).second->NotifyAnimationStarted(events->events_[event_index]); |
316 break; | 317 break; |
317 | 318 |
318 case AnimationEvent::FINISHED: | 319 case AnimationEvent::FINISHED: |
319 (*iter).second->NotifyAnimationFinished(events->events_[event_index]); | 320 (*iter).second->NotifyAnimationFinished(events->events_[event_index]); |
320 break; | 321 break; |
321 | 322 |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
566 const AnimationHost::ElementToAnimationsMap& | 567 const AnimationHost::ElementToAnimationsMap& |
567 AnimationHost::all_element_animations_for_testing() const { | 568 AnimationHost::all_element_animations_for_testing() const { |
568 return element_to_animations_map_; | 569 return element_to_animations_map_; |
569 } | 570 } |
570 | 571 |
571 void AnimationHost::OnAnimationWaitingForDeletion() { | 572 void AnimationHost::OnAnimationWaitingForDeletion() { |
572 animation_waiting_for_deletion_ = true; | 573 animation_waiting_for_deletion_ = true; |
573 } | 574 } |
574 | 575 |
575 } // namespace cc | 576 } // namespace cc |
OLD | NEW |