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

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

Issue 2309873003: Extend PropertyHandle to include custom property identifiers (Closed)
Patch Set: Add unit tests Created 4 years, 2 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 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/Keyframe.h" 8 #include "core/animation/Keyframe.h"
9 #include "core/css/StylePropertySet.h" 9 #include "core/css/StylePropertySet.h"
10 10
11 #include "wtf/HashMap.h" 11 #include "wtf/HashMap.h"
12 12
13 namespace blink { 13 namespace blink {
14 14
15 class StyleSheetContents; 15 class StyleSheetContents;
16 16
17 // A specialization of Keyframe that associates user specified keyframe properti es with either CSS properties or SVG attributes. 17 // A specialization of Keyframe that associates user specified keyframe properti es with either CSS properties or SVG attributes.
18 class StringKeyframe : public Keyframe { 18 class StringKeyframe : public Keyframe {
19 public: 19 public:
20 static PassRefPtr<StringKeyframe> create() 20 static PassRefPtr<StringKeyframe> create()
21 { 21 {
22 return adoptRef(new StringKeyframe); 22 return adoptRef(new StringKeyframe);
23 } 23 }
24 24
25 void setCSSPropertyValue(const AtomicString& propertyName, const String& val ue, StyleSheetContents*);
25 void setCSSPropertyValue(CSSPropertyID, const String& value, StyleSheetConte nts*); 26 void setCSSPropertyValue(CSSPropertyID, const String& value, StyleSheetConte nts*);
26 void setCSSPropertyValue(CSSPropertyID, const CSSValue&); 27 void setCSSPropertyValue(CSSPropertyID, const CSSValue&);
27 void setPresentationAttributeValue(CSSPropertyID, const String& value, Style SheetContents*); 28 void setPresentationAttributeValue(CSSPropertyID, const String& value, Style SheetContents*);
28 void setSVGAttributeValue(const QualifiedName&, const String& value); 29 void setSVGAttributeValue(const QualifiedName&, const String& value);
29 30
30 const CSSValue& cssPropertyValue(CSSPropertyID property) const 31 const CSSValue& cssPropertyValue(const PropertyHandle& property) const
31 { 32 {
32 int index = m_cssPropertyMap->findPropertyIndex(property); 33 int index = -1;
33 RELEASE_ASSERT(index >= 0); 34 if (property.isCSSCustomProperty())
35 index = m_cssPropertyMap->findPropertyIndex(property.customPropertyN ame());
36 else
37 index = m_cssPropertyMap->findPropertyIndex(property.cssProperty());
38 CHECK_GE(index, 0);
34 return m_cssPropertyMap->propertyAt(static_cast<unsigned>(index)).value( ); 39 return m_cssPropertyMap->propertyAt(static_cast<unsigned>(index)).value( );
35 } 40 }
36 41
37 const CSSValue& presentationAttributeValue(CSSPropertyID property) const 42 const CSSValue& presentationAttributeValue(CSSPropertyID property) const
38 { 43 {
39 int index = m_presentationAttributeMap->findPropertyIndex(property); 44 int index = m_presentationAttributeMap->findPropertyIndex(property);
40 RELEASE_ASSERT(index >= 0); 45 CHECK_GE(index, 0);
41 return m_presentationAttributeMap->propertyAt(static_cast<unsigned>(inde x)).value(); 46 return m_presentationAttributeMap->propertyAt(static_cast<unsigned>(inde x)).value();
42 } 47 }
43 48
44 String svgPropertyValue(const QualifiedName& attributeName) const 49 String svgPropertyValue(const QualifiedName& attributeName) const
45 { 50 {
46 return m_svgAttributeMap.get(&attributeName); 51 return m_svgAttributeMap.get(&attributeName);
47 } 52 }
48 53
49 PropertyHandleSet properties() const override; 54 PropertyHandleSet properties() const override;
50 55
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 using CSSPropertySpecificKeyframe = StringKeyframe::CSSPropertySpecificKeyframe; 133 using CSSPropertySpecificKeyframe = StringKeyframe::CSSPropertySpecificKeyframe;
129 using SVGPropertySpecificKeyframe = StringKeyframe::SVGPropertySpecificKeyframe; 134 using SVGPropertySpecificKeyframe = StringKeyframe::SVGPropertySpecificKeyframe;
130 135
131 DEFINE_TYPE_CASTS(StringKeyframe, Keyframe, value, value->isStringKeyframe(), va lue.isStringKeyframe()); 136 DEFINE_TYPE_CASTS(StringKeyframe, Keyframe, value, value->isStringKeyframe(), va lue.isStringKeyframe());
132 DEFINE_TYPE_CASTS(CSSPropertySpecificKeyframe, Keyframe::PropertySpecificKeyfram e, value, value->isCSSPropertySpecificKeyframe(), value.isCSSPropertySpecificKey frame()); 137 DEFINE_TYPE_CASTS(CSSPropertySpecificKeyframe, Keyframe::PropertySpecificKeyfram e, value, value->isCSSPropertySpecificKeyframe(), value.isCSSPropertySpecificKey frame());
133 DEFINE_TYPE_CASTS(SVGPropertySpecificKeyframe, Keyframe::PropertySpecificKeyfram e, value, value->isSVGPropertySpecificKeyframe(), value.isSVGPropertySpecificKey frame()); 138 DEFINE_TYPE_CASTS(SVGPropertySpecificKeyframe, Keyframe::PropertySpecificKeyfram e, value, value->isSVGPropertySpecificKeyframe(), value.isSVGPropertySpecificKey frame());
134 139
135 } // namespace blink 140 } // namespace blink
136 141
137 #endif 142 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698