summaryrefslogtreecommitdiffstats
path: root/dom/animation/ElementAnimationData.cpp
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /dom/animation/ElementAnimationData.cpp
parentInitial commit. (diff)
downloadfirefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz
firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/animation/ElementAnimationData.cpp')
-rw-r--r--dom/animation/ElementAnimationData.cpp126
1 files changed, 126 insertions, 0 deletions
diff --git a/dom/animation/ElementAnimationData.cpp b/dom/animation/ElementAnimationData.cpp
new file mode 100644
index 0000000000..d87caf8a58
--- /dev/null
+++ b/dom/animation/ElementAnimationData.cpp
@@ -0,0 +1,126 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "ElementAnimationData.h"
+#include "mozilla/AnimationCollection.h"
+#include "mozilla/TimelineCollection.h"
+#include "mozilla/EffectSet.h"
+#include "mozilla/dom/CSSTransition.h"
+#include "mozilla/dom/CSSAnimation.h"
+#include "mozilla/dom/ScrollTimeline.h"
+#include "mozilla/dom/ViewTimeline.h"
+
+namespace mozilla {
+
+void ElementAnimationData::Traverse(nsCycleCollectionTraversalCallback& cb) {
+ mElementData.Traverse(cb);
+ mBeforeData.Traverse(cb);
+ mAfterData.Traverse(cb);
+ mMarkerData.Traverse(cb);
+}
+
+void ElementAnimationData::ClearAllAnimationCollections() {
+ for (auto* data : {&mElementData, &mBeforeData, &mAfterData, &mMarkerData}) {
+ data->mAnimations = nullptr;
+ data->mTransitions = nullptr;
+ data->mScrollTimelines = nullptr;
+ data->mViewTimelines = nullptr;
+ data->mProgressTimelineScheduler = nullptr;
+ }
+}
+
+ElementAnimationData::PerElementOrPseudoData::PerElementOrPseudoData() =
+ default;
+ElementAnimationData::PerElementOrPseudoData::~PerElementOrPseudoData() =
+ default;
+
+void ElementAnimationData::PerElementOrPseudoData::Traverse(
+ nsCycleCollectionTraversalCallback& cb) {
+ // We only care about mEffectSet. The animation collections are managed by the
+ // pres context and go away when presentation of the document goes away.
+ if (mEffectSet) {
+ mEffectSet->Traverse(cb);
+ }
+}
+
+EffectSet& ElementAnimationData::PerElementOrPseudoData::DoEnsureEffectSet() {
+ MOZ_ASSERT(!mEffectSet);
+ mEffectSet = MakeUnique<EffectSet>();
+ return *mEffectSet;
+}
+
+CSSTransitionCollection&
+ElementAnimationData::PerElementOrPseudoData::DoEnsureTransitions(
+ dom::Element& aOwner, PseudoStyleType aType) {
+ MOZ_ASSERT(!mTransitions);
+ mTransitions = MakeUnique<CSSTransitionCollection>(aOwner, aType);
+ return *mTransitions;
+}
+
+CSSAnimationCollection&
+ElementAnimationData::PerElementOrPseudoData::DoEnsureAnimations(
+ dom::Element& aOwner, PseudoStyleType aType) {
+ MOZ_ASSERT(!mAnimations);
+ mAnimations = MakeUnique<CSSAnimationCollection>(aOwner, aType);
+ return *mAnimations;
+}
+
+ScrollTimelineCollection&
+ElementAnimationData::PerElementOrPseudoData::DoEnsureScrollTimelines(
+ dom::Element& aOwner, PseudoStyleType aType) {
+ MOZ_ASSERT(!mScrollTimelines);
+ mScrollTimelines = MakeUnique<ScrollTimelineCollection>(aOwner, aType);
+ return *mScrollTimelines;
+}
+
+ViewTimelineCollection&
+ElementAnimationData::PerElementOrPseudoData::DoEnsureViewTimelines(
+ dom::Element& aOwner, PseudoStyleType aType) {
+ MOZ_ASSERT(!mViewTimelines);
+ mViewTimelines = MakeUnique<ViewTimelineCollection>(aOwner, aType);
+ return *mViewTimelines;
+}
+
+dom::ProgressTimelineScheduler&
+ElementAnimationData::PerElementOrPseudoData::DoEnsureProgressTimelineScheduler(
+ dom::Element& aOwner, PseudoStyleType aType) {
+ MOZ_ASSERT(!mProgressTimelineScheduler);
+ mProgressTimelineScheduler = MakeUnique<dom::ProgressTimelineScheduler>();
+ return *mProgressTimelineScheduler;
+}
+
+void ElementAnimationData::PerElementOrPseudoData::DoClearEffectSet() {
+ MOZ_ASSERT(mEffectSet);
+ mEffectSet = nullptr;
+}
+
+void ElementAnimationData::PerElementOrPseudoData::DoClearTransitions() {
+ MOZ_ASSERT(mTransitions);
+ mTransitions = nullptr;
+}
+
+void ElementAnimationData::PerElementOrPseudoData::DoClearAnimations() {
+ MOZ_ASSERT(mAnimations);
+ mAnimations = nullptr;
+}
+
+void ElementAnimationData::PerElementOrPseudoData::DoClearScrollTimelines() {
+ MOZ_ASSERT(mScrollTimelines);
+ mScrollTimelines = nullptr;
+}
+
+void ElementAnimationData::PerElementOrPseudoData::DoClearViewTimelines() {
+ MOZ_ASSERT(mViewTimelines);
+ mViewTimelines = nullptr;
+}
+
+void ElementAnimationData::PerElementOrPseudoData::
+ DoClearProgressTimelineScheduler() {
+ MOZ_ASSERT(mProgressTimelineScheduler);
+ mProgressTimelineScheduler = nullptr;
+}
+
+} // namespace mozilla