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/. */
7 * Retrieves and displays icons in native menu items on Mac OS X.
10 #ifndef nsMenuItemIconX_h_
11 #define nsMenuItemIconX_h_
13 #include "IconLoaderHelperCocoa.h"
15 class nsIconLoaderService
;
19 class imgRequestProxy
;
22 #import <Cocoa/Cocoa.h>
24 class nsMenuItemIconX
: public mozilla::widget::IconLoaderListenerCocoa
{
26 nsMenuItemIconX(nsMenuObjectX
* aMenuItem
, nsIContent
* aContent
,
27 NSMenuItem
* aNativeMenuItem
);
30 virtual ~nsMenuItemIconX();
33 // SetupIcon succeeds if it was able to set up the icon, or if there should
34 // be no icon, in which case it clears any existing icon but still succeeds.
37 // GetIconURI fails if the item should not have any icon.
38 nsresult
GetIconURI(nsIURI
** aIconURI
);
40 // Unless we take precautions, we may outlive the object that created us
41 // (mMenuObject, which owns our native menu item (mNativeMenuItem)).
42 // Destroy() should be called from mMenuObject's destructor to prevent
43 // this from happening. See bug 499600.
46 // Implements this method for mozilla::widget::IconLoaderListenerCocoa.
47 // Called once the icon load is complete.
48 nsresult
OnComplete();
51 nsCOMPtr
<nsIContent
> mContent
;
52 nsContentPolicyType mContentType
;
53 nsMenuObjectX
* mMenuObject
; // [weak]
54 nsIntRect mImageRegionRect
;
56 NSMenuItem
* mNativeMenuItem
; // [weak]
57 // The icon loader object should never outlive its creating nsMenuItemIconX
59 RefPtr
<mozilla::widget::IconLoader
> mIconLoader
;
60 RefPtr
<mozilla::widget::IconLoaderHelperCocoa
> mIconLoaderHelper
;
63 #endif // nsMenuItemIconX_h_