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

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

Issue 2346193002: Split CSSPrimitiveValue into CSSPrimitiveValue and CSSIdentifierValue (Closed)
Patch Set: Rebase please work Created 4 years, 2 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 "core/css/CSSPrimitiveValueMappings.h" 7 #include "core/css/CSSPrimitiveValueMappings.h"
8 #include "core/css/resolver/StyleResolverState.h" 8 #include "core/css/resolver/StyleResolverState.h"
9 #include "wtf/PtrUtil.h" 9 #include "wtf/PtrUtil.h"
10 #include <memory> 10 #include <memory>
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 { 96 {
97 if (!state.parentStyle()) 97 if (!state.parentStyle())
98 return nullptr; 98 return nullptr;
99 FontWeight inheritedFontWeight = state.parentStyle()->fontWeight(); 99 FontWeight inheritedFontWeight = state.parentStyle()->fontWeight();
100 conversionCheckers.append(ParentFontWeightChecker::create(inheritedFontWeigh t)); 100 conversionCheckers.append(ParentFontWeightChecker::create(inheritedFontWeigh t));
101 return createFontWeightValue(inheritedFontWeight); 101 return createFontWeightValue(inheritedFontWeight);
102 } 102 }
103 103
104 InterpolationValue CSSFontWeightInterpolationType::maybeConvertValue(const CSSVa lue& value, const StyleResolverState& state, ConversionCheckers& conversionCheck ers) const 104 InterpolationValue CSSFontWeightInterpolationType::maybeConvertValue(const CSSVa lue& value, const StyleResolverState& state, ConversionCheckers& conversionCheck ers) const
105 { 105 {
106 if (!value.isPrimitiveValue()) 106 if (!value.isIdentifierValue())
107 return nullptr; 107 return nullptr;
108 108
109 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); 109 const CSSIdentifierValue& identifierValue = toCSSIdentifierValue(value);
110 CSSValueID keyword = primitiveValue.getValueID(); 110 CSSValueID keyword = identifierValue.getValueID();
111 111
112 switch (keyword) { 112 switch (keyword) {
113 case CSSValueInvalid: 113 case CSSValueInvalid:
114 return nullptr; 114 return nullptr;
115 115
116 case CSSValueBolder: 116 case CSSValueBolder:
117 case CSSValueLighter: { 117 case CSSValueLighter: {
118 FontWeight inheritedFontWeight = state.parentStyle()->fontWeight(); 118 FontWeight inheritedFontWeight = state.parentStyle()->fontWeight();
119 conversionCheckers.append(ParentFontWeightChecker::create(inheritedFontW eight)); 119 conversionCheckers.append(ParentFontWeightChecker::create(inheritedFontW eight));
120 if (keyword == CSSValueBolder) 120 if (keyword == CSSValueBolder)
121 return createFontWeightValue(FontDescription::bolderWeight(inherited FontWeight)); 121 return createFontWeightValue(FontDescription::bolderWeight(inherited FontWeight));
122 return createFontWeightValue(FontDescription::lighterWeight(inheritedFon tWeight)); 122 return createFontWeightValue(FontDescription::lighterWeight(inheritedFon tWeight));
123 } 123 }
124 124
125 default: 125 default:
126 return createFontWeightValue(primitiveValue.convertTo<FontWeight>()); 126 return createFontWeightValue(identifierValue.convertTo<FontWeight>());
127 } 127 }
128 } 128 }
129 129
130 InterpolationValue CSSFontWeightInterpolationType::maybeConvertUnderlyingValue(c onst InterpolationEnvironment& environment) const 130 InterpolationValue CSSFontWeightInterpolationType::maybeConvertUnderlyingValue(c onst InterpolationEnvironment& environment) const
131 { 131 {
132 return createFontWeightValue(environment.state().style()->fontWeight()); 132 return createFontWeightValue(environment.state().style()->fontWeight());
133 } 133 }
134 134
135 void CSSFontWeightInterpolationType::apply(const InterpolableValue& interpolable Value, const NonInterpolableValue*, InterpolationEnvironment& environment) const 135 void CSSFontWeightInterpolationType::apply(const InterpolableValue& interpolable Value, const NonInterpolableValue*, InterpolationEnvironment& environment) const
136 { 136 {
137 environment.state().fontBuilder().setWeight(doubleToFontWeight(toInterpolabl eNumber(interpolableValue).value())); 137 environment.state().fontBuilder().setWeight(doubleToFontWeight(toInterpolabl eNumber(interpolableValue).value()));
138 } 138 }
139 139
140 } // namespace blink 140 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698