Bumping manifests a=b2g-bump
[gecko.git] / widget / cocoa / nsMenuItemIconX.h
blobe43e3345cc8e808c7d54a115ee7d335232791acd
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 /*
7 * Retrieves and displays icons in native menu items on Mac OS X.
8 */
10 #ifndef nsMenuItemIconX_h_
11 #define nsMenuItemIconX_h_
13 #include "nsCOMPtr.h"
14 #include "nsAutoPtr.h"
15 #include "imgINotificationObserver.h"
17 class nsIURI;
18 class nsIContent;
19 class imgRequestProxy;
20 class nsMenuObjectX;
22 #import <Cocoa/Cocoa.h>
24 class nsMenuItemIconX : public imgINotificationObserver
26 public:
27 nsMenuItemIconX(nsMenuObjectX* aMenuItem,
28 nsIContent* aContent,
29 NSMenuItem* aNativeMenuItem);
30 private:
31 virtual ~nsMenuItemIconX();
33 public:
34 NS_DECL_ISUPPORTS
35 NS_DECL_IMGINOTIFICATIONOBSERVER
37 // SetupIcon succeeds if it was able to set up the icon, or if there should
38 // be no icon, in which case it clears any existing icon but still succeeds.
39 nsresult SetupIcon();
41 // GetIconURI fails if the item should not have any icon.
42 nsresult GetIconURI(nsIURI** aIconURI);
44 // LoadIcon will set a placeholder image and start a load request for the
45 // icon. The request may not complete until after LoadIcon returns.
46 nsresult LoadIcon(nsIURI* aIconURI);
48 // Unless we take precautions, we may outlive the object that created us
49 // (mMenuObject, which owns our native menu item (mNativeMenuItem)).
50 // Destroy() should be called from mMenuObject's destructor to prevent
51 // this from happening. See bug 499600.
52 void Destroy();
54 protected:
55 nsresult OnStopFrame(imgIRequest* aRequest);
57 nsCOMPtr<nsIContent> mContent;
58 nsRefPtr<imgRequestProxy> mIconRequest;
59 nsMenuObjectX* mMenuObject; // [weak]
60 nsIntRect mImageRegionRect;
61 bool mLoadedIcon;
62 bool mSetIcon;
63 NSMenuItem* mNativeMenuItem; // [weak]
66 #endif // nsMenuItemIconX_h_