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

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

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 #include "core/animation/StringKeyframe.h" 5 #include "core/animation/StringKeyframe.h"
6 6
7 #include "core/StylePropertyShorthand.h" 7 #include "core/StylePropertyShorthand.h"
8 #include "core/animation/css/CSSAnimations.h" 8 #include "core/animation/css/CSSAnimations.h"
9 #include "core/css/CSSCustomPropertyDeclaration.h"
9 #include "core/css/CSSPropertyMetadata.h" 10 #include "core/css/CSSPropertyMetadata.h"
10 #include "core/css/resolver/StyleResolver.h" 11 #include "core/css/resolver/StyleResolver.h"
11 #include "core/style/ComputedStyle.h" 12 #include "core/style/ComputedStyle.h"
12 #include "core/svg/SVGElement.h" 13 #include "core/svg/SVGElement.h"
13 #include "platform/RuntimeEnabledFeatures.h" 14 #include "platform/RuntimeEnabledFeatures.h"
14 15
15 namespace blink { 16 namespace blink {
16 17
17 StringKeyframe::StringKeyframe(const StringKeyframe& copyFrom) 18 StringKeyframe::StringKeyframe(const StringKeyframe& copyFrom)
18 : Keyframe(copyFrom.m_offset, copyFrom.m_composite, copyFrom.m_easing) 19 : Keyframe(copyFrom.m_offset, copyFrom.m_composite, copyFrom.m_easing)
19 , m_cssPropertyMap(copyFrom.m_cssPropertyMap->mutableCopy()) 20 , m_cssPropertyMap(copyFrom.m_cssPropertyMap->mutableCopy())
20 , m_presentationAttributeMap(copyFrom.m_presentationAttributeMap->mutableCop y()) 21 , m_presentationAttributeMap(copyFrom.m_presentationAttributeMap->mutableCop y())
21 , m_svgAttributeMap(copyFrom.m_svgAttributeMap) 22 , m_svgAttributeMap(copyFrom.m_svgAttributeMap)
22 { 23 {
23 } 24 }
24 25
26 void StringKeyframe::setCSSPropertyValue(const AtomicString& propertyName, const String& value, StyleSheetContents* styleSheetContents)
27 {
28 m_cssPropertyMap->setProperty(propertyName, value, false, styleSheetContents );
29 }
30
25 void StringKeyframe::setCSSPropertyValue(CSSPropertyID property, const String& v alue, StyleSheetContents* styleSheetContents) 31 void StringKeyframe::setCSSPropertyValue(CSSPropertyID property, const String& v alue, StyleSheetContents* styleSheetContents)
26 { 32 {
27 DCHECK_NE(property, CSSPropertyInvalid); 33 DCHECK_NE(property, CSSPropertyInvalid);
28 if (CSSAnimations::isAnimatableProperty(property)) 34 if (CSSAnimations::isAnimatableProperty(property))
29 m_cssPropertyMap->setProperty(property, value, false, styleSheetContents ); 35 m_cssPropertyMap->setProperty(property, value, false, styleSheetContents );
30 } 36 }
31 37
32 void StringKeyframe::setCSSPropertyValue(CSSPropertyID property, const CSSValue& value) 38 void StringKeyframe::setCSSPropertyValue(CSSPropertyID property, const CSSValue& value)
33 { 39 {
34 DCHECK_NE(property, CSSPropertyInvalid); 40 DCHECK_NE(property, CSSPropertyInvalid);
(...skipping 15 matching lines...) Expand all
50 56
51 PropertyHandleSet StringKeyframe::properties() const 57 PropertyHandleSet StringKeyframe::properties() const
52 { 58 {
53 // This is not used in time-critical code, so we probably don't need to 59 // This is not used in time-critical code, so we probably don't need to
54 // worry about caching this result. 60 // worry about caching this result.
55 PropertyHandleSet properties; 61 PropertyHandleSet properties;
56 for (unsigned i = 0; i < m_cssPropertyMap->propertyCount(); ++i) { 62 for (unsigned i = 0; i < m_cssPropertyMap->propertyCount(); ++i) {
57 StylePropertySet::PropertyReference propertyReference = m_cssPropertyMap ->propertyAt(i); 63 StylePropertySet::PropertyReference propertyReference = m_cssPropertyMap ->propertyAt(i);
58 DCHECK(!isShorthandProperty(propertyReference.id())) 64 DCHECK(!isShorthandProperty(propertyReference.id()))
59 << "Web Animations: Encountered unexpanded shorthand CSS property (" << propertyReference.id() << ")."; 65 << "Web Animations: Encountered unexpanded shorthand CSS property (" << propertyReference.id() << ").";
60 properties.add(PropertyHandle(propertyReference.id(), false)); 66 if (propertyReference.id() == CSSPropertyVariable)
67 properties.add(PropertyHandle(toCSSCustomPropertyDeclaration(propert yReference.value()).name()));
68 else
69 properties.add(PropertyHandle(propertyReference.id(), false));
61 } 70 }
62 71
63 for (unsigned i = 0; i < m_presentationAttributeMap->propertyCount(); ++i) 72 for (unsigned i = 0; i < m_presentationAttributeMap->propertyCount(); ++i)
64 properties.add(PropertyHandle(m_presentationAttributeMap->propertyAt(i). id(), true)); 73 properties.add(PropertyHandle(m_presentationAttributeMap->propertyAt(i). id(), true));
65 74
66 for (const auto& key: m_svgAttributeMap.keys()) 75 for (const auto& key: m_svgAttributeMap.keys())
67 properties.add(PropertyHandle(*key)); 76 properties.add(PropertyHandle(*key));
68 77
69 return properties; 78 return properties;
70 } 79 }
71 80
72 PassRefPtr<Keyframe> StringKeyframe::clone() const 81 PassRefPtr<Keyframe> StringKeyframe::clone() const
73 { 82 {
74 return adoptRef(new StringKeyframe(*this)); 83 return adoptRef(new StringKeyframe(*this));
75 } 84 }
76 85
77 PassRefPtr<Keyframe::PropertySpecificKeyframe> StringKeyframe::createPropertySpe cificKeyframe(PropertyHandle property) const 86 PassRefPtr<Keyframe::PropertySpecificKeyframe> StringKeyframe::createPropertySpe cificKeyframe(PropertyHandle property) const
78 { 87 {
79 if (property.isCSSProperty()) 88 if (property.isCSSProperty())
80 return CSSPropertySpecificKeyframe::create(offset(), &easing(), &cssProp ertyValue(property.cssProperty()), composite()); 89 return CSSPropertySpecificKeyframe::create(offset(), &easing(), &cssProp ertyValue(property), composite());
81 90
82 if (property.isPresentationAttribute()) 91 if (property.isPresentationAttribute())
83 return CSSPropertySpecificKeyframe::create(offset(), &easing(), &present ationAttributeValue(property.presentationAttribute()), composite()); 92 return CSSPropertySpecificKeyframe::create(offset(), &easing(), &present ationAttributeValue(property.presentationAttribute()), composite());
84 93
85 DCHECK(property.isSVGAttribute()); 94 DCHECK(property.isSVGAttribute());
86 return SVGPropertySpecificKeyframe::create(offset(), &easing(), svgPropertyV alue(property.svgAttribute()), composite()); 95 return SVGPropertySpecificKeyframe::create(offset(), &easing(), svgPropertyV alue(property.svgAttribute()), composite());
87 } 96 }
88 97
89 bool StringKeyframe::CSSPropertySpecificKeyframe::populateAnimatableValue(CSSPro pertyID property, Element& element, const ComputedStyle& baseStyle, const Comput edStyle* parentStyle) const 98 bool StringKeyframe::CSSPropertySpecificKeyframe::populateAnimatableValue(CSSPro pertyID property, Element& element, const ComputedStyle& baseStyle, const Comput edStyle* parentStyle) const
90 { 99 {
(...skipping 17 matching lines...) Expand all
108 { 117 {
109 return create(offset, m_easing, m_value, m_composite); 118 return create(offset, m_easing, m_value, m_composite);
110 } 119 }
111 120
112 PassRefPtr<Keyframe::PropertySpecificKeyframe> SVGPropertySpecificKeyframe::neut ralKeyframe(double offset, PassRefPtr<TimingFunction> easing) const 121 PassRefPtr<Keyframe::PropertySpecificKeyframe> SVGPropertySpecificKeyframe::neut ralKeyframe(double offset, PassRefPtr<TimingFunction> easing) const
113 { 122 {
114 return create(offset, std::move(easing), String(), EffectModel::CompositeAdd ); 123 return create(offset, std::move(easing), String(), EffectModel::CompositeAdd );
115 } 124 }
116 125
117 } // namespace blink 126 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698