Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(74)

Side by Side Diff: Source/core/animation/ImageSliceStyleInterpolation.cpp

Issue 1304993002: Change Rect and Quad to be CSSValues (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@split_counter_out_attempt_3
Patch Set: Removed empty destructor Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "config.h" 5 #include "config.h"
6 #include "core/animation/ImageSliceStyleInterpolation.h" 6 #include "core/animation/ImageSliceStyleInterpolation.h"
7 7
8 #include "core/css/CSSBorderImageSliceValue.h" 8 #include "core/css/CSSBorderImageSliceValue.h"
9 #include "core/css/CSSPrimitiveValue.h" 9 #include "core/css/CSSPrimitiveValue.h"
10 #include "core/css/Rect.h" 10 #include "core/css/CSSQuadValue.h"
11 #include "core/css/resolver/StyleBuilder.h" 11 #include "core/css/resolver/StyleBuilder.h"
12 12
13 namespace blink { 13 namespace blink {
14 14
15 bool ImageSliceStyleInterpolation::usesDefaultInterpolation(const CSSValue& star t, const CSSValue& end) 15 bool ImageSliceStyleInterpolation::usesDefaultInterpolation(const CSSValue& star t, const CSSValue& end)
16 { 16 {
17 if (!start.isBorderImageSliceValue() || !end.isBorderImageSliceValue()) 17 if (!start.isBorderImageSliceValue() || !end.isBorderImageSliceValue())
18 return true; 18 return true;
19 const CSSBorderImageSliceValue& startSlice = toCSSBorderImageSliceValue(star t); 19 const CSSBorderImageSliceValue& startSlice = toCSSBorderImageSliceValue(star t);
20 const CSSBorderImageSliceValue& endSlice = toCSSBorderImageSliceValue(end); 20 const CSSBorderImageSliceValue& endSlice = toCSSBorderImageSliceValue(end);
(...skipping 12 matching lines...) Expand all
33 } 33 }
34 34
35 OwnPtrWillBeMember<InterpolableValue> interpolableValue; 35 OwnPtrWillBeMember<InterpolableValue> interpolableValue;
36 ImageSliceStyleInterpolation::Metadata metadata; 36 ImageSliceStyleInterpolation::Metadata metadata;
37 37
38 private: 38 private:
39 void decompose(const CSSBorderImageSliceValue& value) 39 void decompose(const CSSBorderImageSliceValue& value)
40 { 40 {
41 const size_t kQuadSides = 4; 41 const size_t kQuadSides = 4;
42 OwnPtrWillBeRawPtr<InterpolableList> interpolableList = InterpolableList ::create(kQuadSides); 42 OwnPtrWillBeRawPtr<InterpolableList> interpolableList = InterpolableList ::create(kQuadSides);
43 const Quad& quad = *value.slices(); 43 const CSSQuadValue& quad = *value.slices();
44 interpolableList->set(0, InterpolableNumber::create(quad.top()->getDoubl eValue())); 44 interpolableList->set(0, InterpolableNumber::create(quad.top()->getDoubl eValue()));
45 interpolableList->set(1, InterpolableNumber::create(quad.right()->getDou bleValue())); 45 interpolableList->set(1, InterpolableNumber::create(quad.right()->getDou bleValue()));
46 interpolableList->set(2, InterpolableNumber::create(quad.bottom()->getDo ubleValue())); 46 interpolableList->set(2, InterpolableNumber::create(quad.bottom()->getDo ubleValue()));
47 interpolableList->set(3, InterpolableNumber::create(quad.left()->getDoub leValue())); 47 interpolableList->set(3, InterpolableNumber::create(quad.left()->getDoub leValue()));
48 bool isPercentage = quad.top()->isPercentage(); 48 bool isPercentage = quad.top()->isPercentage();
49 ASSERT(quad.bottom()->isPercentage() == isPercentage 49 ASSERT(quad.bottom()->isPercentage() == isPercentage
50 && quad.left()->isPercentage() == isPercentage 50 && quad.left()->isPercentage() == isPercentage
51 && quad.right()->isPercentage() == isPercentage); 51 && quad.right()->isPercentage() == isPercentage);
52 52
53 interpolableValue = interpolableList.release(); 53 interpolableValue = interpolableList.release();
54 metadata = ImageSliceStyleInterpolation::Metadata {isPercentage, value.m _fill}; 54 metadata = ImageSliceStyleInterpolation::Metadata {isPercentage, value.m _fill};
55 } 55 }
56 }; 56 };
57 57
58 PassRefPtrWillBeRawPtr<CSSBorderImageSliceValue> compose(const InterpolableValue & value, const ImageSliceStyleInterpolation::Metadata& metadata) 58 PassRefPtrWillBeRawPtr<CSSBorderImageSliceValue> compose(const InterpolableValue & value, const ImageSliceStyleInterpolation::Metadata& metadata)
59 { 59 {
60 const InterpolableList& interpolableList = toInterpolableList(value); 60 const InterpolableList& interpolableList = toInterpolableList(value);
61 CSSPrimitiveValue::UnitType type = metadata.isPercentage ? CSSPrimitiveValue ::UnitType::Percentage : CSSPrimitiveValue::UnitType::Number; 61 CSSPrimitiveValue::UnitType type = metadata.isPercentage ? CSSPrimitiveValue ::UnitType::Percentage : CSSPrimitiveValue::UnitType::Number;
62 RefPtrWillBeRawPtr<Quad> quad = Quad::create(); 62 RefPtrWillBeRawPtr<CSSPrimitiveValue> top = CSSPrimitiveValue::create(clampT o<double>(toInterpolableNumber(interpolableList.get(0))->value(), 0), type);
63 quad->setTop(CSSPrimitiveValue::create(clampTo<double>(toInterpolableNumber( interpolableList.get(0))->value(), 0), type)); 63 RefPtrWillBeRawPtr<CSSPrimitiveValue> right = CSSPrimitiveValue::create(clam pTo<double>(toInterpolableNumber(interpolableList.get(1))->value(), 0), type);
64 quad->setRight(CSSPrimitiveValue::create(clampTo<double>(toInterpolableNumbe r(interpolableList.get(1))->value(), 0), type)); 64 RefPtrWillBeRawPtr<CSSPrimitiveValue> bottom = CSSPrimitiveValue::create(cla mpTo<double>(toInterpolableNumber(interpolableList.get(2))->value(), 0), type);
65 quad->setBottom(CSSPrimitiveValue::create(clampTo<double>(toInterpolableNumb er(interpolableList.get(2))->value(), 0), type)); 65 RefPtrWillBeRawPtr<CSSPrimitiveValue> left = CSSPrimitiveValue::create(clamp To<double>(toInterpolableNumber(interpolableList.get(3))->value(), 0), type);
66 quad->setLeft(CSSPrimitiveValue::create(clampTo<double>(toInterpolableNumber (interpolableList.get(3))->value(), 0), type)); 66 return CSSBorderImageSliceValue::create(CSSQuadValue::createQuad(top, right, bottom, left), metadata.fill);
67 return CSSBorderImageSliceValue::create(CSSPrimitiveValue::create(quad.relea se()), metadata.fill);
68 } 67 }
69 68
70 } // namespace 69 } // namespace
71 70
72 PassRefPtrWillBeRawPtr<ImageSliceStyleInterpolation> ImageSliceStyleInterpolatio n::maybeCreate(const CSSValue& start, const CSSValue& end, CSSPropertyID propert y) 71 PassRefPtrWillBeRawPtr<ImageSliceStyleInterpolation> ImageSliceStyleInterpolatio n::maybeCreate(const CSSValue& start, const CSSValue& end, CSSPropertyID propert y)
73 { 72 {
74 if (!start.isBorderImageSliceValue() || !end.isBorderImageSliceValue()) 73 if (!start.isBorderImageSliceValue() || !end.isBorderImageSliceValue())
75 return nullptr; 74 return nullptr;
76 75
77 Decomposition startDecompose(toCSSBorderImageSliceValue(start)); 76 Decomposition startDecompose(toCSSBorderImageSliceValue(start));
(...skipping 13 matching lines...) Expand all
91 { 90 {
92 StyleBuilder::applyProperty(m_id, state, compose(*m_cachedValue, m_metadata) .get()); 91 StyleBuilder::applyProperty(m_id, state, compose(*m_cachedValue, m_metadata) .get());
93 } 92 }
94 93
95 DEFINE_TRACE(ImageSliceStyleInterpolation) 94 DEFINE_TRACE(ImageSliceStyleInterpolation)
96 { 95 {
97 StyleInterpolation::trace(visitor); 96 StyleInterpolation::trace(visitor);
98 } 97 }
99 98
100 } // namespace blink 99 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698