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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
80 { | 80 { |
81 ASSERT(animation->timeContainer() == this); | 81 ASSERT(animation->timeContainer() == this); |
82 ASSERT(target); | 82 ASSERT(target); |
83 ASSERT(animation->hasValidAttributeName()); | 83 ASSERT(animation->hasValidAttributeName()); |
84 | 84 |
85 #ifndef NDEBUG | 85 #ifndef NDEBUG |
86 ASSERT(!m_preventScheduledAnimationsChanges); | 86 ASSERT(!m_preventScheduledAnimationsChanges); |
87 #endif | 87 #endif |
88 | 88 |
89 ElementAttributePair key(target, attributeName); | 89 ElementAttributePair key(target, attributeName); |
90 OwnPtr<AnimationsVector>& scheduled = m_scheduledAnimations.add(key, nullptr ).storedValue->value; | 90 OwnPtrWillBeMember<AnimationsLinkedHashSet>& scheduled = m_scheduledAnimatio ns.add(key, nullptr).storedValue->value; |
91 if (!scheduled) | 91 if (!scheduled) |
92 scheduled = adoptPtr(new AnimationsVector); | 92 scheduled = adoptPtrWillBeNoop(new AnimationsLinkedHashSet); |
93 ASSERT(!scheduled->contains(animation)); | 93 ASSERT(!scheduled->contains(animation)); |
94 scheduled->append(animation); | 94 scheduled->add(animation); |
95 | 95 |
96 SMILTime nextFireTime = animation->nextProgressTime(); | 96 SMILTime nextFireTime = animation->nextProgressTime(); |
97 if (nextFireTime.isFinite()) | 97 if (nextFireTime.isFinite()) |
98 notifyIntervalsChanged(); | 98 notifyIntervalsChanged(); |
99 } | 99 } |
100 | 100 |
101 void SMILTimeContainer::unschedule(SVGSMILElement* animation, SVGElement* target , const QualifiedName& attributeName) | 101 void SMILTimeContainer::unschedule(SVGSMILElement* animation, SVGElement* target , const QualifiedName& attributeName) |
102 { | 102 { |
103 ASSERT(animation->timeContainer() == this); | 103 ASSERT(animation->timeContainer() == this); |
104 | 104 |
105 #ifndef NDEBUG | 105 #ifndef NDEBUG |
106 ASSERT(!m_preventScheduledAnimationsChanges); | 106 ASSERT(!m_preventScheduledAnimationsChanges); |
107 #endif | 107 #endif |
108 | 108 |
109 ElementAttributePair key(target, attributeName); | 109 ElementAttributePair key(target, attributeName); |
110 AnimationsVector* scheduled = m_scheduledAnimations.get(key); | 110 GroupedAnimationsMap::iterator it = m_scheduledAnimations.find(key); |
111 ASSERT(it != m_scheduledAnimations.end()); | |
112 AnimationsLinkedHashSet* scheduled = it->value; | |
111 ASSERT(scheduled); | 113 ASSERT(scheduled); |
112 size_t idx = scheduled->find(animation); | 114 AnimationsLinkedHashSet::iterator itAnimation = scheduled->find(animation); |
113 ASSERT(idx != kNotFound); | 115 ASSERT(itAnimation != scheduled->end()); |
114 scheduled->remove(idx); | 116 scheduled->remove(itAnimation); |
117 | |
118 if (scheduled->isEmpty()) | |
119 m_scheduledAnimations.remove(it); | |
haraken
2014/05/27 08:25:56
Just help me understand: Having this remove() look
kouhei (in TOK)
2014/05/27 08:50:51
I believe the invalid pointer was just there, but
| |
115 } | 120 } |
116 | 121 |
117 bool SMILTimeContainer::hasAnimations() const | 122 bool SMILTimeContainer::hasAnimations() const |
118 { | 123 { |
119 return !m_scheduledAnimations.isEmpty(); | 124 return !m_scheduledAnimations.isEmpty(); |
120 } | 125 } |
121 | 126 |
122 bool SMILTimeContainer::hasPendingSynchronization() const | 127 bool SMILTimeContainer::hasPendingSynchronization() const |
123 { | 128 { |
124 return m_frameSchedulingState == SynchronizeAnimations && m_wakeupTimer.isAc tive() && !m_wakeupTimer.nextFireInterval(); | 129 return m_frameSchedulingState == SynchronizeAnimations && m_wakeupTimer.isAc tive() && !m_wakeupTimer.nextFireInterval(); |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
227 m_pauseTime = now; | 232 m_pauseTime = now; |
228 m_accumulatedActiveTime = time.value(); | 233 m_accumulatedActiveTime = time.value(); |
229 } else { | 234 } else { |
230 m_accumulatedActiveTime = 0; | 235 m_accumulatedActiveTime = 0; |
231 } | 236 } |
232 | 237 |
233 #ifndef NDEBUG | 238 #ifndef NDEBUG |
234 m_preventScheduledAnimationsChanges = true; | 239 m_preventScheduledAnimationsChanges = true; |
235 #endif | 240 #endif |
236 GroupedAnimationsMap::iterator end = m_scheduledAnimations.end(); | 241 GroupedAnimationsMap::iterator end = m_scheduledAnimations.end(); |
237 for (GroupedAnimationsMap::iterator it = m_scheduledAnimations.begin(); it ! = end; ++it) { | 242 for (GroupedAnimationsMap::iterator it = m_scheduledAnimations.begin(); it ! = end; ++it) { |
Erik Corry
2014/05/27 08:55:23
I think you should check for null keys here too.
kouhei (in TOK)
2014/05/28 01:00:50
Done.
| |
238 AnimationsVector* scheduled = it->value.get(); | 243 AnimationsLinkedHashSet* scheduled = it->value.get(); |
239 unsigned size = scheduled->size(); | 244 for (AnimationsLinkedHashSet::const_iterator itAnimation = scheduled->be gin(), itAnimationEnd = scheduled->end(); itAnimation != itAnimationEnd; ++itAni mation) |
240 for (unsigned n = 0; n < size; n++) | 245 (*itAnimation)->reset(); |
241 scheduled->at(n)->reset(); | |
242 } | 246 } |
243 #ifndef NDEBUG | 247 #ifndef NDEBUG |
244 m_preventScheduledAnimationsChanges = false; | 248 m_preventScheduledAnimationsChanges = false; |
245 #endif | 249 #endif |
246 | 250 |
247 updateAnimationsAndScheduleFrameIfNeeded(time, true); | 251 updateAnimationsAndScheduleFrameIfNeeded(time, true); |
248 } | 252 } |
249 | 253 |
250 bool SMILTimeContainer::isTimelineRunning() const | 254 bool SMILTimeContainer::isTimelineRunning() const |
251 { | 255 { |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
369 | 373 |
370 #ifndef NDEBUG | 374 #ifndef NDEBUG |
371 // This boolean will catch any attempts to schedule/unschedule scheduledAnim ations during this critical section. | 375 // This boolean will catch any attempts to schedule/unschedule scheduledAnim ations during this critical section. |
372 // Similarly, any elements removed will unschedule themselves, so this will catch modification of animationsToApply. | 376 // Similarly, any elements removed will unschedule themselves, so this will catch modification of animationsToApply. |
373 m_preventScheduledAnimationsChanges = true; | 377 m_preventScheduledAnimationsChanges = true; |
374 #endif | 378 #endif |
375 | 379 |
376 if (m_documentOrderIndexesDirty) | 380 if (m_documentOrderIndexesDirty) |
377 updateDocumentOrderIndexes(); | 381 updateDocumentOrderIndexes(); |
378 | 382 |
379 WillBeHeapVector<RefPtrWillBeMember<SVGSMILElement> > animationsToApply; | 383 WillBeHeapHashSet<ElementAttributePair> invalidKeys; |
380 GroupedAnimationsMap::iterator end = m_scheduledAnimations.end(); | 384 AnimationsVector animationsToApply; |
381 for (GroupedAnimationsMap::iterator it = m_scheduledAnimations.begin(); it ! = end; ++it) { | 385 for (GroupedAnimationsMap::iterator it = m_scheduledAnimations.begin(), end = m_scheduledAnimations.end(); it != end; ++it) { |
382 AnimationsVector* scheduled = it->value.get(); | 386 if (!it->key.first || !it->value || it->value->isEmpty()) |
haraken
2014/05/27 08:25:56
I don't know if we need the !it->key.first check.
Erik Corry
2014/05/27 08:41:48
No, the associated entry is not removed, that's wh
kouhei (in TOK)
2014/05/27 08:50:51
Ack.
kouhei (in TOK)
2014/05/28 01:00:50
Done.
| |
387 invalidKeys.add(it->key); | |
Erik Corry
2014/05/27 08:28:06
Should there not also be "continue;" here?
kouhei (in TOK)
2014/05/27 08:50:51
Yes! Ack.
kouhei (in TOK)
2014/05/28 01:00:50
Done.
| |
388 | |
389 AnimationsLinkedHashSet* scheduled = it->value.get(); | |
383 | 390 |
384 // Sort according to priority. Elements with later begin time have highe r priority. | 391 // Sort according to priority. Elements with later begin time have highe r priority. |
385 // In case of a tie, document order decides. | 392 // In case of a tie, document order decides. |
386 // FIXME: This should also consider timing relationships between the ele ments. Dependents | 393 // FIXME: This should also consider timing relationships between the ele ments. Dependents |
387 // have higher priority. | 394 // have higher priority. |
388 std::sort(scheduled->begin(), scheduled->end(), PriorityCompare(elapsed) ); | 395 AnimationsVector scheduledAnimations; |
396 copyToVector(*scheduled, scheduledAnimations); | |
397 std::sort(scheduledAnimations.begin(), scheduledAnimations.end(), Priori tyCompare(elapsed)); | |
389 | 398 |
390 SVGSMILElement* resultElement = 0; | 399 SVGSMILElement* resultElement = 0; |
391 unsigned size = scheduled->size(); | 400 for (AnimationsVector::const_iterator itAnimation = scheduledAnimations. begin(), itAnimationEnd = scheduledAnimations.end(); itAnimation != itAnimationE nd; ++itAnimation) { |
392 for (unsigned n = 0; n < size; n++) { | 401 SVGSMILElement* animation = *itAnimation; |
393 SVGSMILElement* animation = scheduled->at(n); | |
394 ASSERT(animation->timeContainer() == this); | 402 ASSERT(animation->timeContainer() == this); |
395 ASSERT(animation->targetElement()); | 403 ASSERT(animation->targetElement()); |
396 ASSERT(animation->hasValidAttributeName()); | 404 ASSERT(animation->hasValidAttributeName()); |
397 | 405 |
398 // Results are accumulated to the first animation that animates and contributes to a particular element/attribute pair. | 406 // Results are accumulated to the first animation that animates and contributes to a particular element/attribute pair. |
399 // FIXME: we should ensure that resultElement is of an appropriate t ype. | 407 // FIXME: we should ensure that resultElement is of an appropriate t ype. |
400 if (!resultElement) { | 408 if (!resultElement) { |
401 if (!animation->hasValidAttributeType()) | 409 if (!animation->hasValidAttributeType()) |
402 continue; | 410 continue; |
403 resultElement = animation; | 411 resultElement = animation; |
404 } | 412 } |
405 | 413 |
406 // This will calculate the contribution from the animation and add i t to the resultsElement. | 414 // This will calculate the contribution from the animation and add i t to the resultsElement. |
407 if (!animation->progress(elapsed, resultElement, seekToTime) && resu ltElement == animation) | 415 if (!animation->progress(elapsed, resultElement, seekToTime) && resu ltElement == animation) |
408 resultElement = 0; | 416 resultElement = 0; |
409 | 417 |
410 SMILTime nextFireTime = animation->nextProgressTime(); | 418 SMILTime nextFireTime = animation->nextProgressTime(); |
411 if (nextFireTime.isFinite()) | 419 if (nextFireTime.isFinite()) |
412 earliestFireTime = min(nextFireTime, earliestFireTime); | 420 earliestFireTime = min(nextFireTime, earliestFireTime); |
413 } | 421 } |
414 | 422 |
415 if (resultElement) | 423 if (resultElement) |
416 animationsToApply.append(resultElement); | 424 animationsToApply.append(resultElement); |
417 } | 425 } |
426 m_scheduledAnimations.removeAll(invalidKeys); | |
haraken
2014/05/27 08:25:56
Ditto. I'm curious how the previous code was worki
kouhei (in TOK)
2014/05/27 08:50:51
if !ENABLE(OILPAN), |unschedule| is guaranteed to
| |
418 | 427 |
419 std::sort(animationsToApply.begin(), animationsToApply.end(), PriorityCompar e(elapsed)); | 428 std::sort(animationsToApply.begin(), animationsToApply.end(), PriorityCompar e(elapsed)); |
420 | 429 |
421 unsigned animationsToApplySize = animationsToApply.size(); | 430 unsigned animationsToApplySize = animationsToApply.size(); |
422 if (!animationsToApplySize) { | 431 if (!animationsToApplySize) { |
423 #ifndef NDEBUG | 432 #ifndef NDEBUG |
424 m_preventScheduledAnimationsChanges = false; | 433 m_preventScheduledAnimationsChanges = false; |
425 #endif | 434 #endif |
426 return earliestFireTime; | 435 return earliestFireTime; |
427 } | 436 } |
(...skipping 17 matching lines...) Expand all Loading... | |
445 | 454 |
446 if (animDiscard->inDocument()) { | 455 if (animDiscard->inDocument()) { |
447 animDiscard->remove(IGNORE_EXCEPTION); | 456 animDiscard->remove(IGNORE_EXCEPTION); |
448 ASSERT(!animDiscard->inDocument()); | 457 ASSERT(!animDiscard->inDocument()); |
449 } | 458 } |
450 } | 459 } |
451 } | 460 } |
452 return earliestFireTime; | 461 return earliestFireTime; |
453 } | 462 } |
454 | 463 |
464 void SMILTimeContainer::trace(Visitor* visitor) | |
465 { | |
466 visitor->trace(m_scheduledAnimations); | |
455 } | 467 } |
468 | |
469 } | |
OLD | NEW |