2019-07-10 01:23:45 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Retrieves and displays icons in native menu items on Mac OS X.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef nsIconLoaderService_h_
|
|
|
|
#define nsIconLoaderService_h_
|
|
|
|
|
|
|
|
#include "imgINotificationObserver.h"
|
|
|
|
#include "mozilla/RefPtr.h"
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsIconLoaderObserver.h"
|
|
|
|
#include "nsIContentPolicy.h"
|
|
|
|
|
|
|
|
class nsIURI;
|
2019-07-29 15:11:19 +00:00
|
|
|
class nsIContent;
|
2019-07-10 01:23:45 +00:00
|
|
|
class nsIPrincipal;
|
|
|
|
class imgRequestProxy;
|
|
|
|
|
|
|
|
class nsIconLoaderService : public imgINotificationObserver {
|
|
|
|
public:
|
2019-08-12 13:53:38 +00:00
|
|
|
// If aScaleFactor is not specified, then an image with both regular and
|
|
|
|
// HiDPI representations will be loaded.
|
2019-07-29 15:11:19 +00:00
|
|
|
nsIconLoaderService(nsIContent* aContent, nsIntRect* aImageRegionRect,
|
2019-08-12 13:53:38 +00:00
|
|
|
RefPtr<nsIconLoaderObserver> aObserver, uint32_t aIconHeight,
|
|
|
|
uint32_t aIconWidth, CGFloat aScaleFactor = 0.0f);
|
2019-07-10 01:23:45 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_IMGINOTIFICATIONOBSERVER
|
|
|
|
|
2019-07-29 15:11:19 +00:00
|
|
|
// LoadIcon will set a placeholder image and start a load request for the
|
|
|
|
// icon. The request may not complete until after LoadIcon returns.
|
2019-07-10 01:23:45 +00:00
|
|
|
nsresult LoadIcon(nsIURI* aIconURI);
|
|
|
|
|
|
|
|
// Unless we take precautions, we may outlive the object that created us
|
|
|
|
// (mMenuObject, which owns our native menu item (mNativeMenuItem)).
|
|
|
|
// Destroy() should be called from mMenuObject's destructor to prevent
|
|
|
|
// this from happening. See bug 499600.
|
|
|
|
void Destroy();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual ~nsIconLoaderService();
|
|
|
|
|
|
|
|
private:
|
|
|
|
nsresult OnFrameComplete(imgIRequest* aRequest);
|
|
|
|
|
2019-07-29 15:11:19 +00:00
|
|
|
nsCOMPtr<nsIContent> mContent;
|
2019-07-10 01:23:45 +00:00
|
|
|
nsContentPolicyType mContentType;
|
|
|
|
RefPtr<imgRequestProxy> mIconRequest;
|
|
|
|
nsIntRect* mImageRegionRect;
|
|
|
|
bool mLoadedIcon;
|
|
|
|
NSImage* mNativeIconImage;
|
|
|
|
uint32_t mIconHeight;
|
|
|
|
uint32_t mIconWidth;
|
2019-08-12 13:53:38 +00:00
|
|
|
CGFloat mScaleFactor;
|
2019-07-10 01:23:45 +00:00
|
|
|
RefPtr<nsIconLoaderObserver> mCompletionHandler;
|
|
|
|
};
|
2019-07-29 15:11:19 +00:00
|
|
|
|
2019-07-10 01:23:45 +00:00
|
|
|
#endif // nsIconLoaderService_h_
|