summaryrefslogtreecommitdiff
path: root/Source/WebCore/svg/SVGAnimatedPath.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/svg/SVGAnimatedPath.cpp')
-rw-r--r--Source/WebCore/svg/SVGAnimatedPath.cpp66
1 files changed, 34 insertions, 32 deletions
diff --git a/Source/WebCore/svg/SVGAnimatedPath.cpp b/Source/WebCore/svg/SVGAnimatedPath.cpp
index b210ad95f..29e249bc8 100644
--- a/Source/WebCore/svg/SVGAnimatedPath.cpp
+++ b/Source/WebCore/svg/SVGAnimatedPath.cpp
@@ -18,11 +18,9 @@
*/
#include "config.h"
-
-#if ENABLE(SVG)
#include "SVGAnimatedPath.h"
-#include "SVGAnimateElement.h"
+#include "SVGAnimateElementBase.h"
#include "SVGAnimatedPathSegListPropertyTearOff.h"
#include "SVGPathUtilities.h"
@@ -36,47 +34,53 @@ SVGAnimatedPathAnimator::SVGAnimatedPathAnimator(SVGAnimationElement* animationE
std::unique_ptr<SVGAnimatedType> SVGAnimatedPathAnimator::constructFromString(const String& string)
{
auto byteStream = std::make_unique<SVGPathByteStream>();
- buildSVGPathByteStreamFromString(string, byteStream.get(), UnalteredParsing);
- return SVGAnimatedType::createPath(std::move(byteStream));
+ buildSVGPathByteStreamFromString(string, *byteStream, UnalteredParsing);
+ return SVGAnimatedType::createPath(WTFMove(byteStream));
}
std::unique_ptr<SVGAnimatedType> SVGAnimatedPathAnimator::startAnimValAnimation(const SVGElementAnimatedPropertyList& animatedTypes)
{
ASSERT(animatedTypes.size() >= 1);
- SVGAnimatedPathSegListPropertyTearOff* property = castAnimatedPropertyToActualType<SVGAnimatedPathSegListPropertyTearOff>(animatedTypes[0].properties[0].get());
- const SVGPathSegList& baseValue = property->currentBaseValue();
// Build initial path byte stream.
auto byteStream = std::make_unique<SVGPathByteStream>();
- buildSVGPathByteStreamFromSVGPathSegList(baseValue, byteStream.get(), UnalteredParsing);
+ resetAnimValToBaseVal(animatedTypes, byteStream.get());
+ return SVGAnimatedType::createPath(WTFMove(byteStream));
+}
- Vector<RefPtr<SVGAnimatedPathSegListPropertyTearOff>> result;
+void SVGAnimatedPathAnimator::stopAnimValAnimation(const SVGElementAnimatedPropertyList& animatedTypes)
+{
+ stopAnimValAnimationForType<SVGAnimatedPathSegListPropertyTearOff>(animatedTypes);
+}
- SVGElementAnimatedPropertyList::const_iterator end = animatedTypes.end();
- for (SVGElementAnimatedPropertyList::const_iterator it = animatedTypes.begin(); it != end; ++it)
- result.append(castAnimatedPropertyToActualType<SVGAnimatedPathSegListPropertyTearOff>(it->properties[0].get()));
+void SVGAnimatedPathAnimator::resetAnimValToBaseVal(const SVGElementAnimatedPropertyList& animatedTypes, SVGPathByteStream* byteStream)
+{
+ SVGAnimatedPathSegListPropertyTearOff* property = castAnimatedPropertyToActualType<SVGAnimatedPathSegListPropertyTearOff>(animatedTypes[0].properties[0].get());
+ const auto& baseValue = property->currentBaseValue();
- SVGElementInstance::InstanceUpdateBlocker blocker(property->contextElement());
+ buildSVGPathByteStreamFromSVGPathSegListValues(baseValue, *byteStream, UnalteredParsing);
- size_t resultSize = result.size();
- for (size_t i = 0; i < resultSize; ++i)
- result[i]->animationStarted(byteStream.get(), &baseValue);
+ Vector<RefPtr<SVGAnimatedPathSegListPropertyTearOff>> result;
- return SVGAnimatedType::createPath(std::move(byteStream));
-}
+ for (auto& type : animatedTypes) {
+ auto* segment = castAnimatedPropertyToActualType<SVGAnimatedPathSegListPropertyTearOff>(type.properties[0].get());
+ if (segment->isAnimating())
+ continue;
+ result.append(segment);
+ }
-void SVGAnimatedPathAnimator::stopAnimValAnimation(const SVGElementAnimatedPropertyList& animatedTypes)
-{
- stopAnimValAnimationForType<SVGAnimatedPathSegListPropertyTearOff>(animatedTypes);
+ if (!result.isEmpty()) {
+ SVGElement::InstanceUpdateBlocker blocker(*property->contextElement());
+ for (auto& segment : result)
+ segment->animationStarted(byteStream, &baseValue);
+ }
}
-void SVGAnimatedPathAnimator::resetAnimValToBaseVal(const SVGElementAnimatedPropertyList& animatedTypes, SVGAnimatedType* type)
+void SVGAnimatedPathAnimator::resetAnimValToBaseVal(const SVGElementAnimatedPropertyList& animatedTypes, SVGAnimatedType& type)
{
ASSERT(animatedTypes.size() >= 1);
- ASSERT(type);
- ASSERT(type->type() == m_type);
- const SVGPathSegList& baseValue = castAnimatedPropertyToActualType<SVGAnimatedPathSegListPropertyTearOff>(animatedTypes[0].properties[0].get())->currentBaseValue();
- buildSVGPathByteStreamFromSVGPathSegList(baseValue, type->path(), UnalteredParsing);
+ ASSERT(type.type() == m_type);
+ resetAnimValToBaseVal(animatedTypes, type.path());
}
void SVGAnimatedPathAnimator::animValWillChange(const SVGElementAnimatedPropertyList& animatedTypes)
@@ -99,7 +103,7 @@ void SVGAnimatedPathAnimator::addAnimatedTypes(SVGAnimatedType* from, SVGAnimate
unsigned fromPathSize = fromPath->size();
if (!fromPathSize || fromPathSize != toPath->size())
return;
- addToSVGPathByteStream(toPath, fromPath);
+ addToSVGPathByteStream(*toPath, *fromPath);
}
void SVGAnimatedPathAnimator::calculateAnimatedValue(float percentage, unsigned repeatCount, SVGAnimatedType* from, SVGAnimatedType* to, SVGAnimatedType* toAtEndOfDuration, SVGAnimatedType* animated)
@@ -128,15 +132,15 @@ void SVGAnimatedPathAnimator::calculateAnimatedValue(float percentage, unsigned
if (!m_animationElement->adjustFromToListValues<SVGPathByteStream>(*fromPath, *toPath, *animatedPath, percentage, false))
return;
- buildAnimatedSVGPathByteStream(fromPath, toPath, animatedPath, percentage);
+ buildAnimatedSVGPathByteStream(*fromPath, *toPath, *animatedPath, percentage);
// Handle additive='sum'.
if (lastAnimatedPath)
- addToSVGPathByteStream(animatedPath, lastAnimatedPath.get());
+ addToSVGPathByteStream(*animatedPath, *lastAnimatedPath);
// Handle accumulate='sum'.
if (m_animationElement->isAccumulated() && repeatCount)
- addToSVGPathByteStream(animatedPath, toAtEndOfDurationPath, repeatCount);
+ addToSVGPathByteStream(*animatedPath, *toAtEndOfDurationPath, repeatCount);
}
float SVGAnimatedPathAnimator::calculateDistance(const String&, const String&)
@@ -146,5 +150,3 @@ float SVGAnimatedPathAnimator::calculateDistance(const String&, const String&)
}
}
-
-#endif // ENABLE(SVG)