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/CSSColorInterpolationType.h" | 5 #include "core/animation/CSSColorInterpolationType.h" |
6 | 6 |
7 #include "core/animation/ColorPropertyFunctions.h" | 7 #include "core/animation/ColorPropertyFunctions.h" |
8 #include "core/css/CSSColorValue.h" | 8 #include "core/css/CSSColorValue.h" |
9 #include "core/css/parser/CSSPropertyParser.h" | 9 #include "core/css/parser/CSSPropertyParser.h" |
Timothy Loh
2016/06/08 03:21:11
no longer needed
rwlbuis
2016/06/08 23:08:39
Done.
| |
10 #include "core/css/resolver/StyleResolverState.h" | 10 #include "core/css/resolver/StyleResolverState.h" |
11 #include "core/layout/LayoutTheme.h" | 11 #include "core/layout/LayoutTheme.h" |
12 | 12 |
13 namespace blink { | 13 namespace blink { |
14 | 14 |
15 enum InterpolableColorIndex { | 15 enum InterpolableColorIndex { |
16 Red, | 16 Red, |
17 Green, | 17 Green, |
18 Blue, | 18 Blue, |
19 Alpha, | 19 Alpha, |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
54 return createInterpolableColorForIndex(Currentcolor); | 54 return createInterpolableColorForIndex(Currentcolor); |
55 case CSSValueWebkitActivelink: | 55 case CSSValueWebkitActivelink: |
56 return createInterpolableColorForIndex(WebkitActivelink); | 56 return createInterpolableColorForIndex(WebkitActivelink); |
57 case CSSValueWebkitLink: | 57 case CSSValueWebkitLink: |
58 return createInterpolableColorForIndex(WebkitLink); | 58 return createInterpolableColorForIndex(WebkitLink); |
59 case CSSValueInternalQuirkInherit: | 59 case CSSValueInternalQuirkInherit: |
60 return createInterpolableColorForIndex(QuirkInherit); | 60 return createInterpolableColorForIndex(QuirkInherit); |
61 case CSSValueWebkitFocusRingColor: | 61 case CSSValueWebkitFocusRingColor: |
62 return createInterpolableColor(LayoutTheme::theme().focusRingColor()); | 62 return createInterpolableColor(LayoutTheme::theme().focusRingColor()); |
63 default: | 63 default: |
64 ASSERT(CSSPropertyParser::isColorKeyword(keyword)); | 64 ASSERT(CSSPropertyParser::isColorKeyword(keyword)); |
Timothy Loh
2016/06/08 03:21:11
needs to be updated
rwlbuis
2016/06/08 23:08:39
Done. Also made it a DCHECK since the style check
| |
65 return createInterpolableColor(StyleColor::colorFromKeyword(keyword)); | 65 return createInterpolableColor(StyleColor::colorFromKeyword(keyword)); |
66 } | 66 } |
67 } | 67 } |
68 | 68 |
69 PassOwnPtr<InterpolableValue> CSSColorInterpolationType::createInterpolableColor (const StyleColor& color) | 69 PassOwnPtr<InterpolableValue> CSSColorInterpolationType::createInterpolableColor (const StyleColor& color) |
70 { | 70 { |
71 if (color.isCurrentColor()) | 71 if (color.isCurrentColor()) |
72 return createInterpolableColorForIndex(Currentcolor); | 72 return createInterpolableColorForIndex(Currentcolor); |
73 return createInterpolableColor(color.getColor()); | 73 return createInterpolableColor(color.getColor()); |
74 } | 74 } |
75 | 75 |
76 PassOwnPtr<InterpolableValue> CSSColorInterpolationType::maybeCreateInterpolable Color(const CSSValue& value) | 76 PassOwnPtr<InterpolableValue> CSSColorInterpolationType::maybeCreateInterpolable Color(const CSSValue& value) |
77 { | 77 { |
78 if (value.isColorValue()) | 78 if (value.isColorValue()) |
79 return createInterpolableColor(toCSSColorValue(value).value()); | 79 return createInterpolableColor(toCSSColorValue(value).value()); |
80 if (!value.isPrimitiveValue()) | 80 if (!value.isPrimitiveValue()) |
81 return nullptr; | 81 return nullptr; |
82 const CSSPrimitiveValue& primitive = toCSSPrimitiveValue(value); | 82 const CSSPrimitiveValue& primitive = toCSSPrimitiveValue(value); |
83 if (!primitive.isValueID()) | 83 if (!primitive.isValueID()) |
84 return nullptr; | 84 return nullptr; |
85 if (!CSSPropertyParser::isColorKeyword(primitive.getValueID())) | 85 if (!isColorKeyword(primitive.getValueID())) |
86 return nullptr; | 86 return nullptr; |
87 return createInterpolableColor(primitive.getValueID()); | 87 return createInterpolableColor(primitive.getValueID()); |
88 } | 88 } |
89 | 89 |
90 static void addPremultipliedColor(double& red, double& green, double& blue, doub le& alpha, double fraction, const Color& color) | 90 static void addPremultipliedColor(double& red, double& green, double& blue, doub le& alpha, double fraction, const Color& color) |
91 { | 91 { |
92 double colorAlpha = color.alpha(); | 92 double colorAlpha = color.alpha(); |
93 red += fraction * color.red() * colorAlpha; | 93 red += fraction * color.red() * colorAlpha; |
94 green += fraction * color.green() * colorAlpha; | 94 green += fraction * color.green() * colorAlpha; |
95 blue += fraction * color.blue() * colorAlpha; | 95 blue += fraction * color.blue() * colorAlpha; |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
216 { | 216 { |
217 const InterpolableList& colorPair = toInterpolableList(interpolableValue); | 217 const InterpolableList& colorPair = toInterpolableList(interpolableValue); |
218 ASSERT(colorPair.length() == InterpolableColorPairIndexCount); | 218 ASSERT(colorPair.length() == InterpolableColorPairIndexCount); |
219 ColorPropertyFunctions::setUnvisitedColor(cssProperty(), *environment.state( ).style(), | 219 ColorPropertyFunctions::setUnvisitedColor(cssProperty(), *environment.state( ).style(), |
220 resolveInterpolableColor(*colorPair.get(Unvisited), environment.state(), false, cssProperty() == CSSPropertyTextDecorationColor)); | 220 resolveInterpolableColor(*colorPair.get(Unvisited), environment.state(), false, cssProperty() == CSSPropertyTextDecorationColor)); |
221 ColorPropertyFunctions::setVisitedColor(cssProperty(), *environment.state(). style(), | 221 ColorPropertyFunctions::setVisitedColor(cssProperty(), *environment.state(). style(), |
222 resolveInterpolableColor(*colorPair.get(Visited), environment.state(), t rue, cssProperty() == CSSPropertyTextDecorationColor)); | 222 resolveInterpolableColor(*colorPair.get(Visited), environment.state(), t rue, cssProperty() == CSSPropertyTextDecorationColor)); |
223 } | 223 } |
224 | 224 |
225 } // namespace blink | 225 } // namespace blink |
OLD | NEW |