tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

nsTransitionManager.h (3669B)


      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/. */
      6 
      7 /* Code to start and animate CSS transitions. */
      8 
      9 #ifndef nsTransitionManager_h_
     10 #define nsTransitionManager_h_
     11 
     12 #include "AnimationCommon.h"
     13 #include "mozilla/dom/CSSTransition.h"
     14 #include "nsISupportsImpl.h"
     15 
     16 class nsPresContext;
     17 class nsCSSPropertyIDSet;
     18 struct nsStyleUIReset;
     19 
     20 namespace mozilla {
     21 class AnimatedPropertyIDSet;
     22 class ComputedStyle;
     23 struct PseudoStyleRequest;
     24 }  // namespace mozilla
     25 
     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) {}
     32 
     33  ~nsTransitionManager() final = default;
     34 
     35  typedef mozilla::AnimationCollection<mozilla::dom::CSSTransition>
     36      CSSTransitionCollection;
     37 
     38  /**
     39   * Update transitions for stylo.
     40   */
     41  bool UpdateTransitions(mozilla::dom::Element* aElement,
     42                         const mozilla::PseudoStyleRequest& aPseudoRequest,
     43                         const mozilla::ComputedStyle& aOldStyle,
     44                         const mozilla::ComputedStyle& aNewStyle);
     45 
     46 protected:
     47  typedef nsTArray<RefPtr<mozilla::dom::CSSTransition>>
     48      OwningCSSTransitionPtrArray;
     49 
     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                           const mozilla::PseudoStyleRequest& aPseudoRequest,
     58                           CSSTransitionCollection*& aElementTransitions,
     59                           const mozilla::ComputedStyle& aOldStyle,
     60                           const mozilla::ComputedStyle& aNewStyle);
     61 
     62  // Returns whether the transition actually started.
     63  bool ConsiderInitiatingTransition(
     64      const mozilla::CSSPropertyId&, const nsStyleUIReset& aStyle,
     65      uint32_t aTransitionIndex, float aDelay, float aDuration,
     66      mozilla::StyleTransitionBehavior aBehavior,
     67      mozilla::dom::Element* aElement,
     68      const mozilla::PseudoStyleRequest& aPseudoRequest,
     69      CSSTransitionCollection*& aElementTransitions,
     70      const mozilla::ComputedStyle& aOldStyle,
     71      const mozilla::ComputedStyle& aNewStyle,
     72      mozilla::AnimatedPropertyIDSet& aPropertiesChecked);
     73 
     74  already_AddRefed<mozilla::dom::CSSTransition> DoCreateTransition(
     75      const mozilla::CSSPropertyId& aProperty, mozilla::dom::Element* aElement,
     76      const mozilla::PseudoStyleRequest& aPseudoRequest,
     77      const mozilla::ComputedStyle& aNewStyle,
     78      CSSTransitionCollection*& aElementTransitions,
     79      mozilla::TimingParams&& aTiming, mozilla::AnimationValue&& aStartValue,
     80      mozilla::AnimationValue&& aEndValue,
     81      mozilla::AnimationValue&& aStartForReversingTest, double aReversePortion);
     82 
     83  void DoCancelTransition(mozilla::dom::Element* aElement,
     84                          const mozilla::PseudoStyleRequest& aPseudoRequest,
     85                          CSSTransitionCollection*& aElementTransitions,
     86                          size_t aIndex);
     87 };
     88 
     89 #endif /* !defined(nsTransitionManager_h_) */