| Index: third_party/WebKit/Source/core/svg/SVGPath.cpp
|
| diff --git a/third_party/WebKit/Source/core/svg/SVGPath.cpp b/third_party/WebKit/Source/core/svg/SVGPath.cpp
|
| index 51637639503b0e4fe970a932d70c2ce193714785..fe94ce40ade47cbe38fd506963600aa250eb07c5 100644
|
| --- a/third_party/WebKit/Source/core/svg/SVGPath.cpp
|
| +++ b/third_party/WebKit/Source/core/svg/SVGPath.cpp
|
| @@ -48,30 +48,35 @@ PassOwnPtr<SVGPathByteStream> blendPathByteStreams(const SVGPathByteStream& from
|
| return resultStream.release();
|
| }
|
|
|
| -PassOwnPtr<SVGPathByteStream> addPathByteStreams(PassOwnPtr<SVGPathByteStream> fromStream, const SVGPathByteStream& byStream, unsigned repeatCount = 1)
|
| +PassOwnPtr<SVGPathByteStream> addPathByteStreams(const SVGPathByteStream& fromStream, const SVGPathByteStream& byStream, unsigned repeatCount = 1)
|
| {
|
| - if (fromStream->isEmpty() || byStream.isEmpty())
|
| - return fromStream;
|
| - OwnPtr<SVGPathByteStream> tempFromStream = fromStream;
|
| OwnPtr<SVGPathByteStream> resultStream = SVGPathByteStream::create();
|
| SVGPathByteStreamBuilder builder(*resultStream);
|
| - SVGPathByteStreamSource fromSource(*tempFromStream);
|
| + SVGPathByteStreamSource fromSource(fromStream);
|
| SVGPathByteStreamSource bySource(byStream);
|
| SVGPathBlender blender(&fromSource, &bySource, &builder);
|
| blender.addAnimatedPath(repeatCount);
|
| return resultStream.release();
|
| }
|
|
|
| +PassOwnPtr<SVGPathByteStream> conditionallyAddPathByteStreams(PassOwnPtr<SVGPathByteStream> fromStream, const SVGPathByteStream& byStream, unsigned repeatCount = 1)
|
| +{
|
| + if (fromStream->isEmpty() || byStream.isEmpty())
|
| + return fromStream;
|
| + return addPathByteStreams(*fromStream, byStream, repeatCount);
|
| +}
|
| +
|
| }
|
|
|
| SVGPath::SVGPath()
|
| : SVGPropertyBase(classType())
|
| + , m_pathValue(CSSPathValue::emptyPathValue())
|
| {
|
| }
|
|
|
| -SVGPath::SVGPath(PassOwnPtr<SVGPathByteStream> byteStream)
|
| +SVGPath::SVGPath(PassRefPtrWillBeRawPtr<CSSPathValue> d)
|
| : SVGPropertyBase(classType())
|
| - , m_byteStream(byteStream)
|
| + , m_pathValue(d)
|
| {
|
| }
|
|
|
| @@ -79,71 +84,40 @@ SVGPath::~SVGPath()
|
| {
|
| }
|
|
|
| -const Path& SVGPath::path() const
|
| -{
|
| - if (!m_cachedPath) {
|
| - m_cachedPath = adoptPtr(new Path);
|
| - buildPathFromByteStream(byteStream(), *m_cachedPath);
|
| - }
|
| -
|
| - return *m_cachedPath;
|
| -}
|
| -
|
| -PassRefPtrWillBeRawPtr<SVGPath> SVGPath::clone() const
|
| -{
|
| - return SVGPath::create(byteStream().copy());
|
| -}
|
| -
|
| -PassRefPtrWillBeRawPtr<SVGPropertyBase> SVGPath::cloneForAnimation(const String& value) const
|
| +String SVGPath::valueAsString() const
|
| {
|
| - RefPtrWillBeRawPtr<SVGPath> svgPath = SVGPath::create();
|
| - svgPath->setValueAsString(value, IGNORE_EXCEPTION);
|
| - return svgPath;
|
| + return m_pathValue->pathString();
|
| }
|
|
|
| -SVGPathByteStream& SVGPath::ensureByteStream()
|
| -{
|
| - if (!m_byteStream)
|
| - m_byteStream = SVGPathByteStream::create();
|
| -
|
| - return *m_byteStream.get();
|
| -}
|
|
|
| -void SVGPath::byteStreamChanged()
|
| -{
|
| - m_cachedPath.clear();
|
| -}
|
| -
|
| -const SVGPathByteStream& SVGPath::byteStream() const
|
| +PassRefPtrWillBeRawPtr<SVGPath> SVGPath::clone() const
|
| {
|
| - return const_cast<SVGPath*>(this)->ensureByteStream();
|
| + return SVGPath::create(m_pathValue);
|
| }
|
|
|
| -String SVGPath::valueAsString() const
|
| -{
|
| - return buildStringFromByteStream(byteStream());
|
| -}
|
|
|
| void SVGPath::setValueAsString(const String& string, ExceptionState& exceptionState)
|
| {
|
| - if (!buildByteStreamFromString(string, ensureByteStream()))
|
| + OwnPtr<SVGPathByteStream> byteStream = SVGPathByteStream::create();
|
| + if (!buildByteStreamFromString(string, *byteStream))
|
| exceptionState.throwDOMException(SyntaxError, "Problem parsing path \"" + string + "\"");
|
| - byteStreamChanged();
|
| + m_pathValue = CSSPathValue::create(byteStream.release());
|
| }
|
|
|
| -void SVGPath::setValueAsByteStream(PassOwnPtr<SVGPathByteStream> byteStream)
|
| +PassRefPtrWillBeRawPtr<SVGPropertyBase> SVGPath::cloneForAnimation(const String& value) const
|
| {
|
| - m_byteStream = byteStream;
|
| - byteStreamChanged();
|
| + return SVGPath::create(CSSPathValue::create(value));
|
| }
|
|
|
| void SVGPath::add(PassRefPtrWillBeRawPtr<SVGPropertyBase> other, SVGElement*)
|
| {
|
| const SVGPathByteStream& otherPathByteStream = toSVGPath(other)->byteStream();
|
| - if (byteStream().size() != otherPathByteStream.size())
|
| + if (byteStream().size() != otherPathByteStream.size()
|
| + || byteStream().isEmpty()
|
| + || otherPathByteStream.isEmpty())
|
| return;
|
|
|
| - setValueAsByteStream(addPathByteStreams(m_byteStream.release(), otherPathByteStream));
|
| + m_pathValue = CSSPathValue::create(addPathByteStreams(byteStream(), otherPathByteStream));
|
| }
|
|
|
| void SVGPath::calculateAnimatedValue(SVGAnimationElement* animationElement, float percentage, unsigned repeatCount, PassRefPtrWillBeRawPtr<SVGPropertyBase> fromValue, PassRefPtrWillBeRawPtr<SVGPropertyBase> toValue, PassRefPtrWillBeRawPtr<SVGPropertyBase> toAtEndOfDurationValue, SVGElement*)
|
| @@ -171,27 +145,26 @@ void SVGPath::calculateAnimatedValue(SVGAnimationElement* animationElement, floa
|
| if (fromStream->size() != toStream.size() && fromStream->size()) {
|
| if (percentage < 0.5) {
|
| if (!isToAnimation) {
|
| - setValueAsByteStream(fromStream->copy());
|
| + m_pathValue = from->pathValue();
|
| return;
|
| }
|
| } else {
|
| - setValueAsByteStream(toStream.copy());
|
| + m_pathValue = to->pathValue();
|
| return;
|
| }
|
| }
|
|
|
| - OwnPtr<SVGPathByteStream> lastAnimatedStream = m_byteStream.release();
|
| OwnPtr<SVGPathByteStream> newStream = blendPathByteStreams(*fromStream, toStream, percentage);
|
|
|
| // Handle additive='sum'.
|
| - if (!fromStream->size() || (animationElement->isAdditive() && !isToAnimation))
|
| - newStream = addPathByteStreams(newStream.release(), *lastAnimatedStream);
|
| + if (animationElement->isAdditive() && !isToAnimation)
|
| + newStream = conditionallyAddPathByteStreams(newStream.release(), byteStream());
|
|
|
| // Handle accumulate='sum'.
|
| if (animationElement->isAccumulated() && repeatCount)
|
| - newStream = addPathByteStreams(newStream.release(), toSVGPath(toAtEndOfDurationValue)->byteStream(), repeatCount);
|
| + newStream = conditionallyAddPathByteStreams(newStream.release(), toSVGPath(toAtEndOfDurationValue)->byteStream(), repeatCount);
|
|
|
| - setValueAsByteStream(newStream.release());
|
| + m_pathValue = CSSPathValue::create(newStream.release());
|
| }
|
|
|
| float SVGPath::calculateDistance(PassRefPtrWillBeRawPtr<SVGPropertyBase> to, SVGElement*)
|
|
|