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/CSSVisibilityInterpolationType.h" | 5 #include "core/animation/CSSVisibilityInterpolationType.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include "core/css/CSSPrimitiveValueMappings.h" | 8 #include "core/css/CSSPrimitiveValueMappings.h" |
9 #include "core/css/resolver/StyleResolverState.h" | 9 #include "core/css/resolver/StyleResolverState.h" |
10 #include "platform/wtf/PtrUtil.h" | 10 #include "platform/wtf/PtrUtil.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 | 42 |
43 const EVisibility start_; | 43 const EVisibility start_; |
44 const EVisibility end_; | 44 const EVisibility end_; |
45 const bool is_single_; | 45 const bool is_single_; |
46 }; | 46 }; |
47 | 47 |
48 DEFINE_NON_INTERPOLABLE_VALUE_TYPE(CSSVisibilityNonInterpolableValue); | 48 DEFINE_NON_INTERPOLABLE_VALUE_TYPE(CSSVisibilityNonInterpolableValue); |
49 DEFINE_NON_INTERPOLABLE_VALUE_TYPE_CASTS(CSSVisibilityNonInterpolableValue); | 49 DEFINE_NON_INTERPOLABLE_VALUE_TYPE_CASTS(CSSVisibilityNonInterpolableValue); |
50 | 50 |
51 class UnderlyingVisibilityChecker | 51 class UnderlyingVisibilityChecker |
52 : public InterpolationType::ConversionChecker { | 52 : public CSSInterpolationType::CSSConversionChecker { |
53 public: | 53 public: |
54 ~UnderlyingVisibilityChecker() final {} | 54 ~UnderlyingVisibilityChecker() final {} |
55 | 55 |
56 static std::unique_ptr<UnderlyingVisibilityChecker> Create( | 56 static std::unique_ptr<UnderlyingVisibilityChecker> Create( |
57 EVisibility visibility) { | 57 EVisibility visibility) { |
58 return WTF::WrapUnique(new UnderlyingVisibilityChecker(visibility)); | 58 return WTF::WrapUnique(new UnderlyingVisibilityChecker(visibility)); |
59 } | 59 } |
60 | 60 |
61 private: | 61 private: |
62 UnderlyingVisibilityChecker(EVisibility visibility) | 62 UnderlyingVisibilityChecker(EVisibility visibility) |
63 : visibility_(visibility) {} | 63 : visibility_(visibility) {} |
64 | 64 |
65 bool IsValid(const InterpolationEnvironment&, | 65 bool IsValid(const StyleResolverState&, |
66 const InterpolationValue& underlying) const final { | 66 const InterpolationValue& underlying) const final { |
67 double underlying_fraction = | 67 double underlying_fraction = |
68 ToInterpolableNumber(*underlying.interpolable_value).Value(); | 68 ToInterpolableNumber(*underlying.interpolable_value).Value(); |
69 EVisibility underlying_visibility = | 69 EVisibility underlying_visibility = |
70 ToCSSVisibilityNonInterpolableValue(*underlying.non_interpolable_value) | 70 ToCSSVisibilityNonInterpolableValue(*underlying.non_interpolable_value) |
71 .Visibility(underlying_fraction); | 71 .Visibility(underlying_fraction); |
72 return visibility_ == underlying_visibility; | 72 return visibility_ == underlying_visibility; |
73 } | 73 } |
74 | 74 |
75 const EVisibility visibility_; | 75 const EVisibility visibility_; |
76 }; | 76 }; |
77 | 77 |
78 class InheritedVisibilityChecker : public InterpolationType::ConversionChecker { | 78 class InheritedVisibilityChecker |
| 79 : public CSSInterpolationType::CSSConversionChecker { |
79 public: | 80 public: |
80 static std::unique_ptr<InheritedVisibilityChecker> Create( | 81 static std::unique_ptr<InheritedVisibilityChecker> Create( |
81 EVisibility visibility) { | 82 EVisibility visibility) { |
82 return WTF::WrapUnique(new InheritedVisibilityChecker(visibility)); | 83 return WTF::WrapUnique(new InheritedVisibilityChecker(visibility)); |
83 } | 84 } |
84 | 85 |
85 private: | 86 private: |
86 InheritedVisibilityChecker(EVisibility visibility) | 87 InheritedVisibilityChecker(EVisibility visibility) |
87 : visibility_(visibility) {} | 88 : visibility_(visibility) {} |
88 | 89 |
89 bool IsValid(const InterpolationEnvironment& environment, | 90 bool IsValid(const StyleResolverState& state, |
90 const InterpolationValue& underlying) const final { | 91 const InterpolationValue& underlying) const final { |
91 return visibility_ == environment.GetState().ParentStyle()->Visibility(); | 92 return visibility_ == state.ParentStyle()->Visibility(); |
92 } | 93 } |
93 | 94 |
94 const EVisibility visibility_; | 95 const EVisibility visibility_; |
95 }; | 96 }; |
96 | 97 |
97 InterpolationValue CSSVisibilityInterpolationType::CreateVisibilityValue( | 98 InterpolationValue CSSVisibilityInterpolationType::CreateVisibilityValue( |
98 EVisibility visibility) const { | 99 EVisibility visibility) const { |
99 return InterpolationValue( | 100 return InterpolationValue( |
100 InterpolableNumber::Create(0), | 101 InterpolableNumber::Create(0), |
101 CSSVisibilityNonInterpolableValue::Create(visibility, visibility)); | 102 CSSVisibilityNonInterpolableValue::Create(visibility, visibility)); |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 // Visibility interpolation has been deferred to application time here due to | 195 // Visibility interpolation has been deferred to application time here due to |
195 // its non-linear behaviour. | 196 // its non-linear behaviour. |
196 double fraction = ToInterpolableNumber(interpolable_value).Value(); | 197 double fraction = ToInterpolableNumber(interpolable_value).Value(); |
197 EVisibility visibility = | 198 EVisibility visibility = |
198 ToCSSVisibilityNonInterpolableValue(non_interpolable_value) | 199 ToCSSVisibilityNonInterpolableValue(non_interpolable_value) |
199 ->Visibility(fraction); | 200 ->Visibility(fraction); |
200 state.Style()->SetVisibility(visibility); | 201 state.Style()->SetVisibility(visibility); |
201 } | 202 } |
202 | 203 |
203 } // namespace blink | 204 } // namespace blink |
OLD | NEW |