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/LengthStyleInterpolation.h" | 6 #include "core/animation/LengthStyleInterpolation.h" |
7 | 7 |
8 #include "core/animation/css/CSSAnimatableValueFactory.h" | 8 #include "core/animation/css/CSSAnimatableValueFactory.h" |
9 #include "core/css/CSSCalculationValue.h" | 9 #include "core/css/CSSCalculationValue.h" |
10 #include "core/css/resolver/StyleBuilder.h" | 10 #include "core/css/resolver/StyleBuilder.h" |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 return CSSPrimitiveValue::create(value, toUnitType(i)); | 305 return CSSPrimitiveValue::create(value, toUnitType(i)); |
306 } | 306 } |
307 } | 307 } |
308 ASSERT_NOT_REACHED(); | 308 ASSERT_NOT_REACHED(); |
309 default: | 309 default: |
310 ValueRange valueRange = (range == RangeNonNegative) ? ValueRangeNonNegat
ive : ValueRangeAll; | 310 ValueRange valueRange = (range == RangeNonNegative) ? ValueRangeNonNegat
ive : ValueRangeAll; |
311 return CSSPrimitiveValue::create(CSSCalcValue::create(constructCalcExpre
ssion(listOfValuesAndTypes), valueRange)); | 311 return CSSPrimitiveValue::create(CSSCalcValue::create(constructCalcExpre
ssion(listOfValuesAndTypes), valueRange)); |
312 } | 312 } |
313 } | 313 } |
314 | 314 |
| 315 void LengthStyleInterpolation::applyInterpolableValue(CSSPropertyID property, co
nst InterpolableValue& value, InterpolationRange range, StyleResolverState& stat
e, LengthSetter lengthSetter) |
| 316 { |
| 317 if (lengthSetter && isPixelsOrPercentOnly(value)) { |
| 318 (state.style()->*lengthSetter)(lengthFromInterpolableValue(value, range,
state.style()->effectiveZoom())); |
| 319 #if ENABLE(ASSERT) |
| 320 RefPtrWillBeRawPtr<AnimatableValue> before = CSSAnimatableValueFactory::
create(property, *state.style()); |
| 321 StyleBuilder::applyProperty(property, state, fromInterpolableValue(value
, range).get()); |
| 322 RefPtrWillBeRawPtr<AnimatableValue> after = CSSAnimatableValueFactory::c
reate(property, *state.style()); |
| 323 ASSERT(before->equals(*after)); |
| 324 #endif |
| 325 } else { |
| 326 StyleBuilder::applyProperty(property, state, fromInterpolableValue(value
, range).get()); |
| 327 } |
| 328 } |
| 329 |
315 void LengthStyleInterpolation::apply(StyleResolverState& state) const | 330 void LengthStyleInterpolation::apply(StyleResolverState& state) const |
316 { | 331 { |
317 if (m_lengthSetter) { | 332 applyInterpolableValue(m_id, *m_cachedValue, m_range, state, m_lengthSetter)
; |
318 (state.style()->*m_lengthSetter)(lengthFromInterpolableValue(*m_cachedVa
lue, m_range, state.style()->effectiveZoom())); | |
319 #if ENABLE(ASSERT) | |
320 RefPtrWillBeRawPtr<AnimatableValue> before = CSSAnimatableValueFactory::
create(m_id, *state.style()); | |
321 StyleBuilder::applyProperty(m_id, state, fromInterpolableValue(*m_cached
Value, m_range).get()); | |
322 RefPtrWillBeRawPtr<AnimatableValue> after = CSSAnimatableValueFactory::c
reate(m_id, *state.style()); | |
323 ASSERT(before->equals(*after)); | |
324 #endif | |
325 } else { | |
326 StyleBuilder::applyProperty(m_id, state, fromInterpolableValue(*m_cached
Value, m_range).get()); | |
327 } | |
328 } | 333 } |
329 | 334 |
330 DEFINE_TRACE(LengthStyleInterpolation) | 335 DEFINE_TRACE(LengthStyleInterpolation) |
331 { | 336 { |
332 StyleInterpolation::trace(visitor); | 337 StyleInterpolation::trace(visitor); |
333 } | 338 } |
334 | 339 |
335 } | 340 } |
OLD | NEW |