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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 if (const ConditionEventListener* conditionEventListener = | 114 if (const ConditionEventListener* conditionEventListener = |
115 ConditionEventListener::cast(&listener)) | 115 ConditionEventListener::cast(&listener)) |
116 return m_animation == conditionEventListener->m_animation && | 116 return m_animation == conditionEventListener->m_animation && |
117 m_condition == conditionEventListener->m_condition; | 117 m_condition == conditionEventListener->m_condition; |
118 return false; | 118 return false; |
119 } | 119 } |
120 | 120 |
121 void ConditionEventListener::handleEvent(ExecutionContext*, Event* event) { | 121 void ConditionEventListener::handleEvent(ExecutionContext*, Event* event) { |
122 if (!m_animation) | 122 if (!m_animation) |
123 return; | 123 return; |
124 m_animation->handleConditionEvent(event, m_condition); | 124 if (event->type() == "repeatn" && |
| 125 toRepeatEvent(event)->repeat() != m_condition->repeat()) |
| 126 return; |
| 127 m_animation->addInstanceTime(m_condition->getBeginOrEnd(), |
| 128 m_animation->elapsed() + m_condition->offset()); |
125 } | 129 } |
126 | 130 |
127 SVGSMILElement::Condition::Condition(Type type, | 131 SVGSMILElement::Condition::Condition(Type type, |
128 BeginOrEnd beginOrEnd, | 132 BeginOrEnd beginOrEnd, |
129 const AtomicString& baseID, | 133 const AtomicString& baseID, |
130 const AtomicString& name, | 134 const AtomicString& name, |
131 SMILTime offset, | 135 SMILTime offset, |
132 int repeat) | 136 int repeat) |
133 : m_type(type), | 137 : m_type(type), |
134 m_beginOrEnd(beginOrEnd), | 138 m_beginOrEnd(beginOrEnd), |
(...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
713 return m_cachedMin; | 717 return m_cachedMin; |
714 const AtomicString& value = fastGetAttribute(SVGNames::minAttr); | 718 const AtomicString& value = fastGetAttribute(SVGNames::minAttr); |
715 SMILTime result = parseClockValue(value); | 719 SMILTime result = parseClockValue(value); |
716 return m_cachedMin = (result.isUnresolved() || result < 0) ? 0 : result; | 720 return m_cachedMin = (result.isUnresolved() || result < 0) ? 0 : result; |
717 } | 721 } |
718 | 722 |
719 SMILTime SVGSMILElement::simpleDuration() const { | 723 SMILTime SVGSMILElement::simpleDuration() const { |
720 return std::min(dur(), SMILTime::indefinite()); | 724 return std::min(dur(), SMILTime::indefinite()); |
721 } | 725 } |
722 | 726 |
723 void SVGSMILElement::addBeginTime(SMILTime eventTime, | 727 void SVGSMILElement::addInstanceTime(BeginOrEnd beginOrEnd, |
724 SMILTime beginTime, | 728 SMILTime time, |
725 SMILTimeWithOrigin::Origin origin) { | 729 SMILTimeWithOrigin::Origin origin) { |
726 m_beginTimes.push_back(SMILTimeWithOrigin(beginTime, origin)); | 730 SMILTime elapsed = this->elapsed(); |
727 sortTimeList(m_beginTimes); | 731 if (elapsed.isUnresolved()) |
728 beginListChanged(eventTime); | 732 return; |
729 } | 733 Vector<SMILTimeWithOrigin>& list = |
730 | 734 beginOrEnd == Begin ? m_beginTimes : m_endTimes; |
731 void SVGSMILElement::addEndTime(SMILTime eventTime, | 735 list.push_back(SMILTimeWithOrigin(time, origin)); |
732 SMILTime endTime, | 736 sortTimeList(list); |
733 SMILTimeWithOrigin::Origin origin) { | 737 if (beginOrEnd == Begin) |
734 m_endTimes.push_back(SMILTimeWithOrigin(endTime, origin)); | 738 beginListChanged(elapsed); |
735 sortTimeList(m_endTimes); | 739 else |
736 endListChanged(eventTime); | 740 endListChanged(elapsed); |
737 } | 741 } |
738 | 742 |
739 inline bool compareTimes(const SMILTimeWithOrigin& left, | 743 inline bool compareTimes(const SMILTimeWithOrigin& left, |
740 const SMILTimeWithOrigin& right) { | 744 const SMILTimeWithOrigin& right) { |
741 return left.time() < right.time(); | 745 return left.time() < right.time(); |
742 } | 746 } |
743 | 747 |
744 SMILTime SVGSMILElement::findInstanceTime(BeginOrEnd beginOrEnd, | 748 SMILTime SVGSMILElement::findInstanceTime(BeginOrEnd beginOrEnd, |
745 SMILTime minimumTime, | 749 SMILTime minimumTime, |
746 bool equalsMinimumOK) const { | 750 bool equalsMinimumOK) const { |
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1203 ASSERT(condition->name() == "begin" || condition->name() == "end"); | 1207 ASSERT(condition->name() == "begin" || condition->name() == "end"); |
1204 // No nested time containers in SVG, no need for crazy time space | 1208 // No nested time containers in SVG, no need for crazy time space |
1205 // conversions. Phew! | 1209 // conversions. Phew! |
1206 SMILTime time = 0; | 1210 SMILTime time = 0; |
1207 if (condition->name() == "begin") | 1211 if (condition->name() == "begin") |
1208 time = syncBase.m_interval.begin + condition->offset(); | 1212 time = syncBase.m_interval.begin + condition->offset(); |
1209 else | 1213 else |
1210 time = syncBase.m_interval.end + condition->offset(); | 1214 time = syncBase.m_interval.end + condition->offset(); |
1211 if (!time.isFinite()) | 1215 if (!time.isFinite()) |
1212 continue; | 1216 continue; |
1213 SMILTime elapsed = this->elapsed(); | 1217 addInstanceTime(condition->getBeginOrEnd(), time); |
1214 if (elapsed.isUnresolved()) | |
1215 continue; | |
1216 if (condition->getBeginOrEnd() == Begin) | |
1217 addBeginTime(elapsed, time); | |
1218 else | |
1219 addEndTime(elapsed, time); | |
1220 } | 1218 } |
1221 } | 1219 } |
1222 } | 1220 } |
1223 | 1221 |
1224 void SVGSMILElement::addSyncBaseDependent(SVGSMILElement& animation) { | 1222 void SVGSMILElement::addSyncBaseDependent(SVGSMILElement& animation) { |
1225 m_syncBaseDependents.insert(&animation); | 1223 m_syncBaseDependents.insert(&animation); |
1226 if (m_interval.begin.isFinite()) | 1224 if (m_interval.begin.isFinite()) |
1227 animation.createInstanceTimesFromSyncbase(*this); | 1225 animation.createInstanceTimesFromSyncbase(*this); |
1228 } | 1226 } |
1229 | 1227 |
1230 void SVGSMILElement::removeSyncBaseDependent(SVGSMILElement& animation) { | 1228 void SVGSMILElement::removeSyncBaseDependent(SVGSMILElement& animation) { |
1231 m_syncBaseDependents.erase(&animation); | 1229 m_syncBaseDependents.erase(&animation); |
1232 } | 1230 } |
1233 | 1231 |
1234 void SVGSMILElement::handleConditionEvent(Event* event, Condition* condition) { | |
1235 if (event->type() == "repeatn" && | |
1236 toRepeatEvent(event)->repeat() != condition->repeat()) | |
1237 return; | |
1238 | |
1239 SMILTime elapsed = this->elapsed(); | |
1240 if (elapsed.isUnresolved()) | |
1241 return; | |
1242 if (condition->getBeginOrEnd() == Begin) | |
1243 addBeginTime(elapsed, elapsed + condition->offset()); | |
1244 else | |
1245 addEndTime(elapsed, elapsed + condition->offset()); | |
1246 } | |
1247 | |
1248 void SVGSMILElement::beginByLinkActivation() { | 1232 void SVGSMILElement::beginByLinkActivation() { |
1249 SMILTime elapsed = this->elapsed(); | 1233 addInstanceTime(Begin, elapsed()); |
1250 if (elapsed.isUnresolved()) | |
1251 return; | |
1252 addBeginTime(elapsed, elapsed); | |
1253 } | 1234 } |
1254 | 1235 |
1255 void SVGSMILElement::endedActiveInterval() { | 1236 void SVGSMILElement::endedActiveInterval() { |
1256 clearTimesWithDynamicOrigins(m_beginTimes); | 1237 clearTimesWithDynamicOrigins(m_beginTimes); |
1257 clearTimesWithDynamicOrigins(m_endTimes); | 1238 clearTimesWithDynamicOrigins(m_endTimes); |
1258 } | 1239 } |
1259 | 1240 |
1260 void SVGSMILElement::scheduleRepeatEvents(unsigned count) { | 1241 void SVGSMILElement::scheduleRepeatEvents(unsigned count) { |
1261 m_repeatEventCountList.push_back(count); | 1242 m_repeatEventCountList.push_back(count); |
1262 scheduleEvent(EventTypeNames::repeatEvent); | 1243 scheduleEvent(EventTypeNames::repeatEvent); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1310 DEFINE_TRACE(SVGSMILElement) { | 1291 DEFINE_TRACE(SVGSMILElement) { |
1311 visitor->trace(m_targetElement); | 1292 visitor->trace(m_targetElement); |
1312 visitor->trace(m_timeContainer); | 1293 visitor->trace(m_timeContainer); |
1313 visitor->trace(m_conditions); | 1294 visitor->trace(m_conditions); |
1314 visitor->trace(m_syncBaseDependents); | 1295 visitor->trace(m_syncBaseDependents); |
1315 SVGElement::trace(visitor); | 1296 SVGElement::trace(visitor); |
1316 SVGTests::trace(visitor); | 1297 SVGTests::trace(visitor); |
1317 } | 1298 } |
1318 | 1299 |
1319 } // namespace blink | 1300 } // namespace blink |
OLD | NEW |