OLD | NEW |
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/CSSFontSizeInterpolationType.h" | 5 #include "core/animation/CSSFontSizeInterpolationType.h" |
6 | 6 |
7 #include "core/animation/LengthInterpolationFunctions.h" | 7 #include "core/animation/LengthInterpolationFunctions.h" |
8 #include "core/css/CSSPrimitiveValue.h" | 8 #include "core/css/CSSIdentifierValue.h" |
9 #include "core/css/resolver/StyleResolverState.h" | 9 #include "core/css/resolver/StyleResolverState.h" |
10 #include "platform/LengthFunctions.h" | 10 #include "platform/LengthFunctions.h" |
11 #include "platform/fonts/FontDescription.h" | 11 #include "platform/fonts/FontDescription.h" |
12 #include "wtf/PtrUtil.h" | 12 #include "wtf/PtrUtil.h" |
13 #include <memory> | 13 #include <memory> |
14 | 14 |
15 namespace blink { | 15 namespace blink { |
16 | 16 |
17 namespace { | 17 namespace { |
18 | 18 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 conversionCheckers.append(InheritedFontSizeChecker::create(inheritedFontSize
)); | 96 conversionCheckers.append(InheritedFontSizeChecker::create(inheritedFontSize
)); |
97 return convertFontSize(inheritedFontSize.value); | 97 return convertFontSize(inheritedFontSize.value); |
98 } | 98 } |
99 | 99 |
100 InterpolationValue CSSFontSizeInterpolationType::maybeConvertValue(const CSSValu
e& value, const StyleResolverState& state, ConversionCheckers& conversionChecker
s) const | 100 InterpolationValue CSSFontSizeInterpolationType::maybeConvertValue(const CSSValu
e& value, const StyleResolverState& state, ConversionCheckers& conversionChecker
s) const |
101 { | 101 { |
102 std::unique_ptr<InterpolableValue> result = LengthInterpolationFunctions::ma
ybeConvertCSSValue(value).interpolableValue; | 102 std::unique_ptr<InterpolableValue> result = LengthInterpolationFunctions::ma
ybeConvertCSSValue(value).interpolableValue; |
103 if (result) | 103 if (result) |
104 return InterpolationValue(std::move(result)); | 104 return InterpolationValue(std::move(result)); |
105 | 105 |
106 if (!value.isPrimitiveValue() || !toCSSPrimitiveValue(value).isValueID()) | 106 if (!value.isIdentifierValue()) |
107 return nullptr; | 107 return nullptr; |
108 | 108 |
109 return maybeConvertKeyword(toCSSPrimitiveValue(value).getValueID(), state, c
onversionCheckers); | 109 return maybeConvertKeyword(toCSSIdentifierValue(value).getValueID(), state,
conversionCheckers); |
110 } | 110 } |
111 | 111 |
112 InterpolationValue CSSFontSizeInterpolationType::maybeConvertUnderlyingValue(con
st InterpolationEnvironment& environment) const | 112 InterpolationValue CSSFontSizeInterpolationType::maybeConvertUnderlyingValue(con
st InterpolationEnvironment& environment) const |
113 { | 113 { |
114 return convertFontSize(environment.state().style()->specifiedFontSize()); | 114 return convertFontSize(environment.state().style()->specifiedFontSize()); |
115 } | 115 } |
116 | 116 |
117 void CSSFontSizeInterpolationType::apply(const InterpolableValue& interpolableVa
lue, const NonInterpolableValue*, InterpolationEnvironment& environment) const | 117 void CSSFontSizeInterpolationType::apply(const InterpolableValue& interpolableVa
lue, const NonInterpolableValue*, InterpolationEnvironment& environment) const |
118 { | 118 { |
119 const FontDescription& parentFont = environment.state().parentFontDescriptio
n(); | 119 const FontDescription& parentFont = environment.state().parentFontDescriptio
n(); |
120 Length fontSizeLength = LengthInterpolationFunctions::createLength(interpola
bleValue, nullptr, environment.state().fontSizeConversionData(), ValueRangeNonNe
gative); | 120 Length fontSizeLength = LengthInterpolationFunctions::createLength(interpola
bleValue, nullptr, environment.state().fontSizeConversionData(), ValueRangeNonNe
gative); |
121 float fontSize = floatValueForLength(fontSizeLength, parentFont.getSize().va
lue); | 121 float fontSize = floatValueForLength(fontSizeLength, parentFont.getSize().va
lue); |
122 environment.state().fontBuilder().setSize(FontDescription::Size(0, fontSize,
!fontSizeLength.isPercentOrCalc() || parentFont.isAbsoluteSize())); | 122 environment.state().fontBuilder().setSize(FontDescription::Size(0, fontSize,
!fontSizeLength.isPercentOrCalc() || parentFont.isAbsoluteSize())); |
123 } | 123 } |
124 | 124 |
125 } // namespace blink | 125 } // namespace blink |
OLD | NEW |