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

Side by Side Diff: third_party/WebKit/Source/core/svg/animation/SMILTimeContainer.cpp

Issue 2287973002: Tidy up some loops in SMILTimeContainer::updateAnimations (Closed)
Patch Set: Created 4 years, 3 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2008 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 // Go through the sandwich from lowest prio to highest and generate 492 // Go through the sandwich from lowest prio to highest and generate
493 // the animated value (if any.) 493 // the animated value (if any.)
494 for (const auto& animation : sandwich) 494 for (const auto& animation : sandwich)
495 animation->updateAnimatedValue(resultElement); 495 animation->updateAnimatedValue(resultElement);
496 496
497 animationsToApply.append(resultElement); 497 animationsToApply.append(resultElement);
498 } 498 }
499 } 499 }
500 m_scheduledAnimations.removeAll(invalidKeys); 500 m_scheduledAnimations.removeAll(invalidKeys);
501 501
502 std::sort(animationsToApply.begin(), animationsToApply.end(), PriorityCompar e(elapsed)); 502 if (animationsToApply.isEmpty()) {
503
504 unsigned animationsToApplySize = animationsToApply.size();
505 if (!animationsToApplySize) {
506 #if ENABLE(ASSERT) 503 #if ENABLE(ASSERT)
507 m_preventScheduledAnimationsChanges = false; 504 m_preventScheduledAnimationsChanges = false;
508 #endif 505 #endif
509 return earliestFireTime; 506 return earliestFireTime;
510 } 507 }
511 508
512 UseCounter::count(&document(), UseCounter::SVGSMILAnimationAppliedEffect); 509 UseCounter::count(&document(), UseCounter::SVGSMILAnimationAppliedEffect);
513 510
511 std::sort(animationsToApply.begin(), animationsToApply.end(), PriorityCompar e(elapsed));
512
514 // Apply results to target elements. 513 // Apply results to target elements.
515 for (unsigned i = 0; i < animationsToApplySize; ++i) 514 for (const auto& timedElement : animationsToApply)
516 animationsToApply[i]->applyResultsToTarget(); 515 timedElement->applyResultsToTarget();
517 516
518 #if ENABLE(ASSERT) 517 #if ENABLE(ASSERT)
519 m_preventScheduledAnimationsChanges = false; 518 m_preventScheduledAnimationsChanges = false;
520 #endif 519 #endif
521 520
522 for (unsigned i = 0; i < animationsToApplySize; ++i) { 521 for (const auto& timedElement : animationsToApply) {
523 if (animationsToApply[i]->isConnected() && animationsToApply[i]->isSVGDi scardElement()) { 522 if (timedElement->isConnected() && timedElement->isSVGDiscardElement()) {
pdr. 2016/08/29 00:47:03 Forever reminded of the mistakes I made reviewing
fs 2016/08/29 08:14:16 Mmm, discard, yum... (I think I know which mistake
524 SVGSMILElement* animDiscard = animationsToApply[i]; 523 SVGElement* targetElement = timedElement->targetElement();
525 SVGElement* targetElement = animDiscard->targetElement();
526 if (targetElement && targetElement->isConnected()) { 524 if (targetElement && targetElement->isConnected()) {
527 targetElement->remove(IGNORE_EXCEPTION); 525 targetElement->remove(IGNORE_EXCEPTION);
528 ASSERT(!targetElement->isConnected()); 526 DCHECK(!targetElement->isConnected());
529 } 527 }
530 528
531 if (animDiscard->isConnected()) { 529 if (timedElement->isConnected()) {
532 animDiscard->remove(IGNORE_EXCEPTION); 530 timedElement->remove(IGNORE_EXCEPTION);
533 ASSERT(!animDiscard->isConnected()); 531 DCHECK(!timedElement->isConnected());
534 } 532 }
535 } 533 }
536 } 534 }
537 return earliestFireTime; 535 return earliestFireTime;
538 } 536 }
539 537
540 void SMILTimeContainer::advanceFrameForTesting() 538 void SMILTimeContainer::advanceFrameForTesting()
541 { 539 {
542 setElapsed(elapsed() + initialFrameDelay); 540 setElapsed(elapsed() + initialFrameDelay);
543 } 541 }
544 542
545 DEFINE_TRACE(SMILTimeContainer) 543 DEFINE_TRACE(SMILTimeContainer)
546 { 544 {
547 visitor->trace(m_scheduledAnimations); 545 visitor->trace(m_scheduledAnimations);
548 visitor->trace(m_ownerSVGElement); 546 visitor->trace(m_ownerSVGElement);
549 } 547 }
550 548
551 } // namespace blink 549 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698