Backed out changeset 1b14354719c0 (bug 1895254) for causing bustages on NavigationTra...
[gecko.git] / layout / style / nsTransitionManager.h
blob02a577690d7198d71d11a726e64dbdcdab4f26ed
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 /* Code to start and animate CSS transitions. */
9 #ifndef nsTransitionManager_h_
10 #define nsTransitionManager_h_
12 #include "mozilla/dom/CSSTransition.h"
13 #include "AnimationCommon.h"
14 #include "nsISupportsImpl.h"
16 class nsPresContext;
17 class nsCSSPropertyIDSet;
18 struct nsStyleUIReset;
20 namespace mozilla {
21 class AnimatedPropertyIDSet;
22 class ComputedStyle;
23 enum class PseudoStyleType : uint8_t;
24 } // namespace mozilla
26 class nsTransitionManager final
27 : public mozilla::CommonAnimationManager<mozilla::dom::CSSTransition> {
28 public:
29 explicit nsTransitionManager(nsPresContext* aPresContext)
30 : mozilla::CommonAnimationManager<mozilla::dom::CSSTransition>(
31 aPresContext) {}
33 ~nsTransitionManager() final = default;
35 typedef mozilla::AnimationCollection<mozilla::dom::CSSTransition>
36 CSSTransitionCollection;
38 /**
39 * Update transitions for stylo.
41 bool UpdateTransitions(mozilla::dom::Element* aElement,
42 mozilla::PseudoStyleType aPseudoType,
43 const mozilla::ComputedStyle& aOldStyle,
44 const mozilla::ComputedStyle& aNewStyle);
46 protected:
47 typedef nsTArray<RefPtr<mozilla::dom::CSSTransition>>
48 OwningCSSTransitionPtrArray;
50 // Update transitions. This will start new transitions,
51 // replace existing transitions, and stop existing transitions
52 // as needed. aDisp and aElement must be non-null.
53 // aElementTransitions is the collection of current transitions, and it
54 // could be a nullptr if we don't have any transitions.
55 bool DoUpdateTransitions(const nsStyleUIReset& aStyle,
56 mozilla::dom::Element* aElement,
57 mozilla::PseudoStyleType aPseudoType,
58 CSSTransitionCollection*& aElementTransitions,
59 const mozilla::ComputedStyle& aOldStyle,
60 const mozilla::ComputedStyle& aNewStyle);
62 // Returns whether the transition actually started.
63 bool ConsiderInitiatingTransition(
64 const mozilla::AnimatedPropertyID&, const nsStyleUIReset& aStyle,
65 uint32_t aTransitionIndex, float aDelay, float aDuration,
66 mozilla::StyleTransitionBehavior aBehavior,
67 mozilla::dom::Element* aElement, mozilla::PseudoStyleType aPseudoType,
68 CSSTransitionCollection*& aElementTransitions,
69 const mozilla::ComputedStyle& aOldStyle,
70 const mozilla::ComputedStyle& aNewStyle,
71 mozilla::AnimatedPropertyIDSet& aPropertiesChecked);
73 already_AddRefed<mozilla::dom::CSSTransition> DoCreateTransition(
74 const mozilla::AnimatedPropertyID& aProperty,
75 mozilla::dom::Element* aElement, mozilla::PseudoStyleType aPseudoType,
76 const mozilla::ComputedStyle& aNewStyle,
77 CSSTransitionCollection*& aElementTransitions,
78 mozilla::TimingParams&& aTiming, mozilla::AnimationValue&& aStartValue,
79 mozilla::AnimationValue&& aEndValue,
80 mozilla::AnimationValue&& aStartForReversingTest, double aReversePortion);
82 void DoCancelTransition(mozilla::dom::Element* aElement,
83 mozilla::PseudoStyleType aPseudoType,
84 CSSTransitionCollection*& aElementTransitions,
85 size_t aIndex);
88 #endif /* !defined(nsTransitionManager_h_) */