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/ColorStyleInterpolation.h" | 6 #include "core/animation/ColorStyleInterpolation.h" |
7 | 7 |
8 #include "core/CSSValueKeywords.h" | 8 #include "core/CSSValueKeywords.h" |
9 #include "core/css/CSSPrimitiveValue.h" | 9 #include "core/css/CSSPrimitiveValue.h" |
10 #include "core/css/parser/CSSPropertyParser.h" | 10 #include "core/css/parser/CSSPropertyParser.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 | 43 |
44 OwnPtrWillBeRawPtr<InterpolableList> list = InterpolableList::create(4); | 44 OwnPtrWillBeRawPtr<InterpolableList> list = InterpolableList::create(4); |
45 list->set(0, InterpolableNumber::create(redChannel(color) * alpha)); | 45 list->set(0, InterpolableNumber::create(redChannel(color) * alpha)); |
46 list->set(1, InterpolableNumber::create(greenChannel(color) * alpha)); | 46 list->set(1, InterpolableNumber::create(greenChannel(color) * alpha)); |
47 list->set(2, InterpolableNumber::create(blueChannel(color) * alpha)); | 47 list->set(2, InterpolableNumber::create(blueChannel(color) * alpha)); |
48 list->set(3, InterpolableNumber::create(alpha)); | 48 list->set(3, InterpolableNumber::create(alpha)); |
49 | 49 |
50 return list->clone(); | 50 return list->clone(); |
51 } | 51 } |
52 | 52 |
53 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> ColorStyleInterpolation::interpolableV
alueToColor(const InterpolableValue& value) | 53 PassRefPtr<CSSPrimitiveValue> ColorStyleInterpolation::interpolableValueToColor(
const InterpolableValue& value) |
54 { | 54 { |
55 ASSERT(value.isList()); | 55 ASSERT(value.isList()); |
56 const InterpolableList* list = toInterpolableList(&value); | 56 const InterpolableList* list = toInterpolableList(&value); |
57 | 57 |
58 double alpha = toInterpolableNumber(list->get(3))->value(); | 58 double alpha = toInterpolableNumber(list->get(3))->value(); |
59 if (!alpha) | 59 if (!alpha) |
60 return CSSPrimitiveValue::createColor(Color::transparent); | 60 return CSSPrimitiveValue::createColor(Color::transparent); |
61 | 61 |
62 // Clamping is inside makeRGBA. | 62 // Clamping is inside makeRGBA. |
63 unsigned rgba = makeRGBA( | 63 unsigned rgba = makeRGBA( |
(...skipping 25 matching lines...) Expand all Loading... |
89 bool ColorStyleInterpolation::shouldUseLegacyStyleInterpolation(const CSSValue&
start, const CSSValue& end) | 89 bool ColorStyleInterpolation::shouldUseLegacyStyleInterpolation(const CSSValue&
start, const CSSValue& end) |
90 { | 90 { |
91 if (ColorStyleInterpolation::canCreateFrom(start) && ColorStyleInterpolation
::canCreateFrom(end)) { | 91 if (ColorStyleInterpolation::canCreateFrom(start) && ColorStyleInterpolation
::canCreateFrom(end)) { |
92 if (toCSSPrimitiveValue(start).colorIsDerivedFromElement() || toCSSPrimi
tiveValue(end).colorIsDerivedFromElement()) | 92 if (toCSSPrimitiveValue(start).colorIsDerivedFromElement() || toCSSPrimi
tiveValue(end).colorIsDerivedFromElement()) |
93 return true; | 93 return true; |
94 } | 94 } |
95 return false; | 95 return false; |
96 } | 96 } |
97 | 97 |
98 } | 98 } |
OLD | NEW |