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 19 matching lines...) Expand all Loading... |
30 #include "core/animation/DocumentTimeline.h" | 30 #include "core/animation/DocumentTimeline.h" |
31 #include "core/dom/ElementTraversal.h" | 31 #include "core/dom/ElementTraversal.h" |
32 #include "core/frame/FrameView.h" | 32 #include "core/frame/FrameView.h" |
33 #include "core/svg/SVGSVGElement.h" | 33 #include "core/svg/SVGSVGElement.h" |
34 #include "core/svg/animation/SVGSMILElement.h" | 34 #include "core/svg/animation/SVGSMILElement.h" |
35 | 35 |
36 using namespace std; | 36 using namespace std; |
37 | 37 |
38 namespace WebCore { | 38 namespace WebCore { |
39 | 39 |
40 SMILTimeContainer::SMILTimeContainer(SVGSVGElement* owner) | 40 SMILTimeContainer::SMILTimeContainer(SVGSVGElement& owner) |
41 : m_beginTime(0) | 41 : m_beginTime(0) |
42 , m_pauseTime(0) | 42 , m_pauseTime(0) |
43 , m_resumeTime(0) | 43 , m_resumeTime(0) |
44 , m_accumulatedActiveTime(0) | 44 , m_accumulatedActiveTime(0) |
45 , m_presetStartTime(0) | 45 , m_presetStartTime(0) |
46 , m_frameSchedulingState(Idle) | 46 , m_frameSchedulingState(Idle) |
47 , m_documentOrderIndexesDirty(false) | 47 , m_documentOrderIndexesDirty(false) |
48 , m_animationClock(AnimationClock::create()) | 48 , m_animationClock(AnimationClock::create()) |
49 , m_wakeupTimer(this, &SMILTimeContainer::wakeupTimerFired) | 49 , m_wakeupTimer(this, &SMILTimeContainer::wakeupTimerFired) |
50 , m_ownerSVGElement(owner) | 50 , m_ownerSVGElement(owner) |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 } else { | 261 } else { |
262 ASSERT(m_frameSchedulingState == SynchronizeAnimations); | 262 ASSERT(m_frameSchedulingState == SynchronizeAnimations); |
263 m_frameSchedulingState = Idle; | 263 m_frameSchedulingState = Idle; |
264 updateAnimationsAndScheduleFrameIfNeeded(elapsed()); | 264 updateAnimationsAndScheduleFrameIfNeeded(elapsed()); |
265 } | 265 } |
266 } | 266 } |
267 | 267 |
268 void SMILTimeContainer::updateDocumentOrderIndexes() | 268 void SMILTimeContainer::updateDocumentOrderIndexes() |
269 { | 269 { |
270 unsigned timingElementCount = 0; | 270 unsigned timingElementCount = 0; |
271 for (Element* element = m_ownerSVGElement; element; element = ElementTravers
al::next(*element, m_ownerSVGElement)) { | 271 for (SVGSMILElement* element = Traversal<SVGSMILElement>::firstWithin(m_owne
rSVGElement); element; element = Traversal<SVGSMILElement>::next(*element, &m_ow
nerSVGElement)) |
272 if (isSVGSMILElement(*element)) | 272 element->setDocumentOrderIndex(timingElementCount++); |
273 toSVGSMILElement(element)->setDocumentOrderIndex(timingElementCount+
+); | |
274 } | |
275 m_documentOrderIndexesDirty = false; | 273 m_documentOrderIndexesDirty = false; |
276 } | 274 } |
277 | 275 |
278 struct PriorityCompare { | 276 struct PriorityCompare { |
279 PriorityCompare(SMILTime elapsed) : m_elapsed(elapsed) {} | 277 PriorityCompare(SMILTime elapsed) : m_elapsed(elapsed) {} |
280 bool operator()(const RefPtr<SVGSMILElement>& a, const RefPtr<SVGSMILElement
>& b) | 278 bool operator()(const RefPtr<SVGSMILElement>& a, const RefPtr<SVGSMILElement
>& b) |
281 { | 279 { |
282 // FIXME: This should also consider possible timing relations between th
e elements. | 280 // FIXME: This should also consider possible timing relations between th
e elements. |
283 SMILTime aBegin = a->intervalBegin(); | 281 SMILTime aBegin = a->intervalBegin(); |
284 SMILTime bBegin = b->intervalBegin(); | 282 SMILTime bBegin = b->intervalBegin(); |
285 // Frozen elements need to be prioritized based on their previous interv
al. | 283 // Frozen elements need to be prioritized based on their previous interv
al. |
286 aBegin = a->isFrozen() && m_elapsed < aBegin ? a->previousIntervalBegin(
) : aBegin; | 284 aBegin = a->isFrozen() && m_elapsed < aBegin ? a->previousIntervalBegin(
) : aBegin; |
287 bBegin = b->isFrozen() && m_elapsed < bBegin ? b->previousIntervalBegin(
) : bBegin; | 285 bBegin = b->isFrozen() && m_elapsed < bBegin ? b->previousIntervalBegin(
) : bBegin; |
288 if (aBegin == bBegin) | 286 if (aBegin == bBegin) |
289 return a->documentOrderIndex() < b->documentOrderIndex(); | 287 return a->documentOrderIndex() < b->documentOrderIndex(); |
290 return aBegin < bBegin; | 288 return aBegin < bBegin; |
291 } | 289 } |
292 SMILTime m_elapsed; | 290 SMILTime m_elapsed; |
293 }; | 291 }; |
294 | 292 |
295 Document& SMILTimeContainer::document() const | 293 Document& SMILTimeContainer::document() const |
296 { | 294 { |
297 ASSERT(m_ownerSVGElement); | 295 return m_ownerSVGElement.document(); |
298 return m_ownerSVGElement->document(); | |
299 } | 296 } |
300 | 297 |
301 AnimationClock& SMILTimeContainer::animationClock() const | 298 AnimationClock& SMILTimeContainer::animationClock() const |
302 { | 299 { |
303 ASSERT(m_animationClock); | 300 ASSERT(m_animationClock); |
304 return *m_animationClock; | 301 return *m_animationClock; |
305 } | 302 } |
306 | 303 |
307 double SMILTimeContainer::currentTime() const | 304 double SMILTimeContainer::currentTime() const |
308 { | 305 { |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 if (animDiscard->inDocument()) { | 420 if (animDiscard->inDocument()) { |
424 animDiscard->remove(IGNORE_EXCEPTION); | 421 animDiscard->remove(IGNORE_EXCEPTION); |
425 ASSERT(!animDiscard->inDocument()); | 422 ASSERT(!animDiscard->inDocument()); |
426 } | 423 } |
427 } | 424 } |
428 } | 425 } |
429 return earliestFireTime; | 426 return earliestFireTime; |
430 } | 427 } |
431 | 428 |
432 } | 429 } |
OLD | NEW |