Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(128)

Unified Diff: third_party/WebKit/Source/core/animation/animatable/AnimatablePath.cpp

Issue 1473963004: CSS animation for SVG presentation attribute 'd' (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/animation/animatable/AnimatablePath.cpp
diff --git a/third_party/WebKit/Source/core/animation/animatable/AnimatablePath.cpp b/third_party/WebKit/Source/core/animation/animatable/AnimatablePath.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..5b30309676b013ab5e79108ce5798abd425cf0dd
--- /dev/null
+++ b/third_party/WebKit/Source/core/animation/animatable/AnimatablePath.cpp
@@ -0,0 +1,68 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "config.h"
+#include "core/animation/animatable/AnimatablePath.h"
+
+#include "core/style/DataEquivalency.h"
+#include "core/svg/SVGPathBlender.h"
+#include "core/svg/SVGPathByteStreamBuilder.h"
+#include "core/svg/SVGPathByteStreamSource.h"
+#include "core/svg/SVGPathUtilities.h"
+
+namespace blink {
+
+bool AnimatablePath::usesDefaultInterpolationWith(const AnimatableValue* value) const
+{
+ // Default interpolation is used if either path is not specified,
+ // or the paths have different lengths,
+ // or the paths have a segment with different types (ignoring "relativeness").
+
+ const SVGPathByteStream* toByteStream = toAnimatablePath(value)->m_byteStream.get();
+ if (!m_byteStream || !toByteStream)
+ return true;
+
+ SVGPathByteStreamSource fromSource(*m_byteStream);
+ SVGPathByteStreamSource toSource(*toByteStream);
+
+ while (fromSource.hasMoreData()) {
+ if (!toSource.hasMoreData())
+ return true;
+
+ PathSegmentData fromSeg = fromSource.parseSegment();
+ PathSegmentData toSeg = toSource.parseSegment();
+ if (fromSeg.command == PathSegUnknown || toSeg.command == PathSegUnknown)
+ return true;
+
+ if (toAbsolutePathSegType(fromSeg.command) != toAbsolutePathSegType(toSeg.command))
+ return true;
+ }
+
+ return toSource.hasMoreData();
+}
+
+PassRefPtr<AnimatableValue> AnimatablePath::interpolateTo(const AnimatableValue* value, double fraction) const
+{
+ if (usesDefaultInterpolationWith(value))
+ return defaultInterpolateTo(this, value, fraction);
+
+ OwnPtr<SVGPathByteStream> byteStream;
+ byteStream = SVGPathByteStream::create();
+ SVGPathByteStreamBuilder builder(*byteStream);
+
+ SVGPathByteStreamSource fromSource(*m_byteStream);
+ SVGPathByteStreamSource toSource(*toAnimatablePath(value)->m_byteStream);
dstockwell 2015/11/26 08:38:40 Is there a representation of paths which is not en
fs 2015/11/26 11:21:38 I believe it's the cheapest representation that re
Eric Willigers 2015/11/26 21:16:33 We will have an InterpolationType. It will fix thi
+
+ SVGPathBlender blender(&fromSource, &toSource, &builder);
+ bool ok = blender.blendAnimatedPath(fraction);
+ ASSERT_UNUSED(ok, ok);
+ return AnimatablePath::create(byteStream.release());
+}
+
+bool AnimatablePath::equalTo(const AnimatableValue* value) const
+{
+ return dataEquivalent(m_byteStream, toAnimatablePath(value)->m_byteStream);
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698