summaryrefslogtreecommitdiffstats
path: root/dom/canvas/nsICanvasRenderingContextInternal.cpp
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:14:29 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:14:29 +0000
commitfbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8 (patch)
tree4c1ccaf5486d4f2009f9a338a98a83e886e29c97 /dom/canvas/nsICanvasRenderingContextInternal.cpp
parentReleasing progress-linux version 124.0.1-1~progress7.99u1. (diff)
downloadfirefox-fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8.tar.xz
firefox-fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8.zip
Merging upstream version 125.0.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/canvas/nsICanvasRenderingContextInternal.cpp')
-rw-r--r--dom/canvas/nsICanvasRenderingContextInternal.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/dom/canvas/nsICanvasRenderingContextInternal.cpp b/dom/canvas/nsICanvasRenderingContextInternal.cpp
index c463a00a1a..ca8e16136c 100644
--- a/dom/canvas/nsICanvasRenderingContextInternal.cpp
+++ b/dom/canvas/nsICanvasRenderingContextInternal.cpp
@@ -7,9 +7,12 @@
#include "mozilla/dom/CanvasUtils.h"
#include "mozilla/dom/Document.h"
+#include "mozilla/dom/Event.h"
#include "mozilla/dom/WorkerCommon.h"
#include "mozilla/dom/WorkerPrivate.h"
+#include "mozilla/ErrorResult.h"
#include "mozilla/PresShell.h"
+#include "nsContentUtils.h"
#include "nsPIDOMWindow.h"
#include "nsRefreshDriver.h"
@@ -116,3 +119,24 @@ bool nsICanvasRenderingContextInternal::ShouldResistFingerprinting(
// Last resort, just check the global preference
return nsContentUtils::ShouldResistFingerprinting("Fallback", aTarget);
}
+
+bool nsICanvasRenderingContextInternal::DispatchEvent(
+ const nsAString& eventName, mozilla::CanBubble aCanBubble,
+ mozilla::Cancelable aIsCancelable) const {
+ bool useDefaultHandler = true;
+
+ if (mCanvasElement) {
+ nsContentUtils::DispatchTrustedEvent(mCanvasElement->OwnerDoc(),
+ mCanvasElement, eventName, aCanBubble,
+ aIsCancelable, &useDefaultHandler);
+ } else if (mOffscreenCanvas) {
+ // OffscreenCanvas case
+ auto event = mozilla::MakeRefPtr<mozilla::dom::Event>(mOffscreenCanvas,
+ nullptr, nullptr);
+ event->InitEvent(eventName, aCanBubble, aIsCancelable);
+ event->SetTrusted(true);
+ useDefaultHandler = mOffscreenCanvas->DispatchEvent(
+ *event, mozilla::dom::CallerType::System, mozilla::IgnoreErrors());
+ }
+ return useDefaultHandler;
+}