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

Side by Side Diff: third_party/WebKit/Source/core/animation/CSSLengthInterpolationType.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 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/CSSLengthInterpolationType.h" 5 #include "core/animation/CSSLengthInterpolationType.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include "core/animation/LengthInterpolationFunctions.h" 8 #include "core/animation/LengthInterpolationFunctions.h"
9 #include "core/animation/LengthPropertyFunctions.h" 9 #include "core/animation/LengthPropertyFunctions.h"
10 #include "core/animation/css/CSSAnimatableValueFactory.h" 10 #include "core/animation/css/CSSAnimatableValueFactory.h"
(...skipping 10 matching lines...) Expand all
21 : CSSInterpolationType(property), 21 : CSSInterpolationType(property),
22 value_range_(LengthPropertyFunctions::GetValueRange(CssProperty())) {} 22 value_range_(LengthPropertyFunctions::GetValueRange(CssProperty())) {}
23 23
24 float CSSLengthInterpolationType::EffectiveZoom( 24 float CSSLengthInterpolationType::EffectiveZoom(
25 const ComputedStyle& style) const { 25 const ComputedStyle& style) const {
26 return LengthPropertyFunctions::IsZoomedLength(CssProperty()) 26 return LengthPropertyFunctions::IsZoomedLength(CssProperty())
27 ? style.EffectiveZoom() 27 ? style.EffectiveZoom()
28 : 1; 28 : 1;
29 } 29 }
30 30
31 class InheritedLengthChecker : public InterpolationType::ConversionChecker { 31 class InheritedLengthChecker
32 : public CSSInterpolationType::CSSConversionChecker {
32 public: 33 public:
33 static std::unique_ptr<InheritedLengthChecker> Create(CSSPropertyID property, 34 static std::unique_ptr<InheritedLengthChecker> Create(CSSPropertyID property,
34 const Length& length) { 35 const Length& length) {
35 return WTF::WrapUnique(new InheritedLengthChecker(property, length)); 36 return WTF::WrapUnique(new InheritedLengthChecker(property, length));
36 } 37 }
37 38
38 private: 39 private:
39 InheritedLengthChecker(CSSPropertyID property, const Length& length) 40 InheritedLengthChecker(CSSPropertyID property, const Length& length)
40 : property_(property), length_(length) {} 41 : property_(property), length_(length) {}
41 42
42 bool IsValid(const InterpolationEnvironment& environment, 43 bool IsValid(const StyleResolverState& state,
43 const InterpolationValue& underlying) const final { 44 const InterpolationValue& underlying) const final {
44 Length parent_length; 45 Length parent_length;
45 if (!LengthPropertyFunctions::GetLength( 46 if (!LengthPropertyFunctions::GetLength(property_, *state.ParentStyle(),
46 property_, *environment.GetState().ParentStyle(), parent_length)) 47 parent_length))
47 return false; 48 return false;
48 return parent_length == length_; 49 return parent_length == length_;
49 } 50 }
50 51
51 const CSSPropertyID property_; 52 const CSSPropertyID property_;
52 const Length length_; 53 const Length length_;
53 }; 54 };
54 55
55 InterpolationValue CSSLengthInterpolationType::MaybeConvertNeutral( 56 InterpolationValue CSSLengthInterpolationType::MaybeConvertNeutral(
56 const InterpolationValue&, 57 const InterpolationValue&,
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 FloatValueForLength(after, 100) - FloatValueForLength(before, 100); 166 FloatValueForLength(after, 100) - FloatValueForLength(before, 100);
166 DCHECK_LT(std::abs(delta), kSlack); 167 DCHECK_LT(std::abs(delta), kSlack);
167 #endif 168 #endif
168 return; 169 return;
169 } 170 }
170 StyleBuilder::ApplyProperty(CssProperty(), state, 171 StyleBuilder::ApplyProperty(CssProperty(), state,
171 *CSSValue::Create(length, zoom)); 172 *CSSValue::Create(length, zoom));
172 } 173 }
173 174
174 } // namespace blink 175 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698