| OLD | NEW |
| 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 InterpolationEnvironment& environment, |
| 72 const InterpolationValue& underlying) const final { | 72 const InterpolationValue& underlying) const final { |
| 73 return inherited_rotation_type_ == | 73 return inherited_rotation_type_ == |
| 74 environment.GetState().ParentStyle()->OffsetRotation().type; | 74 environment.GetState().ParentStyle()->OffsetRotate().type; |
| 75 } | 75 } |
| 76 | 76 |
| 77 private: | 77 private: |
| 78 InheritedRotationTypeChecker(OffsetRotationType inherited_rotation_type) | 78 InheritedRotationTypeChecker(OffsetRotationType inherited_rotation_type) |
| 79 : inherited_rotation_type_(inherited_rotation_type) {} | 79 : inherited_rotation_type_(inherited_rotation_type) {} |
| 80 | 80 |
| 81 OffsetRotationType inherited_rotation_type_; | 81 OffsetRotationType inherited_rotation_type_; |
| 82 }; | 82 }; |
| 83 | 83 |
| 84 InterpolationValue ConvertOffsetRotate(const StyleOffsetRotation& rotation) { | 84 InterpolationValue ConvertOffsetRotate(const StyleOffsetRotation& rotation) { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 104 InterpolationValue CSSOffsetRotateInterpolationType::MaybeConvertInitial( | 104 InterpolationValue CSSOffsetRotateInterpolationType::MaybeConvertInitial( |
| 105 const StyleResolverState&, | 105 const StyleResolverState&, |
| 106 ConversionCheckers& conversion_checkers) const { | 106 ConversionCheckers& conversion_checkers) const { |
| 107 return ConvertOffsetRotate(StyleOffsetRotation(0, kOffsetRotationAuto)); | 107 return ConvertOffsetRotate(StyleOffsetRotation(0, kOffsetRotationAuto)); |
| 108 } | 108 } |
| 109 | 109 |
| 110 InterpolationValue CSSOffsetRotateInterpolationType::MaybeConvertInherit( | 110 InterpolationValue CSSOffsetRotateInterpolationType::MaybeConvertInherit( |
| 111 const StyleResolverState& state, | 111 const StyleResolverState& state, |
| 112 ConversionCheckers& conversion_checkers) const { | 112 ConversionCheckers& conversion_checkers) const { |
| 113 OffsetRotationType inherited_rotation_type = | 113 OffsetRotationType inherited_rotation_type = |
| 114 state.ParentStyle()->OffsetRotation().type; | 114 state.ParentStyle()->OffsetRotate().type; |
| 115 conversion_checkers.push_back( | 115 conversion_checkers.push_back( |
| 116 InheritedRotationTypeChecker::Create(inherited_rotation_type)); | 116 InheritedRotationTypeChecker::Create(inherited_rotation_type)); |
| 117 return ConvertOffsetRotate(state.ParentStyle()->OffsetRotation()); | 117 return ConvertOffsetRotate(state.ParentStyle()->OffsetRotate()); |
| 118 } | 118 } |
| 119 | 119 |
| 120 InterpolationValue CSSOffsetRotateInterpolationType::MaybeConvertValue( | 120 InterpolationValue CSSOffsetRotateInterpolationType::MaybeConvertValue( |
| 121 const CSSValue& value, | 121 const CSSValue& value, |
| 122 const StyleResolverState*, | 122 const StyleResolverState*, |
| 123 ConversionCheckers&) const { | 123 ConversionCheckers&) const { |
| 124 return ConvertOffsetRotate(StyleBuilderConverter::ConvertOffsetRotate(value)); | 124 return ConvertOffsetRotate(StyleBuilderConverter::ConvertOffsetRotate(value)); |
| 125 } | 125 } |
| 126 | 126 |
| 127 PairwiseInterpolationValue CSSOffsetRotateInterpolationType::MaybeMergeSingles( | 127 PairwiseInterpolationValue CSSOffsetRotateInterpolationType::MaybeMergeSingles( |
| 128 InterpolationValue&& start, | 128 InterpolationValue&& start, |
| 129 InterpolationValue&& end) const { | 129 InterpolationValue&& end) const { |
| 130 const OffsetRotationType& start_type = | 130 const OffsetRotationType& start_type = |
| 131 ToCSSOffsetRotationNonInterpolableValue(*start.non_interpolable_value) | 131 ToCSSOffsetRotationNonInterpolableValue(*start.non_interpolable_value) |
| 132 .RotationType(); | 132 .RotationType(); |
| 133 const OffsetRotationType& end_type = | 133 const OffsetRotationType& end_type = |
| 134 ToCSSOffsetRotationNonInterpolableValue(*end.non_interpolable_value) | 134 ToCSSOffsetRotationNonInterpolableValue(*end.non_interpolable_value) |
| 135 .RotationType(); | 135 .RotationType(); |
| 136 if (start_type != end_type) | 136 if (start_type != end_type) |
| 137 return nullptr; | 137 return nullptr; |
| 138 return PairwiseInterpolationValue(std::move(start.interpolable_value), | 138 return PairwiseInterpolationValue(std::move(start.interpolable_value), |
| 139 std::move(end.interpolable_value), | 139 std::move(end.interpolable_value), |
| 140 std::move(start.non_interpolable_value)); | 140 std::move(start.non_interpolable_value)); |
| 141 } | 141 } |
| 142 | 142 |
| 143 InterpolationValue | 143 InterpolationValue |
| 144 CSSOffsetRotateInterpolationType::MaybeConvertStandardPropertyUnderlyingValue( | 144 CSSOffsetRotateInterpolationType::MaybeConvertStandardPropertyUnderlyingValue( |
| 145 const ComputedStyle& style) const { | 145 const ComputedStyle& style) const { |
| 146 return ConvertOffsetRotate(style.OffsetRotation()); | 146 return ConvertOffsetRotate(style.OffsetRotate()); |
| 147 } | 147 } |
| 148 | 148 |
| 149 void CSSOffsetRotateInterpolationType::Composite( | 149 void CSSOffsetRotateInterpolationType::Composite( |
| 150 UnderlyingValueOwner& underlying_value_owner, | 150 UnderlyingValueOwner& underlying_value_owner, |
| 151 double underlying_fraction, | 151 double underlying_fraction, |
| 152 const InterpolationValue& value, | 152 const InterpolationValue& value, |
| 153 double interpolation_fraction) const { | 153 double interpolation_fraction) const { |
| 154 const OffsetRotationType& underlying_type = | 154 const OffsetRotationType& underlying_type = |
| 155 ToCSSOffsetRotationNonInterpolableValue( | 155 ToCSSOffsetRotationNonInterpolableValue( |
| 156 *underlying_value_owner.Value().non_interpolable_value) | 156 *underlying_value_owner.Value().non_interpolable_value) |
| 157 .RotationType(); | 157 .RotationType(); |
| 158 const OffsetRotationType& rotation_type = | 158 const OffsetRotationType& rotation_type = |
| 159 ToCSSOffsetRotationNonInterpolableValue(*value.non_interpolable_value) | 159 ToCSSOffsetRotationNonInterpolableValue(*value.non_interpolable_value) |
| 160 .RotationType(); | 160 .RotationType(); |
| 161 if (underlying_type == rotation_type) { | 161 if (underlying_type == rotation_type) { |
| 162 underlying_value_owner.MutableValue().interpolable_value->ScaleAndAdd( | 162 underlying_value_owner.MutableValue().interpolable_value->ScaleAndAdd( |
| 163 underlying_fraction, *value.interpolable_value); | 163 underlying_fraction, *value.interpolable_value); |
| 164 } else { | 164 } else { |
| 165 underlying_value_owner.Set(*this, value); | 165 underlying_value_owner.Set(*this, value); |
| 166 } | 166 } |
| 167 } | 167 } |
| 168 | 168 |
| 169 void CSSOffsetRotateInterpolationType::ApplyStandardPropertyValue( | 169 void CSSOffsetRotateInterpolationType::ApplyStandardPropertyValue( |
| 170 const InterpolableValue& interpolable_value, | 170 const InterpolableValue& interpolable_value, |
| 171 const NonInterpolableValue* non_interpolable_value, | 171 const NonInterpolableValue* non_interpolable_value, |
| 172 StyleResolverState& state) const { | 172 StyleResolverState& state) const { |
| 173 state.Style()->SetOffsetRotation(StyleOffsetRotation( | 173 state.Style()->SetOffsetRotate(StyleOffsetRotation( |
| 174 ToInterpolableNumber(interpolable_value).Value(), | 174 ToInterpolableNumber(interpolable_value).Value(), |
| 175 ToCSSOffsetRotationNonInterpolableValue(*non_interpolable_value) | 175 ToCSSOffsetRotationNonInterpolableValue(*non_interpolable_value) |
| 176 .RotationType())); | 176 .RotationType())); |
| 177 } | 177 } |
| 178 | 178 |
| 179 } // namespace blink | 179 } // namespace blink |
| OLD | NEW |