Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 54 &SMILTimeContainer::wakeupTimerFired), | 54 &SMILTimeContainer::wakeupTimerFired), |
| 55 m_animationPolicyOnceTimer( | 55 m_animationPolicyOnceTimer( |
| 56 TaskRunnerHelper::get(TaskType::UnspecedTimer, &owner.document()), | 56 TaskRunnerHelper::get(TaskType::UnspecedTimer, &owner.document()), |
| 57 this, | 57 this, |
| 58 &SMILTimeContainer::animationPolicyTimerFired), | 58 &SMILTimeContainer::animationPolicyTimerFired), |
| 59 m_ownerSVGElement(&owner) {} | 59 m_ownerSVGElement(&owner) {} |
| 60 | 60 |
| 61 SMILTimeContainer::~SMILTimeContainer() { | 61 SMILTimeContainer::~SMILTimeContainer() { |
| 62 cancelAnimationFrame(); | 62 cancelAnimationFrame(); |
| 63 cancelAnimationPolicyTimer(); | 63 cancelAnimationPolicyTimer(); |
| 64 ASSERT(!m_wakeupTimer.isActive()); | 64 DCHECK(!m_wakeupTimer.isActive()); |
| 65 #if DCHECK_IS_ON() | 65 #if DCHECK_IS_ON() |
| 66 ASSERT(!m_preventScheduledAnimationsChanges); | 66 DCHECK(!m_preventScheduledAnimationsChanges); |
| 67 #endif | 67 #endif |
| 68 } | 68 } |
| 69 | 69 |
| 70 void SMILTimeContainer::schedule(SVGSMILElement* animation, | 70 void SMILTimeContainer::schedule(SVGSMILElement* animation, |
| 71 SVGElement* target, | 71 SVGElement* target, |
| 72 const QualifiedName& attributeName) { | 72 const QualifiedName& attributeName) { |
| 73 DCHECK_EQ(animation->timeContainer(), this); | 73 DCHECK_EQ(animation->timeContainer(), this); |
| 74 DCHECK(target); | 74 DCHECK(target); |
| 75 DCHECK(animation->hasValidTarget()); | 75 DCHECK(animation->hasValidTarget()); |
| 76 | 76 |
| 77 #if DCHECK_IS_ON() | 77 #if DCHECK_IS_ON() |
| 78 ASSERT(!m_preventScheduledAnimationsChanges); | 78 DCHECK(!m_preventScheduledAnimationsChanges); |
| 79 #endif | 79 #endif |
| 80 | 80 |
| 81 ElementAttributePair key(target, attributeName); | 81 ElementAttributePair key(target, attributeName); |
| 82 Member<AnimationsLinkedHashSet>& scheduled = | 82 Member<AnimationsLinkedHashSet>& scheduled = |
| 83 m_scheduledAnimations.insert(key, nullptr).storedValue->value; | 83 m_scheduledAnimations.insert(key, nullptr).storedValue->value; |
| 84 if (!scheduled) | 84 if (!scheduled) |
| 85 scheduled = new AnimationsLinkedHashSet; | 85 scheduled = new AnimationsLinkedHashSet; |
| 86 ASSERT(!scheduled->contains(animation)); | 86 DCHECK(!scheduled->contains(animation)); |
| 87 scheduled->insert(animation); | 87 scheduled->insert(animation); |
| 88 | 88 |
| 89 SMILTime nextFireTime = animation->nextProgressTime(); | 89 SMILTime nextFireTime = animation->nextProgressTime(); |
| 90 if (nextFireTime.isFinite()) | 90 if (nextFireTime.isFinite()) |
| 91 notifyIntervalsChanged(); | 91 notifyIntervalsChanged(); |
| 92 } | 92 } |
| 93 | 93 |
| 94 void SMILTimeContainer::unschedule(SVGSMILElement* animation, | 94 void SMILTimeContainer::unschedule(SVGSMILElement* animation, |
| 95 SVGElement* target, | 95 SVGElement* target, |
| 96 const QualifiedName& attributeName) { | 96 const QualifiedName& attributeName) { |
| 97 ASSERT(animation->timeContainer() == this); | 97 DCHECK_EQ(animation->timeContainer(), this); |
| 98 | 98 |
| 99 #if DCHECK_IS_ON() | 99 #if DCHECK_IS_ON() |
| 100 ASSERT(!m_preventScheduledAnimationsChanges); | 100 DCHECK(!m_preventScheduledAnimationsChanges); |
| 101 #endif | 101 #endif |
| 102 | 102 |
| 103 ElementAttributePair key(target, attributeName); | 103 ElementAttributePair key(target, attributeName); |
| 104 GroupedAnimationsMap::iterator it = m_scheduledAnimations.find(key); | 104 GroupedAnimationsMap::iterator it = m_scheduledAnimations.find(key); |
| 105 ASSERT(it != m_scheduledAnimations.end()); | 105 DCHECK_NE(it, m_scheduledAnimations.end()); |
| 106 AnimationsLinkedHashSet* scheduled = it->value.get(); | 106 AnimationsLinkedHashSet* scheduled = it->value.get(); |
| 107 ASSERT(scheduled); | 107 DCHECK(scheduled); |
| 108 AnimationsLinkedHashSet::iterator itAnimation = scheduled->find(animation); | 108 AnimationsLinkedHashSet::iterator itAnimation = scheduled->find(animation); |
| 109 ASSERT(itAnimation != scheduled->end()); | 109 DCHECK(itAnimation != scheduled->end()); |
|
tkent
2017/03/14 22:33:14
Use DCHECK_NE if possible
mrunal
2017/03/14 23:52:14
It throws a compiler error,
../../base/logging.h:6
| |
| 110 scheduled->erase(itAnimation); | 110 scheduled->erase(itAnimation); |
| 111 | 111 |
| 112 if (scheduled->isEmpty()) | 112 if (scheduled->isEmpty()) |
| 113 m_scheduledAnimations.remove(it); | 113 m_scheduledAnimations.remove(it); |
| 114 } | 114 } |
| 115 | 115 |
| 116 bool SMILTimeContainer::hasAnimations() const { | 116 bool SMILTimeContainer::hasAnimations() const { |
| 117 return !m_scheduledAnimations.isEmpty(); | 117 return !m_scheduledAnimations.isEmpty(); |
| 118 } | 118 } |
| 119 | 119 |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 264 } | 264 } |
| 265 | 265 |
| 266 void SMILTimeContainer::cancelAnimationFrame() { | 266 void SMILTimeContainer::cancelAnimationFrame() { |
| 267 m_frameSchedulingState = Idle; | 267 m_frameSchedulingState = Idle; |
| 268 m_wakeupTimer.stop(); | 268 m_wakeupTimer.stop(); |
| 269 } | 269 } |
| 270 | 270 |
| 271 void SMILTimeContainer::scheduleWakeUp( | 271 void SMILTimeContainer::scheduleWakeUp( |
| 272 double delayTime, | 272 double delayTime, |
| 273 FrameSchedulingState frameSchedulingState) { | 273 FrameSchedulingState frameSchedulingState) { |
| 274 ASSERT(frameSchedulingState == SynchronizeAnimations || | 274 DCHECK(frameSchedulingState == SynchronizeAnimations || |
| 275 frameSchedulingState == FutureAnimationFrame); | 275 frameSchedulingState == FutureAnimationFrame); |
| 276 m_wakeupTimer.startOneShot(delayTime, BLINK_FROM_HERE); | 276 m_wakeupTimer.startOneShot(delayTime, BLINK_FROM_HERE); |
| 277 m_frameSchedulingState = frameSchedulingState; | 277 m_frameSchedulingState = frameSchedulingState; |
| 278 } | 278 } |
| 279 | 279 |
| 280 void SMILTimeContainer::wakeupTimerFired(TimerBase*) { | 280 void SMILTimeContainer::wakeupTimerFired(TimerBase*) { |
| 281 ASSERT(m_frameSchedulingState == SynchronizeAnimations || | 281 DCHECK(m_frameSchedulingState == SynchronizeAnimations || |
| 282 m_frameSchedulingState == FutureAnimationFrame); | 282 m_frameSchedulingState == FutureAnimationFrame); |
| 283 if (m_frameSchedulingState == FutureAnimationFrame) { | 283 if (m_frameSchedulingState == FutureAnimationFrame) { |
| 284 ASSERT(isTimelineRunning()); | 284 DCHECK(isTimelineRunning()); |
| 285 m_frameSchedulingState = Idle; | 285 m_frameSchedulingState = Idle; |
| 286 serviceOnNextFrame(); | 286 serviceOnNextFrame(); |
| 287 } else { | 287 } else { |
| 288 m_frameSchedulingState = Idle; | 288 m_frameSchedulingState = Idle; |
| 289 updateAnimationsAndScheduleFrameIfNeeded(elapsed()); | 289 updateAnimationsAndScheduleFrameIfNeeded(elapsed()); |
| 290 } | 290 } |
| 291 } | 291 } |
| 292 | 292 |
| 293 void SMILTimeContainer::scheduleAnimationPolicyTimer() { | 293 void SMILTimeContainer::scheduleAnimationPolicyTimer() { |
| 294 m_animationPolicyOnceTimer.startOneShot(animationPolicyOnceDuration, | 294 m_animationPolicyOnceTimer.startOneShot(animationPolicyOnceDuration, |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 412 return; | 412 return; |
| 413 | 413 |
| 414 SMILTime earliestFireTime = updateAnimations(elapsed, seekToTime); | 414 SMILTime earliestFireTime = updateAnimations(elapsed, seekToTime); |
| 415 if (!canScheduleFrame(earliestFireTime)) | 415 if (!canScheduleFrame(earliestFireTime)) |
| 416 return; | 416 return; |
| 417 double delayTime = earliestFireTime.value() - elapsed; | 417 double delayTime = earliestFireTime.value() - elapsed; |
| 418 scheduleAnimationFrame(delayTime); | 418 scheduleAnimationFrame(delayTime); |
| 419 } | 419 } |
| 420 | 420 |
| 421 SMILTime SMILTimeContainer::updateAnimations(double elapsed, bool seekToTime) { | 421 SMILTime SMILTimeContainer::updateAnimations(double elapsed, bool seekToTime) { |
| 422 ASSERT(document().isActive()); | 422 DCHECK(document().isActive()); |
| 423 SMILTime earliestFireTime = SMILTime::unresolved(); | 423 SMILTime earliestFireTime = SMILTime::unresolved(); |
| 424 | 424 |
| 425 #if DCHECK_IS_ON() | 425 #if DCHECK_IS_ON() |
| 426 // This boolean will catch any attempts to schedule/unschedule | 426 // This boolean will catch any attempts to schedule/unschedule |
| 427 // scheduledAnimations during this critical section. Similarly, any elements | 427 // scheduledAnimations during this critical section. Similarly, any elements |
| 428 // removed will unschedule themselves, so this will catch modification of | 428 // removed will unschedule themselves, so this will catch modification of |
| 429 // animationsToApply. | 429 // animationsToApply. |
| 430 m_preventScheduledAnimationsChanges = true; | 430 m_preventScheduledAnimationsChanges = true; |
| 431 #endif | 431 #endif |
| 432 | 432 |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 529 void SMILTimeContainer::advanceFrameForTesting() { | 529 void SMILTimeContainer::advanceFrameForTesting() { |
| 530 setElapsed(elapsed() + initialFrameDelay); | 530 setElapsed(elapsed() + initialFrameDelay); |
| 531 } | 531 } |
| 532 | 532 |
| 533 DEFINE_TRACE(SMILTimeContainer) { | 533 DEFINE_TRACE(SMILTimeContainer) { |
| 534 visitor->trace(m_scheduledAnimations); | 534 visitor->trace(m_scheduledAnimations); |
| 535 visitor->trace(m_ownerSVGElement); | 535 visitor->trace(m_ownerSVGElement); |
| 536 } | 536 } |
| 537 | 537 |
| 538 } // namespace blink | 538 } // namespace blink |
| OLD | NEW |