| 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 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 592 return nullptr; | 592 return nullptr; |
| 593 } | 593 } |
| 594 | 594 |
| 595 void SVGSMILElement::connectSyncBaseConditions() | 595 void SVGSMILElement::connectSyncBaseConditions() |
| 596 { | 596 { |
| 597 if (m_syncBaseConditionsConnected) | 597 if (m_syncBaseConditionsConnected) |
| 598 disconnectSyncBaseConditions(); | 598 disconnectSyncBaseConditions(); |
| 599 m_syncBaseConditionsConnected = true; | 599 m_syncBaseConditionsConnected = true; |
| 600 for (unsigned n = 0; n < m_conditions.size(); ++n) { | 600 for (unsigned n = 0; n < m_conditions.size(); ++n) { |
| 601 Condition* condition = m_conditions[n].get(); | 601 Condition* condition = m_conditions[n].get(); |
| 602 if (condition->type() == Condition::Syncbase) { | 602 if (condition->getType() == Condition::Syncbase) { |
| 603 ASSERT(!condition->baseID().isEmpty()); | 603 ASSERT(!condition->baseID().isEmpty()); |
| 604 Element* element = treeScope().getElementById(AtomicString(condition
->baseID())); | 604 Element* element = treeScope().getElementById(AtomicString(condition
->baseID())); |
| 605 if (!element || !isSVGSMILElement(*element)) { | 605 if (!element || !isSVGSMILElement(*element)) { |
| 606 condition->setSyncBase(0); | 606 condition->setSyncBase(0); |
| 607 continue; | 607 continue; |
| 608 } | 608 } |
| 609 SVGSMILElement* svgSMILElement = toSVGSMILElement(element); | 609 SVGSMILElement* svgSMILElement = toSVGSMILElement(element); |
| 610 condition->setSyncBase(svgSMILElement); | 610 condition->setSyncBase(svgSMILElement); |
| 611 svgSMILElement->addSyncBaseDependent(this); | 611 svgSMILElement->addSyncBaseDependent(this); |
| 612 } | 612 } |
| 613 } | 613 } |
| 614 } | 614 } |
| 615 | 615 |
| 616 void SVGSMILElement::disconnectSyncBaseConditions() | 616 void SVGSMILElement::disconnectSyncBaseConditions() |
| 617 { | 617 { |
| 618 if (!m_syncBaseConditionsConnected) | 618 if (!m_syncBaseConditionsConnected) |
| 619 return; | 619 return; |
| 620 m_syncBaseConditionsConnected = false; | 620 m_syncBaseConditionsConnected = false; |
| 621 for (unsigned n = 0; n < m_conditions.size(); ++n) { | 621 for (unsigned n = 0; n < m_conditions.size(); ++n) { |
| 622 Condition* condition = m_conditions[n].get(); | 622 Condition* condition = m_conditions[n].get(); |
| 623 if (condition->type() == Condition::Syncbase) { | 623 if (condition->getType() == Condition::Syncbase) { |
| 624 if (condition->syncBase()) | 624 if (condition->syncBase()) |
| 625 condition->syncBase()->removeSyncBaseDependent(this); | 625 condition->syncBase()->removeSyncBaseDependent(this); |
| 626 condition->setSyncBase(0); | 626 condition->setSyncBase(0); |
| 627 } | 627 } |
| 628 } | 628 } |
| 629 } | 629 } |
| 630 | 630 |
| 631 void SVGSMILElement::connectEventBaseConditions() | 631 void SVGSMILElement::connectEventBaseConditions() |
| 632 { | 632 { |
| 633 disconnectEventBaseConditions(); | 633 disconnectEventBaseConditions(); |
| 634 for (unsigned n = 0; n < m_conditions.size(); ++n) { | 634 for (unsigned n = 0; n < m_conditions.size(); ++n) { |
| 635 Condition* condition = m_conditions[n].get(); | 635 Condition* condition = m_conditions[n].get(); |
| 636 if (condition->type() == Condition::EventBase) { | 636 if (condition->getType() == Condition::EventBase) { |
| 637 ASSERT(!condition->syncBase()); | 637 ASSERT(!condition->syncBase()); |
| 638 SVGElement* eventBase = eventBaseFor(*condition); | 638 SVGElement* eventBase = eventBaseFor(*condition); |
| 639 if (!eventBase) { | 639 if (!eventBase) { |
| 640 if (!condition->baseID().isEmpty() && !document().accessSVGExten
sions().isElementPendingResource(this, AtomicString(condition->baseID()))) | 640 if (!condition->baseID().isEmpty() && !document().accessSVGExten
sions().isElementPendingResource(this, AtomicString(condition->baseID()))) |
| 641 document().accessSVGExtensions().addPendingResource(AtomicSt
ring(condition->baseID()), this); | 641 document().accessSVGExtensions().addPendingResource(AtomicSt
ring(condition->baseID()), this); |
| 642 continue; | 642 continue; |
| 643 } | 643 } |
| 644 ASSERT(!condition->eventListener()); | 644 ASSERT(!condition->eventListener()); |
| 645 condition->setEventListener(ConditionEventListener::create(this, con
dition)); | 645 condition->setEventListener(ConditionEventListener::create(this, con
dition)); |
| 646 eventBase->addEventListener(AtomicString(condition->name()), conditi
on->eventListener(), false); | 646 eventBase->addEventListener(AtomicString(condition->name()), conditi
on->eventListener(), false); |
| 647 addReferenceTo(eventBase); | 647 addReferenceTo(eventBase); |
| 648 } | 648 } |
| 649 } | 649 } |
| 650 } | 650 } |
| 651 | 651 |
| 652 void SVGSMILElement::disconnectEventBaseConditions() | 652 void SVGSMILElement::disconnectEventBaseConditions() |
| 653 { | 653 { |
| 654 for (unsigned n = 0; n < m_conditions.size(); ++n) { | 654 for (unsigned n = 0; n < m_conditions.size(); ++n) { |
| 655 Condition* condition = m_conditions[n].get(); | 655 Condition* condition = m_conditions[n].get(); |
| 656 if (condition->type() == Condition::EventBase) { | 656 if (condition->getType() == Condition::EventBase) { |
| 657 ASSERT(!condition->syncBase()); | 657 ASSERT(!condition->syncBase()); |
| 658 if (!condition->eventListener()) | 658 if (!condition->eventListener()) |
| 659 continue; | 659 continue; |
| 660 // 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 |
| 661 // 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 |
| 662 // 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 |
| 663 // original eventBase. So, we also have to disconnect ourselves from | 663 // original eventBase. So, we also have to disconnect ourselves from |
| 664 // our condition event listener, in case it later fires. | 664 // our condition event listener, in case it later fires. |
| 665 SVGElement* eventBase = eventBaseFor(*condition); | 665 SVGElement* eventBase = eventBaseFor(*condition); |
| 666 if (eventBase) | 666 if (eventBase) |
| (...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1242 | 1242 |
| 1243 loopBreaker->remove(this); | 1243 loopBreaker->remove(this); |
| 1244 } | 1244 } |
| 1245 | 1245 |
| 1246 void SVGSMILElement::createInstanceTimesFromSyncbase(SVGSMILElement* syncBase) | 1246 void SVGSMILElement::createInstanceTimesFromSyncbase(SVGSMILElement* syncBase) |
| 1247 { | 1247 { |
| 1248 // FIXME: To be really correct, this should handle updating exising interval
by changing | 1248 // FIXME: To be really correct, this should handle updating exising interval
by changing |
| 1249 // the associated times instead of creating new ones. | 1249 // the associated times instead of creating new ones. |
| 1250 for (unsigned n = 0; n < m_conditions.size(); ++n) { | 1250 for (unsigned n = 0; n < m_conditions.size(); ++n) { |
| 1251 Condition* condition = m_conditions[n].get(); | 1251 Condition* condition = m_conditions[n].get(); |
| 1252 if (condition->type() == Condition::Syncbase && condition->syncBase() ==
syncBase) { | 1252 if (condition->getType() == Condition::Syncbase && condition->syncBase()
== syncBase) { |
| 1253 ASSERT(condition->name() == "begin" || condition->name() == "end"); | 1253 ASSERT(condition->name() == "begin" || condition->name() == "end"); |
| 1254 // No nested time containers in SVG, no need for crazy time space co
nversions. Phew! | 1254 // No nested time containers in SVG, no need for crazy time space co
nversions. Phew! |
| 1255 SMILTime time = 0; | 1255 SMILTime time = 0; |
| 1256 if (condition->name() == "begin") | 1256 if (condition->name() == "begin") |
| 1257 time = syncBase->m_interval.begin + condition->offset(); | 1257 time = syncBase->m_interval.begin + condition->offset(); |
| 1258 else | 1258 else |
| 1259 time = syncBase->m_interval.end + condition->offset(); | 1259 time = syncBase->m_interval.end + condition->offset(); |
| 1260 if (!time.isFinite()) | 1260 if (!time.isFinite()) |
| 1261 continue; | 1261 continue; |
| 1262 SMILTime elapsed = this->elapsed(); | 1262 SMILTime elapsed = this->elapsed(); |
| 1263 if (elapsed.isUnresolved()) | 1263 if (elapsed.isUnresolved()) |
| 1264 continue; | 1264 continue; |
| 1265 if (condition->beginOrEnd() == Begin) | 1265 if (condition->getBeginOrEnd() == Begin) |
| 1266 addBeginTime(elapsed, time); | 1266 addBeginTime(elapsed, time); |
| 1267 else | 1267 else |
| 1268 addEndTime(elapsed, time); | 1268 addEndTime(elapsed, time); |
| 1269 } | 1269 } |
| 1270 } | 1270 } |
| 1271 } | 1271 } |
| 1272 | 1272 |
| 1273 void SVGSMILElement::addSyncBaseDependent(SVGSMILElement* animation) | 1273 void SVGSMILElement::addSyncBaseDependent(SVGSMILElement* animation) |
| 1274 { | 1274 { |
| 1275 m_syncBaseDependents.add(animation); | 1275 m_syncBaseDependents.add(animation); |
| 1276 if (m_interval.begin.isFinite()) | 1276 if (m_interval.begin.isFinite()) |
| 1277 animation->createInstanceTimesFromSyncbase(this); | 1277 animation->createInstanceTimesFromSyncbase(this); |
| 1278 } | 1278 } |
| 1279 | 1279 |
| 1280 void SVGSMILElement::removeSyncBaseDependent(SVGSMILElement* animation) | 1280 void SVGSMILElement::removeSyncBaseDependent(SVGSMILElement* animation) |
| 1281 { | 1281 { |
| 1282 m_syncBaseDependents.remove(animation); | 1282 m_syncBaseDependents.remove(animation); |
| 1283 } | 1283 } |
| 1284 | 1284 |
| 1285 void SVGSMILElement::handleConditionEvent(Event* event, Condition* condition) | 1285 void SVGSMILElement::handleConditionEvent(Event* event, Condition* condition) |
| 1286 { | 1286 { |
| 1287 if (event->type() == "repeatn" && toRepeatEvent(event)->repeat() != conditio
n->repeat()) | 1287 if (event->type() == "repeatn" && toRepeatEvent(event)->repeat() != conditio
n->repeat()) |
| 1288 return; | 1288 return; |
| 1289 | 1289 |
| 1290 SMILTime elapsed = this->elapsed(); | 1290 SMILTime elapsed = this->elapsed(); |
| 1291 if (elapsed.isUnresolved()) | 1291 if (elapsed.isUnresolved()) |
| 1292 return; | 1292 return; |
| 1293 if (condition->beginOrEnd() == Begin) | 1293 if (condition->getBeginOrEnd() == Begin) |
| 1294 addBeginTime(elapsed, elapsed + condition->offset()); | 1294 addBeginTime(elapsed, elapsed + condition->offset()); |
| 1295 else | 1295 else |
| 1296 addEndTime(elapsed, elapsed + condition->offset()); | 1296 addEndTime(elapsed, elapsed + condition->offset()); |
| 1297 } | 1297 } |
| 1298 | 1298 |
| 1299 void SVGSMILElement::beginByLinkActivation() | 1299 void SVGSMILElement::beginByLinkActivation() |
| 1300 { | 1300 { |
| 1301 SMILTime elapsed = this->elapsed(); | 1301 SMILTime elapsed = this->elapsed(); |
| 1302 if (elapsed.isUnresolved()) | 1302 if (elapsed.isUnresolved()) |
| 1303 return; | 1303 return; |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1368 visitor->trace(m_targetElement); | 1368 visitor->trace(m_targetElement); |
| 1369 visitor->trace(m_timeContainer); | 1369 visitor->trace(m_timeContainer); |
| 1370 visitor->trace(m_conditions); | 1370 visitor->trace(m_conditions); |
| 1371 visitor->trace(m_syncBaseDependents); | 1371 visitor->trace(m_syncBaseDependents); |
| 1372 #endif | 1372 #endif |
| 1373 SVGElement::trace(visitor); | 1373 SVGElement::trace(visitor); |
| 1374 SVGTests::trace(visitor); | 1374 SVGTests::trace(visitor); |
| 1375 } | 1375 } |
| 1376 | 1376 |
| 1377 } // namespace blink | 1377 } // namespace blink |
| OLD | NEW |