Index: Source/core/svg/animation/SVGSMILElement.cpp |
diff --git a/Source/core/svg/animation/SVGSMILElement.cpp b/Source/core/svg/animation/SVGSMILElement.cpp |
index 8d5347cff2b4dfccc706fa5d7db72cd276fbb6d6..ded42ac2d7dbb93ff065edee0ec9e2b1796cf28e 100644 |
--- a/Source/core/svg/animation/SVGSMILElement.cpp |
+++ b/Source/core/svg/animation/SVGSMILElement.cpp |
@@ -63,6 +63,12 @@ static SMILEventSender& smilRepeatEventSender() |
return sender; |
} |
+static SMILEventSender& smilRepeatNEventSender() |
+{ |
+ DEFINE_STATIC_LOCAL(SMILEventSender, sender, ("repeatn")); |
pdr.
2013/09/03 17:48:14
repeatNEvent?
pavane
2013/09/03 19:00:52
yes, i felt this name is the closest to represent
|
+ return sender; |
+} |
+ |
// This is used for duration type time values that can't be negative. |
static const double invalidCachedTime = -1.; |
@@ -115,13 +121,12 @@ void ConditionEventListener::handleEvent(ScriptExecutionContext*, Event* event) |
m_animation->handleConditionEvent(event, m_condition); |
} |
-SVGSMILElement::Condition::Condition(Type type, BeginOrEnd beginOrEnd, const String& baseID, const String& name, SMILTime offset, int repeats) |
+SVGSMILElement::Condition::Condition(Type type, BeginOrEnd beginOrEnd, const String& baseID, const String& name, SMILTime offset) |
: m_type(type) |
, m_beginOrEnd(beginOrEnd) |
, m_baseID(baseID) |
, m_name(name) |
, m_offset(offset) |
- , m_repeats(repeats) |
{ |
} |
@@ -155,6 +160,7 @@ SVGSMILElement::~SVGSMILElement() |
smilEndEventSender().cancelEvent(this); |
smilBeginEventSender().cancelEvent(this); |
smilRepeatEventSender().cancelEvent(this); |
+ smilRepeatNEventSender().cancelEvent(this); |
disconnectConditions(); |
if (m_timeContainer && m_targetElement && hasValidAttributeName()) |
m_timeContainer->unschedule(this, m_targetElement, m_attributeName); |
@@ -367,7 +373,6 @@ bool SVGSMILElement::parseCondition(const String& value, BeginOrEnd beginOrEnd) |
String parseString = value.stripWhiteSpace(); |
double sign = 1.; |
- bool ok; |
size_t pos = parseString.find('+'); |
if (pos == notFound) { |
pos = parseString.find('-'); |
@@ -402,16 +407,7 @@ bool SVGSMILElement::parseCondition(const String& value, BeginOrEnd beginOrEnd) |
return false; |
Condition::Type type; |
- int repeats = -1; |
- if (nameString.startsWith("repeat(") && nameString.endsWith(')')) { |
- // FIXME: For repeat events we just need to add the data carrying TimeEvent class and |
- // fire the events at appropiate times. |
- repeats = nameString.substring(7, nameString.length() - 8).toUIntStrict(&ok); |
- if (!ok) |
- return false; |
- nameString = "repeat"; |
- type = Condition::EventBase; |
- } else if (nameString == "begin" || nameString == "end") { |
+ if (nameString == "begin" || nameString == "end") { |
if (baseID.isEmpty()) |
return false; |
type = Condition::Syncbase; |
@@ -421,7 +417,7 @@ bool SVGSMILElement::parseCondition(const String& value, BeginOrEnd beginOrEnd) |
} else |
type = Condition::EventBase; |
- m_conditions.append(Condition(type, beginOrEnd, baseID, nameString, offset, repeats)); |
+ m_conditions.append(Condition(type, beginOrEnd, baseID, nameString, offset)); |
if (type == Condition::EventBase && beginOrEnd == End) |
m_hasEndEventConditions = true; |
@@ -1124,8 +1120,11 @@ bool SVGSMILElement::progress(SMILTime elapsed, SVGSMILElement* resultElement, b |
startedActiveInterval(); |
} |
- if (repeat && repeat != m_lastRepeat) |
+ if (repeat && repeat != m_lastRepeat) { |
smilRepeatEventSender().dispatchEventSoon(this); |
pdr.
2013/09/03 17:48:14
This code is duplicated 3 times. Can you move it t
pavane
2013/09/03 19:00:52
Done.
|
+ m_repeatEventCountList.append(repeat); |
+ smilRepeatNEventSender().dispatchEventSoon(this); |
+ } |
updateAnimation(percent, repeat, resultElement); |
m_lastPercent = percent; |
@@ -1147,9 +1146,14 @@ bool SVGSMILElement::progress(SMILTime elapsed, SVGSMILElement* resultElement, b |
if (repeat) { |
for (unsigned repeatEventCount = 1; repeatEventCount < repeat; repeatEventCount++) { |
smilRepeatEventSender().dispatchEventSoon(this); |
+ m_repeatEventCountList.append(repeatEventCount); |
+ smilRepeatNEventSender().dispatchEventSoon(this); |
} |
- if (m_activeState == Inactive) |
+ if (m_activeState == Inactive) { |
smilRepeatEventSender().dispatchEventSoon(this); |
+ m_repeatEventCountList.append(repeat); |
+ smilRepeatNEventSender().dispatchEventSoon(this); |
+ } |
} |
if (m_activeState == Inactive || m_activeState == Frozen) |
@@ -1234,9 +1238,15 @@ void SVGSMILElement::endedActiveInterval() |
void SVGSMILElement::dispatchPendingEvent(SMILEventSender* eventSender) |
{ |
- ASSERT(eventSender == &smilEndEventSender() || eventSender == &smilBeginEventSender() || eventSender == &smilRepeatEventSender()); |
+ ASSERT(eventSender == &smilEndEventSender() || eventSender == &smilBeginEventSender() || eventSender == &smilRepeatEventSender() || eventSender == &smilRepeatNEventSender()); |
const AtomicString& eventType = eventSender->eventType(); |
- dispatchEvent(Event::create(eventType)); |
+ if (eventType == "repeatn") { |
+ unsigned repeatEventCount = m_repeatEventCountList.first(); |
+ m_repeatEventCountList.remove(0); |
pdr.
2013/09/03 17:48:14
Because this is the only place you remove the even
pavane
2013/09/03 19:00:52
This is not an event list. i am just storing the r
|
+ dispatchEvent(Event::create(String("repeat(" + String::number(repeatEventCount) + ")"))); |
+ } else { |
+ dispatchEvent(Event::create(eventType)); |
+ } |
} |
} |