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

Side by Side Diff: Source/core/animation/KeyframeAnimationEffect.cpp

Issue 22707006: Web Animations CSS: Assert underlying value is not used (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Review changes Created 7 years, 4 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 26 matching lines...) Expand all
37 namespace { 37 namespace {
38 38
39 using namespace WebCore; 39 using namespace WebCore;
40 40
41 class ReplaceCompositableValue : public AnimationEffect::CompositableValue { 41 class ReplaceCompositableValue : public AnimationEffect::CompositableValue {
42 public: 42 public:
43 static PassRefPtr<ReplaceCompositableValue> create(const AnimatableValue* va lue) 43 static PassRefPtr<ReplaceCompositableValue> create(const AnimatableValue* va lue)
44 { 44 {
45 return adoptRef(new ReplaceCompositableValue(value)); 45 return adoptRef(new ReplaceCompositableValue(value));
46 } 46 }
47 virtual bool dependsOnUnderlyingValue() const
48 {
49 return false;
50 }
47 virtual PassRefPtr<AnimatableValue> compositeOnto(const AnimatableValue* und erlyingValue) const 51 virtual PassRefPtr<AnimatableValue> compositeOnto(const AnimatableValue* und erlyingValue) const
48 { 52 {
49 return PassRefPtr<AnimatableValue>(m_value); 53 return PassRefPtr<AnimatableValue>(m_value);
50 } 54 }
51 private: 55 private:
52 ReplaceCompositableValue(const AnimatableValue* value) 56 ReplaceCompositableValue(const AnimatableValue* value)
53 : m_value(const_cast<AnimatableValue*>(value)) 57 : m_value(const_cast<AnimatableValue*>(value))
54 { 58 {
55 } 59 }
56 RefPtr<AnimatableValue> m_value; 60 RefPtr<AnimatableValue> m_value;
57 }; 61 };
58 62
59 class AddCompositableValue : public AnimationEffect::CompositableValue { 63 class AddCompositableValue : public AnimationEffect::CompositableValue {
60 public: 64 public:
61 static PassRefPtr<AddCompositableValue> create(const AnimatableValue* value) 65 static PassRefPtr<AddCompositableValue> create(const AnimatableValue* value)
62 { 66 {
63 return adoptRef(new AddCompositableValue(value)); 67 return adoptRef(new AddCompositableValue(value));
64 } 68 }
69 virtual bool dependsOnUnderlyingValue() const
70 {
71 return true;
72 }
65 virtual PassRefPtr<AnimatableValue> compositeOnto(const AnimatableValue* und erlyingValue) const 73 virtual PassRefPtr<AnimatableValue> compositeOnto(const AnimatableValue* und erlyingValue) const
66 { 74 {
67 return AnimatableValue::add(underlyingValue, m_value.get()); 75 return AnimatableValue::add(underlyingValue, m_value.get());
68 } 76 }
69 private: 77 private:
70 AddCompositableValue(const AnimatableValue* value) 78 AddCompositableValue(const AnimatableValue* value)
71 : m_value(const_cast<AnimatableValue*>(value)) 79 : m_value(const_cast<AnimatableValue*>(value))
72 { 80 {
73 } 81 }
74 RefPtr<AnimatableValue> m_value; 82 RefPtr<AnimatableValue> m_value;
75 }; 83 };
76 84
77 class BlendedCompositableValue : public AnimationEffect::CompositableValue { 85 class BlendedCompositableValue : public AnimationEffect::CompositableValue {
78 public: 86 public:
79 static PassRefPtr<BlendedCompositableValue> create(const AnimationEffect::Co mpositableValue* before, const AnimationEffect::CompositableValue* after, double fraction) 87 static PassRefPtr<BlendedCompositableValue> create(const AnimationEffect::Co mpositableValue* before, const AnimationEffect::CompositableValue* after, double fraction)
80 { 88 {
81 return adoptRef(new BlendedCompositableValue(before, after, fraction)); 89 return adoptRef(new BlendedCompositableValue(before, after, fraction));
82 } 90 }
91 virtual bool dependsOnUnderlyingValue() const
92 {
93 return m_dependsOnUnderlyingValue;
94 }
83 virtual PassRefPtr<AnimatableValue> compositeOnto(const AnimatableValue* und erlyingValue) const 95 virtual PassRefPtr<AnimatableValue> compositeOnto(const AnimatableValue* und erlyingValue) const
84 { 96 {
85 return AnimatableValue::interpolate(m_before->compositeOnto(underlyingVa lue).get(), m_after->compositeOnto(underlyingValue).get(), m_fraction); 97 return AnimatableValue::interpolate(m_before->compositeOnto(underlyingVa lue).get(), m_after->compositeOnto(underlyingValue).get(), m_fraction);
86 } 98 }
87 private: 99 private:
88 BlendedCompositableValue(const AnimationEffect::CompositableValue* before, c onst AnimationEffect::CompositableValue* after, double fraction) 100 BlendedCompositableValue(const AnimationEffect::CompositableValue* before, c onst AnimationEffect::CompositableValue* after, double fraction)
89 : m_before(const_cast<AnimationEffect::CompositableValue*>(before)) 101 : m_before(const_cast<AnimationEffect::CompositableValue*>(before))
90 , m_after(const_cast<AnimationEffect::CompositableValue*>(after)) 102 , m_after(const_cast<AnimationEffect::CompositableValue*>(after))
91 , m_fraction(fraction) 103 , m_fraction(fraction)
104 , m_dependsOnUnderlyingValue(before->dependsOnUnderlyingValue() || after ->dependsOnUnderlyingValue())
92 { } 105 { }
93 RefPtr<AnimationEffect::CompositableValue> m_before; 106 RefPtr<AnimationEffect::CompositableValue> m_before;
94 RefPtr<AnimationEffect::CompositableValue> m_after; 107 RefPtr<AnimationEffect::CompositableValue> m_after;
95 double m_fraction; 108 double m_fraction;
109 bool m_dependsOnUnderlyingValue;
96 }; 110 };
97 111
98 } // namespace 112 } // namespace
99 113
100 114
101 namespace WebCore { 115 namespace WebCore {
102 116
103 Keyframe::Keyframe() 117 Keyframe::Keyframe()
104 : m_offset(std::numeric_limits<double>::quiet_NaN()) 118 : m_offset(std::numeric_limits<double>::quiet_NaN())
105 , m_composite(AnimationEffect::CompositeReplace) 119 , m_composite(AnimationEffect::CompositeReplace)
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 315
302 if ((*before)->offset() == offset) 316 if ((*before)->offset() == offset)
303 return const_cast<CompositableValue*>((*before)->value()); 317 return const_cast<CompositableValue*>((*before)->value());
304 if ((*after)->offset() == offset) 318 if ((*after)->offset() == offset)
305 return const_cast<CompositableValue*>((*after)->value()); 319 return const_cast<CompositableValue*>((*after)->value());
306 return BlendedCompositableValue::create((*before)->value(), (*after)->value( ), 320 return BlendedCompositableValue::create((*before)->value(), (*after)->value( ),
307 (offset - (*before)->offset()) / ((*after)->offset() - (*before)->offset ())); 321 (offset - (*before)->offset()) / ((*after)->offset() - (*before)->offset ()));
308 } 322 }
309 323
310 } // namespace 324 } // namespace
OLDNEW
« no previous file with comments | « Source/core/animation/AnimationEffect.h ('k') | Source/core/animation/KeyframeAnimationEffectTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698