Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(435)

Side by Side Diff: Source/core/svg/animation/SMILTimeContainer.cpp

Issue 99533004: [SVG] Implement 'discard' element (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * 12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */ 24 */
25 25
26 #include "config.h" 26 #include "config.h"
27 #include "core/svg/animation/SMILTimeContainer.h" 27 #include "core/svg/animation/SMILTimeContainer.h"
28 28
29 #include "core/dom/ElementTraversal.h" 29 #include "core/dom/ElementTraversal.h"
30 #include "core/svg/SVGDiscardElement.h"
30 #include "core/svg/SVGSVGElement.h" 31 #include "core/svg/SVGSVGElement.h"
31 #include "core/svg/animation/SVGSMILElement.h" 32 #include "core/svg/animation/SVGSMILElement.h"
32 #include "wtf/CurrentTime.h" 33 #include "wtf/CurrentTime.h"
33 34
34 using namespace std; 35 using namespace std;
35 36
36 namespace WebCore { 37 namespace WebCore {
37 38
38 static const double animationFrameDelay = 0.025; 39 static const double animationFrameDelay = 0.025;
39 40
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 void SMILTimeContainer::updateAnimations(SMILTime elapsed, bool seekToTime) 263 void SMILTimeContainer::updateAnimations(SMILTime elapsed, bool seekToTime)
263 { 264 {
264 SMILTime earliestFireTime = SMILTime::unresolved(); 265 SMILTime earliestFireTime = SMILTime::unresolved();
265 266
266 #ifndef NDEBUG 267 #ifndef NDEBUG
267 // This boolean will catch any attempts to schedule/unschedule scheduledAnim ations during this critical section. 268 // This boolean will catch any attempts to schedule/unschedule scheduledAnim ations during this critical section.
268 // Similarly, any elements removed will unschedule themselves, so this will catch modification of animationsToApply. 269 // Similarly, any elements removed will unschedule themselves, so this will catch modification of animationsToApply.
269 m_preventScheduledAnimationsChanges = true; 270 m_preventScheduledAnimationsChanges = true;
270 #endif 271 #endif
271 272
272 AnimationsVector animationsToApply; 273 Vector< RefPtr<SVGSMILElement> > animationsToApply;
273 GroupedAnimationsMap::iterator end = m_scheduledAnimations.end(); 274 GroupedAnimationsMap::iterator end = m_scheduledAnimations.end();
274 for (GroupedAnimationsMap::iterator it = m_scheduledAnimations.begin(); it ! = end; ++it) { 275 for (GroupedAnimationsMap::iterator it = m_scheduledAnimations.begin(); it ! = end; ++it) {
275 AnimationsVector* scheduled = it->value.get(); 276 AnimationsVector* scheduled = it->value.get();
276 277
277 // Sort according to priority. Elements with later begin time have highe r priority. 278 // Sort according to priority. Elements with later begin time have highe r priority.
278 // In case of a tie, document order decides. 279 // In case of a tie, document order decides.
279 // FIXME: This should also consider timing relationships between the ele ments. Dependents 280 // FIXME: This should also consider timing relationships between the ele ments. Dependents
280 // have higher priority. 281 // have higher priority.
281 sortByPriority(*scheduled, elapsed); 282 sortByPriority(*scheduled, elapsed);
282 283
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 } 319 }
319 320
320 // Apply results to target elements. 321 // Apply results to target elements.
321 for (unsigned i = 0; i < animationsToApplySize; ++i) 322 for (unsigned i = 0; i < animationsToApplySize; ++i)
322 animationsToApply[i]->applyResultsToTarget(); 323 animationsToApply[i]->applyResultsToTarget();
323 324
324 #ifndef NDEBUG 325 #ifndef NDEBUG
325 m_preventScheduledAnimationsChanges = false; 326 m_preventScheduledAnimationsChanges = false;
326 #endif 327 #endif
327 328
329 for (unsigned n = 0; n < animationsToApplySize; ++n) {
330 if (animationsToApply[n] && animationsToApply[n]->inDocument() && isSVGD iscardElement(*animationsToApply[n])) {
pdr. 2013/12/20 23:49:11 Can animationsToApply[n] ever be null? I don't thi
331 RefPtr<SVGSMILElement> animDiscard = animationsToApply[n];
332 RefPtr<SVGElement> targetElement = animDiscard->targetElement();
333 animDiscard->remove(IGNORE_EXCEPTION);
pdr. 2013/12/20 23:49:11 I think the ordering here matters. Can you remove
pavane 2013/12/21 12:28:10 I think the current order is logical. If discard i
334 if (targetElement && targetElement->inDocument())
335 targetElement->remove(IGNORE_EXCEPTION);
pdr. 2013/12/20 23:49:11 After both of these removal calls, can you add: AS
336 }
337 }
338
328 startTimer(earliestFireTime, animationFrameDelay); 339 startTimer(earliestFireTime, animationFrameDelay);
329 } 340 }
330 341
331 } 342 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698