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

Side by Side Diff: cc/animation/animation_host.cc

Issue 1973083002: Use element id's for animations (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: get element id's from scroll node data directly. Created 4 years, 6 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 unified diff | Download patch
OLDNEW
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
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 DCHECK(element_id); 220 if (!element_id)
221 return nullptr;
221 auto iter = element_to_animations_map_.find(element_id); 222 auto iter = element_to_animations_map_.find(element_id);
222 return iter == element_to_animations_map_.end() ? nullptr : iter->second; 223 return iter == element_to_animations_map_.end() ? nullptr : iter->second;
223 } 224 }
224 225
225 void AnimationHost::SetSupportsScrollAnimations( 226 void AnimationHost::SetSupportsScrollAnimations(
226 bool supports_scroll_animations) { 227 bool supports_scroll_animations) {
227 supports_scroll_animations_ = supports_scroll_animations; 228 supports_scroll_animations_ = supports_scroll_animations;
228 } 229 }
229 230
230 bool AnimationHost::SupportsScrollAnimations() const { 231 bool AnimationHost::SupportsScrollAnimations() const {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 } 277 }
277 278
278 std::unique_ptr<AnimationEvents> AnimationHost::CreateEvents() { 279 std::unique_ptr<AnimationEvents> AnimationHost::CreateEvents() {
279 return base::WrapUnique(new AnimationEvents()); 280 return base::WrapUnique(new AnimationEvents());
280 } 281 }
281 282
282 void AnimationHost::SetAnimationEvents( 283 void AnimationHost::SetAnimationEvents(
283 std::unique_ptr<AnimationEvents> events) { 284 std::unique_ptr<AnimationEvents> events) {
284 for (size_t event_index = 0; event_index < events->events_.size(); 285 for (size_t event_index = 0; event_index < events->events_.size();
285 ++event_index) { 286 ++event_index) {
286 int event_layer_id = events->events_[event_index].element_id; 287 ElementId element_id = events->events_[event_index].element_id;
287 288
288 // Use the map of all ElementAnimations, not just active ones, since 289 // Use the map of all ElementAnimations, not just active ones, since
289 // non-active ElementAnimations may still receive events for impl-only 290 // non-active ElementAnimations may still receive events for impl-only
290 // animations. 291 // animations.
291 const ElementToAnimationsMap& all_element_animations = 292 const ElementToAnimationsMap& all_element_animations =
292 element_to_animations_map_; 293 element_to_animations_map_;
293 auto iter = all_element_animations.find(event_layer_id); 294 auto iter = all_element_animations.find(element_id);
294 if (iter != all_element_animations.end()) { 295 if (iter != all_element_animations.end()) {
295 switch (events->events_[event_index].type) { 296 switch (events->events_[event_index].type) {
296 case AnimationEvent::STARTED: 297 case AnimationEvent::STARTED:
297 (*iter).second->NotifyAnimationStarted(events->events_[event_index]); 298 (*iter).second->NotifyAnimationStarted(events->events_[event_index]);
298 break; 299 break;
299 300
300 case AnimationEvent::FINISHED: 301 case AnimationEvent::FINISHED:
301 (*iter).second->NotifyAnimationFinished(events->events_[event_index]); 302 (*iter).second->NotifyAnimationFinished(events->events_[event_index]);
302 break; 303 break;
303 304
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 const AnimationHost::ElementToAnimationsMap& 549 const AnimationHost::ElementToAnimationsMap&
549 AnimationHost::all_element_animations_for_testing() const { 550 AnimationHost::all_element_animations_for_testing() const {
550 return element_to_animations_map_; 551 return element_to_animations_map_;
551 } 552 }
552 553
553 void AnimationHost::OnAnimationWaitingForDeletion() { 554 void AnimationHost::OnAnimationWaitingForDeletion() {
554 animation_waiting_for_deletion_ = true; 555 animation_waiting_for_deletion_ = true;
555 } 556 }
556 557
557 } // namespace cc 558 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698