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 TransformStyleInterpolation_h | 5 #ifndef TransformStyleInterpolation_h |
6 #define TransformStyleInterpolation_h | 6 #define TransformStyleInterpolation_h |
7 | 7 |
8 #include "core/animation/StyleInterpolation.h" | 8 #include "core/animation/StyleInterpolation.h" |
9 #include "core/css/CSSTransformValue.h" | 9 #include "core/css/CSSTransformValue.h" |
10 | 10 |
11 namespace blink { | 11 namespace blink { |
12 | 12 |
13 class TransformStyleInterpolation : public StyleInterpolation { | 13 class TransformStyleInterpolation : public StyleInterpolation { |
14 public: | 14 public: |
15 static PassRefPtrWillBeRawPtr<TransformStyleInterpolation> maybeCreateFrom(C
SSValue& start, CSSValue& end, CSSPropertyID id) | 15 static PassRefPtrWillBeRawPtr<TransformStyleInterpolation> maybeCreateFrom(C
SSValue& start, CSSValue& end, CSSPropertyID id) |
16 { | 16 { |
17 if (!canCreateFrom(start) || !canCreateFrom(end)) | 17 if (!canCreateFrom(start) || !canCreateFrom(end)) |
18 return nullptr; | 18 return nullptr; |
19 ASSERT(!TransformStyleInterpolation::fallBackToLegacy(start, end)); | 19 ASSERT(!TransformStyleInterpolation::fallBackToLegacy(start, end)); |
20 WillBeHeapVector<CSSTransformValue::TransformOperationType> types; | 20 Vector<CSSTransformValue::TransformOperationType> types; |
21 if (start.isPrimitiveValue() && end.isPrimitiveValue()) | 21 if (start.isPrimitiveValue() && end.isPrimitiveValue()) |
22 return adoptRefWillBeNoop(new TransformStyleInterpolation(transformT
oInterpolableValue(start), transformToInterpolableValue(end), id, types)); | 22 return adoptRefWillBeNoop(new TransformStyleInterpolation(transformT
oInterpolableValue(start), transformToInterpolableValue(end), id, types)); |
23 const CSSValueList* startList = toCSSValueList(&start); | 23 const CSSValueList* startList = toCSSValueList(&start); |
24 | 24 |
25 types.reserveCapacity(startList->length()); | 25 types.reserveCapacity(startList->length()); |
26 for (size_t i = 0; i < startList->length(); i++) { | 26 for (size_t i = 0; i < startList->length(); i++) { |
27 types.append(toCSSTransformValue(startList->item(i))->operationType(
)); | 27 types.append(toCSSTransformValue(startList->item(i))->operationType(
)); |
28 } | 28 } |
29 return adoptRefWillBeNoop(new TransformStyleInterpolation(transformToInt
erpolableValue(start), transformToInterpolableValue(end), id, types)); | 29 return adoptRefWillBeNoop(new TransformStyleInterpolation(transformToInt
erpolableValue(start), transformToInterpolableValue(end), id, types)); |
30 } | 30 } |
31 | 31 |
32 static bool fallBackToLegacy(CSSValue&, CSSValue&); | 32 static bool fallBackToLegacy(CSSValue&, CSSValue&); |
33 | 33 |
34 virtual void apply(StyleResolverState&) const override; | 34 virtual void apply(StyleResolverState&) const override; |
35 virtual void trace(Visitor*) override; | 35 virtual void trace(Visitor*) override; |
36 | 36 |
37 private: | 37 private: |
38 TransformStyleInterpolation(PassOwnPtrWillBeRawPtr<InterpolableValue> start,
PassOwnPtrWillBeRawPtr<InterpolableValue> end, CSSPropertyID id, WillBeHeapVect
or<CSSTransformValue::TransformOperationType> types) | 38 TransformStyleInterpolation(PassOwnPtrWillBeRawPtr<InterpolableValue> start,
PassOwnPtrWillBeRawPtr<InterpolableValue> end, CSSPropertyID id, Vector<CSSTran
sformValue::TransformOperationType> types) |
39 : StyleInterpolation(start, end, id) | 39 : StyleInterpolation(start, end, id) |
40 , m_types(types) | 40 , m_types(types) |
41 { } | 41 { } |
42 | 42 |
43 static bool canCreateFrom(const CSSValue&); | 43 static bool canCreateFrom(const CSSValue&); |
44 | 44 |
45 static PassOwnPtrWillBeRawPtr<InterpolableValue> transformToInterpolableValu
e(CSSValue&); | 45 static PassOwnPtrWillBeRawPtr<InterpolableValue> transformToInterpolableValu
e(CSSValue&); |
46 static PassRefPtrWillBeRawPtr<CSSValue> interpolableValueToTransform(Interpo
lableValue*, WillBeHeapVector<CSSTransformValue::TransformOperationType> types); | 46 static PassRefPtrWillBeRawPtr<CSSValue> interpolableValueToTransform(Interpo
lableValue*, Vector<CSSTransformValue::TransformOperationType> types); |
47 | 47 |
48 WillBeHeapVector<CSSTransformValue::TransformOperationType> m_types; | 48 Vector<CSSTransformValue::TransformOperationType> m_types; |
49 | 49 |
50 friend class AnimationTransformStyleInterpolationTest; | 50 friend class AnimationTransformStyleInterpolationTest; |
51 }; | 51 }; |
52 | 52 |
53 } // namespace blink | 53 } // namespace blink |
54 | 54 |
55 #endif // TransformStyleInterpolation_h | 55 #endif // TransformStyleInterpolation_h |
56 | 56 |
OLD | NEW |