OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "config.h" |
| 6 #include "core/animation/LegacyStyleInterpolation.h" |
| 7 |
| 8 #include "core/css/resolver/AnimatedStyleBuilder.h" |
| 9 #include "core/css/resolver/StyleResolverState.h" |
| 10 |
| 11 namespace WebCore { |
| 12 |
| 13 PassRefPtrWillBeRawPtr<LegacyStyleInterpolation> LegacyStyleInterpolation::creat
e(PassRefPtrWillBeRawPtr<InterpolableValuePromise> start, PassRefPtrWillBeRawPtr
<InterpolableValuePromise> end, CSSPropertyID id) |
| 14 { |
| 15 RefPtrWillBeRawPtr<AnimatableValue> startValue = start->extractAnimatableVal
ue(); |
| 16 RefPtrWillBeRawPtr<AnimatableValue> endValue = end->extractAnimatableValue()
; |
| 17 if (startValue && endValue) |
| 18 return create(startValue, endValue, id); |
| 19 return adoptRefWillBeNoop(new LegacyStyleInterpolation(start, end, id)); |
| 20 } |
| 21 |
| 22 void LegacyStyleInterpolation::apply(StyleResolverState& state) const |
| 23 { |
| 24 if (m_cachedValue) { |
| 25 AnimatedStyleBuilder::applyProperty(m_id, state, toInterpolableAnimatabl
eValue(m_cachedValue.get())->value()); |
| 26 } else { |
| 27 OwnPtrWillBeRawPtr<InterpolableValue> start = m_startPromise->extract(st
ate, m_id); |
| 28 OwnPtrWillBeRawPtr<InterpolableValue> end = m_endPromise->extract(state,
m_id); |
| 29 OwnPtrWillBeRawPtr<InterpolableValue> interpolated = start->interpolate(
*end, m_cachedFraction); |
| 30 AnimatedStyleBuilder::applyProperty(m_id, state, toInterpolableAnimatabl
eValue(interpolated.get())->value()); |
| 31 // We avoid caching to remain responsive outside of our active interval. |
| 32 } |
| 33 } |
| 34 |
| 35 void LegacyStyleInterpolation::trace(Visitor* visitor) |
| 36 { |
| 37 StyleInterpolation::trace(visitor); |
| 38 visitor->trace(m_startPromise); |
| 39 visitor->trace(m_endPromise); |
| 40 } |
| 41 |
| 42 } |
OLD | NEW |