From fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 03:14:29 +0200 Subject: Merging upstream version 125.0.1. Signed-off-by: Daniel Baumann --- image/imgRequest.cpp | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) (limited to 'image/imgRequest.cpp') diff --git a/image/imgRequest.cpp b/image/imgRequest.cpp index 47bdd3480c..9713d2f33e 100644 --- a/image/imgRequest.cpp +++ b/image/imgRequest.cpp @@ -334,8 +334,7 @@ void imgRequest::Cancel(nsresult aStatus) { if (NS_IsMainThread()) { ContinueCancel(aStatus); } else { - RefPtr progressTracker = GetProgressTracker(); - nsCOMPtr eventTarget = progressTracker->GetEventTarget(); + nsCOMPtr eventTarget = GetMainThreadSerialEventTarget(); nsCOMPtr ev = new imgRequestMainThreadCancel(this, aStatus); eventTarget->Dispatch(ev.forget(), NS_DISPATCH_NORMAL); } @@ -1027,26 +1026,23 @@ imgRequest::OnDataAvailable(nsIRequest* aRequest, nsIInputStream* aInStr, if (result.mImage) { image = result.mImage; - nsCOMPtr eventTarget; // Update our state to reflect this new part. { MutexAutoLock lock(mMutex); mImage = image; - // We only get an event target if we are not on the main thread, because - // we have to dispatch in that case. If we are on the main thread, but - // on a different scheduler group than ProgressTracker would give us, - // that is okay because nothing in imagelib requires that, just our - // listeners (which have their own checks). - if (!NS_IsMainThread()) { - eventTarget = mProgressTracker->GetEventTarget(); - MOZ_ASSERT(eventTarget); - } - mProgressTracker = nullptr; } + // We only get an event target if we are not on the main thread, because + // we have to dispatch in that case. + nsCOMPtr eventTarget; + if (!NS_IsMainThread()) { + eventTarget = GetMainThreadSerialEventTarget(); + MOZ_ASSERT(eventTarget); + } + // Some property objects are not threadsafe, and we need to send // OnImageAvailable on the main thread, so finish on the main thread. if (!eventTarget) { -- cgit v1.2.3