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/CSSPaintInterpolationType.h" | 5 #include "core/animation/CSSPaintInterpolationType.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include "core/animation/CSSColorInterpolationType.h" | 8 #include "core/animation/CSSColorInterpolationType.h" |
9 #include "core/animation/PaintPropertyFunctions.h" | 9 #include "core/animation/PaintPropertyFunctions.h" |
10 #include "core/css/resolver/StyleResolverState.h" | 10 #include "core/css/resolver/StyleResolverState.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 InterpolationValue CSSPaintInterpolationType::MaybeConvertInitial( | 22 InterpolationValue CSSPaintInterpolationType::MaybeConvertInitial( |
23 const StyleResolverState&, | 23 const StyleResolverState&, |
24 ConversionCheckers& conversion_checkers) const { | 24 ConversionCheckers& conversion_checkers) const { |
25 StyleColor initial_color; | 25 StyleColor initial_color; |
26 if (!PaintPropertyFunctions::GetInitialColor(CssProperty(), initial_color)) | 26 if (!PaintPropertyFunctions::GetInitialColor(CssProperty(), initial_color)) |
27 return nullptr; | 27 return nullptr; |
28 return InterpolationValue( | 28 return InterpolationValue( |
29 CSSColorInterpolationType::CreateInterpolableColor(initial_color)); | 29 CSSColorInterpolationType::CreateInterpolableColor(initial_color)); |
30 } | 30 } |
31 | 31 |
32 class InheritedPaintChecker : public InterpolationType::ConversionChecker { | 32 class InheritedPaintChecker |
| 33 : public CSSInterpolationType::CSSConversionChecker { |
33 public: | 34 public: |
34 static std::unique_ptr<InheritedPaintChecker> Create( | 35 static std::unique_ptr<InheritedPaintChecker> Create( |
35 CSSPropertyID property, | 36 CSSPropertyID property, |
36 const StyleColor& color) { | 37 const StyleColor& color) { |
37 return WTF::WrapUnique(new InheritedPaintChecker(property, color)); | 38 return WTF::WrapUnique(new InheritedPaintChecker(property, color)); |
38 } | 39 } |
39 static std::unique_ptr<InheritedPaintChecker> Create(CSSPropertyID property) { | 40 static std::unique_ptr<InheritedPaintChecker> Create(CSSPropertyID property) { |
40 return WTF::WrapUnique(new InheritedPaintChecker(property)); | 41 return WTF::WrapUnique(new InheritedPaintChecker(property)); |
41 } | 42 } |
42 | 43 |
43 private: | 44 private: |
44 InheritedPaintChecker(CSSPropertyID property) | 45 InheritedPaintChecker(CSSPropertyID property) |
45 : property_(property), valid_color_(false) {} | 46 : property_(property), valid_color_(false) {} |
46 InheritedPaintChecker(CSSPropertyID property, const StyleColor& color) | 47 InheritedPaintChecker(CSSPropertyID property, const StyleColor& color) |
47 : property_(property), valid_color_(true), color_(color) {} | 48 : property_(property), valid_color_(true), color_(color) {} |
48 | 49 |
49 bool IsValid(const InterpolationEnvironment& environment, | 50 bool IsValid(const StyleResolverState& state, |
50 const InterpolationValue& underlying) const final { | 51 const InterpolationValue& underlying) const final { |
51 StyleColor parent_color; | 52 StyleColor parent_color; |
52 if (!PaintPropertyFunctions::GetColor( | 53 if (!PaintPropertyFunctions::GetColor(property_, *state.ParentStyle(), |
53 property_, *environment.GetState().ParentStyle(), parent_color)) | 54 parent_color)) |
54 return !valid_color_; | 55 return !valid_color_; |
55 return valid_color_ && parent_color == color_; | 56 return valid_color_ && parent_color == color_; |
56 } | 57 } |
57 | 58 |
58 const CSSPropertyID property_; | 59 const CSSPropertyID property_; |
59 const bool valid_color_; | 60 const bool valid_color_; |
60 const StyleColor color_; | 61 const StyleColor color_; |
61 }; | 62 }; |
62 | 63 |
63 InterpolationValue CSSPaintInterpolationType::MaybeConvertInherit( | 64 InterpolationValue CSSPaintInterpolationType::MaybeConvertInherit( |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 const InterpolableValue& interpolable_color, | 105 const InterpolableValue& interpolable_color, |
105 const NonInterpolableValue*, | 106 const NonInterpolableValue*, |
106 StyleResolverState& state) const { | 107 StyleResolverState& state) const { |
107 PaintPropertyFunctions::SetColor( | 108 PaintPropertyFunctions::SetColor( |
108 CssProperty(), *state.Style(), | 109 CssProperty(), *state.Style(), |
109 CSSColorInterpolationType::ResolveInterpolableColor(interpolable_color, | 110 CSSColorInterpolationType::ResolveInterpolableColor(interpolable_color, |
110 state)); | 111 state)); |
111 } | 112 } |
112 | 113 |
113 } // namespace blink | 114 } // namespace blink |
OLD | NEW |