Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(46)

Side by Side Diff: third_party/WebKit/Source/core/animation/TransitionInterpolation.h

Issue 2650133002: Add TransitionInterpolation class for CSS Transition refactor (Closed)
Patch Set: lint Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef TransitionInterpolation_h
6 #define TransitionInterpolation_h
7
8 #include "core/animation/CompositorAnimations.h"
9 #include "core/animation/Interpolation.h"
10 #include "core/animation/InterpolationType.h"
11
12 namespace blink {
13
14 class StyleResolverState;
15 class InterpolationType;
16
17 class TransitionInterpolation : public Interpolation {
18 public:
19 static PassRefPtr<TransitionInterpolation> create(
20 const PropertyHandle& property,
21 const InterpolationType& type,
22 InterpolationValue&& start,
23 InterpolationValue&& end,
24 const RefPtr<AnimatableValue> compositorStart,
25 const RefPtr<AnimatableValue> compositorEnd) {
26 return adoptRef(new TransitionInterpolation(
27 property, type, std::move(start), std::move(end),
28 std::move(compositorStart), std::move(compositorEnd)));
29 }
30
31 void apply(StyleResolverState&) const;
32
33 bool isTransitionInterpolation() const final { return true; }
34
35 const PropertyHandle& getProperty() const final { return m_property; }
36
37 std::unique_ptr<TypedInterpolationValue> getInterpolatedValue() const;
38
39 RefPtr<AnimatableValue> getInterpolatedCompositorValue() const;
40
41 void interpolate(int iteration, double fraction) final;
42
43 protected:
44 TransitionInterpolation(const PropertyHandle& property,
45 const InterpolationType& type,
46 InterpolationValue&& start,
47 InterpolationValue&& end,
48 const RefPtr<AnimatableValue> compositorStart,
49 const RefPtr<AnimatableValue> compositorEnd)
50 : m_property(property),
51 m_type(type),
52 m_start(std::move(start)),
53 m_end(std::move(end)),
54 m_merge(type.maybeMergeSingles(m_start.clone(), m_end.clone())),
55 m_compositorStart(std::move(compositorStart)),
56 m_compositorEnd(std::move(compositorEnd)),
57 m_cachedInterpolableValue(m_merge.startInterpolableValue->clone()) {
58 DCHECK(m_merge);
59 DCHECK_EQ(
60 m_compositorStart && m_compositorEnd,
61 CompositorAnimations::isCompositableProperty(m_property.cssProperty()));
62 }
63
64 private:
65 const InterpolableValue& currentInterpolableValue() const;
66 NonInterpolableValue* currentNonInterpolableValue() const;
67
68 const PropertyHandle m_property;
69 const InterpolationType& m_type;
70 const InterpolationValue m_start;
71 const InterpolationValue m_end;
72 const PairwiseInterpolationValue m_merge;
73 const RefPtr<AnimatableValue> m_compositorStart;
74 const RefPtr<AnimatableValue> m_compositorEnd;
75
76 mutable double m_cachedFraction = 0;
77 mutable int m_cachedIteration = 0;
78 mutable std::unique_ptr<InterpolableValue> m_cachedInterpolableValue;
79 };
80
81 DEFINE_TYPE_CASTS(TransitionInterpolation,
82 Interpolation,
83 value,
84 value->isTransitionInterpolation(),
85 value.isTransitionInterpolation());
86
87 } // namespace blink
88
89 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698