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 #include "TimelineCollection.h"
9 #include "mozilla/ElementAnimationData.h"
10 #include "mozilla/dom/Element.h"
11 #include "mozilla/dom/ScrollTimeline.h"
12 #include "mozilla/dom/ViewTimeline.h"
13 #include <type_traits>
17 template <class TimelineType
>
18 TimelineCollection
<TimelineType
>::~TimelineCollection() {
19 MOZ_COUNT_DTOR(TimelineCollection
);
21 // FIXME: Bug 1774060. We have to restyle the animations which use the
22 // timelines associtated with this TimelineCollection.
24 LinkedListElement
<SelfType
>::remove();
27 template <class TimelineType
>
28 void TimelineCollection
<TimelineType
>::Destroy() {
29 auto* data
= mElement
.GetAnimationData();
31 if constexpr (std::is_same_v
<TimelineType
, dom::ScrollTimeline
>) {
32 MOZ_ASSERT(data
->GetScrollTimelineCollection(mPseudo
) == this);
33 data
->ClearScrollTimelineCollectionFor(mPseudo
);
34 } else if constexpr (std::is_same_v
<TimelineType
, dom::ViewTimeline
>) {
35 MOZ_ASSERT(data
->GetViewTimelineCollection(mPseudo
) == this);
36 data
->ClearViewTimelineCollectionFor(mPseudo
);
38 MOZ_ASSERT_UNREACHABLE("Unsupported TimelienType");
42 template <class TimelineType
>
43 /* static */ TimelineCollection
<TimelineType
>*
44 TimelineCollection
<TimelineType
>::Get(const dom::Element
* aElement
,
45 const PseudoStyleType aPseudoType
) {
47 auto* data
= aElement
->GetAnimationData();
52 if constexpr (std::is_same_v
<TimelineType
, dom::ScrollTimeline
>) {
53 return data
->GetScrollTimelineCollection(aPseudoType
);
56 if constexpr (std::is_same_v
<TimelineType
, dom::ViewTimeline
>) {
57 return data
->GetViewTimelineCollection(aPseudoType
);
63 // Explicit class instantiations
64 template class TimelineCollection
<dom::ScrollTimeline
>;
65 template class TimelineCollection
<dom::ViewTimeline
>;
67 } // namespace mozilla