| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 SMILTimeContainer::SMILTimeContainer(SVGSVGElement& owner) | 52 SMILTimeContainer::SMILTimeContainer(SVGSVGElement& owner) |
| 53 : m_beginTime(0) | 53 : m_beginTime(0) |
| 54 , m_pauseTime(0) | 54 , m_pauseTime(0) |
| 55 , m_resumeTime(0) | 55 , m_resumeTime(0) |
| 56 , m_accumulatedActiveTime(0) | 56 , m_accumulatedActiveTime(0) |
| 57 , m_presetStartTime(0) | 57 , m_presetStartTime(0) |
| 58 , m_frameSchedulingState(Idle) | 58 , m_frameSchedulingState(Idle) |
| 59 , m_documentOrderIndexesDirty(false) | 59 , m_documentOrderIndexesDirty(false) |
| 60 , m_wakeupTimer(this, &SMILTimeContainer::wakeupTimerFired) | 60 , m_wakeupTimer(this, &SMILTimeContainer::wakeupTimerFired) |
| 61 , m_ownerSVGElement(owner) | 61 , m_ownerSVGElement(owner) |
| 62 #ifndef NDEBUG | 62 #if ENABLE(ASSERT) |
| 63 , m_preventScheduledAnimationsChanges(false) | 63 , m_preventScheduledAnimationsChanges(false) |
| 64 #endif | 64 #endif |
| 65 { | 65 { |
| 66 } | 66 } |
| 67 | 67 |
| 68 SMILTimeContainer::~SMILTimeContainer() | 68 SMILTimeContainer::~SMILTimeContainer() |
| 69 { | 69 { |
| 70 cancelAnimationFrame(); | 70 cancelAnimationFrame(); |
| 71 ASSERT(!m_wakeupTimer.isActive()); | 71 ASSERT(!m_wakeupTimer.isActive()); |
| 72 #ifndef NDEBUG | 72 #if ENABLE(ASSERT) |
| 73 ASSERT(!m_preventScheduledAnimationsChanges); | 73 ASSERT(!m_preventScheduledAnimationsChanges); |
| 74 #endif | 74 #endif |
| 75 } | 75 } |
| 76 | 76 |
| 77 void SMILTimeContainer::schedule(SVGSMILElement* animation, SVGElement* target,
const QualifiedName& attributeName) | 77 void SMILTimeContainer::schedule(SVGSMILElement* animation, SVGElement* target,
const QualifiedName& attributeName) |
| 78 { | 78 { |
| 79 ASSERT(animation->timeContainer() == this); | 79 ASSERT(animation->timeContainer() == this); |
| 80 ASSERT(target); | 80 ASSERT(target); |
| 81 ASSERT(animation->hasValidAttributeName()); | 81 ASSERT(animation->hasValidAttributeName()); |
| 82 | 82 |
| 83 #ifndef NDEBUG | 83 #if ENABLE(ASSERT) |
| 84 ASSERT(!m_preventScheduledAnimationsChanges); | 84 ASSERT(!m_preventScheduledAnimationsChanges); |
| 85 #endif | 85 #endif |
| 86 | 86 |
| 87 ElementAttributePair key(target, attributeName); | 87 ElementAttributePair key(target, attributeName); |
| 88 OwnPtrWillBeMember<AnimationsLinkedHashSet>& scheduled = m_scheduledAnimatio
ns.add(key, nullptr).storedValue->value; | 88 OwnPtrWillBeMember<AnimationsLinkedHashSet>& scheduled = m_scheduledAnimatio
ns.add(key, nullptr).storedValue->value; |
| 89 if (!scheduled) | 89 if (!scheduled) |
| 90 scheduled = adoptPtrWillBeNoop(new AnimationsLinkedHashSet); | 90 scheduled = adoptPtrWillBeNoop(new AnimationsLinkedHashSet); |
| 91 ASSERT(!scheduled->contains(animation)); | 91 ASSERT(!scheduled->contains(animation)); |
| 92 scheduled->add(animation); | 92 scheduled->add(animation); |
| 93 | 93 |
| 94 SMILTime nextFireTime = animation->nextProgressTime(); | 94 SMILTime nextFireTime = animation->nextProgressTime(); |
| 95 if (nextFireTime.isFinite()) | 95 if (nextFireTime.isFinite()) |
| 96 notifyIntervalsChanged(); | 96 notifyIntervalsChanged(); |
| 97 } | 97 } |
| 98 | 98 |
| 99 void SMILTimeContainer::unschedule(SVGSMILElement* animation, SVGElement* target
, const QualifiedName& attributeName) | 99 void SMILTimeContainer::unschedule(SVGSMILElement* animation, SVGElement* target
, const QualifiedName& attributeName) |
| 100 { | 100 { |
| 101 ASSERT(animation->timeContainer() == this); | 101 ASSERT(animation->timeContainer() == this); |
| 102 | 102 |
| 103 #ifndef NDEBUG | 103 #if ENABLE(ASSERT) |
| 104 ASSERT(!m_preventScheduledAnimationsChanges); | 104 ASSERT(!m_preventScheduledAnimationsChanges); |
| 105 #endif | 105 #endif |
| 106 | 106 |
| 107 ElementAttributePair key(target, attributeName); | 107 ElementAttributePair key(target, attributeName); |
| 108 GroupedAnimationsMap::iterator it = m_scheduledAnimations.find(key); | 108 GroupedAnimationsMap::iterator it = m_scheduledAnimations.find(key); |
| 109 ASSERT(it != m_scheduledAnimations.end()); | 109 ASSERT(it != m_scheduledAnimations.end()); |
| 110 AnimationsLinkedHashSet* scheduled = it->value.get(); | 110 AnimationsLinkedHashSet* scheduled = it->value.get(); |
| 111 ASSERT(scheduled); | 111 ASSERT(scheduled); |
| 112 AnimationsLinkedHashSet::iterator itAnimation = scheduled->find(animation); | 112 AnimationsLinkedHashSet::iterator itAnimation = scheduled->find(animation); |
| 113 ASSERT(itAnimation != scheduled->end()); | 113 ASSERT(itAnimation != scheduled->end()); |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 double now = currentTime(); | 226 double now = currentTime(); |
| 227 m_beginTime = now - time.value(); | 227 m_beginTime = now - time.value(); |
| 228 m_resumeTime = 0; | 228 m_resumeTime = 0; |
| 229 if (m_pauseTime) { | 229 if (m_pauseTime) { |
| 230 m_pauseTime = now; | 230 m_pauseTime = now; |
| 231 m_accumulatedActiveTime = time.value(); | 231 m_accumulatedActiveTime = time.value(); |
| 232 } else { | 232 } else { |
| 233 m_accumulatedActiveTime = 0; | 233 m_accumulatedActiveTime = 0; |
| 234 } | 234 } |
| 235 | 235 |
| 236 #ifndef NDEBUG | 236 #if ENABLE(ASSERT) |
| 237 m_preventScheduledAnimationsChanges = true; | 237 m_preventScheduledAnimationsChanges = true; |
| 238 #endif | 238 #endif |
| 239 GroupedAnimationsMap::iterator end = m_scheduledAnimations.end(); | 239 GroupedAnimationsMap::iterator end = m_scheduledAnimations.end(); |
| 240 for (GroupedAnimationsMap::iterator it = m_scheduledAnimations.begin(); it !
= end; ++it) { | 240 for (GroupedAnimationsMap::iterator it = m_scheduledAnimations.begin(); it !
= end; ++it) { |
| 241 if (!it->key.first) | 241 if (!it->key.first) |
| 242 continue; | 242 continue; |
| 243 | 243 |
| 244 AnimationsLinkedHashSet* scheduled = it->value.get(); | 244 AnimationsLinkedHashSet* scheduled = it->value.get(); |
| 245 for (AnimationsLinkedHashSet::const_iterator itAnimation = scheduled->be
gin(), itAnimationEnd = scheduled->end(); itAnimation != itAnimationEnd; ++itAni
mation) | 245 for (AnimationsLinkedHashSet::const_iterator itAnimation = scheduled->be
gin(), itAnimationEnd = scheduled->end(); itAnimation != itAnimationEnd; ++itAni
mation) |
| 246 (*itAnimation)->reset(); | 246 (*itAnimation)->reset(); |
| 247 } | 247 } |
| 248 #ifndef NDEBUG | 248 #if ENABLE(ASSERT) |
| 249 m_preventScheduledAnimationsChanges = false; | 249 m_preventScheduledAnimationsChanges = false; |
| 250 #endif | 250 #endif |
| 251 | 251 |
| 252 updateAnimationsAndScheduleFrameIfNeeded(time, true); | 252 updateAnimationsAndScheduleFrameIfNeeded(time, true); |
| 253 } | 253 } |
| 254 | 254 |
| 255 bool SMILTimeContainer::isTimelineRunning() const | 255 bool SMILTimeContainer::isTimelineRunning() const |
| 256 { | 256 { |
| 257 return m_beginTime && !isPaused(); | 257 return m_beginTime && !isPaused(); |
| 258 } | 258 } |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 if (!earliestFireTime.isFinite()) | 365 if (!earliestFireTime.isFinite()) |
| 366 return; | 366 return; |
| 367 | 367 |
| 368 scheduleAnimationFrame(earliestFireTime); | 368 scheduleAnimationFrame(earliestFireTime); |
| 369 } | 369 } |
| 370 | 370 |
| 371 SMILTime SMILTimeContainer::updateAnimations(SMILTime elapsed, bool seekToTime) | 371 SMILTime SMILTimeContainer::updateAnimations(SMILTime elapsed, bool seekToTime) |
| 372 { | 372 { |
| 373 SMILTime earliestFireTime = SMILTime::unresolved(); | 373 SMILTime earliestFireTime = SMILTime::unresolved(); |
| 374 | 374 |
| 375 #ifndef NDEBUG | 375 #if ENABLE(ASSERT) |
| 376 // This boolean will catch any attempts to schedule/unschedule scheduledAnim
ations during this critical section. | 376 // This boolean will catch any attempts to schedule/unschedule scheduledAnim
ations during this critical section. |
| 377 // Similarly, any elements removed will unschedule themselves, so this will
catch modification of animationsToApply. | 377 // Similarly, any elements removed will unschedule themselves, so this will
catch modification of animationsToApply. |
| 378 m_preventScheduledAnimationsChanges = true; | 378 m_preventScheduledAnimationsChanges = true; |
| 379 #endif | 379 #endif |
| 380 | 380 |
| 381 if (m_documentOrderIndexesDirty) | 381 if (m_documentOrderIndexesDirty) |
| 382 updateDocumentOrderIndexes(); | 382 updateDocumentOrderIndexes(); |
| 383 | 383 |
| 384 WillBeHeapHashSet<ElementAttributePair> invalidKeys; | 384 WillBeHeapHashSet<ElementAttributePair> invalidKeys; |
| 385 typedef WillBeHeapVector<RefPtrWillBeMember<SVGSMILElement> > AnimationsVect
or; | 385 typedef WillBeHeapVector<RefPtrWillBeMember<SVGSMILElement> > AnimationsVect
or; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 426 | 426 |
| 427 if (resultElement) | 427 if (resultElement) |
| 428 animationsToApply.append(resultElement); | 428 animationsToApply.append(resultElement); |
| 429 } | 429 } |
| 430 m_scheduledAnimations.removeAll(invalidKeys); | 430 m_scheduledAnimations.removeAll(invalidKeys); |
| 431 | 431 |
| 432 std::sort(animationsToApply.begin(), animationsToApply.end(), PriorityCompar
e(elapsed)); | 432 std::sort(animationsToApply.begin(), animationsToApply.end(), PriorityCompar
e(elapsed)); |
| 433 | 433 |
| 434 unsigned animationsToApplySize = animationsToApply.size(); | 434 unsigned animationsToApplySize = animationsToApply.size(); |
| 435 if (!animationsToApplySize) { | 435 if (!animationsToApplySize) { |
| 436 #ifndef NDEBUG | 436 #if ENABLE(ASSERT) |
| 437 m_preventScheduledAnimationsChanges = false; | 437 m_preventScheduledAnimationsChanges = false; |
| 438 #endif | 438 #endif |
| 439 return earliestFireTime; | 439 return earliestFireTime; |
| 440 } | 440 } |
| 441 | 441 |
| 442 // Apply results to target elements. | 442 // Apply results to target elements. |
| 443 for (unsigned i = 0; i < animationsToApplySize; ++i) | 443 for (unsigned i = 0; i < animationsToApplySize; ++i) |
| 444 animationsToApply[i]->applyResultsToTarget(); | 444 animationsToApply[i]->applyResultsToTarget(); |
| 445 | 445 |
| 446 #ifndef NDEBUG | 446 #if ENABLE(ASSERT) |
| 447 m_preventScheduledAnimationsChanges = false; | 447 m_preventScheduledAnimationsChanges = false; |
| 448 #endif | 448 #endif |
| 449 | 449 |
| 450 for (unsigned i = 0; i < animationsToApplySize; ++i) { | 450 for (unsigned i = 0; i < animationsToApplySize; ++i) { |
| 451 if (animationsToApply[i]->inDocument() && animationsToApply[i]->isSVGDis
cardElement()) { | 451 if (animationsToApply[i]->inDocument() && animationsToApply[i]->isSVGDis
cardElement()) { |
| 452 RefPtrWillBeRawPtr<SVGSMILElement> animDiscard = animationsToApply[i
]; | 452 RefPtrWillBeRawPtr<SVGSMILElement> animDiscard = animationsToApply[i
]; |
| 453 RefPtrWillBeRawPtr<SVGElement> targetElement = animDiscard->targetEl
ement(); | 453 RefPtrWillBeRawPtr<SVGElement> targetElement = animDiscard->targetEl
ement(); |
| 454 if (targetElement && targetElement->inDocument()) { | 454 if (targetElement && targetElement->inDocument()) { |
| 455 targetElement->remove(IGNORE_EXCEPTION); | 455 targetElement->remove(IGNORE_EXCEPTION); |
| 456 ASSERT(!targetElement->inDocument()); | 456 ASSERT(!targetElement->inDocument()); |
| 457 } | 457 } |
| 458 | 458 |
| 459 if (animDiscard->inDocument()) { | 459 if (animDiscard->inDocument()) { |
| 460 animDiscard->remove(IGNORE_EXCEPTION); | 460 animDiscard->remove(IGNORE_EXCEPTION); |
| 461 ASSERT(!animDiscard->inDocument()); | 461 ASSERT(!animDiscard->inDocument()); |
| 462 } | 462 } |
| 463 } | 463 } |
| 464 } | 464 } |
| 465 return earliestFireTime; | 465 return earliestFireTime; |
| 466 } | 466 } |
| 467 | 467 |
| 468 void SMILTimeContainer::trace(Visitor* visitor) | 468 void SMILTimeContainer::trace(Visitor* visitor) |
| 469 { | 469 { |
| 470 visitor->trace(m_scheduledAnimations); | 470 visitor->trace(m_scheduledAnimations); |
| 471 } | 471 } |
| 472 | 472 |
| 473 } | 473 } |
| OLD | NEW |