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

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

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

Powered by Google App Engine
This is Rietveld 408576698