summaryrefslogtreecommitdiffstats
path: root/dom/animation
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-15 03:34:42 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-15 03:34:42 +0000
commitda4c7e7ed675c3bf405668739c3012d140856109 (patch)
treecdd868dba063fecba609a1d819de271f0d51b23e /dom/animation
parentAdding upstream version 125.0.3. (diff)
downloadfirefox-da4c7e7ed675c3bf405668739c3012d140856109.tar.xz
firefox-da4c7e7ed675c3bf405668739c3012d140856109.zip
Adding upstream version 126.0.upstream/126.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/animation')
-rw-r--r--dom/animation/Animation.cpp30
-rw-r--r--dom/animation/Animation.h4
-rw-r--r--dom/animation/AnimationEventDispatcher.cpp4
-rw-r--r--dom/animation/AnimationEventDispatcher.h34
-rw-r--r--dom/animation/test/chrome.toml4
5 files changed, 46 insertions, 30 deletions
diff --git a/dom/animation/Animation.cpp b/dom/animation/Animation.cpp
index ad52495e67..fbfd689c9a 100644
--- a/dom/animation/Animation.cpp
+++ b/dom/animation/Animation.cpp
@@ -11,7 +11,6 @@
#include "AnimationUtils.h"
#include "mozAutoDocUpdate.h"
#include "mozilla/dom/AnimationBinding.h"
-#include "mozilla/dom/AnimationPlaybackEvent.h"
#include "mozilla/dom/Document.h"
#include "mozilla/dom/DocumentInlines.h"
#include "mozilla/dom/DocumentTimeline.h"
@@ -645,7 +644,8 @@ void Animation::Cancel(PostRestyleMode aPostRestyle) {
}
ResetFinishedPromise();
- QueuePlaybackEvent(u"cancel"_ns, GetTimelineCurrentTimeAsTimeStamp());
+ QueuePlaybackEvent(nsGkAtoms::oncancel,
+ GetTimelineCurrentTimeAsTimeStamp());
}
StickyTimeDuration activeTime =
@@ -1189,7 +1189,7 @@ void Animation::Remove() {
UpdateEffect(PostRestyleMode::IfNeeded);
PostUpdate();
- QueuePlaybackEvent(u"remove"_ns, GetTimelineCurrentTimeAsTimeStamp());
+ QueuePlaybackEvent(nsGkAtoms::onremove, GetTimelineCurrentTimeAsTimeStamp());
}
bool Animation::HasLowerCompositeOrderThan(const Animation& aOther) const {
@@ -1869,10 +1869,11 @@ void Animation::DoFinishNotificationImmediately(MicroTaskRunnable* aAsync) {
MaybeResolveFinishedPromise();
- QueuePlaybackEvent(u"finish"_ns, AnimationTimeToTimeStamp(EffectEnd()));
+ QueuePlaybackEvent(nsGkAtoms::onfinish,
+ AnimationTimeToTimeStamp(EffectEnd()));
}
-void Animation::QueuePlaybackEvent(const nsAString& aName,
+void Animation::QueuePlaybackEvent(nsAtom* aOnEvent,
TimeStamp&& aScheduledEventTime) {
// Use document for timing.
// https://drafts.csswg.org/web-animations-1/#document-for-timing
@@ -1886,20 +1887,19 @@ void Animation::QueuePlaybackEvent(const nsAString& aName,
return;
}
- AnimationPlaybackEventInit init;
- if (aName.EqualsLiteral("finish") || aName.EqualsLiteral("remove")) {
- init.mCurrentTime = GetCurrentTimeAsDouble();
+ Nullable<double> currentTime;
+ if (aOnEvent == nsGkAtoms::onfinish || aOnEvent == nsGkAtoms::onremove) {
+ currentTime = GetCurrentTimeAsDouble();
}
+
+ Nullable<double> timelineTime;
if (mTimeline) {
- init.mTimelineTime = mTimeline->GetCurrentTimeAsDouble();
+ timelineTime = mTimeline->GetCurrentTimeAsDouble();
}
- RefPtr<AnimationPlaybackEvent> event =
- AnimationPlaybackEvent::Constructor(this, aName, init);
- event->SetTrusted(true);
-
- presContext->AnimationEventDispatcher()->QueueEvent(AnimationEventInfo(
- std::move(event), std::move(aScheduledEventTime), this));
+ presContext->AnimationEventDispatcher()->QueueEvent(
+ AnimationEventInfo(aOnEvent, currentTime, timelineTime,
+ std::move(aScheduledEventTime), this));
}
bool Animation::IsRunningOnCompositor() const {
diff --git a/dom/animation/Animation.h b/dom/animation/Animation.h
index d7edfedfc2..e80370370e 100644
--- a/dom/animation/Animation.h
+++ b/dom/animation/Animation.h
@@ -26,6 +26,7 @@ struct JSContext;
class nsCSSPropertyIDSet;
class nsIFrame;
class nsIGlobalObject;
+class nsAtom;
namespace mozilla {
@@ -450,8 +451,7 @@ class Animation : public DOMEventTargetHelper,
void DoFinishNotification(SyncNotifyFlag aSyncNotifyFlag);
friend class AsyncFinishNotification;
void DoFinishNotificationImmediately(MicroTaskRunnable* aAsync = nullptr);
- void QueuePlaybackEvent(const nsAString& aName,
- TimeStamp&& aScheduledEventTime);
+ void QueuePlaybackEvent(nsAtom* aOnEvent, TimeStamp&& aScheduledEventTime);
/**
* Remove this animation from the pending animation tracker and reset
diff --git a/dom/animation/AnimationEventDispatcher.cpp b/dom/animation/AnimationEventDispatcher.cpp
index 86884abbe5..0ec5686d8f 100644
--- a/dom/animation/AnimationEventDispatcher.cpp
+++ b/dom/animation/AnimationEventDispatcher.cpp
@@ -91,10 +91,6 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(AnimationEventDispatcher)
ImplCycleCollectionTraverse(
cb, target->mElement,
"mozilla::AnimationEventDispatcher.mPendingEvents.mTarget");
- } else {
- ImplCycleCollectionTraverse(
- cb, info.mData.as<AnimationEventInfo::WebAnimationData>().mEvent,
- "mozilla::AnimationEventDispatcher.mPendingEvents.mEvent");
}
ImplCycleCollectionTraverse(
cb, info.mAnimation,
diff --git a/dom/animation/AnimationEventDispatcher.h b/dom/animation/AnimationEventDispatcher.h
index 98d1557901..dc11972f6d 100644
--- a/dom/animation/AnimationEventDispatcher.h
+++ b/dom/animation/AnimationEventDispatcher.h
@@ -12,6 +12,7 @@
#include "mozilla/Attributes.h"
#include "mozilla/ContentEvents.h"
#include "mozilla/EventDispatcher.h"
+#include "mozilla/EventListenerManager.h"
#include "mozilla/Variant.h"
#include "mozilla/dom/AnimationPlaybackEvent.h"
#include "mozilla/dom/KeyframeEffect.h"
@@ -44,7 +45,10 @@ struct AnimationEventInfo {
};
struct WebAnimationData {
- RefPtr<dom::AnimationPlaybackEvent> mEvent;
+ const RefPtr<nsAtom> mOnEvent;
+ const dom::Nullable<double> mCurrentTime;
+ const dom::Nullable<double> mTimelineTime;
+ const TimeStamp mEventEnqueueTimeStamp{TimeStamp::Now()};
};
using Data = Variant<CssAnimationData, CssTransitionData, WebAnimationData>;
@@ -100,12 +104,15 @@ struct AnimationEventInfo {
}
// For web animation events
- AnimationEventInfo(RefPtr<dom::AnimationPlaybackEvent>&& aEvent,
+ AnimationEventInfo(nsAtom* aOnEvent,
+ const dom::Nullable<double>& aCurrentTime,
+ const dom::Nullable<double>& aTimelineTime,
TimeStamp&& aScheduledEventTimeStamp,
dom::Animation* aAnimation)
: mAnimation(aAnimation),
mScheduledEventTimeStamp(std::move(aScheduledEventTimeStamp)),
- mData(WebAnimationData{std::move(aEvent)}) {}
+ mData(WebAnimationData{RefPtr{aOnEvent}, aCurrentTime, aTimelineTime}) {
+ }
AnimationEventInfo(const AnimationEventInfo& aOther) = delete;
AnimationEventInfo& operator=(const AnimationEventInfo& aOther) = delete;
@@ -137,10 +144,27 @@ struct AnimationEventInfo {
// TODO: Convert this to MOZ_CAN_RUN_SCRIPT (bug 1415230)
MOZ_CAN_RUN_SCRIPT_BOUNDARY void Dispatch(nsPresContext* aPresContext) {
if (mData.is<WebAnimationData>()) {
- RefPtr playbackEvent = mData.as<WebAnimationData>().mEvent;
+ const auto& data = mData.as<WebAnimationData>();
+ EventListenerManager* elm = mAnimation->GetExistingListenerManager();
+ if (!elm || !elm->HasListenersFor(data.mOnEvent)) {
+ return;
+ }
+
+ dom::AnimationPlaybackEventInit init;
+ init.mCurrentTime = data.mCurrentTime;
+ init.mTimelineTime = data.mTimelineTime;
+ MOZ_ASSERT(nsDependentAtomString(data.mOnEvent).Find(u"on"_ns) == 0,
+ "mOnEvent atom should start with 'on'!");
+ RefPtr<dom::AnimationPlaybackEvent> event =
+ dom::AnimationPlaybackEvent::Constructor(
+ mAnimation, Substring(nsDependentAtomString(data.mOnEvent), 2),
+ init);
+ event->SetTrusted(true);
+ event->WidgetEventPtr()->AssignEventTime(
+ WidgetEventTime(data.mEventEnqueueTimeStamp));
RefPtr target = mAnimation;
EventDispatcher::DispatchDOMEvent(target, nullptr /* WidgetEvent */,
- playbackEvent, aPresContext,
+ event, aPresContext,
nullptr /* nsEventStatus */);
return;
}
diff --git a/dom/animation/test/chrome.toml b/dom/animation/test/chrome.toml
index fa1d21457c..0783d9bb5a 100644
--- a/dom/animation/test/chrome.toml
+++ b/dom/animation/test/chrome.toml
@@ -5,10 +5,6 @@ prefs = [
"layout.css.basic-shape-rect.enabled=true",
"layout.css.basic-shape-xywh.enabled=true",
"layout.css.individual-transform.enabled=true",
- "layout.css.motion-path-basic-shapes.enabled=true",
- "layout.css.motion-path-coord-box.enabled=true",
- "layout.css.motion-path-offset-position.enabled=true",
- "layout.css.motion-path-ray.enabled=true",
]
support-files = [
"testcommon.js",