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

Side by Side 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: Oilpan Created 5 years 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "config.h"
6 #include "core/animation/animatable/AnimatablePath.h"
7
8 #include "core/svg/SVGPathBlender.h"
9 #include "core/svg/SVGPathByteStreamBuilder.h"
10 #include "core/svg/SVGPathByteStreamSource.h"
11 #include "core/svg/SVGPathUtilities.h"
12
13 namespace blink {
14
15 bool AnimatablePath::usesDefaultInterpolationWith(const AnimatableValue* value) const
16 {
17 // Default interpolation is used if the paths have different lengths,
18 // or the paths have a segment with different types (ignoring "relativeness" ).
19
20 SVGPathByteStreamSource fromSource(pathValue()->byteStream());
21 SVGPathByteStreamSource toSource(toAnimatablePath(value)->pathValue()->byteS tream());
22
23 while (fromSource.hasMoreData()) {
24 if (!toSource.hasMoreData())
25 return true;
26
27 PathSegmentData fromSeg = fromSource.parseSegment();
28 PathSegmentData toSeg = toSource.parseSegment();
29 ASSERT(fromSeg.command != PathSegUnknown);
30 ASSERT(toSeg.command != PathSegUnknown);
31
32 if (toAbsolutePathSegType(fromSeg.command) != toAbsolutePathSegType(toSe g.command))
33 return true;
34 }
35
36 return toSource.hasMoreData();
37 }
38
39 PassRefPtr<AnimatableValue> AnimatablePath::interpolateTo(const AnimatableValue* value, double fraction) const
40 {
41 if (usesDefaultInterpolationWith(value))
42 return defaultInterpolateTo(this, value, fraction);
43
44 OwnPtr<SVGPathByteStream> byteStream = SVGPathByteStream::create();
45 SVGPathByteStreamBuilder builder(*byteStream);
46
47 SVGPathByteStreamSource fromSource(pathValue()->byteStream());
48 SVGPathByteStreamSource toSource(toAnimatablePath(value)->pathValue()->byteS tream());
49
50 SVGPathBlender blender(&fromSource, &toSource, &builder);
51 bool ok = blender.blendAnimatedPath(fraction);
52 ASSERT_UNUSED(ok, ok);
53 return AnimatablePath::create(CSSPathValue::create(byteStream.release()));
54 }
55
56 bool AnimatablePath::equalTo(const AnimatableValue* value) const
57 {
58 return pathValue()->equals(*toAnimatablePath(value)->pathValue());
59 }
60
61 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698