OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef LengthBoxStyleInterpolation_h | 5 #ifndef LengthBoxStyleInterpolation_h |
6 #define LengthBoxStyleInterpolation_h | 6 #define LengthBoxStyleInterpolation_h |
7 | 7 |
8 #include "core/animation/LengthStyleInterpolation.h" | 8 #include "core/animation/LengthStyleInterpolation.h" |
9 #include "core/css/CSSBorderImageSliceValue.h" | 9 #include "core/css/CSSBorderImageSliceValue.h" |
10 #include "core/css/Rect.h" | |
10 | 11 |
11 namespace blink { | 12 namespace blink { |
12 | 13 |
13 class LengthBoxStyleInterpolation : public StyleInterpolation { | 14 class LengthBoxStyleInterpolation : public StyleInterpolation { |
14 public: | 15 public: |
15 static PassRefPtrWillBeRawPtr<LengthBoxStyleInterpolation> create(const CSSV alue& start, const CSSValue& end, CSSPropertyID id) | 16 static bool onlyLengthToAuto(Rect* startRect, Rect* endRect) |
Eric Willigers
2015/02/11 03:56:32
This method isn't trivial, so move implementation
jadeg
2015/02/12 05:06:00
Done.
| |
16 { | 17 { |
17 return adoptRefWillBeNoop(new LengthBoxStyleInterpolation(lengthBoxtoInt erpolableValue(start), lengthBoxtoInterpolableValue(end), id, false)); | 18 return (startRect->left()->isLength() == endRect->left()->isValueID() || endRect->left()->isLength() == startRect->left()->isValueID()) |
19 && (startRect->right()->isLength() == endRect->right()->isValueID() || endRect->right()->isLength() == startRect->right()->isValueID()) | |
20 && (startRect->top()->isLength() == endRect->top()->isValueID() || e ndRect->top()->isLength() == startRect->top()->isValueID()) | |
21 && (startRect->bottom()->isLength() == endRect->bottom()->isValueID( ) || endRect->bottom()->isLength() == startRect->bottom()->isValueID()); | |
18 } | 22 } |
19 | 23 |
20 static PassRefPtrWillBeRawPtr<LengthBoxStyleInterpolation> createFromBorderI mageSlice(CSSValue& start, CSSValue& end, CSSPropertyID id) | 24 static PassRefPtrWillBeRawPtr<LengthBoxStyleInterpolation> maybeCreateFrom(C SSValue* start, CSSValue* end, CSSPropertyID id) |
Eric Willigers
2015/02/11 03:56:32
This method isn't trivial, so move implementation
jadeg
2015/02/12 05:06:00
Done.
| |
21 { | 25 { |
22 return adoptRefWillBeNoop(new LengthBoxStyleInterpolation(borderImageSli cetoInterpolableValue(start), borderImageSlicetoInterpolableValue(end), id, toCS SBorderImageSliceValue(start).m_fill)); | 26 bool startRect = start->isPrimitiveValue() && toCSSPrimitiveValue(start) ->isRect(); |
27 bool endRect = end->isPrimitiveValue() && toCSSPrimitiveValue(end)->isRe ct(); | |
28 bool startAuto = start->isPrimitiveValue() && toCSSPrimitiveValue(start) ->isValueID() && toCSSPrimitiveValue(start)->getValueID() == CSSValueAuto; | |
29 bool endAuto = end->isPrimitiveValue() && toCSSPrimitiveValue(end)->isVa lueID() && toCSSPrimitiveValue(end)->getValueID() == CSSValueAuto; | |
30 | |
31 if (startAuto || endAuto) { | |
32 return adoptRefWillBeNoop(new LengthBoxStyleInterpolation(Interpolab leBool::create(false), InterpolableBool::create(true), id, false, start, end)); | |
33 } | |
34 if (startRect && endRect) { | |
35 Rect* startRectValue = toCSSPrimitiveValue(start)->getRectValue(); | |
36 Rect* endRectValue = toCSSPrimitiveValue(end)->getRectValue(); | |
37 | |
38 if (onlyLengthToAuto(startRectValue, endRectValue)) | |
39 return adoptRefWillBeNoop(new LengthBoxStyleInterpolation(Interp olableBool::create(false), InterpolableBool::create(true), id, false, start, end )); | |
40 return adoptRefWillBeNoop(new LengthBoxStyleInterpolation(lengthBoxt oInterpolableValue(*start, *end, false), lengthBoxtoInterpolableValue(*end, *sta rt, true), id, false, start, end)); | |
41 } | |
42 if (start->isBorderImageSliceValue() && toCSSBorderImageSliceValue(start )->slices() | |
43 && end->isBorderImageSliceValue() && toCSSBorderImageSliceValue(end) ->slices() | |
44 && toCSSBorderImageSliceValue(start)->m_fill == toCSSBorderImageSlic eValue(end)->m_fill) | |
45 return adoptRefWillBeNoop(new LengthBoxStyleInterpolation(borderImag eSlicetoInterpolableValue(*start), borderImageSlicetoInterpolableValue(*end), id , toCSSBorderImageSliceValue(start)->m_fill, start, end)); | |
46 return nullptr; | |
23 } | 47 } |
24 | 48 |
25 static bool canCreateFrom(const CSSValue&); | 49 static bool usesDefault(const CSSValue&, const CSSValue&); |
26 | |
27 static bool matchingFill(CSSValue&, CSSValue&); | |
28 static bool canCreateFromBorderImageSlice(CSSValue&); | |
29 | 50 |
30 virtual void apply(StyleResolverState&) const override; | 51 virtual void apply(StyleResolverState&) const override; |
31 virtual void trace(Visitor*) override; | 52 virtual void trace(Visitor*) override; |
32 | 53 |
33 private: | 54 private: |
34 LengthBoxStyleInterpolation(PassOwnPtrWillBeRawPtr<InterpolableValue> start, PassOwnPtrWillBeRawPtr<InterpolableValue> end, CSSPropertyID id, bool fill) | 55 LengthBoxStyleInterpolation(PassOwnPtrWillBeRawPtr<InterpolableValue> startI nterpolation, PassOwnPtrWillBeRawPtr<InterpolableValue> endInterpolation, CSSPro pertyID id, bool fill, CSSValue* startCSS, CSSValue* endCSS) |
35 : StyleInterpolation(start, end, id) | 56 : StyleInterpolation(startInterpolation, endInterpolation, id) |
36 , m_fill(fill) | 57 , m_fill(fill) |
58 , m_startCSSValue(startCSS) | |
59 , m_endCSSValue(endCSS) | |
37 { } | 60 { } |
38 | 61 |
39 static PassOwnPtrWillBeRawPtr<InterpolableValue> lengthBoxtoInterpolableValu e(const CSSValue&); | 62 static PassOwnPtrWillBeRawPtr<InterpolableValue> lengthBoxtoInterpolableValu e(const CSSValue&, const CSSValue&, bool); |
40 static PassOwnPtrWillBeRawPtr<InterpolableValue> borderImageSlicetoInterpola bleValue(CSSValue&); | 63 static PassOwnPtrWillBeRawPtr<InterpolableValue> borderImageSlicetoInterpola bleValue(const CSSValue&); |
41 static PassRefPtrWillBeRawPtr<CSSValue> interpolableValueToLengthBox(Interpo lableValue*, InterpolationRange = RangeAll); | 64 static PassRefPtrWillBeRawPtr<CSSValue> interpolableValueToLengthBox(Interpo lableValue*, const CSSValue&, const CSSValue&); |
42 static PassRefPtrWillBeRawPtr<CSSValue> interpolableValueToBorderImageSlice( InterpolableValue*, bool); | 65 static PassRefPtrWillBeRawPtr<CSSValue> interpolableValueToBorderImageSlice( InterpolableValue*, bool); |
43 | 66 |
44 bool m_fill; | 67 bool m_fill; |
68 RefPtrWillBeMember<CSSValue> m_startCSSValue; | |
69 RefPtrWillBeMember<CSSValue> m_endCSSValue; | |
45 | 70 |
46 friend class AnimationLengthBoxStyleInterpolationTest; | 71 friend class AnimationLengthBoxStyleInterpolationTest; |
47 }; | 72 }; |
48 | 73 |
49 } // namespace blink | 74 } // namespace blink |
50 | 75 |
51 #endif // LengthBoxStyleInterpolation_h | 76 #endif // LengthBoxStyleInterpolation_h |
OLD | NEW |