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

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

Issue 2812213002: Add CSSInterpolationType specific ConversionChecker (Closed)
Patch Set: rebased Created 3 years, 7 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/CSSTranslateInterpolationType.h" 5 #include "core/animation/CSSTranslateInterpolationType.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include "core/animation/LengthInterpolationFunctions.h" 8 #include "core/animation/LengthInterpolationFunctions.h"
9 #include "core/css/CSSValueList.h" 9 #include "core/css/CSSValueList.h"
10 #include "core/css/resolver/StyleResolverState.h" 10 #include "core/css/resolver/StyleResolverState.h"
11 #include "platform/transforms/TranslateTransformOperation.h" 11 #include "platform/transforms/TranslateTransformOperation.h"
12 #include "platform/wtf/PtrUtil.h" 12 #include "platform/wtf/PtrUtil.h"
13 13
14 namespace blink { 14 namespace blink {
15 15
16 namespace { 16 namespace {
17 17
18 InterpolationValue CreateNoneValue() { 18 InterpolationValue CreateNoneValue() {
19 return InterpolationValue(InterpolableList::Create(0)); 19 return InterpolationValue(InterpolableList::Create(0));
20 } 20 }
21 21
22 bool IsNoneValue(const InterpolationValue& value) { 22 bool IsNoneValue(const InterpolationValue& value) {
23 return ToInterpolableList(*value.interpolable_value).length() == 0; 23 return ToInterpolableList(*value.interpolable_value).length() == 0;
24 } 24 }
25 25
26 class InheritedTranslateChecker : public InterpolationType::ConversionChecker { 26 class InheritedTranslateChecker
27 : public CSSInterpolationType::CSSConversionChecker {
27 public: 28 public:
28 ~InheritedTranslateChecker() {} 29 ~InheritedTranslateChecker() {}
29 30
30 static std::unique_ptr<InheritedTranslateChecker> Create( 31 static std::unique_ptr<InheritedTranslateChecker> Create(
31 PassRefPtr<TranslateTransformOperation> inherited_translate) { 32 PassRefPtr<TranslateTransformOperation> inherited_translate) {
32 return WTF::WrapUnique( 33 return WTF::WrapUnique(
33 new InheritedTranslateChecker(std::move(inherited_translate))); 34 new InheritedTranslateChecker(std::move(inherited_translate)));
34 } 35 }
35 36
36 bool IsValid(const InterpolationEnvironment& environment, 37 bool IsValid(const StyleResolverState& state,
37 const InterpolationValue& underlying) const final { 38 const InterpolationValue& underlying) const final {
38 const TransformOperation* inherited_translate = 39 const TransformOperation* inherited_translate =
39 environment.GetState().ParentStyle()->Translate(); 40 state.ParentStyle()->Translate();
40 if (inherited_translate_ == inherited_translate) 41 if (inherited_translate_ == inherited_translate)
41 return true; 42 return true;
42 if (!inherited_translate_ || !inherited_translate) 43 if (!inherited_translate_ || !inherited_translate)
43 return false; 44 return false;
44 return *inherited_translate_ == *inherited_translate; 45 return *inherited_translate_ == *inherited_translate;
45 } 46 }
46 47
47 private: 48 private:
48 InheritedTranslateChecker( 49 InheritedTranslateChecker(
49 PassRefPtr<TranslateTransformOperation> inherited_translate) 50 PassRefPtr<TranslateTransformOperation> inherited_translate)
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 *list.Get(kTranslateZ), nullptr, conversion_data, kValueRangeAll) 207 *list.Get(kTranslateZ), nullptr, conversion_data, kValueRangeAll)
207 .Pixels(); 208 .Pixels();
208 209
209 RefPtr<TranslateTransformOperation> result = 210 RefPtr<TranslateTransformOperation> result =
210 TranslateTransformOperation::Create(x, y, z, 211 TranslateTransformOperation::Create(x, y, z,
211 TransformOperation::kTranslate3D); 212 TransformOperation::kTranslate3D);
212 state.Style()->SetTranslate(std::move(result)); 213 state.Style()->SetTranslate(std::move(result));
213 } 214 }
214 215
215 } // namespace blink 216 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698