| 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/LengthBoxStyleInterpolation.h" | 6 #include "core/animation/LengthBoxStyleInterpolation.h" |
| 7 | 7 |
| 8 #include "core/css/CSSQuadValue.h" | 8 #include "core/css/CSSQuadValue.h" |
| 9 #include "core/css/resolver/StyleBuilder.h" | 9 #include "core/css/resolver/StyleBuilder.h" |
| 10 | 10 |
| 11 namespace blink { | 11 namespace blink { |
| 12 | 12 |
| 13 namespace { | 13 namespace { |
| 14 | 14 |
| 15 bool onlyInterpolateBetweenLengthAndCSSValueAuto(const CSSQuadValue& startRect,
const CSSQuadValue& endRect) | 15 bool onlyInterpolateBetweenLengthAndCSSValueAuto(const CSSQuadValue& startRect,
const CSSQuadValue& endRect) |
| 16 { | 16 { |
| 17 return startRect.left()->isLength() != endRect.left()->isLength() | 17 return startRect.left()->isLength() != endRect.left()->isLength() |
| 18 && startRect.right()->isLength() != endRect.right()->isLength() | 18 && startRect.right()->isLength() != endRect.right()->isLength() |
| 19 && startRect.top()->isLength() != endRect.top()->isLength() | 19 && startRect.top()->isLength() != endRect.top()->isLength() |
| 20 && startRect.bottom()->isLength() != endRect.bottom()->isLength(); | 20 && startRect.bottom()->isLength() != endRect.bottom()->isLength(); |
| 21 } | 21 } |
| 22 | 22 |
| 23 } // namespace | 23 } // namespace |
| 24 | 24 |
| 25 PassRefPtrWillBeRawPtr<LengthBoxStyleInterpolation> LengthBoxStyleInterpolation:
:maybeCreateFrom(CSSValue& start, CSSValue& end, CSSPropertyID id) | 25 PassRefPtr<LengthBoxStyleInterpolation> LengthBoxStyleInterpolation::maybeCreate
From(CSSValue& start, CSSValue& end, CSSPropertyID id) |
| 26 { | 26 { |
| 27 bool startRect = start.isQuadValue() && toCSSQuadValue(start).serializationT
ype() == CSSQuadValue::SerializationType::SerializeAsRect; | 27 bool startRect = start.isQuadValue() && toCSSQuadValue(start).serializationT
ype() == CSSQuadValue::SerializationType::SerializeAsRect; |
| 28 bool endRect = end.isQuadValue() && toCSSQuadValue(end).serializationType()
== CSSQuadValue::SerializationType::SerializeAsRect; | 28 bool endRect = end.isQuadValue() && toCSSQuadValue(end).serializationType()
== CSSQuadValue::SerializationType::SerializeAsRect; |
| 29 | 29 |
| 30 if (startRect && endRect) | 30 if (startRect && endRect) |
| 31 return adoptRefWillBeNoop(new LengthBoxStyleInterpolation(lengthBoxtoInt
erpolableValue(start, end, false), lengthBoxtoInterpolableValue(end, start, true
), id, &start, &end)); | 31 return adoptRef(new LengthBoxStyleInterpolation(lengthBoxtoInterpolableV
alue(start, end, false), lengthBoxtoInterpolableValue(end, start, true), id, &st
art, &end)); |
| 32 return nullptr; | 32 return nullptr; |
| 33 } | 33 } |
| 34 | 34 |
| 35 PassOwnPtrWillBeRawPtr<InterpolableValue> LengthBoxStyleInterpolation::lengthBox
toInterpolableValue(const CSSValue& lengthBox, const CSSValue& matchingValue, bo
ol isEndInterpolation) | 35 PassOwnPtr<InterpolableValue> LengthBoxStyleInterpolation::lengthBoxtoInterpolab
leValue(const CSSValue& lengthBox, const CSSValue& matchingValue, bool isEndInte
rpolation) |
| 36 { | 36 { |
| 37 const int numberOfSides = 4; | 37 const int numberOfSides = 4; |
| 38 OwnPtrWillBeRawPtr<InterpolableList> result = InterpolableList::create(numbe
rOfSides); | 38 OwnPtr<InterpolableList> result = InterpolableList::create(numberOfSides); |
| 39 const CSSQuadValue& rect = toCSSQuadValue(lengthBox); | 39 const CSSQuadValue& rect = toCSSQuadValue(lengthBox); |
| 40 const CSSQuadValue& matchingRect = toCSSQuadValue(matchingValue); | 40 const CSSQuadValue& matchingRect = toCSSQuadValue(matchingValue); |
| 41 CSSPrimitiveValue* side[numberOfSides] = { rect.left(), rect.right(), rect.t
op(), rect.bottom() }; | 41 CSSPrimitiveValue* side[numberOfSides] = { rect.left(), rect.right(), rect.t
op(), rect.bottom() }; |
| 42 CSSPrimitiveValue* matchingSide[numberOfSides] = { matchingRect.left(), matc
hingRect.right(), matchingRect.top(), matchingRect.bottom() }; | 42 CSSPrimitiveValue* matchingSide[numberOfSides] = { matchingRect.left(), matc
hingRect.right(), matchingRect.top(), matchingRect.bottom() }; |
| 43 | 43 |
| 44 for (size_t i = 0; i < numberOfSides; i++) { | 44 for (size_t i = 0; i < numberOfSides; i++) { |
| 45 if (side[i]->isValueID() || matchingSide[i]->isValueID()) { | 45 if (side[i]->isValueID() || matchingSide[i]->isValueID()) { |
| 46 result->set(i, InterpolableBool::create(isEndInterpolation)); | 46 result->set(i, InterpolableBool::create(isEndInterpolation)); |
| 47 } else { | 47 } else { |
| 48 ASSERT(LengthStyleInterpolation::canCreateFrom(*side[i])); | 48 ASSERT(LengthStyleInterpolation::canCreateFrom(*side[i])); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 } | 100 } |
| 101 | 101 |
| 102 void LengthBoxStyleInterpolation::apply(StyleResolverState& state) const | 102 void LengthBoxStyleInterpolation::apply(StyleResolverState& state) const |
| 103 { | 103 { |
| 104 if (m_cachedValue.get()->isBool()) | 104 if (m_cachedValue.get()->isBool()) |
| 105 StyleBuilder::applyProperty(m_id, state, toInterpolableBool(m_cachedValu
e.get())->value() ? m_endCSSValue.get() : m_startCSSValue.get()); | 105 StyleBuilder::applyProperty(m_id, state, toInterpolableBool(m_cachedValu
e.get())->value() ? m_endCSSValue.get() : m_startCSSValue.get()); |
| 106 else | 106 else |
| 107 StyleBuilder::applyProperty(m_id, state, interpolableValueToLengthBox(m_
cachedValue.get(), *m_startCSSValue, *m_endCSSValue).get()); | 107 StyleBuilder::applyProperty(m_id, state, interpolableValueToLengthBox(m_
cachedValue.get(), *m_startCSSValue, *m_endCSSValue).get()); |
| 108 } | 108 } |
| 109 | 109 |
| 110 DEFINE_TRACE(LengthBoxStyleInterpolation) | |
| 111 { | |
| 112 StyleInterpolation::trace(visitor); | |
| 113 visitor->trace(m_startCSSValue); | |
| 114 visitor->trace(m_endCSSValue); | |
| 115 } | 110 } |
| 116 | |
| 117 } | |
| OLD | NEW |