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

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

Issue 1120003002: [Oilpan] Migrate most classes under core/animations to Oilpan heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase 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 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/ShadowStyleInterpolation.h" 6 #include "core/animation/ShadowStyleInterpolation.h"
7 7
8 #include "core/animation/ColorStyleInterpolation.h" 8 #include "core/animation/ColorStyleInterpolation.h"
9 #include "core/animation/LengthStyleInterpolation.h" 9 #include "core/animation/LengthStyleInterpolation.h"
10 #include "core/css/CSSPrimitiveValue.h" 10 #include "core/css/CSSPrimitiveValue.h"
11 #include "core/css/CSSValueList.h" 11 #include "core/css/CSSValueList.h"
12 #include "core/css/CSSValuePool.h" 12 #include "core/css/CSSValuePool.h"
13 #include "core/css/resolver/StyleBuilder.h" 13 #include "core/css/resolver/StyleBuilder.h"
14 14
15 namespace blink { 15 namespace blink {
16 16
17 bool ShadowStyleInterpolation::canCreateFrom(const CSSValue& start, const CSSVal ue& end) 17 bool ShadowStyleInterpolation::canCreateFrom(const CSSValue& start, const CSSVal ue& end)
18 { 18 {
19 if (!start.isShadowValue() || end.isShadowValue()) 19 if (!start.isShadowValue() || end.isShadowValue())
20 return false; 20 return false;
21 const CSSShadowValue& startShadow = toCSSShadowValue(start); 21 const CSSShadowValue& startShadow = toCSSShadowValue(start);
22 const CSSShadowValue& endShadow = toCSSShadowValue(end); 22 const CSSShadowValue& endShadow = toCSSShadowValue(end);
23 if (startShadow.style != endShadow.style || !startShadow.color || !endShadow .color) 23 if (startShadow.style != endShadow.style || !startShadow.color || !endShadow .color)
24 return false; 24 return false;
25 return !ColorStyleInterpolation::shouldUseLegacyStyleInterpolation(*startSha dow.color, *endShadow.color); 25 return !ColorStyleInterpolation::shouldUseLegacyStyleInterpolation(*startSha dow.color, *endShadow.color);
26 } 26 }
27 27
28 PassOwnPtrWillBeRawPtr<InterpolableValue> ShadowStyleInterpolation::lengthToInte rpolableValue(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> value) 28 InterpolableValue* ShadowStyleInterpolation::lengthToInterpolableValue(PassRefPt rWillBeRawPtr<CSSPrimitiveValue> value)
29 { 29 {
30 if (value) 30 if (value)
31 return LengthStyleInterpolation::toInterpolableValue(*value); 31 return LengthStyleInterpolation::toInterpolableValue(*value);
32 return LengthStyleInterpolation::toInterpolableValue(*CSSPrimitiveValue::cre ate(0, CSSPrimitiveValue::UnitType::Pixels)); 32 return LengthStyleInterpolation::toInterpolableValue(*CSSPrimitiveValue::cre ate(0, CSSPrimitiveValue::UnitType::Pixels));
33 } 33 }
34 34
35 PassOwnPtrWillBeRawPtr<InterpolableValue> ShadowStyleInterpolation::toInterpolab leValue(const CSSValue& value, NonInterpolableType& nonInterpolableData) 35 InterpolableValue* ShadowStyleInterpolation::toInterpolableValue(const CSSValue& value, NonInterpolableType& nonInterpolableData)
36 { 36 {
37 OwnPtrWillBeRawPtr<InterpolableList> result = InterpolableList::create(5); 37 InterpolableList* result = InterpolableList::create(5);
38 const CSSShadowValue* shadowValue = toCSSShadowValue(&value); 38 const CSSShadowValue* shadowValue = toCSSShadowValue(&value);
39 ASSERT(shadowValue); 39 ASSERT(shadowValue);
40 40
41 result->set(0, lengthToInterpolableValue(shadowValue->x)); 41 result->set(0, lengthToInterpolableValue(shadowValue->x));
42 result->set(1, lengthToInterpolableValue(shadowValue->y)); 42 result->set(1, lengthToInterpolableValue(shadowValue->y));
43 result->set(2, lengthToInterpolableValue(shadowValue->blur)); 43 result->set(2, lengthToInterpolableValue(shadowValue->blur));
44 result->set(3, lengthToInterpolableValue(shadowValue->spread)); 44 result->set(3, lengthToInterpolableValue(shadowValue->spread));
45 45
46 if (shadowValue->color && ColorStyleInterpolation::canCreateFrom(*shadowValu e->color)) 46 if (shadowValue->color && ColorStyleInterpolation::canCreateFrom(*shadowValu e->color))
47 result->set(4, ColorStyleInterpolation::colorToInterpolableValue(*shadow Value->color)); 47 result->set(4, ColorStyleInterpolation::colorToInterpolableValue(*shadow Value->color));
48 48
49 if (shadowValue->style) 49 if (shadowValue->style)
50 nonInterpolableData = (shadowValue->style->getValueID() == CSSValueInset ); 50 nonInterpolableData = (shadowValue->style->getValueID() == CSSValueInset );
51 else 51 else
52 nonInterpolableData = false; 52 nonInterpolableData = false;
53 53
54 return result.release(); 54 return result;
55 } 55 }
56 56
57 PassRefPtrWillBeRawPtr<CSSValue> ShadowStyleInterpolation::fromInterpolableValue (const InterpolableValue& value, NonInterpolableType nonInterpolableData, Interp olationRange range) 57 PassRefPtrWillBeRawPtr<CSSValue> ShadowStyleInterpolation::fromInterpolableValue (const InterpolableValue& value, NonInterpolableType nonInterpolableData, Interp olationRange range)
58 { 58 {
59 const InterpolableList* shadow = toInterpolableList(&value); 59 const InterpolableList* shadow = toInterpolableList(&value);
60 RefPtrWillBeRawPtr<CSSPrimitiveValue> x = LengthStyleInterpolation::fromInte rpolableValue(*shadow->get(0), RangeAll); 60 RefPtrWillBeRawPtr<CSSPrimitiveValue> x = LengthStyleInterpolation::fromInte rpolableValue(*shadow->get(0), RangeAll);
61 RefPtrWillBeRawPtr<CSSPrimitiveValue> y = LengthStyleInterpolation::fromInte rpolableValue(*shadow->get(1), RangeAll); 61 RefPtrWillBeRawPtr<CSSPrimitiveValue> y = LengthStyleInterpolation::fromInte rpolableValue(*shadow->get(1), RangeAll);
62 RefPtrWillBeRawPtr<CSSPrimitiveValue> blur = LengthStyleInterpolation::fromI nterpolableValue(*shadow->get(2), RangeNonNegative); 62 RefPtrWillBeRawPtr<CSSPrimitiveValue> blur = LengthStyleInterpolation::fromI nterpolableValue(*shadow->get(2), RangeNonNegative);
63 RefPtrWillBeRawPtr<CSSPrimitiveValue> spread = LengthStyleInterpolation::fro mInterpolableValue(*shadow->get(3), RangeAll); 63 RefPtrWillBeRawPtr<CSSPrimitiveValue> spread = LengthStyleInterpolation::fro mInterpolableValue(*shadow->get(3), RangeAll);
64 64
(...skipping 12 matching lines...) Expand all
77 for (size_t i = 0; i < toCSSValueList(start).length(); i++) { 77 for (size_t i = 0; i < toCSSValueList(start).length(); i++) {
78 if (startList->item(i)->isShadowValue() && endList->item(i)->isShado wValue() 78 if (startList->item(i)->isShadowValue() && endList->item(i)->isShado wValue()
79 && toCSSShadowValue(startList->item(i))->style != toCSSShadowVal ue(endList->item(i))->style) 79 && toCSSShadowValue(startList->item(i))->style != toCSSShadowVal ue(endList->item(i))->style)
80 return true; 80 return true;
81 } 81 }
82 } 82 }
83 return false; 83 return false;
84 } 84 }
85 85
86 } // namespace blink 86 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/animation/ShadowStyleInterpolation.h ('k') | Source/core/animation/ShadowStyleInterpolationTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698