| 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 "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/ConstantStyleInterpolation.h" | 8 #include "core/animation/ConstantStyleInterpolation.h" |
| 9 #include "core/animation/DeferredLegacyStyleInterpolation.h" | 9 #include "core/animation/DeferredLegacyStyleInterpolation.h" |
| 10 #include "core/animation/DoubleStyleInterpolation.h" | 10 #include "core/animation/DoubleStyleInterpolation.h" |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 properties.add(PropertyHandle(*key)); | 80 properties.add(PropertyHandle(*key)); |
| 81 | 81 |
| 82 return properties; | 82 return properties; |
| 83 } | 83 } |
| 84 | 84 |
| 85 PassRefPtr<Keyframe> StringKeyframe::clone() const | 85 PassRefPtr<Keyframe> StringKeyframe::clone() const |
| 86 { | 86 { |
| 87 return adoptRef(new StringKeyframe(*this)); | 87 return adoptRef(new StringKeyframe(*this)); |
| 88 } | 88 } |
| 89 | 89 |
| 90 PassOwnPtr<Keyframe::PropertySpecificKeyframe> StringKeyframe::createPropertySpe
cificKeyframe(PropertyHandle property) const | 90 PassRefPtr<Keyframe::PropertySpecificKeyframe> StringKeyframe::createPropertySpe
cificKeyframe(PropertyHandle property) const |
| 91 { | 91 { |
| 92 if (property.isCSSProperty()) | 92 if (property.isCSSProperty()) |
| 93 return adoptPtr(new CSSPropertySpecificKeyframe(offset(), &easing(), css
PropertyValue(property.cssProperty()), composite())); | 93 return CSSPropertySpecificKeyframe::create(offset(), &easing(), cssPrope
rtyValue(property.cssProperty()), composite()); |
| 94 | 94 |
| 95 if (property.isPresentationAttribute()) | 95 if (property.isPresentationAttribute()) |
| 96 return adoptPtr(new CSSPropertySpecificKeyframe(offset(), &easing(), pre
sentationAttributeValue(property.presentationAttribute()), composite())); | 96 return CSSPropertySpecificKeyframe::create(offset(), &easing(), presenta
tionAttributeValue(property.presentationAttribute()), composite()); |
| 97 | 97 |
| 98 ASSERT(property.isSVGAttribute()); | 98 ASSERT(property.isSVGAttribute()); |
| 99 return adoptPtr(new SVGPropertySpecificKeyframe(offset(), &easing(), svgProp
ertyValue(property.svgAttribute()), composite())); | 99 return SVGPropertySpecificKeyframe::create(offset(), &easing(), svgPropertyV
alue(property.svgAttribute()), composite()); |
| 100 } | |
| 101 | |
| 102 StringKeyframe::CSSPropertySpecificKeyframe::CSSPropertySpecificKeyframe(double
offset, PassRefPtr<TimingFunction> easing, CSSValue* value, EffectModel::Composi
teOperation op) | |
| 103 : Keyframe::PropertySpecificKeyframe(offset, easing, op) | |
| 104 , m_value(value) | |
| 105 { } | |
| 106 | |
| 107 StringKeyframe::CSSPropertySpecificKeyframe::CSSPropertySpecificKeyframe(double
offset, PassRefPtr<TimingFunction> easing, CSSValue* value) | |
| 108 : Keyframe::PropertySpecificKeyframe(offset, easing, EffectModel::CompositeR
eplace) | |
| 109 , m_value(value) | |
| 110 { | |
| 111 ASSERT(!isNull(m_offset)); | |
| 112 } | 100 } |
| 113 | 101 |
| 114 bool StringKeyframe::CSSPropertySpecificKeyframe::populateAnimatableValue(CSSPro
pertyID property, Element& element, const ComputedStyle* baseStyle, bool force)
const | 102 bool StringKeyframe::CSSPropertySpecificKeyframe::populateAnimatableValue(CSSPro
pertyID property, Element& element, const ComputedStyle* baseStyle, bool force)
const |
| 115 { | 103 { |
| 116 if (m_animatableValueCache && !force) | 104 if (m_animatableValueCache && !force) |
| 117 return false; | 105 return false; |
| 118 if (!baseStyle && (!m_value || DeferredLegacyStyleInterpolation::interpolati
onRequiresStyleResolve(*m_value))) | 106 if (!baseStyle && (!m_value || DeferredLegacyStyleInterpolation::interpolati
onRequiresStyleResolve(*m_value))) |
| 119 return false; | 107 return false; |
| 120 if (!element.document().frame()) | 108 if (!element.document().frame()) |
| 121 return false; | 109 return false; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 136 ASSERT(element); | 124 ASSERT(element); |
| 137 populateAnimatableValue(property, *element, baseStyle, false); | 125 populateAnimatableValue(property, *element, baseStyle, false); |
| 138 end.populateAnimatableValue(property, *element, baseStyle, false); | 126 end.populateAnimatableValue(property, *element, baseStyle, false); |
| 139 return LegacyStyleInterpolation::create(getAnimatableValue(), end.getAnimata
bleValue(), property); | 127 return LegacyStyleInterpolation::create(getAnimatableValue(), end.getAnimata
bleValue(), property); |
| 140 } | 128 } |
| 141 | 129 |
| 142 PassRefPtr<Interpolation> StringKeyframe::CSSPropertySpecificKeyframe::maybeCrea
teInterpolation(PropertyHandle propertyHandle, Keyframe::PropertySpecificKeyfram
e& end, Element* element, const ComputedStyle* baseStyle) const | 130 PassRefPtr<Interpolation> StringKeyframe::CSSPropertySpecificKeyframe::maybeCrea
teInterpolation(PropertyHandle propertyHandle, Keyframe::PropertySpecificKeyfram
e& end, Element* element, const ComputedStyle* baseStyle) const |
| 143 { | 131 { |
| 144 const InterpolationTypes* applicableTypes = PropertyInterpolationTypesMappin
g::get(propertyHandle); | 132 const InterpolationTypes* applicableTypes = PropertyInterpolationTypesMappin
g::get(propertyHandle); |
| 145 if (applicableTypes) | 133 if (applicableTypes) |
| 146 return InvalidatableInterpolation::create(propertyHandle, *applicableTyp
es, *this, end); | 134 return InvalidatableInterpolation::create(propertyHandle, *applicableTyp
es, const_cast<CSSPropertySpecificKeyframe*>(this), &end); |
| 147 | 135 |
| 148 // TODO(alancutter): Remove the remainder of this function. | 136 // TODO(alancutter): Remove the remainder of this function. |
| 149 | 137 |
| 150 // FIXME: Refactor this into a generic piece that lives in InterpolationEffe
ct, and a template parameter specific converter. | 138 // FIXME: Refactor this into a generic piece that lives in InterpolationEffe
ct, and a template parameter specific converter. |
| 151 CSSPropertyID property = propertyHandle.isCSSProperty() ? propertyHandle.css
Property() : propertyHandle.presentationAttribute(); | 139 CSSPropertyID property = propertyHandle.isCSSProperty() ? propertyHandle.css
Property() : propertyHandle.presentationAttribute(); |
| 152 CSSValue* fromCSSValue = m_value.get(); | 140 CSSValue* fromCSSValue = m_value.get(); |
| 153 CSSValue* toCSSValue = toCSSPropertySpecificKeyframe(end).value(); | 141 CSSValue* toCSSValue = toCSSPropertySpecificKeyframe(end).value(); |
| 154 InterpolationRange range = RangeAll; | 142 InterpolationRange range = RangeAll; |
| 155 | 143 |
| 156 // FIXME: Remove this flag once we can rely on legacy's behaviour being corr
ect. | 144 // FIXME: Remove this flag once we can rely on legacy's behaviour being corr
ect. |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 if (!forceDefaultInterpolation) { | 265 if (!forceDefaultInterpolation) { |
| 278 ASSERT(AnimatableValue::usesDefaultInterpolation( | 266 ASSERT(AnimatableValue::usesDefaultInterpolation( |
| 279 StyleResolver::createAnimatableValueSnapshot(*element, baseStyle, pr
operty, fromCSSValue).get(), | 267 StyleResolver::createAnimatableValueSnapshot(*element, baseStyle, pr
operty, fromCSSValue).get(), |
| 280 StyleResolver::createAnimatableValueSnapshot(*element, baseStyle, pr
operty, toCSSValue).get())); | 268 StyleResolver::createAnimatableValueSnapshot(*element, baseStyle, pr
operty, toCSSValue).get())); |
| 281 } | 269 } |
| 282 | 270 |
| 283 return nullptr; | 271 return nullptr; |
| 284 | 272 |
| 285 } | 273 } |
| 286 | 274 |
| 287 PassOwnPtr<Keyframe::PropertySpecificKeyframe> StringKeyframe::CSSPropertySpecif
icKeyframe::neutralKeyframe(double offset, PassRefPtr<TimingFunction> easing) co
nst | 275 PassRefPtr<Keyframe::PropertySpecificKeyframe> StringKeyframe::CSSPropertySpecif
icKeyframe::neutralKeyframe(double offset, PassRefPtr<TimingFunction> easing) co
nst |
| 288 { | 276 { |
| 289 return adoptPtr(new CSSPropertySpecificKeyframe(offset, easing, static_cast<
CSSValue*>(0), EffectModel::CompositeAdd)); | 277 return create(offset, easing, nullptr, EffectModel::CompositeAdd); |
| 290 } | 278 } |
| 291 | 279 |
| 292 PassOwnPtr<Keyframe::PropertySpecificKeyframe> StringKeyframe::CSSPropertySpecif
icKeyframe::cloneWithOffset(double offset) const | 280 PassRefPtr<Keyframe::PropertySpecificKeyframe> StringKeyframe::CSSPropertySpecif
icKeyframe::cloneWithOffset(double offset) const |
| 293 { | 281 { |
| 294 Keyframe::PropertySpecificKeyframe* theClone = new CSSPropertySpecificKeyfra
me(offset, m_easing, m_value.get()); | 282 RefPtr<CSSPropertySpecificKeyframe> clone = create(offset, m_easing, m_value
.get(), m_composite); |
| 295 toCSSPropertySpecificKeyframe(theClone)->m_animatableValueCache = m_animatab
leValueCache; | 283 clone->m_animatableValueCache = m_animatableValueCache; |
| 296 return adoptPtr(theClone); | 284 return clone.release(); |
| 297 } | 285 } |
| 298 | 286 |
| 299 SVGPropertySpecificKeyframe::SVGPropertySpecificKeyframe(double offset, PassRefP
tr<TimingFunction> easing, const String& value, EffectModel::CompositeOperation
op) | 287 PassRefPtr<Keyframe::PropertySpecificKeyframe> SVGPropertySpecificKeyframe::clon
eWithOffset(double offset) const |
| 300 : Keyframe::PropertySpecificKeyframe(offset, easing, op) | |
| 301 , m_value(value) | |
| 302 { | 288 { |
| 289 return create(offset, m_easing, m_value, m_composite); |
| 303 } | 290 } |
| 304 | 291 |
| 305 SVGPropertySpecificKeyframe::SVGPropertySpecificKeyframe(double offset, PassRefP
tr<TimingFunction> easing, const String& value) | 292 PassRefPtr<Keyframe::PropertySpecificKeyframe> SVGPropertySpecificKeyframe::neut
ralKeyframe(double offset, PassRefPtr<TimingFunction> easing) const |
| 306 : Keyframe::PropertySpecificKeyframe(offset, easing, EffectModel::CompositeR
eplace) | |
| 307 , m_value(value) | |
| 308 { | 293 { |
| 309 ASSERT(!isNull(m_offset)); | 294 return create(offset, easing, String(), EffectModel::CompositeAdd); |
| 310 } | |
| 311 | |
| 312 PassOwnPtr<Keyframe::PropertySpecificKeyframe> SVGPropertySpecificKeyframe::clon
eWithOffset(double offset) const | |
| 313 { | |
| 314 return adoptPtr(new SVGPropertySpecificKeyframe(offset, m_easing, m_value)); | |
| 315 } | |
| 316 | |
| 317 PassOwnPtr<Keyframe::PropertySpecificKeyframe> SVGPropertySpecificKeyframe::neut
ralKeyframe(double offset, PassRefPtr<TimingFunction> easing) const | |
| 318 { | |
| 319 return adoptPtr(new SVGPropertySpecificKeyframe(offset, easing, String(), Ef
fectModel::CompositeAdd)); | |
| 320 } | 295 } |
| 321 | 296 |
| 322 PassRefPtr<Interpolation> SVGPropertySpecificKeyframe::maybeCreateInterpolation(
PropertyHandle propertyHandle, Keyframe::PropertySpecificKeyframe& end, Element*
, const ComputedStyle*) const | 297 PassRefPtr<Interpolation> SVGPropertySpecificKeyframe::maybeCreateInterpolation(
PropertyHandle propertyHandle, Keyframe::PropertySpecificKeyframe& end, Element*
, const ComputedStyle*) const |
| 323 { | 298 { |
| 324 const InterpolationTypes* applicableTypes = PropertyInterpolationTypesMappin
g::get(propertyHandle); | 299 const InterpolationTypes* applicableTypes = PropertyInterpolationTypesMappin
g::get(propertyHandle); |
| 325 ASSERT(applicableTypes); | 300 ASSERT(applicableTypes); |
| 326 return InvalidatableInterpolation::create(propertyHandle, *applicableTypes,
*this, end); | 301 return InvalidatableInterpolation::create(propertyHandle, *applicableTypes,
const_cast<SVGPropertySpecificKeyframe*>(this), &end); |
| 327 } | 302 } |
| 328 | 303 |
| 329 } // namespace blink | 304 } // namespace blink |
| OLD | NEW |