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 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
198 SVGSMILElement::~SVGSMILElement() | 198 SVGSMILElement::~SVGSMILElement() |
199 { | 199 { |
200 #if !ENABLE(OILPAN) | 200 #if !ENABLE(OILPAN) |
201 clearResourceAndEventBaseReferences(); | 201 clearResourceAndEventBaseReferences(); |
202 #endif | 202 #endif |
203 smilEndEventSender().cancelEvent(this); | 203 smilEndEventSender().cancelEvent(this); |
204 smilBeginEventSender().cancelEvent(this); | 204 smilBeginEventSender().cancelEvent(this); |
205 smilRepeatEventSender().cancelEvent(this); | 205 smilRepeatEventSender().cancelEvent(this); |
206 smilRepeatNEventSender().cancelEvent(this); | 206 smilRepeatNEventSender().cancelEvent(this); |
207 #if !ENABLE(OILPAN) | 207 #if !ENABLE(OILPAN) |
208 // FIXME: Oilpan: Clear |m_syncBaseDependents| using weak processing. | |
209 clearConditions(); | 208 clearConditions(); |
210 | 209 |
211 if (m_timeContainer && m_targetElement && hasValidAttributeName()) | 210 if (m_timeContainer && m_targetElement && hasValidAttributeName()) |
212 m_timeContainer->unschedule(this, m_targetElement, m_attributeName); | 211 m_timeContainer->unschedule(this, m_targetElement, m_attributeName); |
213 #endif | 212 #endif |
214 } | 213 } |
215 | 214 |
216 void SVGSMILElement::clearResourceAndEventBaseReferences() | 215 void SVGSMILElement::clearResourceAndEventBaseReferences() |
217 { | 216 { |
218 document().accessSVGExtensions().removeAllTargetReferencesForElement(this); | 217 document().accessSVGExtensions().removeAllTargetReferencesForElement(this); |
219 } | 218 } |
220 | 219 |
221 void SVGSMILElement::clearConditions() | 220 void SVGSMILElement::clearConditions() |
222 { | 221 { |
223 disconnectSyncBaseConditions(); | 222 disconnectSyncBaseConditions(); |
224 disconnectEventBaseConditions(); | 223 disconnectEventBaseConditions(); |
haraken
2014/05/29 04:58:58
Making m_syncBaseDependents weak will allow us to
kouhei (in TOK)
2014/05/29 05:08:10
|disconnectEventBaseConditions()| can also be remo
| |
225 m_conditions.clear(); | 224 m_conditions.clear(); |
226 } | 225 } |
227 | 226 |
228 void SVGSMILElement::buildPendingResource() | 227 void SVGSMILElement::buildPendingResource() |
229 { | 228 { |
230 clearResourceAndEventBaseReferences(); | 229 clearResourceAndEventBaseReferences(); |
231 | 230 |
232 if (!inDocument()) { | 231 if (!inDocument()) { |
233 // Reset the target element if we are no longer in the document. | 232 // Reset the target element if we are no longer in the document. |
234 setTargetElement(0); | 233 setTargetElement(0); |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
595 | 594 |
596 void SVGSMILElement::connectSyncBaseConditions() | 595 void SVGSMILElement::connectSyncBaseConditions() |
597 { | 596 { |
598 if (m_syncBaseConditionsConnected) | 597 if (m_syncBaseConditionsConnected) |
599 disconnectSyncBaseConditions(); | 598 disconnectSyncBaseConditions(); |
600 m_syncBaseConditionsConnected = true; | 599 m_syncBaseConditionsConnected = true; |
601 for (unsigned n = 0; n < m_conditions.size(); ++n) { | 600 for (unsigned n = 0; n < m_conditions.size(); ++n) { |
602 Condition* condition = m_conditions[n].get(); | 601 Condition* condition = m_conditions[n].get(); |
603 if (condition->type() == Condition::Syncbase) { | 602 if (condition->type() == Condition::Syncbase) { |
604 ASSERT(!condition->baseID().isEmpty()); | 603 ASSERT(!condition->baseID().isEmpty()); |
605 condition->setSyncBase(treeScope().getElementById(AtomicString(condi tion->baseID()))); | 604 Element* element = treeScope().getElementById(AtomicString(condition ->baseID())); |
606 if (!condition->syncBase() || !isSVGSMILElement(*condition->syncBase ())) { | 605 if (!element || !isSVGSMILElement(*element)) { |
607 condition->setSyncBase(0); | 606 condition->setSyncBase(0); |
608 continue; | 607 continue; |
609 } | 608 } |
610 toSVGSMILElement(condition->syncBase())->addSyncBaseDependent(this); | 609 SVGSMILElement* svgSMILElement = toSVGSMILElement(element); |
610 condition->setSyncBase(svgSMILElement); | |
611 svgSMILElement->addSyncBaseDependent(this); | |
611 } | 612 } |
612 } | 613 } |
613 } | 614 } |
614 | 615 |
615 void SVGSMILElement::disconnectSyncBaseConditions() | 616 void SVGSMILElement::disconnectSyncBaseConditions() |
616 { | 617 { |
617 if (!m_syncBaseConditionsConnected) | 618 if (!m_syncBaseConditionsConnected) |
618 return; | 619 return; |
619 m_syncBaseConditionsConnected = false; | 620 m_syncBaseConditionsConnected = false; |
620 for (unsigned n = 0; n < m_conditions.size(); ++n) { | 621 for (unsigned n = 0; n < m_conditions.size(); ++n) { |
621 Condition* condition = m_conditions[n].get(); | 622 Condition* condition = m_conditions[n].get(); |
622 if (condition->type() == Condition::Syncbase) { | 623 if (condition->type() == Condition::Syncbase) { |
623 if (condition->syncBase()) | 624 if (condition->syncBase()) |
624 toSVGSMILElement(condition->syncBase())->removeSyncBaseDependent (this); | 625 condition->syncBase()->removeSyncBaseDependent(this); |
625 condition->setSyncBase(0); | 626 condition->setSyncBase(0); |
626 } | 627 } |
627 } | 628 } |
628 } | 629 } |
629 | 630 |
630 void SVGSMILElement::connectEventBaseConditions() | 631 void SVGSMILElement::connectEventBaseConditions() |
631 { | 632 { |
632 disconnectEventBaseConditions(); | 633 disconnectEventBaseConditions(); |
633 for (unsigned n = 0; n < m_conditions.size(); ++n) { | 634 for (unsigned n = 0; n < m_conditions.size(); ++n) { |
634 Condition* condition = m_conditions[n].get(); | 635 Condition* condition = m_conditions[n].get(); |
(...skipping 19 matching lines...) Expand all Loading... | |
654 Condition* condition = m_conditions[n].get(); | 655 Condition* condition = m_conditions[n].get(); |
655 if (condition->type() == Condition::EventBase) { | 656 if (condition->type() == Condition::EventBase) { |
656 ASSERT(!condition->syncBase()); | 657 ASSERT(!condition->syncBase()); |
657 if (!condition->eventListener()) | 658 if (!condition->eventListener()) |
658 continue; | 659 continue; |
659 // Note: It's a memory optimization to try to remove our condition | 660 // Note: It's a memory optimization to try to remove our condition |
660 // event listener, but it's not guaranteed to work, since we have | 661 // event listener, but it's not guaranteed to work, since we have |
661 // no guarantee that eventBaseFor() will be able to find our conditi on's | 662 // no guarantee that eventBaseFor() will be able to find our conditi on's |
662 // original eventBase. So, we also have to disconnect ourselves from | 663 // original eventBase. So, we also have to disconnect ourselves from |
663 // our condition event listener, in case it later fires. | 664 // our condition event listener, in case it later fires. |
664 SVGElement* eventBase = eventBaseFor(*condition); | 665 SVGElement* eventBase = eventBaseFor(*condition); |
haraken
2014/05/29 06:14:10
Is it guaranteed that the eventBase exists in the
| |
665 if (eventBase) | 666 if (eventBase) |
666 eventBase->removeEventListener(AtomicString(condition->name()), condition->eventListener(), false); | 667 eventBase->removeEventListener(AtomicString(condition->name()), condition->eventListener(), false); |
667 condition->eventListener()->disconnectAnimation(); | 668 condition->eventListener()->disconnectAnimation(); |
668 condition->setEventListener(nullptr); | 669 condition->setEventListener(nullptr); |
haraken
2014/05/29 06:14:10
I don't fully understand this. Would you elaborate
| |
669 } | 670 } |
670 } | 671 } |
671 } | 672 } |
672 | 673 |
673 void SVGSMILElement::setAttributeName(const QualifiedName& attributeName) | 674 void SVGSMILElement::setAttributeName(const QualifiedName& attributeName) |
674 { | 675 { |
675 if (m_timeContainer && m_targetElement && m_attributeName != attributeName) { | 676 if (m_timeContainer && m_targetElement && m_attributeName != attributeName) { |
676 if (hasValidAttributeName()) | 677 if (hasValidAttributeName()) |
677 m_timeContainer->unschedule(this, m_targetElement, m_attributeName); | 678 m_timeContainer->unschedule(this, m_targetElement, m_attributeName); |
678 m_attributeName = attributeName; | 679 m_attributeName = attributeName; |
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1239 smilEndEventSender().dispatchEventSoon(this); | 1240 smilEndEventSender().dispatchEventSoon(this); |
1240 } | 1241 } |
1241 | 1242 |
1242 m_nextProgressTime = calculateNextProgressTime(elapsed); | 1243 m_nextProgressTime = calculateNextProgressTime(elapsed); |
1243 return animationIsContributing; | 1244 return animationIsContributing; |
1244 } | 1245 } |
1245 | 1246 |
1246 void SVGSMILElement::notifyDependentsIntervalChanged() | 1247 void SVGSMILElement::notifyDependentsIntervalChanged() |
1247 { | 1248 { |
1248 ASSERT(m_intervalBegin.isFinite()); | 1249 ASSERT(m_intervalBegin.isFinite()); |
1249 DEFINE_STATIC_LOCAL(HashSet<SVGSMILElement*>, loopBreaker, ()); | 1250 DEFINE_STATIC_LOCAL(OwnPtrWillBePersistent<WillBeHeapHashSet<RawPtrWillBeMem ber<SVGSMILElement> > >, loopBreaker, (adoptPtrWillBeNoop(new WillBeHeapHashSet< RawPtrWillBeMember<SVGSMILElement> >()))); |
1250 if (!loopBreaker.add(this).isNewEntry) | 1251 if (!loopBreaker->add(this).isNewEntry) |
1251 return; | 1252 return; |
1252 | 1253 |
1253 TimeDependentSet::iterator end = m_syncBaseDependents.end(); | 1254 TimeDependentSet::iterator end = m_syncBaseDependents.end(); |
1254 for (TimeDependentSet::iterator it = m_syncBaseDependents.begin(); it != end ; ++it) { | 1255 for (TimeDependentSet::iterator it = m_syncBaseDependents.begin(); it != end ; ++it) { |
1255 SVGSMILElement* dependent = *it; | 1256 SVGSMILElement* dependent = *it; |
1256 dependent->createInstanceTimesFromSyncbase(this); | 1257 dependent->createInstanceTimesFromSyncbase(this); |
1257 } | 1258 } |
1258 | 1259 |
1259 loopBreaker.remove(this); | 1260 loopBreaker->remove(this); |
1260 } | 1261 } |
1261 | 1262 |
1262 void SVGSMILElement::createInstanceTimesFromSyncbase(SVGSMILElement* syncBase) | 1263 void SVGSMILElement::createInstanceTimesFromSyncbase(SVGSMILElement* syncBase) |
1263 { | 1264 { |
1264 // FIXME: To be really correct, this should handle updating exising interval by changing | 1265 // FIXME: To be really correct, this should handle updating exising interval by changing |
1265 // the associated times instead of creating new ones. | 1266 // the associated times instead of creating new ones. |
1266 for (unsigned n = 0; n < m_conditions.size(); ++n) { | 1267 for (unsigned n = 0; n < m_conditions.size(); ++n) { |
1267 Condition* condition = m_conditions[n].get(); | 1268 Condition* condition = m_conditions[n].get(); |
1268 if (condition->type() == Condition::Syncbase && condition->syncBase() == syncBase) { | 1269 if (condition->type() == Condition::Syncbase && condition->syncBase() == syncBase) { |
1269 ASSERT(condition->name() == "begin" || condition->name() == "end"); | 1270 ASSERT(condition->name() == "begin" || condition->name() == "end"); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1351 void SVGSMILElement::trace(Visitor* visitor) | 1352 void SVGSMILElement::trace(Visitor* visitor) |
1352 { | 1353 { |
1353 visitor->trace(m_targetElement); | 1354 visitor->trace(m_targetElement); |
1354 visitor->trace(m_timeContainer); | 1355 visitor->trace(m_timeContainer); |
1355 visitor->trace(m_conditions); | 1356 visitor->trace(m_conditions); |
1356 visitor->trace(m_syncBaseDependents); | 1357 visitor->trace(m_syncBaseDependents); |
1357 SVGElement::trace(visitor); | 1358 SVGElement::trace(visitor); |
1358 } | 1359 } |
1359 | 1360 |
1360 } | 1361 } |
OLD | NEW |