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 "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));
}

View File

@@ -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<imgRequestProxy> mIconRequest;
// The listener, which is notified when loading completes.

View File

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

View File

@@ -44,7 +44,6 @@ static const uint32_t kIconSize = 16;
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 @@ nsresult nsMenuItemIconX::GetIconURI(nsIURI** aIconURI) {
return NS_ERROR_FAILURE;
}
} 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,
// and NS_NewURI will fail.
rv = NS_NewURI(getter_AddRefs(iconURI), imageURIString);