Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "config.h" | 31 #include "config.h" |
| 32 #include "core/animation/KeyframeEffectModel.h" | 32 #include "core/animation/KeyframeEffectModel.h" |
| 33 | 33 |
| 34 #include "core/StylePropertyShorthand.h" | 34 #include "core/StylePropertyShorthand.h" |
| 35 #include "core/animation/AnimationNode.h" | 35 #include "core/animation/AnimationNode.h" |
| 36 #include "core/animation/css/CSSAnimatableValueFactory.h" | |
| 37 #include "core/animation/css/CSSPropertyEquality.h" | |
| 38 #include "core/css/resolver/StyleResolver.h" | |
| 36 #include "platform/animation/AnimationUtilities.h" | 39 #include "platform/animation/AnimationUtilities.h" |
| 37 #include "platform/geometry/FloatBox.h" | 40 #include "platform/geometry/FloatBox.h" |
| 38 #include "platform/transforms/TransformationMatrix.h" | 41 #include "platform/transforms/TransformationMatrix.h" |
| 39 #include "wtf/text/StringHash.h" | 42 #include "wtf/text/StringHash.h" |
| 40 | 43 |
| 41 namespace blink { | 44 namespace blink { |
| 42 | 45 |
| 43 PropertySet KeyframeEffectModelBase::properties() const | 46 PropertySet KeyframeEffectModelBase::properties() const |
| 44 { | 47 { |
| 45 PropertySet result; | 48 PropertySet result; |
| 46 for (const auto& keyframe : m_keyframes) { | 49 for (const auto& keyframe : m_keyframes) { |
| 47 for (const auto& property : keyframe->properties()) | 50 for (const auto& property : keyframe->properties()) |
| 48 result.add(property); | 51 result.add(property); |
| 49 } | 52 } |
| 50 return result; | 53 return result; |
| 51 } | 54 } |
| 52 | 55 |
| 53 void KeyframeEffectModelBase::sample(int iteration, double fraction, double iter ationDuration, OwnPtrWillBeRawPtr<WillBeHeapVector<RefPtrWillBeMember<Interpolat ion>>>& result) const | 56 void KeyframeEffectModelBase::sample(int iteration, double fraction, double iter ationDuration, OwnPtrWillBeRawPtr<WillBeHeapVector<RefPtrWillBeMember<Interpolat ion>>>& result) const |
| 54 { | 57 { |
| 55 ASSERT(iteration >= 0); | 58 ASSERT(iteration >= 0); |
| 56 ASSERT(!isNull(fraction)); | 59 ASSERT(!isNull(fraction)); |
| 57 ensureKeyframeGroups(); | 60 ensureKeyframeGroups(); |
| 58 ensureInterpolationEffect(); | 61 ensureInterpolationEffect(); |
| 59 | 62 |
| 60 return m_interpolationEffect->getActiveInterpolations(fraction, iterationDur ation, result); | 63 return m_interpolationEffect->getActiveInterpolations(fraction, iterationDur ation, result); |
| 61 } | 64 } |
| 62 | 65 |
| 66 void KeyframeEffectModelBase::snapshotCompositableProperties(const Element* elem ent, const RenderStyle& style) | |
| 67 { | |
| 68 if (affects(CSSPropertyOpacity)) | |
| 69 snapshotCompositableProperty(CSSPropertyOpacity, element, style); | |
| 70 if (affects(CSSPropertyTransform)) | |
| 71 snapshotCompositableProperty(CSSPropertyTransform, element, style); | |
| 72 if (affects(CSSPropertyWebkitFilter)) | |
| 73 snapshotCompositableProperty(CSSPropertyWebkitFilter, element, style); | |
| 74 } | |
| 75 | |
| 76 void KeyframeEffectModelBase::snapshotCompositableProperty(CSSPropertyID propert y, const Element* element, const RenderStyle& style) | |
| 77 { | |
| 78 ensureKeyframeGroups(); | |
| 79 auto& keyframes = m_keyframeGroups->get(property)->m_keyframes; | |
| 80 for (size_t i = 0; i < keyframes.size(); i++) { | |
| 81 auto& keyframe = toStringPropertySpecificKeyframe(*keyframes[i]); | |
| 82 if (!keyframe.value()) | |
| 83 keyframe.setAnimatableValue(CSSAnimatableValueFactory::create(proper ty, style)); | |
| 84 else if (!keyframe.getAnimatableValue()) | |
| 85 keyframe.setAnimatableValue(StyleResolver::createAnimatableValueSnap shot(const_cast<Element&>(*element), property, *keyframe.value())); | |
| 86 } | |
| 87 } | |
| 88 | |
| 89 void KeyframeEffectModelBase::updateNeutralKeyframeAnimatableValues(CSSPropertyI D property, PassRefPtrWillBeRawPtr<AnimatableValue> value) | |
| 90 { | |
| 91 if (!value) | |
| 92 return; | |
| 93 | |
| 94 ensureKeyframeGroups(); | |
| 95 auto& keyframes = m_keyframeGroups->get(property)->m_keyframes; | |
| 96 for (size_t i = 0; i < keyframes.size(); i++) { | |
|
shend
2015/02/03 00:51:28
Since there can only be two neutral keyframes, sho
shend
2015/02/04 22:51:33
Done.
| |
| 97 auto& keyframe = toStringPropertySpecificKeyframe(*keyframes[i]); | |
| 98 if (!keyframe.value()) | |
| 99 keyframe.setAnimatableValue(value); | |
| 100 } | |
| 101 } | |
| 102 | |
| 103 void KeyframeEffectModelBase::setNeutralKeyframeEasings(RefPtrWillBeRawPtr<Timin gFunction> easing) | |
| 104 { | |
| 105 ensureKeyframeGroups(); | |
| 106 for (const auto& entry : *m_keyframeGroups) { | |
| 107 auto& keyframes = entry.value->keyframes(); | |
| 108 for (size_t i = 0; i < keyframes.size(); i++) { | |
|
shend
2015/02/03 00:51:28
Ditto
shend
2015/02/04 22:51:33
Done.
| |
| 109 auto& keyframe = toStringPropertySpecificKeyframe(*keyframes[i]); | |
| 110 if (!keyframe.value()) | |
| 111 keyframe.setEasing(easing); | |
| 112 } | |
| 113 } | |
| 114 } | |
| 115 | |
| 63 KeyframeEffectModelBase::KeyframeVector KeyframeEffectModelBase::normalizedKeyfr ames(const KeyframeVector& keyframes) | 116 KeyframeEffectModelBase::KeyframeVector KeyframeEffectModelBase::normalizedKeyfr ames(const KeyframeVector& keyframes) |
| 64 { | 117 { |
| 65 double lastOffset = 0; | 118 double lastOffset = 0; |
| 66 KeyframeVector result; | 119 KeyframeVector result; |
| 67 result.reserveCapacity(keyframes.size()); | 120 result.reserveCapacity(keyframes.size()); |
| 68 | 121 |
| 69 for (const auto& keyframe : keyframes) { | 122 for (const auto& keyframe : keyframes) { |
| 70 double offset = keyframe->offset(); | 123 double offset = keyframe->offset(); |
| 71 if (!isNull(offset)) { | 124 if (!isNull(offset)) { |
| 72 ASSERT(offset >= 0); | 125 ASSERT(offset >= 0); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 133 } | 186 } |
| 134 | 187 |
| 135 void KeyframeEffectModelBase::ensureInterpolationEffect(Element* element) const | 188 void KeyframeEffectModelBase::ensureInterpolationEffect(Element* element) const |
| 136 { | 189 { |
| 137 if (m_interpolationEffect) | 190 if (m_interpolationEffect) |
| 138 return; | 191 return; |
| 139 m_interpolationEffect = InterpolationEffect::create(); | 192 m_interpolationEffect = InterpolationEffect::create(); |
| 140 | 193 |
| 141 for (const auto& entry : *m_keyframeGroups) { | 194 for (const auto& entry : *m_keyframeGroups) { |
| 142 const PropertySpecificKeyframeVector& keyframes = entry.value->keyframes (); | 195 const PropertySpecificKeyframeVector& keyframes = entry.value->keyframes (); |
| 143 ASSERT(keyframes[0]->composite() == AnimationEffect::CompositeReplace); | 196 ASSERT(keyframes[0]->composite() == AnimationEffect::CompositeReplace || keyframes[0]->composite() == AnimationEffect::CompositeAdd); |
| 144 for (size_t i = 0; i < keyframes.size() - 1; i++) { | 197 for (size_t i = 0; i < keyframes.size() - 1; i++) { |
| 145 ASSERT(keyframes[i + 1]->composite() == AnimationEffect::CompositeRe place); | 198 ASSERT(keyframes[i + 1]->composite() == AnimationEffect::CompositeRe place || keyframes[i + 1]->composite() == AnimationEffect::CompositeAdd); |
| 146 double applyFrom = i ? keyframes[i]->offset() : (-std::numeric_limit s<double>::infinity()); | 199 double applyFrom = i ? keyframes[i]->offset() : (-std::numeric_limit s<double>::infinity()); |
| 147 double applyTo = i == keyframes.size() - 2 ? std::numeric_limits<dou ble>::infinity() : keyframes[i + 1]->offset(); | 200 double applyTo = i == keyframes.size() - 2 ? std::numeric_limits<dou ble>::infinity() : keyframes[i + 1]->offset(); |
| 148 if (applyTo == 1) | 201 if (applyTo == 1) |
| 149 applyTo = std::numeric_limits<double>::infinity(); | 202 applyTo = std::numeric_limits<double>::infinity(); |
| 150 | 203 |
| 151 m_interpolationEffect->addInterpolationsFromKeyframes(entry.key, ele ment, *keyframes[i], *keyframes[i + 1], applyFrom, applyTo); | 204 m_interpolationEffect->addInterpolationsFromKeyframes(entry.key, ele ment, *keyframes[i], *keyframes[i + 1], applyFrom, applyTo); |
| 152 } | 205 } |
| 153 } | 206 } |
| 154 } | 207 } |
| 155 | 208 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 226 } | 279 } |
| 227 | 280 |
| 228 void KeyframeEffectModelBase::PropertySpecificKeyframeGroup::trace(Visitor* visi tor) | 281 void KeyframeEffectModelBase::PropertySpecificKeyframeGroup::trace(Visitor* visi tor) |
| 229 { | 282 { |
| 230 #if ENABLE(OILPAN) | 283 #if ENABLE(OILPAN) |
| 231 visitor->trace(m_keyframes); | 284 visitor->trace(m_keyframes); |
| 232 #endif | 285 #endif |
| 233 } | 286 } |
| 234 | 287 |
| 235 } // namespace | 288 } // namespace |
| OLD | NEW |