OLD | NEW |
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 "config.h" | 5 #include "config.h" |
6 #include "core/animation/StringKeyframe.h" | 6 #include "core/animation/StringKeyframe.h" |
7 | 7 |
8 #include "core/animation/AngleSVGInterpolation.h" | 8 #include "core/animation/AngleSVGInterpolation.h" |
9 #include "core/animation/CSSValueInterpolationType.h" | 9 #include "core/animation/CSSValueInterpolationType.h" |
10 #include "core/animation/ColorStyleInterpolation.h" | 10 #include "core/animation/ColorStyleInterpolation.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 StringKeyframe::StringKeyframe(const StringKeyframe& copyFrom) | 48 StringKeyframe::StringKeyframe(const StringKeyframe& copyFrom) |
49 : Keyframe(copyFrom.m_offset, copyFrom.m_composite, copyFrom.m_easing) | 49 : Keyframe(copyFrom.m_offset, copyFrom.m_composite, copyFrom.m_easing) |
50 , m_propertySet(copyFrom.m_propertySet->mutableCopy()) | 50 , m_propertySet(copyFrom.m_propertySet->mutableCopy()) |
51 , m_svgPropertyMap(copyFrom.m_svgPropertyMap) | 51 , m_svgPropertyMap(copyFrom.m_svgPropertyMap) |
52 { | 52 { |
53 } | 53 } |
54 | 54 |
55 void StringKeyframe::setPropertyValue(CSSPropertyID property, const String& valu
e, Element* element, StyleSheetContents* styleSheetContents) | 55 void StringKeyframe::setPropertyValue(CSSPropertyID property, const String& valu
e, Element* element, StyleSheetContents* styleSheetContents) |
56 { | 56 { |
57 ASSERT(property != CSSPropertyInvalid); | 57 ASSERT(property != CSSPropertyInvalid); |
58 if (CSSAnimations::isAllowedAnimation(property)) | 58 if (CSSAnimations::isAnimatableProperty(property)) |
59 m_propertySet->setProperty(property, value, false, styleSheetContents); | 59 m_propertySet->setProperty(property, value, false, styleSheetContents); |
60 } | 60 } |
61 | 61 |
62 void StringKeyframe::setPropertyValue(CSSPropertyID property, PassRefPtrWillBeRa
wPtr<CSSValue> value) | 62 void StringKeyframe::setPropertyValue(CSSPropertyID property, PassRefPtrWillBeRa
wPtr<CSSValue> value) |
63 { | 63 { |
64 ASSERT(property != CSSPropertyInvalid); | 64 ASSERT(property != CSSPropertyInvalid); |
65 ASSERT(CSSAnimations::isAllowedAnimation(property)); | 65 ASSERT(CSSAnimations::isAnimatableProperty(property)); |
66 m_propertySet->setProperty(property, value, false); | 66 m_propertySet->setProperty(property, value, false); |
67 } | 67 } |
68 | 68 |
69 void StringKeyframe::setPropertyValue(const QualifiedName& attributeName, const
String& value, Element* element) | 69 void StringKeyframe::setPropertyValue(const QualifiedName& attributeName, const
String& value, Element* element) |
70 { | 70 { |
71 ASSERT(element->isSVGElement()); | 71 ASSERT(element->isSVGElement()); |
72 m_svgPropertyMap.set(&attributeName, value); | 72 m_svgPropertyMap.set(&attributeName, value); |
73 } | 73 } |
74 | 74 |
75 PropertyHandleSet StringKeyframe::properties() const | 75 PropertyHandleSet StringKeyframe::properties() const |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 } | 154 } |
155 | 155 |
156 const Vector<const InterpolationType*>* applicableTypesForProperty(CSSPropertyID
property) | 156 const Vector<const InterpolationType*>* applicableTypesForProperty(CSSPropertyID
property) |
157 { | 157 { |
158 using ApplicableTypesMap = HashMap<CSSPropertyID, const Vector<const Interpo
lationType*>*>; | 158 using ApplicableTypesMap = HashMap<CSSPropertyID, const Vector<const Interpo
lationType*>*>; |
159 DEFINE_STATIC_LOCAL(ApplicableTypesMap, applicableTypesMap, ()); | 159 DEFINE_STATIC_LOCAL(ApplicableTypesMap, applicableTypesMap, ()); |
160 auto entry = applicableTypesMap.find(property); | 160 auto entry = applicableTypesMap.find(property); |
161 if (entry != applicableTypesMap.end()) | 161 if (entry != applicableTypesMap.end()) |
162 return entry->value; | 162 return entry->value; |
163 | 163 |
164 // TODO(alancutter): Support all animatable CSS properties here so we can st
op falling back to the old StyleInterpolation implementation. | 164 // TODO(alancutter): Support all interpolable CSS properties here so we can
stop falling back to the old StyleInterpolation implementation. |
165 if (CSSPropertyMetadata::isAnimatableProperty(property)) | 165 if (CSSPropertyMetadata::isInterpolableProperty(property)) |
166 return nullptr; | 166 return nullptr; |
167 | 167 |
168 auto applicableTypes = new Vector<const InterpolationType*>(); | 168 auto applicableTypes = new Vector<const InterpolationType*>(); |
169 applicableTypes->append(new CSSValueInterpolationType(property)); | 169 applicableTypes->append(new CSSValueInterpolationType(property)); |
170 applicableTypesMap.add(property, applicableTypes); | 170 applicableTypesMap.add(property, applicableTypes); |
171 return applicableTypes; | 171 return applicableTypes; |
172 } | 172 } |
173 | 173 |
174 } // namespace | 174 } // namespace |
175 | 175 |
(...skipping 14 matching lines...) Expand all Loading... |
190 | 190 |
191 // FIXME: Remove this flag once we can rely on legacy's behaviour being corr
ect. | 191 // FIXME: Remove this flag once we can rely on legacy's behaviour being corr
ect. |
192 bool forceDefaultInterpolation = false; | 192 bool forceDefaultInterpolation = false; |
193 | 193 |
194 // FIXME: Remove this check once neutral keyframes are implemented in String
Keyframes. | 194 // FIXME: Remove this check once neutral keyframes are implemented in String
Keyframes. |
195 if (!fromCSSValue || !toCSSValue) | 195 if (!fromCSSValue || !toCSSValue) |
196 return DeferredLegacyStyleInterpolation::create(fromCSSValue, toCSSValue
, property); | 196 return DeferredLegacyStyleInterpolation::create(fromCSSValue, toCSSValue
, property); |
197 | 197 |
198 ASSERT(fromCSSValue && toCSSValue); | 198 ASSERT(fromCSSValue && toCSSValue); |
199 | 199 |
200 if (!CSSPropertyMetadata::isAnimatableProperty(property)) { | 200 if (!CSSPropertyMetadata::isInterpolableProperty(property)) { |
201 if (fromCSSValue == toCSSValue) | 201 if (fromCSSValue == toCSSValue) |
202 return ConstantStyleInterpolation::create(fromCSSValue, property); | 202 return ConstantStyleInterpolation::create(fromCSSValue, property); |
203 | 203 |
204 return nullptr; | 204 return nullptr; |
205 } | 205 } |
206 | 206 |
207 switch (property) { | 207 switch (property) { |
208 case CSSPropertyLineHeight: | 208 case CSSPropertyLineHeight: |
209 if (LengthStyleInterpolation::canCreateFrom(*fromCSSValue) && LengthStyl
eInterpolation::canCreateFrom(*toCSSValue)) | 209 if (LengthStyleInterpolation::canCreateFrom(*fromCSSValue) && LengthStyl
eInterpolation::canCreateFrom(*toCSSValue)) |
210 return LengthStyleInterpolation::create(*fromCSSValue, *toCSSValue,
property, RangeNonNegative); | 210 return LengthStyleInterpolation::create(*fromCSSValue, *toCSSValue,
property, RangeNonNegative); |
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
594 RefPtrWillBeRawPtr<SVGPropertyBase> fromValue = attribute->currentValueBase(
)->cloneForAnimation(m_value); | 594 RefPtrWillBeRawPtr<SVGPropertyBase> fromValue = attribute->currentValueBase(
)->cloneForAnimation(m_value); |
595 RefPtrWillBeRawPtr<SVGPropertyBase> toValue = attribute->currentValueBase()-
>cloneForAnimation(toSVGPropertySpecificKeyframe(end).value()); | 595 RefPtrWillBeRawPtr<SVGPropertyBase> toValue = attribute->currentValueBase()-
>cloneForAnimation(toSVGPropertySpecificKeyframe(end).value()); |
596 | 596 |
597 if (!fromValue || !toValue) | 597 if (!fromValue || !toValue) |
598 return nullptr; | 598 return nullptr; |
599 | 599 |
600 return createSVGInterpolation(fromValue.get(), toValue.get(), attribute.get(
)); | 600 return createSVGInterpolation(fromValue.get(), toValue.get(), attribute.get(
)); |
601 } | 601 } |
602 | 602 |
603 } // namespace blink | 603 } // namespace blink |
OLD | NEW |