widget/cocoa/nsMenuItemIconX.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/widget/cocoa/nsMenuItemIconX.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,66 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +/*
    1.10 + * Retrieves and displays icons in native menu items on Mac OS X.
    1.11 + */
    1.12 +
    1.13 +#ifndef nsMenuItemIconX_h_
    1.14 +#define nsMenuItemIconX_h_
    1.15 +
    1.16 +#include "nsCOMPtr.h"
    1.17 +#include "nsAutoPtr.h"
    1.18 +#include "imgINotificationObserver.h"
    1.19 +
    1.20 +class nsIURI;
    1.21 +class nsIContent;
    1.22 +class imgRequestProxy;
    1.23 +class nsMenuObjectX;
    1.24 +
    1.25 +#import <Cocoa/Cocoa.h>
    1.26 +
    1.27 +class nsMenuItemIconX : public imgINotificationObserver
    1.28 +{
    1.29 +public:
    1.30 +  nsMenuItemIconX(nsMenuObjectX* aMenuItem,
    1.31 +                  nsIContent*    aContent,
    1.32 +                  NSMenuItem*    aNativeMenuItem);
    1.33 +private:
    1.34 +  virtual ~nsMenuItemIconX();
    1.35 +
    1.36 +public:
    1.37 +  NS_DECL_ISUPPORTS
    1.38 +  NS_DECL_IMGINOTIFICATIONOBSERVER
    1.39 +
    1.40 +  // SetupIcon succeeds if it was able to set up the icon, or if there should
    1.41 +  // be no icon, in which case it clears any existing icon but still succeeds.
    1.42 +  nsresult SetupIcon();
    1.43 +
    1.44 +  // GetIconURI fails if the item should not have any icon.
    1.45 +  nsresult GetIconURI(nsIURI** aIconURI);
    1.46 +
    1.47 +  // LoadIcon will set a placeholder image and start a load request for the
    1.48 +  // icon.  The request may not complete until after LoadIcon returns.
    1.49 +  nsresult LoadIcon(nsIURI* aIconURI);
    1.50 +
    1.51 +  // Unless we take precautions, we may outlive the object that created us
    1.52 +  // (mMenuObject, which owns our native menu item (mNativeMenuItem)).
    1.53 +  // Destroy() should be called from mMenuObject's destructor to prevent
    1.54 +  // this from happening.  See bug 499600.
    1.55 +  void Destroy();
    1.56 +
    1.57 +protected:
    1.58 +  nsresult OnStopFrame(imgIRequest* aRequest);
    1.59 +
    1.60 +  nsCOMPtr<nsIContent>      mContent;
    1.61 +  nsRefPtr<imgRequestProxy> mIconRequest;
    1.62 +  nsMenuObjectX*            mMenuObject; // [weak]
    1.63 +  nsIntRect                 mImageRegionRect;
    1.64 +  bool                      mLoadedIcon;
    1.65 +  bool                      mSetIcon;
    1.66 +  NSMenuItem*               mNativeMenuItem; // [weak]
    1.67 +};
    1.68 +
    1.69 +#endif // nsMenuItemIconX_h_

mercurial