From b7b30e5a1dab00826ee467ecf2b1cc7b38e4eef1 Mon Sep 17 00:00:00 2001 From: Dan Robertson Date: Wed, 28 Sep 2022 03:56:57 +0000 Subject: [PATCH] Bug 1655598 - The imgIRequest uri attribute should be infallible. r=emilio The implementation of GetURI always returns NS_OK, and therefore the URI can be marked as infallible. Differential Revision: https://phabricator.services.mozilla.com/D157009 --- dom/base/nsContentAreaDragDrop.cpp | 3 +-- image/imgIRequest.idl | 2 +- layout/base/nsRefreshDriver.cpp | 6 ++---- layout/generic/nsImageFrame.cpp | 3 +-- 4 files changed, 5 insertions(+), 9 deletions(-) diff --git a/dom/base/nsContentAreaDragDrop.cpp b/dom/base/nsContentAreaDragDrop.cpp index f3afebb4eee8..7bf42580ecfa 100644 --- a/dom/base/nsContentAreaDragDrop.cpp +++ b/dom/base/nsContentAreaDragDrop.cpp @@ -384,8 +384,7 @@ void DragDataProducer::CreateLinkText(const nsAString& inURL, nsresult DragDataProducer::GetImageData(imgIContainer* aImage, imgIRequest* aRequest) { - nsCOMPtr imgUri; - aRequest->GetURI(getter_AddRefs(imgUri)); + nsCOMPtr imgUri = aRequest->GetURI(); nsCOMPtr imgUrl(do_QueryInterface(imgUri)); if (imgUrl) { diff --git a/image/imgIRequest.idl b/image/imgIRequest.idl index 0a5bb6285f81..12b530a529f3 100644 --- a/image/imgIRequest.idl +++ b/image/imgIRequest.idl @@ -89,7 +89,7 @@ interface imgIRequest : nsIRequest * actual URI for the image (e.g. if HTTP redirects happened during the * load). */ - readonly attribute nsIURI URI; + [infallible] readonly attribute nsIURI URI; /** * The URI of the resource we ended up loading after all redirects, etc. diff --git a/layout/base/nsRefreshDriver.cpp b/layout/base/nsRefreshDriver.cpp index 49b0c3de76fd..edaab6df908e 100644 --- a/layout/base/nsRefreshDriver.cpp +++ b/layout/base/nsRefreshDriver.cpp @@ -1527,8 +1527,7 @@ void nsRefreshDriver::AddImageRequest(imgIRequest* aRequest) { EnsureTimerStarted(); if (profiler_thread_is_being_profiled_for_markers()) { - nsCOMPtr uri; - aRequest->GetURI(getter_AddRefs(uri)); + nsCOMPtr uri = aRequest->GetURI(); nsAutoCString uristr; uri->GetAsciiSpec(uristr); @@ -1552,8 +1551,7 @@ void nsRefreshDriver::RemoveImageRequest(imgIRequest* aRequest) { } if (removed && profiler_thread_is_being_profiled_for_markers()) { - nsCOMPtr uri; - aRequest->GetURI(getter_AddRefs(uri)); + nsCOMPtr uri = aRequest->GetURI(); nsAutoCString uristr; uri->GetAsciiSpec(uristr); diff --git a/layout/generic/nsImageFrame.cpp b/layout/generic/nsImageFrame.cpp index 60e7747ed9d0..892da6a82f21 100644 --- a/layout/generic/nsImageFrame.cpp +++ b/layout/generic/nsImageFrame.cpp @@ -2629,8 +2629,7 @@ void nsImageFrame::List(FILE* out, const char* aPrefix, // output the img src url if (nsCOMPtr currentRequest = GetCurrentRequest()) { - nsCOMPtr uri; - currentRequest->GetURI(getter_AddRefs(uri)); + nsCOMPtr uri = currentRequest->GetURI(); nsAutoCString uristr; uri->GetAsciiSpec(uristr); str += nsPrintfCString(" [src=%s]", uristr.get());