| 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/CSSClipInterpolationType.h" | 5 #include "core/animation/CSSClipInterpolationType.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/CSSQuadValue.h" | 10 #include "core/css/CSSQuadValue.h" | 
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 51   bool is_left_auto; | 51   bool is_left_auto; | 
| 52 }; | 52 }; | 
| 53 | 53 | 
| 54 static ClipAutos GetClipAutos(const ComputedStyle& style) { | 54 static ClipAutos GetClipAutos(const ComputedStyle& style) { | 
| 55   if (style.HasAutoClip()) | 55   if (style.HasAutoClip()) | 
| 56     return ClipAutos(); | 56     return ClipAutos(); | 
| 57   return ClipAutos(style.ClipTop().IsAuto(), style.ClipRight().IsAuto(), | 57   return ClipAutos(style.ClipTop().IsAuto(), style.ClipRight().IsAuto(), | 
| 58                    style.ClipBottom().IsAuto(), style.ClipLeft().IsAuto()); | 58                    style.ClipBottom().IsAuto(), style.ClipLeft().IsAuto()); | 
| 59 } | 59 } | 
| 60 | 60 | 
| 61 class InheritedAutosChecker : public InterpolationType::ConversionChecker { | 61 class InheritedAutosChecker | 
|  | 62     : public CSSInterpolationType::CSSConversionChecker { | 
| 62  public: | 63  public: | 
| 63   static std::unique_ptr<InheritedAutosChecker> Create( | 64   static std::unique_ptr<InheritedAutosChecker> Create( | 
| 64       const ClipAutos& inherited_autos) { | 65       const ClipAutos& inherited_autos) { | 
| 65     return WTF::WrapUnique(new InheritedAutosChecker(inherited_autos)); | 66     return WTF::WrapUnique(new InheritedAutosChecker(inherited_autos)); | 
| 66   } | 67   } | 
| 67 | 68 | 
| 68  private: | 69  private: | 
| 69   InheritedAutosChecker(const ClipAutos& inherited_autos) | 70   InheritedAutosChecker(const ClipAutos& inherited_autos) | 
| 70       : inherited_autos_(inherited_autos) {} | 71       : inherited_autos_(inherited_autos) {} | 
| 71 | 72 | 
| 72   bool IsValid(const InterpolationEnvironment& environment, | 73   bool IsValid(const StyleResolverState& state, | 
| 73                const InterpolationValue& underlying) const final { | 74                const InterpolationValue& underlying) const final { | 
| 74     return inherited_autos_ == | 75     return inherited_autos_ == GetClipAutos(*state.ParentStyle()); | 
| 75            GetClipAutos(*environment.GetState().ParentStyle()); |  | 
| 76   } | 76   } | 
| 77 | 77 | 
| 78   const ClipAutos inherited_autos_; | 78   const ClipAutos inherited_autos_; | 
| 79 }; | 79 }; | 
| 80 | 80 | 
| 81 class CSSClipNonInterpolableValue : public NonInterpolableValue { | 81 class CSSClipNonInterpolableValue : public NonInterpolableValue { | 
| 82  public: | 82  public: | 
| 83   ~CSSClipNonInterpolableValue() final {} | 83   ~CSSClipNonInterpolableValue() final {} | 
| 84 | 84 | 
| 85   static PassRefPtr<CSSClipNonInterpolableValue> Create( | 85   static PassRefPtr<CSSClipNonInterpolableValue> Create( | 
| (...skipping 10 matching lines...) Expand all  Loading... | 
| 96       : clip_autos_(clip_autos) { | 96       : clip_autos_(clip_autos) { | 
| 97     DCHECK(!clip_autos_.is_auto); | 97     DCHECK(!clip_autos_.is_auto); | 
| 98   } | 98   } | 
| 99 | 99 | 
| 100   const ClipAutos clip_autos_; | 100   const ClipAutos clip_autos_; | 
| 101 }; | 101 }; | 
| 102 | 102 | 
| 103 DEFINE_NON_INTERPOLABLE_VALUE_TYPE(CSSClipNonInterpolableValue); | 103 DEFINE_NON_INTERPOLABLE_VALUE_TYPE(CSSClipNonInterpolableValue); | 
| 104 DEFINE_NON_INTERPOLABLE_VALUE_TYPE_CASTS(CSSClipNonInterpolableValue); | 104 DEFINE_NON_INTERPOLABLE_VALUE_TYPE_CASTS(CSSClipNonInterpolableValue); | 
| 105 | 105 | 
| 106 class UnderlyingAutosChecker : public InterpolationType::ConversionChecker { | 106 class UnderlyingAutosChecker | 
|  | 107     : public CSSInterpolationType::CSSConversionChecker { | 
| 107  public: | 108  public: | 
| 108   ~UnderlyingAutosChecker() final {} | 109   ~UnderlyingAutosChecker() final {} | 
| 109 | 110 | 
| 110   static std::unique_ptr<UnderlyingAutosChecker> Create( | 111   static std::unique_ptr<UnderlyingAutosChecker> Create( | 
| 111       const ClipAutos& underlying_autos) { | 112       const ClipAutos& underlying_autos) { | 
| 112     return WTF::WrapUnique(new UnderlyingAutosChecker(underlying_autos)); | 113     return WTF::WrapUnique(new UnderlyingAutosChecker(underlying_autos)); | 
| 113   } | 114   } | 
| 114 | 115 | 
| 115   static ClipAutos GetUnderlyingAutos(const InterpolationValue& underlying) { | 116   static ClipAutos GetUnderlyingAutos(const InterpolationValue& underlying) { | 
| 116     if (!underlying) | 117     if (!underlying) | 
| 117       return ClipAutos(); | 118       return ClipAutos(); | 
| 118     return ToCSSClipNonInterpolableValue(*underlying.non_interpolable_value) | 119     return ToCSSClipNonInterpolableValue(*underlying.non_interpolable_value) | 
| 119         .GetClipAutos(); | 120         .GetClipAutos(); | 
| 120   } | 121   } | 
| 121 | 122 | 
| 122  private: | 123  private: | 
| 123   UnderlyingAutosChecker(const ClipAutos& underlying_autos) | 124   UnderlyingAutosChecker(const ClipAutos& underlying_autos) | 
| 124       : underlying_autos_(underlying_autos) {} | 125       : underlying_autos_(underlying_autos) {} | 
| 125 | 126 | 
| 126   bool IsValid(const InterpolationEnvironment&, | 127   bool IsValid(const StyleResolverState&, | 
| 127                const InterpolationValue& underlying) const final { | 128                const InterpolationValue& underlying) const final { | 
| 128     return underlying_autos_ == GetUnderlyingAutos(underlying); | 129     return underlying_autos_ == GetUnderlyingAutos(underlying); | 
| 129   } | 130   } | 
| 130 | 131 | 
| 131   const ClipAutos underlying_autos_; | 132   const ClipAutos underlying_autos_; | 
| 132 }; | 133 }; | 
| 133 | 134 | 
| 134 enum ClipComponentIndex : unsigned { | 135 enum ClipComponentIndex : unsigned { | 
| 135   kClipTop, | 136   kClipTop, | 
| 136   kClipRight, | 137   kClipRight, | 
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 282         kValueRangeAll); | 283         kValueRangeAll); | 
| 283   }; | 284   }; | 
| 284   state.Style()->SetClip( | 285   state.Style()->SetClip( | 
| 285       LengthBox(convert_index(autos.is_top_auto, kClipTop), | 286       LengthBox(convert_index(autos.is_top_auto, kClipTop), | 
| 286                 convert_index(autos.is_right_auto, kClipRight), | 287                 convert_index(autos.is_right_auto, kClipRight), | 
| 287                 convert_index(autos.is_bottom_auto, kClipBottom), | 288                 convert_index(autos.is_bottom_auto, kClipBottom), | 
| 288                 convert_index(autos.is_left_auto, kClipLeft))); | 289                 convert_index(autos.is_left_auto, kClipLeft))); | 
| 289 } | 290 } | 
| 290 | 291 | 
| 291 }  // namespace blink | 292 }  // namespace blink | 
| OLD | NEW | 
|---|