Bug 1879449 [wpt PR 44489] - [wptrunner] Add `infrastructure/expected-fail/` test...
[gecko.git] / layout / style / TimelineManager.h
blob3fc31a719c23e4927f3597c388ab9e99b6763f25
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 #ifndef mozilla_TimelineManager_h
7 #define mozilla_TimelineManager_h
9 #include "mozilla/Assertions.h"
10 #include "mozilla/LinkedList.h"
11 #include "mozilla/TimelineCollection.h"
12 #include "nsStyleAutoArray.h"
14 class nsPresContext;
16 namespace mozilla {
17 class ComputedStyle;
18 enum class PseudoStyleType : uint8_t;
20 namespace dom {
21 class Element;
22 class ScrollTimeline;
23 class ViewTimeline;
24 } // namespace dom
26 class TimelineManager {
27 public:
28 explicit TimelineManager(nsPresContext* aPresContext)
29 : mPresContext(aPresContext) {}
31 ~TimelineManager() {
32 MOZ_ASSERT(!mPresContext, "Disconnect should have been called");
35 void Disconnect() {
36 while (auto* head = mScrollTimelineCollections.getFirst()) {
37 head->Destroy();
39 while (auto* head = mViewTimelineCollections.getFirst()) {
40 head->Destroy();
43 mPresContext = nullptr;
46 enum class ProgressTimelineType : uint8_t {
47 Scroll,
48 View,
50 void UpdateTimelines(dom::Element* aElement, PseudoStyleType aPseudoType,
51 const ComputedStyle* aComputedStyle,
52 ProgressTimelineType aType);
54 void UpdateHiddenByContentVisibilityForAnimations();
56 private:
57 template <typename StyleType, typename TimelineType>
58 void DoUpdateTimelines(nsPresContext* aPresContext, dom::Element* aElement,
59 PseudoStyleType aPseudoType,
60 const nsStyleAutoArray<StyleType>& aStyleTimelines,
61 size_t aTimelineCount);
63 template <typename T>
64 void AddTimelineCollection(TimelineCollection<T>* aCollection);
66 LinkedList<TimelineCollection<dom::ScrollTimeline>>
67 mScrollTimelineCollections;
68 LinkedList<TimelineCollection<dom::ViewTimeline>> mViewTimelineCollections;
69 nsPresContext* mPresContext;
72 template <>
73 inline void TimelineManager::AddTimelineCollection(
74 TimelineCollection<dom::ScrollTimeline>* aCollection) {
75 mScrollTimelineCollections.insertBack(aCollection);
78 template <>
79 inline void TimelineManager::AddTimelineCollection(
80 TimelineCollection<dom::ViewTimeline>* aCollection) {
81 mViewTimelineCollections.insertBack(aCollection);
84 } // namespace mozilla
86 #endif // mozilla_TimelineManager_h