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

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

Issue 878863002: Animation: Add CSSPropertyClip and CSSPropertyBorderImageSlice to StringKeyframe (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 11 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 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/Rect.h" 8 #include "core/css/Rect.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 bool LengthBoxStyleInterpolation::canCreateFrom(const CSSValue& value) 13 bool LengthBoxStyleInterpolation::isAutoValue(const CSSValue& value)
14 { 14 {
15 return value.isPrimitiveValue() && toCSSPrimitiveValue(value).isRect(); 15 if (value.isPrimitiveValue() && toCSSPrimitiveValue(value).isRect()
16 && (toCSSPrimitiveValue(value).getRectValue()->left()->isValueID()
17 || toCSSPrimitiveValue(value).getRectValue()->right()->isValueID()
18 || toCSSPrimitiveValue(value).getRectValue()->top()->isValueID()
19 || toCSSPrimitiveValue(value).getRectValue()->bottom()->isValueID()))
20 return true;
21 return false;
16 } 22 }
17 23
18 PassOwnPtrWillBeRawPtr<InterpolableValue> LengthBoxStyleInterpolation::lengthBox toInterpolableValue(const CSSValue& lengthBox) 24 PassOwnPtrWillBeRawPtr<InterpolableValue> LengthBoxStyleInterpolation::lengthBox toInterpolableValue(const CSSValue& lengthBox)
19 { 25 {
20 const int numberOfSides = 4; 26 const int numberOfSides = 4;
21 OwnPtrWillBeRawPtr<InterpolableList> result = InterpolableList::create(numbe rOfSides); 27 OwnPtrWillBeRawPtr<InterpolableList> result = InterpolableList::create(numbe rOfSides);
22 Rect* rect = toCSSPrimitiveValue(lengthBox).getRectValue(); 28 Rect* rect = toCSSPrimitiveValue(lengthBox).getRectValue();
23 CSSPrimitiveValue* side[numberOfSides] = { rect->left(), rect->right(), rect ->top(), rect->bottom() }; 29 CSSPrimitiveValue* side[numberOfSides] = { rect->left(), rect->right(), rect ->top(), rect->bottom() };
24 30
25 for (size_t i = 0; i < numberOfSides; i++) { 31 for (size_t i = 0; i < numberOfSides; i++) {
26 result->set(i, LengthStyleInterpolation::lengthToInterpolableValue(*side [i])); 32 result->set(i, LengthStyleInterpolation::lengthToInterpolableValue(*side [i]));
27 } 33 }
28 return result.release(); 34 return result.release();
29 } 35 }
30 36
31 PassRefPtrWillBeRawPtr<CSSValue> LengthBoxStyleInterpolation::interpolableValueT oLengthBox(InterpolableValue* value, InterpolationRange range) 37 PassRefPtrWillBeRawPtr<CSSValue> LengthBoxStyleInterpolation::interpolableValueT oLengthBox(InterpolableValue* value)
32 { 38 {
33 InterpolableList* lengthBox = toInterpolableList(value); 39 InterpolableList* lengthBox = toInterpolableList(value);
34 RefPtrWillBeRawPtr<Rect> result = Rect::create(); 40 RefPtrWillBeRawPtr<Rect> result = Rect::create();
35 41
36 result->setLeft(LengthStyleInterpolation::interpolableValueToLength(lengthBo x->get(0), RangeNonNegative)); 42 result->setLeft(LengthStyleInterpolation::interpolableValueToLength(lengthBo x->get(0), RangeNonNegative));
37 result->setRight(LengthStyleInterpolation::interpolableValueToLength(lengthB ox->get(1), RangeNonNegative)); 43 result->setRight(LengthStyleInterpolation::interpolableValueToLength(lengthB ox->get(1), RangeNonNegative));
38 result->setTop(LengthStyleInterpolation::interpolableValueToLength(lengthBox ->get(2), RangeNonNegative)); 44 result->setTop(LengthStyleInterpolation::interpolableValueToLength(lengthBox ->get(2), RangeNonNegative));
39 result->setBottom(LengthStyleInterpolation::interpolableValueToLength(length Box->get(3), RangeNonNegative)); 45 result->setBottom(LengthStyleInterpolation::interpolableValueToLength(length Box->get(3), RangeNonNegative));
40 46
41 return CSSPrimitiveValue::create(result.release()); 47 return CSSPrimitiveValue::create(result.release());
42 } 48 }
43 49
44 void LengthBoxStyleInterpolation::apply(StyleResolverState& state) const 50 PassOwnPtrWillBeRawPtr<InterpolableValue> LengthBoxStyleInterpolation::borderIma geSlicetoInterpolableValue(const CSSValue& value)
45 {
46 if (m_id == CSSPropertyWebkitMaskBoxImageSlice)
47 StyleBuilder::applyProperty(m_id, state, interpolableValueToBorderImageS lice(m_cachedValue.get(), m_fill).get());
48 else
49 StyleBuilder::applyProperty(m_id, state, interpolableValueToLengthBox(m_ cachedValue.get()).get());
50 }
51
52 void LengthBoxStyleInterpolation::trace(Visitor* visitor)
53 {
54 StyleInterpolation::trace(visitor);
55 }
56
57 bool LengthBoxStyleInterpolation::matchingFill(CSSValue& start, CSSValue& end)
58 {
59 return toCSSBorderImageSliceValue(start).m_fill == toCSSBorderImageSliceValu e(end).m_fill;
60 }
61
62 bool LengthBoxStyleInterpolation::canCreateFromBorderImageSlice(CSSValue& value)
63 {
64 return value.isBorderImageSliceValue() && toCSSBorderImageSliceValue(value). slices();
65 }
66
67 PassOwnPtrWillBeRawPtr<InterpolableValue> LengthBoxStyleInterpolation::borderIma geSlicetoInterpolableValue(CSSValue& value)
68 { 51 {
69 const int numberOfSides = 4; 52 const int numberOfSides = 4;
70 OwnPtrWillBeRawPtr<InterpolableList> result = InterpolableList::create(numbe rOfSides); 53 OwnPtrWillBeRawPtr<InterpolableList> result = InterpolableList::create(numbe rOfSides);
71 Quad* quad = toCSSBorderImageSliceValue(value).slices(); 54 Quad* quad = toCSSBorderImageSliceValue(value).slices();
72 CSSPrimitiveValue* side[numberOfSides] = { quad->left(), quad->right(), quad ->top(), quad->bottom() }; 55 CSSPrimitiveValue* side[numberOfSides] = { quad->left(), quad->right(), quad ->top(), quad->bottom() };
73 56
74 for (size_t i = 0; i < numberOfSides; i++) { 57 for (size_t i = 0; i < numberOfSides; i++) {
75 result->set(i, LengthStyleInterpolation::lengthToInterpolableValue(*side [i])); 58 result->set(i, LengthStyleInterpolation::lengthToInterpolableValue(*side [i]));
76 } 59 }
77 return result.release(); 60 return result.release();
78 } 61 }
79 62
80 static inline PassRefPtrWillBeRawPtr<CSSPrimitiveValue> toPrimitiveValue(PassRef PtrWillBeRawPtr<CSSValue> value)
81 {
82 return adoptRefWillBeNoop(toCSSPrimitiveValue(value.leakRef()));
83 }
84
85 PassRefPtrWillBeRawPtr<CSSValue> LengthBoxStyleInterpolation::interpolableValueT oBorderImageSlice(InterpolableValue* value, bool fill) 63 PassRefPtrWillBeRawPtr<CSSValue> LengthBoxStyleInterpolation::interpolableValueT oBorderImageSlice(InterpolableValue* value, bool fill)
86 { 64 {
87 InterpolableList* lengthBox = toInterpolableList(value); 65 InterpolableList* lengthBox = toInterpolableList(value);
88 RefPtrWillBeRawPtr<Quad> quad = Quad::create(); 66 RefPtrWillBeRawPtr<Quad> quad = Quad::create();
89 67
90 quad->setLeft(toPrimitiveValue(LengthStyleInterpolation::interpolableValueTo Length(lengthBox->get(0), RangeNonNegative))); 68 quad->setLeft(LengthStyleInterpolation::interpolableValueToLength(lengthBox- >get(0), RangeNonNegative));
91 quad->setRight(toPrimitiveValue(LengthStyleInterpolation::interpolableValueT oLength(lengthBox->get(1), RangeNonNegative))); 69 quad->setRight(LengthStyleInterpolation::interpolableValueToLength(lengthBox ->get(1), RangeNonNegative));
92 quad->setTop(toPrimitiveValue(LengthStyleInterpolation::interpolableValueToL ength(lengthBox->get(2), RangeNonNegative))); 70 quad->setTop(LengthStyleInterpolation::interpolableValueToLength(lengthBox-> get(2), RangeNonNegative));
93 quad->setBottom(toPrimitiveValue(LengthStyleInterpolation::interpolableValue ToLength(lengthBox->get(3), RangeNonNegative))); 71 quad->setBottom(LengthStyleInterpolation::interpolableValueToLength(lengthBo x->get(3), RangeNonNegative));
94 72
95 return CSSBorderImageSliceValue::create(CSSPrimitiveValue::create(quad.relea se()), fill); 73 return CSSBorderImageSliceValue::create(CSSPrimitiveValue::create(quad.relea se()), fill);
96 } 74 }
97 75
76 void LengthBoxStyleInterpolation::apply(StyleResolverState& state) const
Eric Willigers 2015/01/27 23:21:14 If you move apply and trace to before borderImageS
77 {
78 if (m_id == CSSPropertyWebkitMaskBoxImageSlice || m_id == CSSPropertyBorderI mageSlice)
79 StyleBuilder::applyProperty(m_id, state, interpolableValueToBorderImageS lice(m_cachedValue.get(), m_fill).get());
80 else
81 StyleBuilder::applyProperty(m_id, state, interpolableValueToLengthBox(m_ cachedValue.get()).get());
98 } 82 }
83
84 void LengthBoxStyleInterpolation::trace(Visitor* visitor)
85 {
86 StyleInterpolation::trace(visitor);
87 }
88
89 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698