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

Side by Side Diff: third_party/WebKit/Source/core/animation/CSSTextIndentInterpolationType.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/CSSTextIndentInterpolationType.h" 5 #include "core/animation/CSSTextIndentInterpolationType.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/CSSIdentifierValue.h" 9 #include "core/css/CSSIdentifierValue.h"
10 #include "core/css/CSSPrimitiveValue.h" 10 #include "core/css/CSSPrimitiveValue.h"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 RefPtr<NonInterpolableValue> length_non_interpolable_value_; 64 RefPtr<NonInterpolableValue> length_non_interpolable_value_;
65 const IndentMode mode_; 65 const IndentMode mode_;
66 }; 66 };
67 67
68 DEFINE_NON_INTERPOLABLE_VALUE_TYPE(CSSTextIndentNonInterpolableValue); 68 DEFINE_NON_INTERPOLABLE_VALUE_TYPE(CSSTextIndentNonInterpolableValue);
69 DEFINE_NON_INTERPOLABLE_VALUE_TYPE_CASTS(CSSTextIndentNonInterpolableValue); 69 DEFINE_NON_INTERPOLABLE_VALUE_TYPE_CASTS(CSSTextIndentNonInterpolableValue);
70 70
71 namespace { 71 namespace {
72 72
73 class UnderlyingIndentModeChecker 73 class UnderlyingIndentModeChecker
74 : public InterpolationType::ConversionChecker { 74 : public CSSInterpolationType::CSSConversionChecker {
75 public: 75 public:
76 static std::unique_ptr<UnderlyingIndentModeChecker> Create( 76 static std::unique_ptr<UnderlyingIndentModeChecker> Create(
77 const IndentMode& mode) { 77 const IndentMode& mode) {
78 return WTF::WrapUnique(new UnderlyingIndentModeChecker(mode)); 78 return WTF::WrapUnique(new UnderlyingIndentModeChecker(mode));
79 } 79 }
80 80
81 bool IsValid(const InterpolationEnvironment&, 81 bool IsValid(const StyleResolverState&,
82 const InterpolationValue& underlying) const final { 82 const InterpolationValue& underlying) const final {
83 return mode_ == ToCSSTextIndentNonInterpolableValue( 83 return mode_ == ToCSSTextIndentNonInterpolableValue(
84 *underlying.non_interpolable_value) 84 *underlying.non_interpolable_value)
85 .Mode(); 85 .Mode();
86 } 86 }
87 87
88 private: 88 private:
89 UnderlyingIndentModeChecker(const IndentMode& mode) : mode_(mode) {} 89 UnderlyingIndentModeChecker(const IndentMode& mode) : mode_(mode) {}
90 90
91 const IndentMode mode_; 91 const IndentMode mode_;
92 }; 92 };
93 93
94 class InheritedIndentModeChecker : public InterpolationType::ConversionChecker { 94 class InheritedIndentModeChecker
95 : public CSSInterpolationType::CSSConversionChecker {
95 public: 96 public:
96 static std::unique_ptr<InheritedIndentModeChecker> Create( 97 static std::unique_ptr<InheritedIndentModeChecker> Create(
97 const IndentMode& mode) { 98 const IndentMode& mode) {
98 return WTF::WrapUnique(new InheritedIndentModeChecker(mode)); 99 return WTF::WrapUnique(new InheritedIndentModeChecker(mode));
99 } 100 }
100 101
101 bool IsValid(const InterpolationEnvironment& environment, 102 bool IsValid(const StyleResolverState& state,
102 const InterpolationValue&) const final { 103 const InterpolationValue&) const final {
103 return mode_ == IndentMode(*environment.GetState().ParentStyle()); 104 return mode_ == IndentMode(*state.ParentStyle());
104 } 105 }
105 106
106 private: 107 private:
107 InheritedIndentModeChecker(const IndentMode& mode) : mode_(mode) {} 108 InheritedIndentModeChecker(const IndentMode& mode) : mode_(mode) {}
108 109
109 const IndentMode mode_; 110 const IndentMode mode_;
110 }; 111 };
111 112
112 InterpolationValue CreateValue(const Length& length, 113 InterpolationValue CreateValue(const Length& length,
113 const IndentMode& mode, 114 const IndentMode& mode,
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 interpolable_value, 249 interpolable_value,
249 css_text_indent_non_interpolable_value.LengthNonInterpolableValue(), 250 css_text_indent_non_interpolable_value.LengthNonInterpolableValue(),
250 state.CssToLengthConversionData(), kValueRangeAll)); 251 state.CssToLengthConversionData(), kValueRangeAll));
251 252
252 const IndentMode& mode = css_text_indent_non_interpolable_value.Mode(); 253 const IndentMode& mode = css_text_indent_non_interpolable_value.Mode();
253 style.SetTextIndentLine(mode.line); 254 style.SetTextIndentLine(mode.line);
254 style.SetTextIndentType(mode.type); 255 style.SetTextIndentType(mode.type);
255 } 256 }
256 257
257 } // namespace blink 258 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698