From 073241f09104fb6bd6e8a02aee2f148394b32f81 Mon Sep 17 00:00:00 2001 From: Markus Stange Date: Fri, 12 Feb 2021 00:32:06 +0000 Subject: [PATCH] Bug 1691861 - Remove unused mContentType fields. r=mconley This code seems to have been broken quite some time ago, but without adverse effect. I have filed bug 1691868 so that a proper fix can be found. In the meantime, this preserves the current behavior and is less confusing. Differential Revision: https://phabricator.services.mozilla.com/D104634 --- widget/IconLoader.cpp | 13 ++++++++----- widget/IconLoader.h | 2 -- widget/cocoa/nsMenuItemIconX.h | 1 - widget/cocoa/nsMenuItemIconX.mm | 6 ------ 4 files changed, 8 insertions(+), 14 deletions(-) diff --git a/widget/IconLoader.cpp b/widget/IconLoader.cpp index 4b38bf573dc17..7c53195bf37d5 100644 --- a/widget/IconLoader.cpp +++ b/widget/IconLoader.cpp @@ -11,6 +11,7 @@ #include "mozilla/dom/Document.h" #include "nsContentUtils.h" #include "nsIContent.h" +#include "nsIContentPolicy.h" using namespace mozilla; @@ -18,9 +19,7 @@ namespace mozilla::widget { NS_IMPL_ISUPPORTS(IconLoader, imgINotificationObserver) -IconLoader::IconLoader(Listener* aListener) - : mContentType(nsIContentPolicy::TYPE_INTERNAL_IMAGE), - mListener(aListener) {} +IconLoader::IconLoader(Listener* aListener) : mListener(aListener) {} IconLoader::~IconLoader() { Destroy(); } @@ -60,13 +59,17 @@ nsresult IconLoader::LoadIcon(nsIURI* aIconURI, nsINode* aNode, if (aIsInternalIcon) { rv = loader->LoadImage( aIconURI, nullptr, nullptr, nullptr, 0, loadGroup, this, nullptr, - nullptr, nsIRequest::LOAD_NORMAL, nullptr, mContentType, u""_ns, + nullptr, nsIRequest::LOAD_NORMAL, nullptr, + nsIContentPolicy::TYPE_INTERNAL_IMAGE, u""_ns, /* aUseUrgentStartForChannel */ false, /* aLinkPreload */ false, getter_AddRefs(mIconRequest)); } else { + // TODO: nsIContentPolicy::TYPE_INTERNAL_IMAGE may not be the correct + // policy. See bug 1691868 for more details. rv = loader->LoadImage( aIconURI, nullptr, nullptr, aNode->NodePrincipal(), 0, loadGroup, this, - aNode, document, nsIRequest::LOAD_NORMAL, nullptr, mContentType, u""_ns, + aNode, document, nsIRequest::LOAD_NORMAL, nullptr, + nsIContentPolicy::TYPE_INTERNAL_IMAGE, u""_ns, /* aUseUrgentStartForChannel */ false, /* aLinkPreload */ false, getter_AddRefs(mIconRequest)); } diff --git a/widget/IconLoader.h b/widget/IconLoader.h index 9bcec7f8519c9..f665df6fc5753 100644 --- a/widget/IconLoader.h +++ b/widget/IconLoader.h @@ -9,7 +9,6 @@ #include "imgINotificationObserver.h" #include "mozilla/RefPtr.h" #include "nsCOMPtr.h" -#include "nsIContentPolicy.h" #include "nsISupports.h" class nsIURI; @@ -57,7 +56,6 @@ class IconLoader : public imgINotificationObserver { virtual ~IconLoader(); private: - nsContentPolicyType mContentType; RefPtr mIconRequest; // The listener, which is notified when loading completes. diff --git a/widget/cocoa/nsMenuItemIconX.h b/widget/cocoa/nsMenuItemIconX.h index 3bb20bd736288..ea0c0a225be6b 100644 --- a/widget/cocoa/nsMenuItemIconX.h +++ b/widget/cocoa/nsMenuItemIconX.h @@ -51,7 +51,6 @@ class nsMenuItemIconX : public mozilla::widget::IconLoader::Listener { protected: nsCOMPtr mContent; - nsContentPolicyType mContentType; nsMenuObjectX* mMenuObject; // [weak] nsIntRect mImageRegionRect; bool mSetIcon; diff --git a/widget/cocoa/nsMenuItemIconX.mm b/widget/cocoa/nsMenuItemIconX.mm index af94f5dc5d74e..b501672cb73f4 100644 --- a/widget/cocoa/nsMenuItemIconX.mm +++ b/widget/cocoa/nsMenuItemIconX.mm @@ -44,7 +44,6 @@ nsMenuItemIconX::nsMenuItemIconX(nsMenuObjectX* aMenuItem, nsIContent* aContent, NSMenuItem* aNativeMenuItem) : mContent(aContent), - mContentType(nsIContentPolicy::TYPE_INTERNAL_IMAGE), mMenuObject(aMenuItem), mSetIcon(false), mNativeMenuItem(aNativeMenuItem) { @@ -160,11 +159,6 @@ return NS_ERROR_FAILURE; } } else { - uint64_t dummy = 0; - nsCOMPtr triggeringPrincipal = mContent->NodePrincipal(); - nsContentUtils::GetContentPolicyTypeForUIImageLoading( - mContent, getter_AddRefs(triggeringPrincipal), mContentType, &dummy); - // If this menu item shouldn't have an icon, the string will be empty, // and NS_NewURI will fail. rv = NS_NewURI(getter_AddRefs(iconURI), imageURIString);