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
This commit is contained in:
Markus Stange
2021-02-12 00:32:06 +00:00
parent 6266a3a9bc
commit 971acb9fde
4 changed files with 8 additions and 14 deletions

View File

@@ -11,6 +11,7 @@
#include "mozilla/dom/Document.h" #include "mozilla/dom/Document.h"
#include "nsContentUtils.h" #include "nsContentUtils.h"
#include "nsIContent.h" #include "nsIContent.h"
#include "nsIContentPolicy.h"
using namespace mozilla; using namespace mozilla;
@@ -18,9 +19,7 @@ namespace mozilla::widget {
NS_IMPL_ISUPPORTS(IconLoader, imgINotificationObserver) NS_IMPL_ISUPPORTS(IconLoader, imgINotificationObserver)
IconLoader::IconLoader(Listener* aListener) IconLoader::IconLoader(Listener* aListener) : mListener(aListener) {}
: mContentType(nsIContentPolicy::TYPE_INTERNAL_IMAGE),
mListener(aListener) {}
IconLoader::~IconLoader() { Destroy(); } IconLoader::~IconLoader() { Destroy(); }
@@ -60,13 +59,17 @@ nsresult IconLoader::LoadIcon(nsIURI* aIconURI, nsINode* aNode,
if (aIsInternalIcon) { if (aIsInternalIcon) {
rv = loader->LoadImage( rv = loader->LoadImage(
aIconURI, nullptr, nullptr, nullptr, 0, loadGroup, this, nullptr, 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, /* aUseUrgentStartForChannel */ false, /* aLinkPreload */ false,
getter_AddRefs(mIconRequest)); getter_AddRefs(mIconRequest));
} else { } else {
// TODO: nsIContentPolicy::TYPE_INTERNAL_IMAGE may not be the correct
// policy. See bug 1691868 for more details.
rv = loader->LoadImage( rv = loader->LoadImage(
aIconURI, nullptr, nullptr, aNode->NodePrincipal(), 0, loadGroup, this, 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, /* aUseUrgentStartForChannel */ false,
/* aLinkPreload */ false, getter_AddRefs(mIconRequest)); /* aLinkPreload */ false, getter_AddRefs(mIconRequest));
} }

View File

@@ -9,7 +9,6 @@
#include "imgINotificationObserver.h" #include "imgINotificationObserver.h"
#include "mozilla/RefPtr.h" #include "mozilla/RefPtr.h"
#include "nsCOMPtr.h" #include "nsCOMPtr.h"
#include "nsIContentPolicy.h"
#include "nsISupports.h" #include "nsISupports.h"
class nsIURI; class nsIURI;
@@ -57,7 +56,6 @@ class IconLoader : public imgINotificationObserver {
virtual ~IconLoader(); virtual ~IconLoader();
private: private:
nsContentPolicyType mContentType;
RefPtr<imgRequestProxy> mIconRequest; RefPtr<imgRequestProxy> mIconRequest;
// The listener, which is notified when loading completes. // The listener, which is notified when loading completes.

View File

@@ -51,7 +51,6 @@ class nsMenuItemIconX : public mozilla::widget::IconLoader::Listener {
protected: protected:
nsCOMPtr<nsIContent> mContent; nsCOMPtr<nsIContent> mContent;
nsContentPolicyType mContentType;
nsMenuObjectX* mMenuObject; // [weak] nsMenuObjectX* mMenuObject; // [weak]
nsIntRect mImageRegionRect; nsIntRect mImageRegionRect;
bool mSetIcon; bool mSetIcon;

View File

@@ -44,7 +44,6 @@ static const uint32_t kIconSize = 16;
nsMenuItemIconX::nsMenuItemIconX(nsMenuObjectX* aMenuItem, nsIContent* aContent, nsMenuItemIconX::nsMenuItemIconX(nsMenuObjectX* aMenuItem, nsIContent* aContent,
NSMenuItem* aNativeMenuItem) NSMenuItem* aNativeMenuItem)
: mContent(aContent), : mContent(aContent),
mContentType(nsIContentPolicy::TYPE_INTERNAL_IMAGE),
mMenuObject(aMenuItem), mMenuObject(aMenuItem),
mSetIcon(false), mSetIcon(false),
mNativeMenuItem(aNativeMenuItem) { mNativeMenuItem(aNativeMenuItem) {
@@ -160,11 +159,6 @@ nsresult nsMenuItemIconX::GetIconURI(nsIURI** aIconURI) {
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
} else { } else {
uint64_t dummy = 0;
nsCOMPtr<nsIPrincipal> 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, // If this menu item shouldn't have an icon, the string will be empty,
// and NS_NewURI will fail. // and NS_NewURI will fail.
rv = NS_NewURI(getter_AddRefs(iconURI), imageURIString); rv = NS_NewURI(getter_AddRefs(iconURI), imageURIString);