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

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

Issue 2640163004: Replace ENABLE(ASSERT) with DCHECK_IS_ON(). (Closed)
Patch Set: Created 3 years, 11 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 /* 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 : m_presentationTime(0), 45 : m_presentationTime(0),
46 m_referenceTime(0), 46 m_referenceTime(0),
47 m_frameSchedulingState(Idle), 47 m_frameSchedulingState(Idle),
48 m_started(false), 48 m_started(false),
49 m_paused(false), 49 m_paused(false),
50 m_documentOrderIndexesDirty(false), 50 m_documentOrderIndexesDirty(false),
51 m_wakeupTimer(this, &SMILTimeContainer::wakeupTimerFired), 51 m_wakeupTimer(this, &SMILTimeContainer::wakeupTimerFired),
52 m_animationPolicyOnceTimer(this, 52 m_animationPolicyOnceTimer(this,
53 &SMILTimeContainer::animationPolicyTimerFired), 53 &SMILTimeContainer::animationPolicyTimerFired),
54 m_ownerSVGElement(&owner) 54 m_ownerSVGElement(&owner)
55 #if ENABLE(ASSERT)
56 ,
57 m_preventScheduledAnimationsChanges(false)
58 #endif
59 { 55 {
60 } 56 }
61 57
62 SMILTimeContainer::~SMILTimeContainer() { 58 SMILTimeContainer::~SMILTimeContainer() {
63 cancelAnimationFrame(); 59 cancelAnimationFrame();
64 cancelAnimationPolicyTimer(); 60 cancelAnimationPolicyTimer();
65 ASSERT(!m_wakeupTimer.isActive()); 61 ASSERT(!m_wakeupTimer.isActive());
66 #if ENABLE(ASSERT) 62 #if DCHECK_IS_ON()
67 ASSERT(!m_preventScheduledAnimationsChanges); 63 ASSERT(!m_preventScheduledAnimationsChanges);
68 #endif 64 #endif
69 } 65 }
70 66
71 void SMILTimeContainer::schedule(SVGSMILElement* animation, 67 void SMILTimeContainer::schedule(SVGSMILElement* animation,
72 SVGElement* target, 68 SVGElement* target,
73 const QualifiedName& attributeName) { 69 const QualifiedName& attributeName) {
74 DCHECK_EQ(animation->timeContainer(), this); 70 DCHECK_EQ(animation->timeContainer(), this);
75 DCHECK(target); 71 DCHECK(target);
76 DCHECK(animation->hasValidTarget()); 72 DCHECK(animation->hasValidTarget());
77 73
78 #if ENABLE(ASSERT) 74 #if DCHECK_IS_ON()
79 ASSERT(!m_preventScheduledAnimationsChanges); 75 ASSERT(!m_preventScheduledAnimationsChanges);
80 #endif 76 #endif
81 77
82 ElementAttributePair key(target, attributeName); 78 ElementAttributePair key(target, attributeName);
83 Member<AnimationsLinkedHashSet>& scheduled = 79 Member<AnimationsLinkedHashSet>& scheduled =
84 m_scheduledAnimations.add(key, nullptr).storedValue->value; 80 m_scheduledAnimations.add(key, nullptr).storedValue->value;
85 if (!scheduled) 81 if (!scheduled)
86 scheduled = new AnimationsLinkedHashSet; 82 scheduled = new AnimationsLinkedHashSet;
87 ASSERT(!scheduled->contains(animation)); 83 ASSERT(!scheduled->contains(animation));
88 scheduled->add(animation); 84 scheduled->add(animation);
89 85
90 SMILTime nextFireTime = animation->nextProgressTime(); 86 SMILTime nextFireTime = animation->nextProgressTime();
91 if (nextFireTime.isFinite()) 87 if (nextFireTime.isFinite())
92 notifyIntervalsChanged(); 88 notifyIntervalsChanged();
93 } 89 }
94 90
95 void SMILTimeContainer::unschedule(SVGSMILElement* animation, 91 void SMILTimeContainer::unschedule(SVGSMILElement* animation,
96 SVGElement* target, 92 SVGElement* target,
97 const QualifiedName& attributeName) { 93 const QualifiedName& attributeName) {
98 ASSERT(animation->timeContainer() == this); 94 ASSERT(animation->timeContainer() == this);
99 95
100 #if ENABLE(ASSERT) 96 #if DCHECK_IS_ON()
101 ASSERT(!m_preventScheduledAnimationsChanges); 97 ASSERT(!m_preventScheduledAnimationsChanges);
102 #endif 98 #endif
103 99
104 ElementAttributePair key(target, attributeName); 100 ElementAttributePair key(target, attributeName);
105 GroupedAnimationsMap::iterator it = m_scheduledAnimations.find(key); 101 GroupedAnimationsMap::iterator it = m_scheduledAnimations.find(key);
106 ASSERT(it != m_scheduledAnimations.end()); 102 ASSERT(it != m_scheduledAnimations.end());
107 AnimationsLinkedHashSet* scheduled = it->value.get(); 103 AnimationsLinkedHashSet* scheduled = it->value.get();
108 ASSERT(scheduled); 104 ASSERT(scheduled);
109 AnimationsLinkedHashSet::iterator itAnimation = scheduled->find(animation); 105 AnimationsLinkedHashSet::iterator itAnimation = scheduled->find(animation);
110 ASSERT(itAnimation != scheduled->end()); 106 ASSERT(itAnimation != scheduled->end());
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 return; 222 return;
227 223
228 if (!handleAnimationPolicy(RestartOnceTimerIfNotPaused)) 224 if (!handleAnimationPolicy(RestartOnceTimerIfNotPaused))
229 return; 225 return;
230 226
231 cancelAnimationFrame(); 227 cancelAnimationFrame();
232 228
233 if (!isPaused()) 229 if (!isPaused())
234 synchronizeToDocumentTimeline(); 230 synchronizeToDocumentTimeline();
235 231
236 #if ENABLE(ASSERT) 232 #if DCHECK_IS_ON()
237 m_preventScheduledAnimationsChanges = true; 233 m_preventScheduledAnimationsChanges = true;
238 #endif 234 #endif
239 for (const auto& entry : m_scheduledAnimations) { 235 for (const auto& entry : m_scheduledAnimations) {
240 if (!entry.key.first) 236 if (!entry.key.first)
241 continue; 237 continue;
242 238
243 AnimationsLinkedHashSet* scheduled = entry.value.get(); 239 AnimationsLinkedHashSet* scheduled = entry.value.get();
244 for (SVGSMILElement* element : *scheduled) 240 for (SVGSMILElement* element : *scheduled)
245 element->reset(); 241 element->reset();
246 } 242 }
247 #if ENABLE(ASSERT) 243 #if DCHECK_IS_ON()
248 m_preventScheduledAnimationsChanges = false; 244 m_preventScheduledAnimationsChanges = false;
249 #endif 245 #endif
250 246
251 updateAnimationsAndScheduleFrameIfNeeded(elapsed, true); 247 updateAnimationsAndScheduleFrameIfNeeded(elapsed, true);
252 } 248 }
253 249
254 void SMILTimeContainer::scheduleAnimationFrame(double delayTime) { 250 void SMILTimeContainer::scheduleAnimationFrame(double delayTime) {
255 DCHECK(std::isfinite(delayTime)); 251 DCHECK(std::isfinite(delayTime));
256 DCHECK(isTimelineRunning()); 252 DCHECK(isTimelineRunning());
257 DCHECK(!m_wakeupTimer.isActive()); 253 DCHECK(!m_wakeupTimer.isActive());
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 if (!canScheduleFrame(earliestFireTime)) 412 if (!canScheduleFrame(earliestFireTime))
417 return; 413 return;
418 double delayTime = earliestFireTime.value() - elapsed; 414 double delayTime = earliestFireTime.value() - elapsed;
419 scheduleAnimationFrame(delayTime); 415 scheduleAnimationFrame(delayTime);
420 } 416 }
421 417
422 SMILTime SMILTimeContainer::updateAnimations(double elapsed, bool seekToTime) { 418 SMILTime SMILTimeContainer::updateAnimations(double elapsed, bool seekToTime) {
423 ASSERT(document().isActive()); 419 ASSERT(document().isActive());
424 SMILTime earliestFireTime = SMILTime::unresolved(); 420 SMILTime earliestFireTime = SMILTime::unresolved();
425 421
426 #if ENABLE(ASSERT) 422 #if DCHECK_IS_ON()
427 // This boolean will catch any attempts to schedule/unschedule 423 // This boolean will catch any attempts to schedule/unschedule
428 // scheduledAnimations during this critical section. Similarly, any elements 424 // scheduledAnimations during this critical section. Similarly, any elements
429 // removed will unschedule themselves, so this will catch modification of 425 // removed will unschedule themselves, so this will catch modification of
430 // animationsToApply. 426 // animationsToApply.
431 m_preventScheduledAnimationsChanges = true; 427 m_preventScheduledAnimationsChanges = true;
432 #endif 428 #endif
433 429
434 if (m_documentOrderIndexesDirty) 430 if (m_documentOrderIndexesDirty)
435 updateDocumentOrderIndexes(); 431 updateDocumentOrderIndexes();
436 432
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 // the animated value (if any.) 480 // the animated value (if any.)
485 for (const auto& animation : sandwich) 481 for (const auto& animation : sandwich)
486 animation->updateAnimatedValue(resultElement); 482 animation->updateAnimatedValue(resultElement);
487 483
488 animationsToApply.push_back(resultElement); 484 animationsToApply.push_back(resultElement);
489 } 485 }
490 } 486 }
491 m_scheduledAnimations.removeAll(invalidKeys); 487 m_scheduledAnimations.removeAll(invalidKeys);
492 488
493 if (animationsToApply.isEmpty()) { 489 if (animationsToApply.isEmpty()) {
494 #if ENABLE(ASSERT) 490 #if DCHECK_IS_ON()
495 m_preventScheduledAnimationsChanges = false; 491 m_preventScheduledAnimationsChanges = false;
496 #endif 492 #endif
497 return earliestFireTime; 493 return earliestFireTime;
498 } 494 }
499 495
500 UseCounter::count(&document(), UseCounter::SVGSMILAnimationAppliedEffect); 496 UseCounter::count(&document(), UseCounter::SVGSMILAnimationAppliedEffect);
501 497
502 std::sort(animationsToApply.begin(), animationsToApply.end(), 498 std::sort(animationsToApply.begin(), animationsToApply.end(),
503 PriorityCompare(elapsed)); 499 PriorityCompare(elapsed));
504 500
505 // Apply results to target elements. 501 // Apply results to target elements.
506 for (const auto& timedElement : animationsToApply) 502 for (const auto& timedElement : animationsToApply)
507 timedElement->applyResultsToTarget(); 503 timedElement->applyResultsToTarget();
508 504
509 #if ENABLE(ASSERT) 505 #if DCHECK_IS_ON()
510 m_preventScheduledAnimationsChanges = false; 506 m_preventScheduledAnimationsChanges = false;
511 #endif 507 #endif
512 508
513 for (const auto& timedElement : animationsToApply) { 509 for (const auto& timedElement : animationsToApply) {
514 if (timedElement->isConnected() && timedElement->isSVGDiscardElement()) { 510 if (timedElement->isConnected() && timedElement->isSVGDiscardElement()) {
515 SVGElement* targetElement = timedElement->targetElement(); 511 SVGElement* targetElement = timedElement->targetElement();
516 if (targetElement && targetElement->isConnected()) { 512 if (targetElement && targetElement->isConnected()) {
517 targetElement->remove(IGNORE_EXCEPTION_FOR_TESTING); 513 targetElement->remove(IGNORE_EXCEPTION_FOR_TESTING);
518 DCHECK(!targetElement->isConnected()); 514 DCHECK(!targetElement->isConnected());
519 } 515 }
(...skipping 10 matching lines...) Expand all
530 void SMILTimeContainer::advanceFrameForTesting() { 526 void SMILTimeContainer::advanceFrameForTesting() {
531 setElapsed(elapsed() + initialFrameDelay); 527 setElapsed(elapsed() + initialFrameDelay);
532 } 528 }
533 529
534 DEFINE_TRACE(SMILTimeContainer) { 530 DEFINE_TRACE(SMILTimeContainer) {
535 visitor->trace(m_scheduledAnimations); 531 visitor->trace(m_scheduledAnimations);
536 visitor->trace(m_ownerSVGElement); 532 visitor->trace(m_ownerSVGElement);
537 } 533 }
538 534
539 } // namespace blink 535 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698