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

Side by Side Diff: Source/core/animation/StringKeyframe.h

Issue 194733002: Web Animations: Use StringKeyframes for element.animate() (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: More comments Created 6 years, 8 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
« no previous file with comments | « Source/core/animation/KeyframeEffectModel.cpp ('k') | Source/core/animation/StringKeyframe.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #ifndef StringKeyframe_h 5 #ifndef StringKeyframe_h
6 #define StringKeyframe_h 6 #define StringKeyframe_h
7 7
8 #include "core/animation/AnimatableValue.h"
9 #include "core/animation/Keyframe.h" 8 #include "core/animation/Keyframe.h"
9 #include "core/css/StylePropertySet.h"
10 10
11 namespace WebCore { 11 namespace WebCore {
12 12
13 class StyleSheetContents;
14
13 class StringKeyframe : public Keyframe { 15 class StringKeyframe : public Keyframe {
14 public: 16 public:
15 static PassRefPtrWillBeRawPtr<StringKeyframe> create() 17 static PassRefPtrWillBeRawPtr<StringKeyframe> create()
16 { 18 {
17 return adoptRefWillBeNoop(new StringKeyframe); 19 return adoptRefWillBeNoop(new StringKeyframe);
18 } 20 }
19 void setPropertyValue(CSSPropertyID property, const String& value) 21 void setPropertyValue(CSSPropertyID, const String& value, StyleSheetContents *);
22 void clearPropertyValue(CSSPropertyID property) { m_propertySet->removePrope rty(property); }
23 CSSValue* propertyValue(CSSPropertyID property) const
20 { 24 {
21 m_propertyValues.add(property, value); 25 int index = m_propertySet->findPropertyIndex(property);
22 } 26 RELEASE_ASSERT(index >= 0);
23 void clearPropertyValue(CSSPropertyID property) { m_propertyValues.remove(pr operty); } 27 return m_propertySet->propertyAt(static_cast<unsigned>(index)).value();
24 String propertyValue(CSSPropertyID property) const
25 {
26 ASSERT(m_propertyValues.contains(property));
27 return m_propertyValues.get(property);
28 } 28 }
29 virtual PropertySet properties() const OVERRIDE; 29 virtual PropertySet properties() const OVERRIDE;
30 30
31 virtual void trace(Visitor*) OVERRIDE; 31 virtual void trace(Visitor*) OVERRIDE;
32 32
33 class PropertySpecificKeyframe : public Keyframe::PropertySpecificKeyframe { 33 class PropertySpecificKeyframe : public Keyframe::PropertySpecificKeyframe {
34 public: 34 public:
35 PropertySpecificKeyframe(double offset, PassRefPtr<TimingFunction> easin g, const String& value, AnimationEffect::CompositeOperation); 35 PropertySpecificKeyframe(double offset, PassRefPtr<TimingFunction> easin g, CSSValue*, AnimationEffect::CompositeOperation);
36 36
37 const String& value() const { return m_value; } 37 CSSValue* value() const { return m_value.get(); }
38 38
39 virtual PassOwnPtrWillBeRawPtr<Keyframe::PropertySpecificKeyframe> neutr alKeyframe(double offset, PassRefPtr<TimingFunction> easing) const OVERRIDE FINA L; 39 virtual PassOwnPtrWillBeRawPtr<Keyframe::PropertySpecificKeyframe> neutr alKeyframe(double offset, PassRefPtr<TimingFunction> easing) const OVERRIDE FINA L;
40 virtual PassRefPtrWillBeRawPtr<Interpolation> createInterpolation(CSSPro pertyID, WebCore::Keyframe::PropertySpecificKeyframe* end) const OVERRIDE FINAL; 40 virtual PassRefPtrWillBeRawPtr<Interpolation> createInterpolation(CSSPro pertyID, WebCore::Keyframe::PropertySpecificKeyframe* end, Element*) const OVERR IDE FINAL;
41 41
42 virtual void trace(Visitor*) OVERRIDE; 42 virtual void trace(Visitor*) OVERRIDE;
43 43
44 private: 44 private:
45 PropertySpecificKeyframe(double offset, PassRefPtr<TimingFunction> easin g, const String& value); 45 PropertySpecificKeyframe(double offset, PassRefPtr<TimingFunction> easin g, CSSValue*);
46 46
47 virtual PassOwnPtrWillBeRawPtr<Keyframe::PropertySpecificKeyframe> clone WithOffset(double offset) const; 47 virtual PassOwnPtrWillBeRawPtr<Keyframe::PropertySpecificKeyframe> clone WithOffset(double offset) const;
48 virtual bool isStringPropertySpecificKeyframe() const OVERRIDE { return true; } 48 virtual bool isStringPropertySpecificKeyframe() const OVERRIDE { return true; }
49 49
50 String m_value; 50 RefPtrWillBeRawPtr<CSSValue> m_value;
51 }; 51 };
52 52
53 private: 53 private:
54 StringKeyframe() { } 54 StringKeyframe()
55 : m_propertySet(MutableStylePropertySet::create())
56 { }
55 57
56 StringKeyframe(const StringKeyframe& copyFrom); 58 StringKeyframe(const StringKeyframe& copyFrom);
57 59
60 void setPropertyCSSValue(CSSPropertyID, CSSValue*);
58 virtual PassRefPtrWillBeRawPtr<Keyframe> clone() const OVERRIDE; 61 virtual PassRefPtrWillBeRawPtr<Keyframe> clone() const OVERRIDE;
59 virtual PassOwnPtrWillBeRawPtr<Keyframe::PropertySpecificKeyframe> createPro pertySpecificKeyframe(CSSPropertyID) const OVERRIDE; 62 virtual PassOwnPtrWillBeRawPtr<Keyframe::PropertySpecificKeyframe> createPro pertySpecificKeyframe(CSSPropertyID) const OVERRIDE;
60 63
61 virtual bool isStringKeyframe() const OVERRIDE { return true; } 64 virtual bool isStringKeyframe() const OVERRIDE { return true; }
62 65
63 typedef HashMap<CSSPropertyID, String> PropertyValueMap; 66 RefPtrWillBeRawPtr<MutableStylePropertySet> m_propertySet;
64 PropertyValueMap m_propertyValues;
65 }; 67 };
66 68
67 typedef StringKeyframe::PropertySpecificKeyframe StringPropertySpecificKeyframe; 69 typedef StringKeyframe::PropertySpecificKeyframe StringPropertySpecificKeyframe;
68 70
71 DEFINE_TYPE_CASTS(StringKeyframe, Keyframe, value, value->isStringKeyframe(), va lue.isStringKeyframe());
72 DEFINE_TYPE_CASTS(StringPropertySpecificKeyframe, Keyframe::PropertySpecificKeyf rame, value, value->isStringPropertySpecificKeyframe(), value.isStringPropertySp ecificKeyframe());
73
69 } 74 }
70 75
71 #endif 76 #endif
OLDNEW
« no previous file with comments | « Source/core/animation/KeyframeEffectModel.cpp ('k') | Source/core/animation/StringKeyframe.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698