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

Side by Side Diff: third_party/WebKit/Source/core/animation/CSSFontWeightInterpolationType.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/CSSFontWeightInterpolationType.h" 5 #include "core/animation/CSSFontWeightInterpolationType.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include "core/animation/FontWeightConversion.h" 8 #include "core/animation/FontWeightConversion.h"
9 #include "core/css/CSSPrimitiveValueMappings.h" 9 #include "core/css/CSSPrimitiveValueMappings.h"
10 #include "core/css/resolver/StyleResolverState.h" 10 #include "core/css/resolver/StyleResolverState.h"
11 #include "platform/wtf/PtrUtil.h" 11 #include "platform/wtf/PtrUtil.h"
12 12
13 namespace blink { 13 namespace blink {
14 14
15 class InheritedFontWeightChecker : public InterpolationType::ConversionChecker { 15 class InheritedFontWeightChecker
16 : public CSSInterpolationType::CSSConversionChecker {
16 public: 17 public:
17 static std::unique_ptr<InheritedFontWeightChecker> Create( 18 static std::unique_ptr<InheritedFontWeightChecker> Create(
18 FontWeight font_weight) { 19 FontWeight font_weight) {
19 return WTF::WrapUnique(new InheritedFontWeightChecker(font_weight)); 20 return WTF::WrapUnique(new InheritedFontWeightChecker(font_weight));
20 } 21 }
21 22
22 private: 23 private:
23 InheritedFontWeightChecker(FontWeight font_weight) 24 InheritedFontWeightChecker(FontWeight font_weight)
24 : font_weight_(font_weight) {} 25 : font_weight_(font_weight) {}
25 26
26 bool IsValid(const InterpolationEnvironment& environment, 27 bool IsValid(const StyleResolverState& state,
27 const InterpolationValue&) const final { 28 const InterpolationValue&) const final {
28 return font_weight_ == 29 return font_weight_ == state.ParentStyle()->GetFontWeight();
29 environment.GetState().ParentStyle()->GetFontWeight();
30 } 30 }
31 31
32 const double font_weight_; 32 const double font_weight_;
33 }; 33 };
34 34
35 InterpolationValue CSSFontWeightInterpolationType::CreateFontWeightValue( 35 InterpolationValue CSSFontWeightInterpolationType::CreateFontWeightValue(
36 FontWeight font_weight) const { 36 FontWeight font_weight) const {
37 return InterpolationValue( 37 return InterpolationValue(
38 InterpolableNumber::Create(FontWeightToDouble(font_weight))); 38 InterpolableNumber::Create(FontWeightToDouble(font_weight)));
39 } 39 }
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 101
102 void CSSFontWeightInterpolationType::ApplyStandardPropertyValue( 102 void CSSFontWeightInterpolationType::ApplyStandardPropertyValue(
103 const InterpolableValue& interpolable_value, 103 const InterpolableValue& interpolable_value,
104 const NonInterpolableValue*, 104 const NonInterpolableValue*,
105 StyleResolverState& state) const { 105 StyleResolverState& state) const {
106 state.GetFontBuilder().SetWeight( 106 state.GetFontBuilder().SetWeight(
107 DoubleToFontWeight(ToInterpolableNumber(interpolable_value).Value())); 107 DoubleToFontWeight(ToInterpolableNumber(interpolable_value).Value()));
108 } 108 }
109 109
110 } // namespace blink 110 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698