Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(66)

Side by Side Diff: third_party/WebKit/Source/core/animation/CSSOffsetRotateInterpolationType.cpp

Issue 2812213002: Add CSSInterpolationType specific ConversionChecker (Closed)
Patch Set: rebased Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/CSSOffsetRotateInterpolationType.h" 5 #include "core/animation/CSSOffsetRotateInterpolationType.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include "core/css/resolver/StyleBuilderConverter.h" 8 #include "core/css/resolver/StyleBuilderConverter.h"
9 #include "core/style/StyleOffsetRotation.h" 9 #include "core/style/StyleOffsetRotation.h"
10 #include "platform/wtf/PtrUtil.h" 10 #include "platform/wtf/PtrUtil.h"
(...skipping 19 matching lines...) Expand all
30 30
31 OffsetRotationType rotation_type_; 31 OffsetRotationType rotation_type_;
32 }; 32 };
33 33
34 DEFINE_NON_INTERPOLABLE_VALUE_TYPE(CSSOffsetRotationNonInterpolableValue); 34 DEFINE_NON_INTERPOLABLE_VALUE_TYPE(CSSOffsetRotationNonInterpolableValue);
35 DEFINE_NON_INTERPOLABLE_VALUE_TYPE_CASTS(CSSOffsetRotationNonInterpolableValue); 35 DEFINE_NON_INTERPOLABLE_VALUE_TYPE_CASTS(CSSOffsetRotationNonInterpolableValue);
36 36
37 namespace { 37 namespace {
38 38
39 class UnderlyingRotationTypeChecker 39 class UnderlyingRotationTypeChecker
40 : public InterpolationType::ConversionChecker { 40 : public CSSInterpolationType::CSSConversionChecker {
41 public: 41 public:
42 static std::unique_ptr<UnderlyingRotationTypeChecker> Create( 42 static std::unique_ptr<UnderlyingRotationTypeChecker> Create(
43 OffsetRotationType underlying_rotation_type) { 43 OffsetRotationType underlying_rotation_type) {
44 return WTF::WrapUnique( 44 return WTF::WrapUnique(
45 new UnderlyingRotationTypeChecker(underlying_rotation_type)); 45 new UnderlyingRotationTypeChecker(underlying_rotation_type));
46 } 46 }
47 47
48 bool IsValid(const InterpolationEnvironment&, 48 bool IsValid(const StyleResolverState&,
49 const InterpolationValue& underlying) const final { 49 const InterpolationValue& underlying) const final {
50 return underlying_rotation_type_ == ToCSSOffsetRotationNonInterpolableValue( 50 return underlying_rotation_type_ == ToCSSOffsetRotationNonInterpolableValue(
51 *underlying.non_interpolable_value) 51 *underlying.non_interpolable_value)
52 .RotationType(); 52 .RotationType();
53 } 53 }
54 54
55 private: 55 private:
56 UnderlyingRotationTypeChecker(OffsetRotationType underlying_rotation_type) 56 UnderlyingRotationTypeChecker(OffsetRotationType underlying_rotation_type)
57 : underlying_rotation_type_(underlying_rotation_type) {} 57 : underlying_rotation_type_(underlying_rotation_type) {}
58 58
59 OffsetRotationType underlying_rotation_type_; 59 OffsetRotationType underlying_rotation_type_;
60 }; 60 };
61 61
62 class InheritedRotationTypeChecker 62 class InheritedRotationTypeChecker
63 : public InterpolationType::ConversionChecker { 63 : public CSSInterpolationType::CSSConversionChecker {
64 public: 64 public:
65 static std::unique_ptr<InheritedRotationTypeChecker> Create( 65 static std::unique_ptr<InheritedRotationTypeChecker> Create(
66 OffsetRotationType inherited_rotation_type) { 66 OffsetRotationType inherited_rotation_type) {
67 return WTF::WrapUnique( 67 return WTF::WrapUnique(
68 new InheritedRotationTypeChecker(inherited_rotation_type)); 68 new InheritedRotationTypeChecker(inherited_rotation_type));
69 } 69 }
70 70
71 bool IsValid(const InterpolationEnvironment& environment, 71 bool IsValid(const StyleResolverState& state,
72 const InterpolationValue& underlying) const final { 72 const InterpolationValue& underlying) const final {
73 return inherited_rotation_type_ == 73 return inherited_rotation_type_ == state.ParentStyle()->OffsetRotate().type;
74 environment.GetState().ParentStyle()->OffsetRotate().type;
75 } 74 }
76 75
77 private: 76 private:
78 InheritedRotationTypeChecker(OffsetRotationType inherited_rotation_type) 77 InheritedRotationTypeChecker(OffsetRotationType inherited_rotation_type)
79 : inherited_rotation_type_(inherited_rotation_type) {} 78 : inherited_rotation_type_(inherited_rotation_type) {}
80 79
81 OffsetRotationType inherited_rotation_type_; 80 OffsetRotationType inherited_rotation_type_;
82 }; 81 };
83 82
84 InterpolationValue ConvertOffsetRotate(const StyleOffsetRotation& rotation) { 83 InterpolationValue ConvertOffsetRotate(const StyleOffsetRotation& rotation) {
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 const InterpolableValue& interpolable_value, 169 const InterpolableValue& interpolable_value,
171 const NonInterpolableValue* non_interpolable_value, 170 const NonInterpolableValue* non_interpolable_value,
172 StyleResolverState& state) const { 171 StyleResolverState& state) const {
173 state.Style()->SetOffsetRotate(StyleOffsetRotation( 172 state.Style()->SetOffsetRotate(StyleOffsetRotation(
174 ToInterpolableNumber(interpolable_value).Value(), 173 ToInterpolableNumber(interpolable_value).Value(),
175 ToCSSOffsetRotationNonInterpolableValue(*non_interpolable_value) 174 ToCSSOffsetRotationNonInterpolableValue(*non_interpolable_value)
176 .RotationType())); 175 .RotationType()));
177 } 176 }
178 177
179 } // namespace blink 178 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698