Bug 1839315: part 4) Link from `SheetLoadData::mWasAlternate` to spec. r=emilio DONTBUILD
[gecko.git] / layout / style / TimelineManager.h
blobf52302a66162e4be4f7731b829bb4af41d6f9d19
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 private:
55 template <typename StyleType, typename TimelineType>
56 void DoUpdateTimelines(nsPresContext* aPresContext, dom::Element* aElement,
57 PseudoStyleType aPseudoType,
58 const nsStyleAutoArray<StyleType>& aStyleTimelines,
59 size_t aTimelineCount);
61 template <typename T>
62 void AddTimelineCollection(TimelineCollection<T>* aCollection);
64 LinkedList<TimelineCollection<dom::ScrollTimeline>>
65 mScrollTimelineCollections;
66 LinkedList<TimelineCollection<dom::ViewTimeline>> mViewTimelineCollections;
67 nsPresContext* mPresContext;
70 template <>
71 inline void TimelineManager::AddTimelineCollection(
72 TimelineCollection<dom::ScrollTimeline>* aCollection) {
73 mScrollTimelineCollections.insertBack(aCollection);
76 template <>
77 inline void TimelineManager::AddTimelineCollection(
78 TimelineCollection<dom::ViewTimeline>* aCollection) {
79 mViewTimelineCollections.insertBack(aCollection);
82 } // namespace mozilla
84 #endif // mozilla_TimelineManager_h