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