Bug 1776444 [wpt PR 34582] - Revert "Add TimedHTMLParserBudget to fieldtrial_testing_...
[gecko.git] / widget / cocoa / nsTouchBarInputIcon.h
blob92f9ab0302890b66f223de68621d9817b4436568
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 on the macOS Touch Bar.
8 */
10 #ifndef nsTouchBarInputIcon_h_
11 #define nsTouchBarInputIcon_h_
13 #import <Cocoa/Cocoa.h>
15 #include "mozilla/widget/IconLoader.h"
16 #include "nsTouchBarInput.h"
17 #include "nsTouchBarNativeAPIDefines.h"
19 using namespace mozilla::dom;
21 class nsIURI;
22 class nsIPrincipal;
23 class imgRequestProxy;
25 namespace mozilla::dom {
26 class Document;
29 class nsTouchBarInputIcon : public mozilla::widget::IconLoader::Listener {
30 public:
31 explicit nsTouchBarInputIcon(RefPtr<Document> aDocument,
32 TouchBarInput* aInput, NSTouchBarItem* aItem);
34 NS_INLINE_DECL_REFCOUNTING(nsTouchBarInputIcon)
36 private:
37 virtual ~nsTouchBarInputIcon();
39 public:
40 // SetupIcon succeeds if it was able to set up the icon, or if there should
41 // be no icon, in which case it clears any existing icon but still succeeds.
42 nsresult SetupIcon(nsCOMPtr<nsIURI> aIconURI);
44 // Implements this method for mozilla::widget::IconLoader::Listener.
45 // Called once the icon load is complete.
46 nsresult OnComplete(imgIContainer* aImage) override;
48 // Unless we take precautions, we may outlive the object that created us
49 // (mTouchBar, which owns our native menu item (mTouchBarInput)).
50 // Destroy() should be called from mTouchBar's destructor to prevent
51 // this from happening.
52 void Destroy();
54 void ReleaseJSObjects();
56 protected:
57 RefPtr<Document> mDocument;
58 nsIntRect mImageRegionRect;
59 bool mSetIcon;
60 NSButton* mButton;
61 // We accept a mShareScrubber only as a special case since
62 // NSSharingServicePickerTouchBarItem does not expose an NSButton* on which we
63 // can set the `image` property.
64 NSSharingServicePickerTouchBarItem* mShareScrubber;
65 // We accept a popover only as a special case.
66 NSPopoverTouchBarItem* mPopoverItem;
67 // The icon loader object should never outlive its creating
68 // nsTouchBarInputIcon object.
69 RefPtr<mozilla::widget::IconLoader> mIconLoader;
72 #endif // nsTouchBarInputIcon_h_