| 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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 ASSERT(target); | 84 ASSERT(target); |
| 85 ASSERT(animation->hasValidAttributeName()); | 85 ASSERT(animation->hasValidAttributeName()); |
| 86 ASSERT(animation->hasValidAttributeType()); | 86 ASSERT(animation->hasValidAttributeType()); |
| 87 ASSERT(animation->inActiveDocument()); | 87 ASSERT(animation->inActiveDocument()); |
| 88 | 88 |
| 89 #if ENABLE(ASSERT) | 89 #if ENABLE(ASSERT) |
| 90 ASSERT(!m_preventScheduledAnimationsChanges); | 90 ASSERT(!m_preventScheduledAnimationsChanges); |
| 91 #endif | 91 #endif |
| 92 | 92 |
| 93 ElementAttributePair key(target, attributeName); | 93 ElementAttributePair key(target, attributeName); |
| 94 OwnPtrWillBeMember<AnimationsLinkedHashSet>& scheduled = m_scheduledAnimatio
ns.add(key, nullptr).storedValue->value; | 94 Member<AnimationsLinkedHashSet>& scheduled = m_scheduledAnimations.add(key,
nullptr).storedValue->value; |
| 95 if (!scheduled) | 95 if (!scheduled) |
| 96 scheduled = adoptPtrWillBeNoop(new AnimationsLinkedHashSet); | 96 scheduled = (new AnimationsLinkedHashSet); |
| 97 ASSERT(!scheduled->contains(animation)); | 97 ASSERT(!scheduled->contains(animation)); |
| 98 scheduled->add(animation); | 98 scheduled->add(animation); |
| 99 | 99 |
| 100 SMILTime nextFireTime = animation->nextProgressTime(); | 100 SMILTime nextFireTime = animation->nextProgressTime(); |
| 101 if (nextFireTime.isFinite()) | 101 if (nextFireTime.isFinite()) |
| 102 notifyIntervalsChanged(); | 102 notifyIntervalsChanged(); |
| 103 } | 103 } |
| 104 | 104 |
| 105 void SMILTimeContainer::unschedule(SVGSMILElement* animation, SVGElement* target
, const QualifiedName& attributeName) | 105 void SMILTimeContainer::unschedule(SVGSMILElement* animation, SVGElement* target
, const QualifiedName& attributeName) |
| 106 { | 106 { |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 void SMILTimeContainer::updateDocumentOrderIndexes() | 379 void SMILTimeContainer::updateDocumentOrderIndexes() |
| 380 { | 380 { |
| 381 unsigned timingElementCount = 0; | 381 unsigned timingElementCount = 0; |
| 382 for (SVGSMILElement& element : Traversal<SVGSMILElement>::descendantsOf(owne
rSVGElement())) | 382 for (SVGSMILElement& element : Traversal<SVGSMILElement>::descendantsOf(owne
rSVGElement())) |
| 383 element.setDocumentOrderIndex(timingElementCount++); | 383 element.setDocumentOrderIndex(timingElementCount++); |
| 384 m_documentOrderIndexesDirty = false; | 384 m_documentOrderIndexesDirty = false; |
| 385 } | 385 } |
| 386 | 386 |
| 387 struct PriorityCompare { | 387 struct PriorityCompare { |
| 388 PriorityCompare(SMILTime elapsed) : m_elapsed(elapsed) {} | 388 PriorityCompare(SMILTime elapsed) : m_elapsed(elapsed) {} |
| 389 bool operator()(const RefPtrWillBeMember<SVGSMILElement>& a, const RefPtrWil
lBeMember<SVGSMILElement>& b) | 389 bool operator()(const Member<SVGSMILElement>& a, const Member<SVGSMILElement
>& b) |
| 390 { | 390 { |
| 391 // FIXME: This should also consider possible timing relations between th
e elements. | 391 // FIXME: This should also consider possible timing relations between th
e elements. |
| 392 SMILTime aBegin = a->intervalBegin(); | 392 SMILTime aBegin = a->intervalBegin(); |
| 393 SMILTime bBegin = b->intervalBegin(); | 393 SMILTime bBegin = b->intervalBegin(); |
| 394 // Frozen elements need to be prioritized based on their previous interv
al. | 394 // Frozen elements need to be prioritized based on their previous interv
al. |
| 395 aBegin = a->isFrozen() && m_elapsed < aBegin ? a->previousIntervalBegin(
) : aBegin; | 395 aBegin = a->isFrozen() && m_elapsed < aBegin ? a->previousIntervalBegin(
) : aBegin; |
| 396 bBegin = b->isFrozen() && m_elapsed < bBegin ? b->previousIntervalBegin(
) : bBegin; | 396 bBegin = b->isFrozen() && m_elapsed < bBegin ? b->previousIntervalBegin(
) : bBegin; |
| 397 if (aBegin == bBegin) | 397 if (aBegin == bBegin) |
| 398 return a->documentOrderIndex() < b->documentOrderIndex(); | 398 return a->documentOrderIndex() < b->documentOrderIndex(); |
| 399 return aBegin < bBegin; | 399 return aBegin < bBegin; |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 463 | 463 |
| 464 #if ENABLE(ASSERT) | 464 #if ENABLE(ASSERT) |
| 465 // This boolean will catch any attempts to schedule/unschedule scheduledAnim
ations during this critical section. | 465 // This boolean will catch any attempts to schedule/unschedule scheduledAnim
ations during this critical section. |
| 466 // Similarly, any elements removed will unschedule themselves, so this will
catch modification of animationsToApply. | 466 // Similarly, any elements removed will unschedule themselves, so this will
catch modification of animationsToApply. |
| 467 m_preventScheduledAnimationsChanges = true; | 467 m_preventScheduledAnimationsChanges = true; |
| 468 #endif | 468 #endif |
| 469 | 469 |
| 470 if (m_documentOrderIndexesDirty) | 470 if (m_documentOrderIndexesDirty) |
| 471 updateDocumentOrderIndexes(); | 471 updateDocumentOrderIndexes(); |
| 472 | 472 |
| 473 WillBeHeapHashSet<ElementAttributePair> invalidKeys; | 473 HeapHashSet<ElementAttributePair> invalidKeys; |
| 474 using AnimationsVector = WillBeHeapVector<RefPtrWillBeMember<SVGSMILElement>
>; | 474 using AnimationsVector = HeapVector<Member<SVGSMILElement>>; |
| 475 AnimationsVector animationsToApply; | 475 AnimationsVector animationsToApply; |
| 476 AnimationsVector scheduledAnimationsInSameGroup; | 476 AnimationsVector scheduledAnimationsInSameGroup; |
| 477 for (const auto& entry : m_scheduledAnimations) { | 477 for (const auto& entry : m_scheduledAnimations) { |
| 478 if (!entry.key.first || entry.value->isEmpty()) { | 478 if (!entry.key.first || entry.value->isEmpty()) { |
| 479 invalidKeys.add(entry.key); | 479 invalidKeys.add(entry.key); |
| 480 continue; | 480 continue; |
| 481 } | 481 } |
| 482 | 482 |
| 483 // Sort according to priority. Elements with later begin time have highe
r priority. | 483 // Sort according to priority. Elements with later begin time have highe
r priority. |
| 484 // In case of a tie, document order decides. | 484 // In case of a tie, document order decides. |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 526 // Apply results to target elements. | 526 // Apply results to target elements. |
| 527 for (unsigned i = 0; i < animationsToApplySize; ++i) | 527 for (unsigned i = 0; i < animationsToApplySize; ++i) |
| 528 animationsToApply[i]->applyResultsToTarget(); | 528 animationsToApply[i]->applyResultsToTarget(); |
| 529 | 529 |
| 530 #if ENABLE(ASSERT) | 530 #if ENABLE(ASSERT) |
| 531 m_preventScheduledAnimationsChanges = false; | 531 m_preventScheduledAnimationsChanges = false; |
| 532 #endif | 532 #endif |
| 533 | 533 |
| 534 for (unsigned i = 0; i < animationsToApplySize; ++i) { | 534 for (unsigned i = 0; i < animationsToApplySize; ++i) { |
| 535 if (animationsToApply[i]->inDocument() && animationsToApply[i]->isSVGDis
cardElement()) { | 535 if (animationsToApply[i]->inDocument() && animationsToApply[i]->isSVGDis
cardElement()) { |
| 536 RefPtrWillBeRawPtr<SVGSMILElement> animDiscard = animationsToApply[i
]; | 536 RawPtr<SVGSMILElement> animDiscard = animationsToApply[i]; |
| 537 RefPtrWillBeRawPtr<SVGElement> targetElement = animDiscard->targetEl
ement(); | 537 RawPtr<SVGElement> targetElement = animDiscard->targetElement(); |
| 538 if (targetElement && targetElement->inDocument()) { | 538 if (targetElement && targetElement->inDocument()) { |
| 539 targetElement->remove(IGNORE_EXCEPTION); | 539 targetElement->remove(IGNORE_EXCEPTION); |
| 540 ASSERT(!targetElement->inDocument()); | 540 ASSERT(!targetElement->inDocument()); |
| 541 } | 541 } |
| 542 | 542 |
| 543 if (animDiscard->inDocument()) { | 543 if (animDiscard->inDocument()) { |
| 544 animDiscard->remove(IGNORE_EXCEPTION); | 544 animDiscard->remove(IGNORE_EXCEPTION); |
| 545 ASSERT(!animDiscard->inDocument()); | 545 ASSERT(!animDiscard->inDocument()); |
| 546 } | 546 } |
| 547 } | 547 } |
| 548 } | 548 } |
| 549 return earliestFireTime; | 549 return earliestFireTime; |
| 550 } | 550 } |
| 551 | 551 |
| 552 void SMILTimeContainer::advanceFrameForTesting() | 552 void SMILTimeContainer::advanceFrameForTesting() |
| 553 { | 553 { |
| 554 setElapsed(elapsed().value() + initialFrameDelay); | 554 setElapsed(elapsed().value() + initialFrameDelay); |
| 555 } | 555 } |
| 556 | 556 |
| 557 DEFINE_TRACE(SMILTimeContainer) | 557 DEFINE_TRACE(SMILTimeContainer) |
| 558 { | 558 { |
| 559 #if ENABLE(OILPAN) | 559 #if ENABLE(OILPAN) |
| 560 visitor->trace(m_scheduledAnimations); | 560 visitor->trace(m_scheduledAnimations); |
| 561 #endif | 561 #endif |
| 562 visitor->trace(m_ownerSVGElement); | 562 visitor->trace(m_ownerSVGElement); |
| 563 } | 563 } |
| 564 | 564 |
| 565 } // namespace blink | 565 } // namespace blink |
| OLD | NEW |