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 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
551 } else if (attrName == SVGNames::minAttr) { | 551 } else if (attrName == SVGNames::minAttr) { |
552 m_cachedMin = invalidCachedTime; | 552 m_cachedMin = invalidCachedTime; |
553 } else if (attrName == SVGNames::maxAttr) { | 553 } else if (attrName == SVGNames::maxAttr) { |
554 m_cachedMax = invalidCachedTime; | 554 m_cachedMax = invalidCachedTime; |
555 } else if (attrName.matches(SVGNames::hrefAttr) || | 555 } else if (attrName.matches(SVGNames::hrefAttr) || |
556 attrName.matches(XLinkNames::hrefAttr)) { | 556 attrName.matches(XLinkNames::hrefAttr)) { |
557 // TODO(fs): Could be smarter here when 'href' is specified and 'xlink:href' | 557 // TODO(fs): Could be smarter here when 'href' is specified and 'xlink:href' |
558 // is changed. | 558 // is changed. |
559 SVGElement::InvalidationGuard invalidationGuard(this); | 559 SVGElement::InvalidationGuard invalidationGuard(this); |
560 buildPendingResource(); | 560 buildPendingResource(); |
561 if (m_targetElement) | |
562 clearAnimatedType(); | |
563 } else { | 561 } else { |
564 SVGElement::svgAttributeChanged(attrName); | 562 SVGElement::svgAttributeChanged(attrName); |
565 return; | 563 return; |
566 } | 564 } |
567 | 565 |
568 animationAttributeChanged(); | 566 animationAttributeChanged(); |
569 } | 567 } |
570 | 568 |
571 void SVGSMILElement::connectSyncBaseConditions() { | 569 void SVGSMILElement::connectSyncBaseConditions() { |
572 if (m_syncBaseConditionsConnected) | 570 if (m_syncBaseConditionsConnected) |
(...skipping 24 matching lines...) Expand all Loading... |
597 } | 595 } |
598 | 596 |
599 void SVGSMILElement::disconnectEventBaseConditions() { | 597 void SVGSMILElement::disconnectEventBaseConditions() { |
600 for (Condition* condition : m_conditions) { | 598 for (Condition* condition : m_conditions) { |
601 if (condition->getType() == Condition::EventBase) | 599 if (condition->getType() == Condition::EventBase) |
602 condition->disconnectEventBase(*this); | 600 condition->disconnectEventBase(*this); |
603 } | 601 } |
604 } | 602 } |
605 | 603 |
606 void SVGSMILElement::setTargetElement(SVGElement* target) { | 604 void SVGSMILElement::setTargetElement(SVGElement* target) { |
607 unscheduleIfScheduled(); | 605 willChangeAnimationTarget(); |
608 | 606 |
609 if (m_targetElement) { | 607 // Clear values that may depend on the previous target. |
610 // Clear values that may depend on the previous target. | 608 if (m_targetElement) |
611 clearAnimatedType(); | |
612 disconnectSyncBaseConditions(); | 609 disconnectSyncBaseConditions(); |
613 } | |
614 | 610 |
615 // If the animation state is not Inactive, always reset to a clear state | 611 // If the animation state is not Inactive, always reset to a clear state |
616 // before leaving the old target element. | 612 // before leaving the old target element. |
617 if (m_activeState != Inactive) | 613 if (m_activeState != Inactive) |
618 endedActiveInterval(); | 614 endedActiveInterval(); |
619 | 615 |
620 m_targetElement = target; | 616 m_targetElement = target; |
621 schedule(); | 617 didChangeAnimationTarget(); |
622 } | 618 } |
623 | 619 |
624 SMILTime SVGSMILElement::elapsed() const { | 620 SMILTime SVGSMILElement::elapsed() const { |
625 return m_timeContainer ? m_timeContainer->elapsed() : 0; | 621 return m_timeContainer ? m_timeContainer->elapsed() : 0; |
626 } | 622 } |
627 | 623 |
628 bool SVGSMILElement::isFrozen() const { | 624 bool SVGSMILElement::isFrozen() const { |
629 return m_activeState == Frozen; | 625 return m_activeState == Frozen; |
630 } | 626 } |
631 | 627 |
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1243 dispatchEvent(RepeatEvent::create(eventType, repeatEventCount)); | 1239 dispatchEvent(RepeatEvent::create(eventType, repeatEventCount)); |
1244 } else { | 1240 } else { |
1245 dispatchEvent(Event::create(eventType)); | 1241 dispatchEvent(Event::create(eventType)); |
1246 } | 1242 } |
1247 } | 1243 } |
1248 | 1244 |
1249 bool SVGSMILElement::hasValidTarget() { | 1245 bool SVGSMILElement::hasValidTarget() { |
1250 return targetElement() && targetElement()->inActiveDocument(); | 1246 return targetElement() && targetElement()->inActiveDocument(); |
1251 } | 1247 } |
1252 | 1248 |
1253 void SVGSMILElement::schedule() { | 1249 void SVGSMILElement::willChangeAnimationTarget() { |
1254 DCHECK(!m_isScheduled); | |
1255 | |
1256 if (!m_timeContainer || !hasValidTarget()) | |
1257 return; | |
1258 | |
1259 m_timeContainer->schedule(this, m_targetElement, m_attributeName); | |
1260 m_isScheduled = true; | |
1261 } | |
1262 | |
1263 void SVGSMILElement::unscheduleIfScheduled() { | |
1264 if (!m_isScheduled) | 1250 if (!m_isScheduled) |
1265 return; | 1251 return; |
1266 | |
1267 DCHECK(m_timeContainer); | 1252 DCHECK(m_timeContainer); |
1268 DCHECK(m_targetElement); | 1253 DCHECK(m_targetElement); |
1269 m_timeContainer->unschedule(this, m_targetElement, m_attributeName); | 1254 m_timeContainer->unschedule(this, m_targetElement, m_attributeName); |
1270 m_isScheduled = false; | 1255 m_isScheduled = false; |
1271 } | 1256 } |
1272 | 1257 |
| 1258 void SVGSMILElement::didChangeAnimationTarget() { |
| 1259 DCHECK(!m_isScheduled); |
| 1260 if (!m_timeContainer || !hasValidTarget()) |
| 1261 return; |
| 1262 m_timeContainer->schedule(this, m_targetElement, m_attributeName); |
| 1263 m_isScheduled = true; |
| 1264 } |
| 1265 |
1273 DEFINE_TRACE(SVGSMILElement) { | 1266 DEFINE_TRACE(SVGSMILElement) { |
1274 visitor->trace(m_targetElement); | 1267 visitor->trace(m_targetElement); |
1275 visitor->trace(m_targetIdObserver); | 1268 visitor->trace(m_targetIdObserver); |
1276 visitor->trace(m_timeContainer); | 1269 visitor->trace(m_timeContainer); |
1277 visitor->trace(m_conditions); | 1270 visitor->trace(m_conditions); |
1278 visitor->trace(m_syncBaseDependents); | 1271 visitor->trace(m_syncBaseDependents); |
1279 SVGElement::trace(visitor); | 1272 SVGElement::trace(visitor); |
1280 SVGTests::trace(visitor); | 1273 SVGTests::trace(visitor); |
1281 } | 1274 } |
1282 | 1275 |
1283 } // namespace blink | 1276 } // namespace blink |
OLD | NEW |