| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/ImageSliceStyleInterpolation.h" | 5 #include "core/animation/ImageSliceStyleInterpolation.h" |
| 6 | 6 |
| 7 #include "core/css/CSSBorderImageSliceValue.h" | 7 #include "core/css/CSSBorderImageSliceValue.h" |
| 8 #include "core/css/CSSPrimitiveValue.h" | 8 #include "core/css/CSSPrimitiveValue.h" |
| 9 #include "core/css/CSSQuadValue.h" | 9 #include "core/css/CSSQuadValue.h" |
| 10 #include "core/css/resolver/StyleBuilder.h" | 10 #include "core/css/resolver/StyleBuilder.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 bool isPercentage = quad.top()->isPercentage(); | 47 bool isPercentage = quad.top()->isPercentage(); |
| 48 ASSERT(quad.bottom()->isPercentage() == isPercentage | 48 ASSERT(quad.bottom()->isPercentage() == isPercentage |
| 49 && quad.left()->isPercentage() == isPercentage | 49 && quad.left()->isPercentage() == isPercentage |
| 50 && quad.right()->isPercentage() == isPercentage); | 50 && quad.right()->isPercentage() == isPercentage); |
| 51 | 51 |
| 52 interpolableValue = interpolableList.release(); | 52 interpolableValue = interpolableList.release(); |
| 53 metadata = ImageSliceStyleInterpolation::Metadata {isPercentage, value.m
_fill}; | 53 metadata = ImageSliceStyleInterpolation::Metadata {isPercentage, value.m
_fill}; |
| 54 } | 54 } |
| 55 }; | 55 }; |
| 56 | 56 |
| 57 PassRefPtrWillBeRawPtr<CSSBorderImageSliceValue> compose(const InterpolableValue
& value, const ImageSliceStyleInterpolation::Metadata& metadata) | 57 RawPtr<CSSBorderImageSliceValue> compose(const InterpolableValue& value, const I
mageSliceStyleInterpolation::Metadata& metadata) |
| 58 { | 58 { |
| 59 const InterpolableList& interpolableList = toInterpolableList(value); | 59 const InterpolableList& interpolableList = toInterpolableList(value); |
| 60 CSSPrimitiveValue::UnitType type = metadata.isPercentage ? CSSPrimitiveValue
::UnitType::Percentage : CSSPrimitiveValue::UnitType::Number; | 60 CSSPrimitiveValue::UnitType type = metadata.isPercentage ? CSSPrimitiveValue
::UnitType::Percentage : CSSPrimitiveValue::UnitType::Number; |
| 61 RefPtrWillBeRawPtr<CSSPrimitiveValue> top = CSSPrimitiveValue::create(clampT
o<double>(toInterpolableNumber(interpolableList.get(0))->value(), 0), type); | 61 RawPtr<CSSPrimitiveValue> top = CSSPrimitiveValue::create(clampTo<double>(to
InterpolableNumber(interpolableList.get(0))->value(), 0), type); |
| 62 RefPtrWillBeRawPtr<CSSPrimitiveValue> right = CSSPrimitiveValue::create(clam
pTo<double>(toInterpolableNumber(interpolableList.get(1))->value(), 0), type); | 62 RawPtr<CSSPrimitiveValue> right = CSSPrimitiveValue::create(clampTo<double>(
toInterpolableNumber(interpolableList.get(1))->value(), 0), type); |
| 63 RefPtrWillBeRawPtr<CSSPrimitiveValue> bottom = CSSPrimitiveValue::create(cla
mpTo<double>(toInterpolableNumber(interpolableList.get(2))->value(), 0), type); | 63 RawPtr<CSSPrimitiveValue> bottom = CSSPrimitiveValue::create(clampTo<double>
(toInterpolableNumber(interpolableList.get(2))->value(), 0), type); |
| 64 RefPtrWillBeRawPtr<CSSPrimitiveValue> left = CSSPrimitiveValue::create(clamp
To<double>(toInterpolableNumber(interpolableList.get(3))->value(), 0), type); | 64 RawPtr<CSSPrimitiveValue> left = CSSPrimitiveValue::create(clampTo<double>(t
oInterpolableNumber(interpolableList.get(3))->value(), 0), type); |
| 65 return CSSBorderImageSliceValue::create(CSSQuadValue::create(top.release(),
right.release(), bottom.release(), left.release(), CSSQuadValue::SerializeAsQuad
), metadata.fill); | 65 return CSSBorderImageSliceValue::create(CSSQuadValue::create(top.release(),
right.release(), bottom.release(), left.release(), CSSQuadValue::SerializeAsQuad
), metadata.fill); |
| 66 } | 66 } |
| 67 | 67 |
| 68 } // namespace | 68 } // namespace |
| 69 | 69 |
| 70 PassRefPtr<ImageSliceStyleInterpolation> ImageSliceStyleInterpolation::maybeCrea
te(const CSSValue& start, const CSSValue& end, CSSPropertyID property) | 70 PassRefPtr<ImageSliceStyleInterpolation> ImageSliceStyleInterpolation::maybeCrea
te(const CSSValue& start, const CSSValue& end, CSSPropertyID property) |
| 71 { | 71 { |
| 72 if (!start.isBorderImageSliceValue() || !end.isBorderImageSliceValue()) | 72 if (!start.isBorderImageSliceValue() || !end.isBorderImageSliceValue()) |
| 73 return nullptr; | 73 return nullptr; |
| 74 | 74 |
| 75 Decomposition startDecompose(toCSSBorderImageSliceValue(start)); | 75 Decomposition startDecompose(toCSSBorderImageSliceValue(start)); |
| 76 Decomposition endDecompose(toCSSBorderImageSliceValue(end)); | 76 Decomposition endDecompose(toCSSBorderImageSliceValue(end)); |
| 77 if (!(startDecompose.metadata == endDecompose.metadata)) | 77 if (!(startDecompose.metadata == endDecompose.metadata)) |
| 78 return nullptr; | 78 return nullptr; |
| 79 | 79 |
| 80 return adoptRef(new ImageSliceStyleInterpolation( | 80 return adoptRef(new ImageSliceStyleInterpolation( |
| 81 startDecompose.interpolableValue.release(), | 81 startDecompose.interpolableValue.release(), |
| 82 endDecompose.interpolableValue.release(), | 82 endDecompose.interpolableValue.release(), |
| 83 property, | 83 property, |
| 84 startDecompose.metadata | 84 startDecompose.metadata |
| 85 )); | 85 )); |
| 86 } | 86 } |
| 87 | 87 |
| 88 void ImageSliceStyleInterpolation::apply(StyleResolverState& state) const | 88 void ImageSliceStyleInterpolation::apply(StyleResolverState& state) const |
| 89 { | 89 { |
| 90 StyleBuilder::applyProperty(m_id, state, compose(*m_cachedValue, m_metadata)
.get()); | 90 StyleBuilder::applyProperty(m_id, state, compose(*m_cachedValue, m_metadata)
.get()); |
| 91 } | 91 } |
| 92 | 92 |
| 93 } // namespace blink | 93 } // namespace blink |
| OLD | NEW |