| 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 <memory> | 7 #include <memory> |
| 8 #include "core/animation/ColorPropertyFunctions.h" | 8 #include "core/animation/ColorPropertyFunctions.h" |
| 9 #include "core/css/CSSColorValue.h" | 9 #include "core/css/CSSColorValue.h" |
| 10 #include "core/css/CSSIdentifierValue.h" | 10 #include "core/css/CSSIdentifierValue.h" |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 colors.TextColor()); | 151 colors.TextColor()); |
| 152 | 152 |
| 153 alpha = clampTo<double>(alpha, 0, 255); | 153 alpha = clampTo<double>(alpha, 0, 255); |
| 154 if (alpha == 0) | 154 if (alpha == 0) |
| 155 return Color::kTransparent; | 155 return Color::kTransparent; |
| 156 | 156 |
| 157 return MakeRGBA(round(red / alpha), round(green / alpha), round(blue / alpha), | 157 return MakeRGBA(round(red / alpha), round(green / alpha), round(blue / alpha), |
| 158 round(alpha)); | 158 round(alpha)); |
| 159 } | 159 } |
| 160 | 160 |
| 161 class InheritedColorChecker : public InterpolationType::ConversionChecker { | 161 class InheritedColorChecker |
| 162 : public CSSInterpolationType::CSSConversionChecker { |
| 162 public: | 163 public: |
| 163 static std::unique_ptr<InheritedColorChecker> Create( | 164 static std::unique_ptr<InheritedColorChecker> Create( |
| 164 CSSPropertyID property, | 165 CSSPropertyID property, |
| 165 const OptionalStyleColor& color) { | 166 const OptionalStyleColor& color) { |
| 166 return WTF::WrapUnique(new InheritedColorChecker(property, color)); | 167 return WTF::WrapUnique(new InheritedColorChecker(property, color)); |
| 167 } | 168 } |
| 168 | 169 |
| 169 private: | 170 private: |
| 170 InheritedColorChecker(CSSPropertyID property, const OptionalStyleColor& color) | 171 InheritedColorChecker(CSSPropertyID property, const OptionalStyleColor& color) |
| 171 : property_(property), color_(color) {} | 172 : property_(property), color_(color) {} |
| 172 | 173 |
| 173 bool IsValid(const InterpolationEnvironment& environment, | 174 bool IsValid(const StyleResolverState& state, |
| 174 const InterpolationValue& underlying) const final { | 175 const InterpolationValue& underlying) const final { |
| 175 return color_ == ColorPropertyFunctions::GetUnvisitedColor( | 176 return color_ == ColorPropertyFunctions::GetUnvisitedColor( |
| 176 property_, *environment.GetState().ParentStyle()); | 177 property_, *state.ParentStyle()); |
| 177 } | 178 } |
| 178 | 179 |
| 179 const CSSPropertyID property_; | 180 const CSSPropertyID property_; |
| 180 const OptionalStyleColor color_; | 181 const OptionalStyleColor color_; |
| 181 }; | 182 }; |
| 182 | 183 |
| 183 InterpolationValue CSSColorInterpolationType::MaybeConvertNeutral( | 184 InterpolationValue CSSColorInterpolationType::MaybeConvertNeutral( |
| 184 const InterpolationValue&, | 185 const InterpolationValue&, |
| 185 ConversionCheckers&) const { | 186 ConversionCheckers&) const { |
| 186 return ConvertStyleColorPair(StyleColor(Color::kTransparent), | 187 return ConvertStyleColorPair(StyleColor(Color::kTransparent), |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 const CSSValue* CSSColorInterpolationType::CreateCSSValue( | 283 const CSSValue* CSSColorInterpolationType::CreateCSSValue( |
| 283 const InterpolableValue& interpolable_value, | 284 const InterpolableValue& interpolable_value, |
| 284 const NonInterpolableValue*, | 285 const NonInterpolableValue*, |
| 285 const StyleResolverState& state) const { | 286 const StyleResolverState& state) const { |
| 286 const InterpolableList& color_pair = ToInterpolableList(interpolable_value); | 287 const InterpolableList& color_pair = ToInterpolableList(interpolable_value); |
| 287 Color color = ResolveInterpolableColor(*color_pair.Get(kUnvisited), state); | 288 Color color = ResolveInterpolableColor(*color_pair.Get(kUnvisited), state); |
| 288 return CSSColorValue::Create(color.Rgb()); | 289 return CSSColorValue::Create(color.Rgb()); |
| 289 } | 290 } |
| 290 | 291 |
| 291 } // namespace blink | 292 } // namespace blink |
| OLD | NEW |