| 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 <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/resolver/StyleResolverState.h" | 10 #include "core/css/resolver/StyleResolverState.h" |
| 11 #include "platform/LengthFunctions.h" | 11 #include "platform/LengthFunctions.h" |
| 12 #include "platform/fonts/FontDescription.h" | 12 #include "platform/fonts/FontDescription.h" |
| 13 #include "platform/wtf/PtrUtil.h" | 13 #include "platform/wtf/PtrUtil.h" |
| 14 | 14 |
| 15 namespace blink { | 15 namespace blink { |
| 16 | 16 |
| 17 namespace { | 17 namespace { |
| 18 | 18 |
| 19 class IsMonospaceChecker : public InterpolationType::ConversionChecker { | 19 class IsMonospaceChecker : public CSSInterpolationType::CSSConversionChecker { |
| 20 public: | 20 public: |
| 21 static std::unique_ptr<IsMonospaceChecker> Create(bool is_monospace) { | 21 static std::unique_ptr<IsMonospaceChecker> Create(bool is_monospace) { |
| 22 return WTF::WrapUnique(new IsMonospaceChecker(is_monospace)); | 22 return WTF::WrapUnique(new IsMonospaceChecker(is_monospace)); |
| 23 } | 23 } |
| 24 | 24 |
| 25 private: | 25 private: |
| 26 IsMonospaceChecker(bool is_monospace) : is_monospace_(is_monospace) {} | 26 IsMonospaceChecker(bool is_monospace) : is_monospace_(is_monospace) {} |
| 27 | 27 |
| 28 bool IsValid(const InterpolationEnvironment& environment, | 28 bool IsValid(const StyleResolverState& state, |
| 29 const InterpolationValue&) const final { | 29 const InterpolationValue&) const final { |
| 30 return is_monospace_ == | 30 return is_monospace_ == state.Style()->GetFontDescription().IsMonospace(); |
| 31 environment.GetState().Style()->GetFontDescription().IsMonospace(); | |
| 32 } | 31 } |
| 33 | 32 |
| 34 const bool is_monospace_; | 33 const bool is_monospace_; |
| 35 }; | 34 }; |
| 36 | 35 |
| 37 class InheritedFontSizeChecker : public InterpolationType::ConversionChecker { | 36 class InheritedFontSizeChecker |
| 37 : public CSSInterpolationType::CSSConversionChecker { |
| 38 public: | 38 public: |
| 39 static std::unique_ptr<InheritedFontSizeChecker> Create( | 39 static std::unique_ptr<InheritedFontSizeChecker> Create( |
| 40 const FontDescription::Size& inherited_font_size) { | 40 const FontDescription::Size& inherited_font_size) { |
| 41 return WTF::WrapUnique(new InheritedFontSizeChecker(inherited_font_size)); | 41 return WTF::WrapUnique(new InheritedFontSizeChecker(inherited_font_size)); |
| 42 } | 42 } |
| 43 | 43 |
| 44 private: | 44 private: |
| 45 InheritedFontSizeChecker(const FontDescription::Size& inherited_font_size) | 45 InheritedFontSizeChecker(const FontDescription::Size& inherited_font_size) |
| 46 : inherited_font_size_(inherited_font_size.value) {} | 46 : inherited_font_size_(inherited_font_size.value) {} |
| 47 | 47 |
| 48 bool IsValid(const InterpolationEnvironment& environment, | 48 bool IsValid(const StyleResolverState& state, |
| 49 const InterpolationValue&) const final { | 49 const InterpolationValue&) const final { |
| 50 return inherited_font_size_ == | 50 return inherited_font_size_ == |
| 51 environment.GetState().ParentFontDescription().GetSize().value; | 51 state.ParentFontDescription().GetSize().value; |
| 52 } | 52 } |
| 53 | 53 |
| 54 const float inherited_font_size_; | 54 const float inherited_font_size_; |
| 55 }; | 55 }; |
| 56 | 56 |
| 57 InterpolationValue ConvertFontSize(float size) { | 57 InterpolationValue ConvertFontSize(float size) { |
| 58 return InterpolationValue( | 58 return InterpolationValue( |
| 59 LengthInterpolationFunctions::CreateInterpolablePixels(size)); | 59 LengthInterpolationFunctions::CreateInterpolablePixels(size)); |
| 60 } | 60 } |
| 61 | 61 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 interpolable_value, nullptr, state.FontSizeConversionData(), | 143 interpolable_value, nullptr, state.FontSizeConversionData(), |
| 144 kValueRangeNonNegative); | 144 kValueRangeNonNegative); |
| 145 float font_size = | 145 float font_size = |
| 146 FloatValueForLength(font_size_length, parent_font.GetSize().value); | 146 FloatValueForLength(font_size_length, parent_font.GetSize().value); |
| 147 state.GetFontBuilder().SetSize(FontDescription::Size( | 147 state.GetFontBuilder().SetSize(FontDescription::Size( |
| 148 0, font_size, | 148 0, font_size, |
| 149 !font_size_length.IsPercentOrCalc() || parent_font.IsAbsoluteSize())); | 149 !font_size_length.IsPercentOrCalc() || parent_font.IsAbsoluteSize())); |
| 150 } | 150 } |
| 151 | 151 |
| 152 } // namespace blink | 152 } // namespace blink |
| OLD | NEW |