Backed out changeset 3ab29c05ea2f (bug 1521893) build bustage in /builds/worker/workspace/build/src/widget/cocoa/nsTouchBarInputIcon.h. CLOSED TREE
This commit is contained in:
@@ -11,7 +11,6 @@ XPCOMUtils.defineLazyModuleGetters(this, {
|
||||
PrivateBrowsingUtils: "resource://gre/modules/PrivateBrowsingUtils.jsm",
|
||||
Services: "resource://gre/modules/Services.jsm",
|
||||
AppConstants: "resource://gre/modules/AppConstants.jsm",
|
||||
PlacesUtils: "resource://gre/modules/PlacesUtils.jsm",
|
||||
});
|
||||
|
||||
/**
|
||||
@@ -58,25 +57,25 @@ function hexToInt(hexString) {
|
||||
const kBuiltInInputs = {
|
||||
Back: {
|
||||
title: "back",
|
||||
image: "chrome://browser/skin/back.svg",
|
||||
image: "back.pdf",
|
||||
type: "button",
|
||||
callback: () => execCommand("Browser:Back", "Back"),
|
||||
},
|
||||
Forward: {
|
||||
title: "forward",
|
||||
image: "chrome://browser/skin/forward.svg",
|
||||
image: "forward.pdf",
|
||||
type: "button",
|
||||
callback: () => execCommand("Browser:Forward", "Forward"),
|
||||
},
|
||||
Reload: {
|
||||
title: "reload",
|
||||
image: "chrome://browser/skin/reload.svg",
|
||||
image: "refresh.pdf",
|
||||
type: "button",
|
||||
callback: () => execCommand("Browser:Reload", "Reload"),
|
||||
},
|
||||
Home: {
|
||||
title: "home",
|
||||
image: "chrome://browser/skin/home.svg",
|
||||
image: "home.pdf",
|
||||
type: "button",
|
||||
callback: () => {
|
||||
let win = BrowserWindowTracker.getTopWindow();
|
||||
@@ -89,25 +88,25 @@ const kBuiltInInputs = {
|
||||
},
|
||||
Fullscreen: {
|
||||
title: "fullscreen",
|
||||
image: "chrome://browser/skin/fullscreen.svg",
|
||||
image: "fullscreen.pdf",
|
||||
type: "button",
|
||||
callback: () => execCommand("View:FullScreen", "Fullscreen"),
|
||||
},
|
||||
Find: {
|
||||
title: "find",
|
||||
image: "chrome://browser/skin/search-glass.svg",
|
||||
image: "search.pdf",
|
||||
type: "button",
|
||||
callback: () => execCommand("cmd_find", "Find"),
|
||||
},
|
||||
NewTab: {
|
||||
title: "new-tab",
|
||||
image: "chrome://browser/skin/add.svg",
|
||||
image: "new.pdf",
|
||||
type: "button",
|
||||
callback: () => execCommand("cmd_newNavigatorTabNoEvent", "NewTab"),
|
||||
},
|
||||
Sidebar: {
|
||||
title: "open-sidebar",
|
||||
image: "chrome://browser/skin/sidebars.svg",
|
||||
image: "sidebar-left.pdf",
|
||||
type: "button",
|
||||
callback: () => {
|
||||
let win = BrowserWindowTracker.getTopWindow();
|
||||
@@ -120,20 +119,20 @@ const kBuiltInInputs = {
|
||||
},
|
||||
AddBookmark: {
|
||||
title: "add-bookmark",
|
||||
image: "chrome://browser/skin/bookmark-hollow.svg",
|
||||
image: "bookmark.pdf",
|
||||
type: "button",
|
||||
callback: () => execCommand("Browser:AddBookmarkAs", "AddBookmark"),
|
||||
},
|
||||
ReaderView: {
|
||||
title: "reader-view",
|
||||
image: "chrome://browser/skin/readerMode.svg",
|
||||
image: "reader-mode.pdf",
|
||||
type: "button",
|
||||
callback: () => execCommand("View:ReaderView", "ReaderView"),
|
||||
disabled: true, // Updated when the page is found to be Reader View-able.
|
||||
},
|
||||
OpenLocation: {
|
||||
title: "open-location",
|
||||
image: "chrome://browser/skin/search-glass.svg",
|
||||
image: "search.pdf",
|
||||
type: "mainButton",
|
||||
callback: () => execCommand("Browser:OpenLocation", "OpenLocation"),
|
||||
},
|
||||
@@ -143,7 +142,7 @@ const kBuiltInInputs = {
|
||||
Share: {
|
||||
title: "share",
|
||||
type: "scrubber",
|
||||
image: "chrome://browser/skin/share.svg",
|
||||
image: "share.pdf",
|
||||
callback: () => execCommand("cmd_share", "Share"),
|
||||
},
|
||||
};
|
||||
@@ -205,10 +204,6 @@ class TouchBarHelper {
|
||||
return BrowserWindowTracker.getTopWindow();
|
||||
}
|
||||
|
||||
get document() {
|
||||
return this.window.document;
|
||||
}
|
||||
|
||||
get bookmarkingUI() {
|
||||
return this.window.BookmarkingUI;
|
||||
}
|
||||
@@ -298,10 +293,8 @@ class TouchBarHelper {
|
||||
break;
|
||||
case "bookmark-icon-updated":
|
||||
data == "starred"
|
||||
? (kBuiltInInputs.AddBookmark.image =
|
||||
"chrome://browser/skin/bookmark.svg")
|
||||
: (kBuiltInInputs.AddBookmark.image =
|
||||
"chrome://browser/skin/bookmark-hollow.svg");
|
||||
? (kBuiltInInputs.AddBookmark.image = "bookmark-filled.pdf")
|
||||
: (kBuiltInInputs.AddBookmark.image = "bookmark.pdf");
|
||||
this._updateTouchBarInputs("AddBookmark");
|
||||
break;
|
||||
case "reader-mode-available":
|
||||
@@ -372,7 +365,7 @@ class TouchBarInput {
|
||||
this._title = title;
|
||||
}
|
||||
get image() {
|
||||
return PlacesUtils.toURI(this._image);
|
||||
return this._image;
|
||||
}
|
||||
set image(image) {
|
||||
this._image = image;
|
||||
|
||||
@@ -37,22 +37,22 @@ add_task(async function updateBookmarkButton() {
|
||||
// nsITouchBarHelper to load on Macs without Touch Bars so that it will be
|
||||
// listening for "bookmark-icon-updated".
|
||||
Assert.equal(
|
||||
TouchBarHelper.getTouchBarInput("AddBookmark").image.spec,
|
||||
"chrome://browser/skin/bookmark-hollow.svg",
|
||||
TouchBarHelper.getTouchBarInput("AddBookmark").image,
|
||||
"bookmark.pdf",
|
||||
"AddBookmark image should be unfilled bookmark after event."
|
||||
);
|
||||
|
||||
Services.obs.notifyObservers(null, "bookmark-icon-updated", "starred");
|
||||
Assert.equal(
|
||||
TouchBarHelper.getTouchBarInput("AddBookmark").image.spec,
|
||||
"chrome://browser/skin/bookmark.svg",
|
||||
TouchBarHelper.getTouchBarInput("AddBookmark").image,
|
||||
"bookmark-filled.pdf",
|
||||
"AddBookmark image should be filled bookmark after event."
|
||||
);
|
||||
|
||||
Services.obs.notifyObservers(null, "bookmark-icon-updated", "unstarred");
|
||||
Assert.equal(
|
||||
TouchBarHelper.getTouchBarInput("AddBookmark").image.spec,
|
||||
"chrome://browser/skin/bookmark-hollow.svg",
|
||||
TouchBarHelper.getTouchBarInput("AddBookmark").image,
|
||||
"bookmark.pdf",
|
||||
"AddBookmark image should be unfilled bookmark after event."
|
||||
);
|
||||
});
|
||||
|
||||
@@ -325,6 +325,7 @@
|
||||
@RESPATH@/res/grabber.gif
|
||||
#ifdef XP_MACOSX
|
||||
@RESPATH@/res/cursors/*
|
||||
@RESPATH@/res/touchbar/*
|
||||
#endif
|
||||
@RESPATH@/res/fonts/*
|
||||
@RESPATH@/res/dtd/*
|
||||
|
||||
@@ -58,7 +58,6 @@ UNIFIED_SOURCES += [
|
||||
'nsSystemStatusBarCocoa.mm',
|
||||
'nsToolkit.mm',
|
||||
'nsTouchBar.mm',
|
||||
'nsTouchBarInputIcon.mm',
|
||||
'nsTouchBarUpdater.mm',
|
||||
'nsWidgetFactory.mm',
|
||||
'nsWindowMap.mm',
|
||||
@@ -142,6 +141,22 @@ RESOURCE_FILES.cursors += [
|
||||
'cursors/zoomOut@2x.png',
|
||||
]
|
||||
|
||||
RESOURCE_FILES.touchbar += [
|
||||
'touchbar/back.pdf',
|
||||
'touchbar/bookmark-filled.pdf',
|
||||
'touchbar/bookmark.pdf',
|
||||
'touchbar/forward.pdf',
|
||||
'touchbar/fullscreen.pdf',
|
||||
'touchbar/home.pdf',
|
||||
'touchbar/new.pdf',
|
||||
'touchbar/reader-mode.pdf',
|
||||
'touchbar/refresh.pdf',
|
||||
'touchbar/search.pdf',
|
||||
'touchbar/share.pdf',
|
||||
'touchbar/sidebar-left.pdf',
|
||||
'touchbar/sidebar-right.pdf',
|
||||
]
|
||||
|
||||
# These resources go in $(DIST)/bin/res/MainMenu.nib, but we can't use a magic
|
||||
# RESOURCE_FILES.MainMenu.nib attribute, since that would put the files in
|
||||
# $(DIST)/bin/res/MainMenu/nib. Instead, we call __setattr__ directly to create
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
#include "nsIInterfaceRequestorUtils.h"
|
||||
#include "nsIXULWindow.h"
|
||||
#include "nsToolkit.h"
|
||||
#include "nsTouchBarNativeAPIDefines.h"
|
||||
#include "nsIDOMWindow.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
#include "nsThreadUtils.h"
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
#include "nsIContentPolicy.h"
|
||||
|
||||
class nsIURI;
|
||||
class nsINode;
|
||||
class nsIContent;
|
||||
class nsIPrincipal;
|
||||
class imgRequestProxy;
|
||||
|
||||
@@ -25,7 +25,7 @@ class nsIconLoaderService : public imgINotificationObserver {
|
||||
public:
|
||||
// If aScaleFactor is not specified, then an image with both regular and
|
||||
// HiDPI representations will be loaded.
|
||||
nsIconLoaderService(nsINode* aContent, nsIntRect* aImageRegionRect,
|
||||
nsIconLoaderService(nsIContent* aContent, nsIntRect* aImageRegionRect,
|
||||
RefPtr<nsIconLoaderObserver> aObserver, uint32_t aIconHeight,
|
||||
uint32_t aIconWidth, CGFloat aScaleFactor = 0.0f);
|
||||
|
||||
@@ -33,23 +33,23 @@ class nsIconLoaderService : public imgINotificationObserver {
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_IMGINOTIFICATIONOBSERVER
|
||||
|
||||
// LoadIcon will start a load request for the icon.
|
||||
// The request may not complete until after LoadIcon returns.
|
||||
// LoadIcon will set a placeholder image and start a load request for the
|
||||
// icon. The request may not complete until after LoadIcon returns.
|
||||
nsresult LoadIcon(nsIURI* aIconURI);
|
||||
|
||||
NSImage* GetNativeIconImage();
|
||||
|
||||
// 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();
|
||||
|
||||
void ReleaseJSObjects() { mContent = nil; }
|
||||
|
||||
protected:
|
||||
virtual ~nsIconLoaderService();
|
||||
|
||||
private:
|
||||
nsresult OnFrameComplete(imgIRequest* aRequest);
|
||||
|
||||
nsCOMPtr<nsINode> mContent;
|
||||
nsCOMPtr<nsIContent> mContent;
|
||||
nsContentPolicyType mContentType;
|
||||
RefPtr<imgRequestProxy> mIconRequest;
|
||||
nsIntRect* mImageRegionRect;
|
||||
@@ -60,4 +60,5 @@ class nsIconLoaderService : public imgINotificationObserver {
|
||||
CGFloat mScaleFactor;
|
||||
RefPtr<nsIconLoaderObserver> mCompletionHandler;
|
||||
};
|
||||
|
||||
#endif // nsIconLoaderService_h_
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsIconLoaderService.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIContentPolicy.h"
|
||||
#include "nsNameSpaceManager.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsObjCExceptions.h"
|
||||
@@ -42,7 +43,7 @@ using mozilla::gfx::SourceSurface;
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsIconLoaderService, imgINotificationObserver)
|
||||
|
||||
nsIconLoaderService::nsIconLoaderService(nsINode* aContent, nsIntRect* aImageRegionRect,
|
||||
nsIconLoaderService::nsIconLoaderService(nsIContent* aContent, nsIntRect* aImageRegionRect,
|
||||
RefPtr<nsIconLoaderObserver> aObserver,
|
||||
uint32_t aIconHeight, uint32_t aIconWidth,
|
||||
CGFloat aScaleFactor)
|
||||
@@ -50,23 +51,24 @@ nsIconLoaderService::nsIconLoaderService(nsINode* aContent, nsIntRect* aImageReg
|
||||
mContentType(nsIContentPolicy::TYPE_INTERNAL_IMAGE),
|
||||
mImageRegionRect(aImageRegionRect),
|
||||
mLoadedIcon(false),
|
||||
mNativeIconImage(nil),
|
||||
mIconHeight(aIconHeight),
|
||||
mIconWidth(aIconWidth),
|
||||
mScaleFactor(aScaleFactor),
|
||||
mCompletionHandler(aObserver) {
|
||||
// Placeholder icon, which will later be replaced.
|
||||
mNativeIconImage = [[NSImage alloc] initWithSize:NSMakeSize(mIconHeight, mIconWidth)];
|
||||
}
|
||||
mCompletionHandler(aObserver) {}
|
||||
|
||||
nsIconLoaderService::~nsIconLoaderService() { Destroy(); }
|
||||
|
||||
// Called from mMenuObjectX's destructor, to prevent us from outliving it
|
||||
// (as might otherwise happen if calls to our imgINotificationObserver methods
|
||||
// are still outstanding). mMenuObjectX owns our nNativeMenuItem.
|
||||
void nsIconLoaderService::Destroy() {
|
||||
if (mIconRequest) {
|
||||
mIconRequest->CancelAndForgetObserver(NS_BINDING_ABORTED);
|
||||
mIconRequest = nullptr;
|
||||
}
|
||||
mNativeIconImage = nil;
|
||||
mImageRegionRect = nullptr;
|
||||
mNativeIconImage = nil;
|
||||
mCompletionHandler = nil;
|
||||
}
|
||||
|
||||
@@ -110,8 +112,6 @@ nsresult nsIconLoaderService::LoadIcon(nsIURI* aIconURI) {
|
||||
NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
|
||||
}
|
||||
|
||||
NSImage* nsIconLoaderService::GetNativeIconImage() { return mNativeIconImage; }
|
||||
|
||||
//
|
||||
// imgINotificationObserver
|
||||
//
|
||||
@@ -248,11 +248,7 @@ nsresult nsIconLoaderService::OnFrameComplete(imgIRequest* aRequest) {
|
||||
[newImage setTemplate:isEntirelyBlack];
|
||||
|
||||
[newImage setSize:origSize];
|
||||
|
||||
NSImage* placeholderImage = mNativeIconImage;
|
||||
mNativeIconImage = newImage;
|
||||
[placeholderImage release];
|
||||
placeholderImage = nil;
|
||||
|
||||
mLoadedIcon = true;
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
#include "nsGkAtoms.h"
|
||||
#include "nsObjCExceptions.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsTouchBarNativeAPIDefines.h"
|
||||
|
||||
#include "nsIContent.h"
|
||||
#include "nsITouchBarUpdater.h"
|
||||
@@ -855,6 +854,12 @@ static BOOL gMenuItemsExecuteCommands = YES;
|
||||
|
||||
@end
|
||||
|
||||
#if !defined(MAC_OS_X_VERSION_10_12_2) || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_12_2
|
||||
@interface NSApplication (TouchBarMenu)
|
||||
- (IBAction)toggleTouchBarCustomizationPalette:(id)sender;
|
||||
@end
|
||||
#endif
|
||||
|
||||
//
|
||||
// Objective-C class used as action target for menu items
|
||||
//
|
||||
|
||||
@@ -10,6 +10,9 @@
|
||||
#ifndef nsMenuItemIconX_h_
|
||||
#define nsMenuItemIconX_h_
|
||||
|
||||
#include "mozilla/RefPtr.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "imgINotificationObserver.h"
|
||||
#include "nsIContentPolicy.h"
|
||||
#include "nsIconLoaderService.h"
|
||||
|
||||
@@ -50,6 +53,7 @@ class nsMenuItemIconX : public nsIconLoaderObserver {
|
||||
|
||||
protected:
|
||||
nsCOMPtr<nsIContent> mContent;
|
||||
nsCOMPtr<nsIPrincipal> mTriggeringPrincipal;
|
||||
nsContentPolicyType mContentType;
|
||||
nsMenuObjectX* mMenuObject; // [weak]
|
||||
nsIntRect mImageRegionRect;
|
||||
|
||||
@@ -42,6 +42,7 @@ static const uint32_t kIconSize = 16;
|
||||
nsMenuItemIconX::nsMenuItemIconX(nsMenuObjectX* aMenuItem, nsIContent* aContent,
|
||||
NSMenuItem* aNativeMenuItem)
|
||||
: mContent(aContent),
|
||||
mTriggeringPrincipal(aContent->NodePrincipal()),
|
||||
mContentType(nsIContentPolicy::TYPE_INTERNAL_IMAGE),
|
||||
mMenuObject(aMenuItem),
|
||||
mSetIcon(false),
|
||||
@@ -56,12 +57,13 @@ nsMenuItemIconX::~nsMenuItemIconX() {
|
||||
|
||||
// Called from mMenuObjectX's destructor, to prevent us from outliving it
|
||||
// (as might otherwise happen if calls to our imgINotificationObserver methods
|
||||
// are still outstanding). mMenuObjectX owns our mNativeMenuItem.
|
||||
// are still outstanding). mMenuObjectX owns our nNativeMenuItem.
|
||||
void nsMenuItemIconX::Destroy() {
|
||||
if (mIconLoader) {
|
||||
mIconLoader->Destroy();
|
||||
mIconLoader = nullptr;
|
||||
}
|
||||
|
||||
mMenuObject = nullptr;
|
||||
mNativeMenuItem = nil;
|
||||
}
|
||||
@@ -85,16 +87,35 @@ nsresult nsMenuItemIconX::SetupIcon() {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (!mSetIcon) {
|
||||
// Set a completely transparent 16x16 image as the icon on this menu item
|
||||
// as a placeholder. This keeps the menu item text displayed in the same
|
||||
// position that it will be displayed when the real icon is loaded, and
|
||||
// prevents it from jumping around or looking misaligned.
|
||||
|
||||
static bool sInitializedPlaceholder;
|
||||
static NSImage* sPlaceholderIconImage;
|
||||
if (!sInitializedPlaceholder) {
|
||||
sInitializedPlaceholder = true;
|
||||
|
||||
// Note that we only create the one and reuse it forever, so this is not a leak.
|
||||
sPlaceholderIconImage = [[NSImage alloc] initWithSize:NSMakeSize(kIconSize, kIconSize)];
|
||||
}
|
||||
|
||||
if (!sPlaceholderIconImage) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (mNativeMenuItem) {
|
||||
[mNativeMenuItem setImage:sPlaceholderIconImage];
|
||||
}
|
||||
}
|
||||
if (!mIconLoader) {
|
||||
mIconLoader = new nsIconLoaderService(mContent, &mImageRegionRect, this, kIconSize, kIconSize);
|
||||
if (!mIconLoader) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
if (!mSetIcon) {
|
||||
// Load placeholder icon.
|
||||
[mNativeMenuItem setImage:mIconLoader->GetNativeIconImage()];
|
||||
}
|
||||
|
||||
rv = mIconLoader->LoadIcon(iconURI);
|
||||
if (NS_FAILED(rv)) {
|
||||
@@ -155,9 +176,8 @@ nsresult nsMenuItemIconX::GetIconURI(nsIURI** aIconURI) {
|
||||
}
|
||||
} else {
|
||||
uint64_t dummy = 0;
|
||||
nsCOMPtr<nsIPrincipal> triggeringPrincipal = mContent->NodePrincipal();
|
||||
nsContentUtils::GetContentPolicyTypeForUIImageLoading(
|
||||
mContent, getter_AddRefs(triggeringPrincipal), mContentType, &dummy);
|
||||
mContent, getter_AddRefs(mTriggeringPrincipal), mContentType, &dummy);
|
||||
|
||||
// If this menu item shouldn't have an icon, the string will be empty,
|
||||
// and NS_NewURI will fail.
|
||||
|
||||
@@ -7,12 +7,59 @@
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
#include "mozilla/RefPtr.h"
|
||||
#include "nsITouchBarHelper.h"
|
||||
#include "nsITouchBarInput.h"
|
||||
#include "nsTouchBarInputIcon.h"
|
||||
#include "nsTouchBarNativeAPIDefines.h"
|
||||
|
||||
using namespace mozilla::dom;
|
||||
#if !defined(MAC_OS_X_VERSION_10_12) || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_12
|
||||
@interface NSButton (NewConstructors)
|
||||
@property(nonatomic) BOOL imageHugsTitle;
|
||||
+ (NSButton*)buttonWithTitle:(NSString*)title target:(id)target action:(SEL)action;
|
||||
@end
|
||||
|
||||
@interface NSColor (DisplayP3Colors)
|
||||
+ (NSColor*)colorWithDisplayP3Red:(CGFloat)red
|
||||
green:(CGFloat)green
|
||||
blue:(CGFloat)blue
|
||||
alpha:(CGFloat)alpha;
|
||||
@end
|
||||
#endif
|
||||
|
||||
#if !defined(MAC_OS_X_VERSION_10_12_2) || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_12_2
|
||||
typedef NSString* NSTouchBarItemIdentifier;
|
||||
__attribute__((weak_import)) @interface NSTouchBarItem : NSObject
|
||||
- (instancetype)initWithIdentifier:(NSTouchBarItemIdentifier)aIdentifier;
|
||||
@end
|
||||
|
||||
__attribute__((weak_import)) @interface NSCustomTouchBarItem : NSTouchBarItem
|
||||
@property(strong) NSView* view;
|
||||
@property(strong) NSString* customizationLabel;
|
||||
@end
|
||||
|
||||
@protocol NSTouchBarDelegate
|
||||
@end
|
||||
|
||||
typedef NSString* NSTouchBarCustomizationIdentifier;
|
||||
__attribute__((weak_import)) @interface NSTouchBar : NSObject
|
||||
@property(strong) NSArray<NSTouchBarItemIdentifier>* defaultItemIdentifiers;
|
||||
@property(strong) id<NSTouchBarDelegate> delegate;
|
||||
@property(strong) NSTouchBarCustomizationIdentifier customizationIdentifier;
|
||||
@property(strong) NSArray<NSTouchBarItemIdentifier>* customizationAllowedItemIdentifiers;
|
||||
- (NSTouchBarItem*)itemForIdentifier:(NSTouchBarItemIdentifier)aIdentifier;
|
||||
@end
|
||||
|
||||
@protocol NSSharingServicePickerTouchBarItemDelegate
|
||||
@end
|
||||
|
||||
__attribute__((weak_import)) @interface NSSharingServicePickerTouchBarItem : NSTouchBarItem
|
||||
@property(strong) id<NSSharingServicePickerTouchBarItemDelegate> delegate;
|
||||
@property(strong) NSImage* buttonImage;
|
||||
@end
|
||||
|
||||
@interface NSButton (TouchBarButton)
|
||||
@property(strong) NSColor* bezelColor;
|
||||
@end
|
||||
#endif
|
||||
|
||||
/**
|
||||
* NSObject representation of nsITouchBarInput.
|
||||
@@ -20,40 +67,34 @@ using namespace mozilla::dom;
|
||||
@interface TouchBarInput : NSObject {
|
||||
NSString* mKey;
|
||||
NSString* mTitle;
|
||||
nsCOMPtr<nsIURI> mImageURI;
|
||||
RefPtr<nsTouchBarInputIcon> mIcon;
|
||||
NSImage* mImage;
|
||||
NSString* mType;
|
||||
NSColor* mColor;
|
||||
BOOL mDisabled;
|
||||
NSTouchBarItemIdentifier mNativeIdentifier;
|
||||
nsCOMPtr<nsITouchBarInputCallback> mCallback;
|
||||
BOOL mIsIconPositionSet;
|
||||
}
|
||||
|
||||
- (NSString*)key;
|
||||
- (NSString*)title;
|
||||
- (nsCOMPtr<nsIURI>)imageURI;
|
||||
- (RefPtr<nsTouchBarInputIcon>)icon;
|
||||
- (NSImage*)image;
|
||||
- (NSString*)type;
|
||||
- (NSColor*)color;
|
||||
- (BOOL)isDisabled;
|
||||
- (NSTouchBarItemIdentifier)nativeIdentifier;
|
||||
- (nsCOMPtr<nsITouchBarInputCallback>)callback;
|
||||
- (BOOL)isIconPositionSet;
|
||||
- (void)setKey:(NSString*)aKey;
|
||||
- (void)setTitle:(NSString*)aTitle;
|
||||
- (void)setImageURI:(nsCOMPtr<nsIURI>)aImageURI;
|
||||
- (void)setIcon:(RefPtr<nsTouchBarInputIcon>)aIcon;
|
||||
- (void)setImage:(NSImage*)aImage;
|
||||
- (void)setType:(NSString*)aType;
|
||||
- (void)setColor:(NSColor*)aColor;
|
||||
- (void)setDisabled:(BOOL)aDisabled;
|
||||
- (void)setNativeIdentifier:(NSString*)aNativeIdentifier;
|
||||
- (void)setCallback:(nsCOMPtr<nsITouchBarInputCallback>)aCallback;
|
||||
- (void)setIconPositionSet:(BOOL)aIsIconPositionSet;
|
||||
|
||||
- (id)initWithKey:(NSString*)aKey
|
||||
title:(NSString*)aTitle
|
||||
imageURI:(nsCOMPtr<nsIURI>)aImageURI
|
||||
image:(NSString*)aImage
|
||||
type:(NSString*)aType
|
||||
callback:(nsCOMPtr<nsITouchBarInputCallback>)aCallback
|
||||
color:(uint32_t)aColor
|
||||
@@ -130,6 +171,11 @@ using namespace mozilla::dom;
|
||||
sharingServicesForItems:(NSArray*)aItems
|
||||
proposedSharingServices:(NSArray<NSSharingService*>*)aProposedServices;
|
||||
|
||||
/**
|
||||
* Retrieves TouchBarInput icons.
|
||||
*/
|
||||
+ (NSImage*)getTouchBarIconNamed:(NSString*)aImageName;
|
||||
|
||||
- (void)releaseJSObjects;
|
||||
|
||||
@end // nsTouchBar
|
||||
|
||||
@@ -143,23 +143,11 @@ static char sIdentifierAssociationKey;
|
||||
}
|
||||
|
||||
button.title = [aInput title];
|
||||
if (![aInput isIconPositionSet]) {
|
||||
if ([aInput image]) {
|
||||
button.image = [aInput image];
|
||||
[button setImagePosition:NSImageOnly];
|
||||
[aInput setIconPositionSet:true];
|
||||
}
|
||||
|
||||
if ([aInput imageURI]) {
|
||||
RefPtr<nsTouchBarInputIcon> icon = [aInput icon];
|
||||
if (!icon) {
|
||||
icon = new nsTouchBarInputIcon(button);
|
||||
[aInput setIcon:icon];
|
||||
}
|
||||
RefPtr<Document> document;
|
||||
nsresult rv = mTouchBarHelper->GetDocument(getter_AddRefs(document));
|
||||
if (!NS_FAILED(rv)) {
|
||||
icon->SetupIcon([aInput imageURI], document);
|
||||
}
|
||||
}
|
||||
[button setEnabled:![aInput isDisabled]];
|
||||
|
||||
if ([aInput color]) {
|
||||
@@ -176,17 +164,16 @@ static char sIdentifierAssociationKey;
|
||||
|
||||
- (NSTouchBarItem*)updateMainButton:(NSCustomTouchBarItem*)aMainButton
|
||||
input:(TouchBarInput*)aInput {
|
||||
aMainButton = (NSCustomTouchBarItem*)[self updateButton:aMainButton input:aInput];
|
||||
NSButton* button = (NSButton*)aMainButton.view;
|
||||
button.imageHugsTitle = YES;
|
||||
// If empty, string is still being localized. Display a blank input instead.
|
||||
if ([[aInput title] isEqualToString:@""]) {
|
||||
if ([button.title isEqualToString:@""]) {
|
||||
[button setImagePosition:NSNoImage];
|
||||
} else {
|
||||
[button setImagePosition:NSImageLeft];
|
||||
}
|
||||
button.imageHugsTitle = YES;
|
||||
[aInput setIconPositionSet:true];
|
||||
|
||||
aMainButton = (NSCustomTouchBarItem*)[self updateButton:aMainButton input:aInput];
|
||||
[button.widthAnchor constraintGreaterThanOrEqualToConstant:MAIN_BUTTON_WIDTH].active = YES;
|
||||
[button setContentHuggingPriority:1.0 forOrientation:NSLayoutConstraintOrientationHorizontal];
|
||||
return aMainButton;
|
||||
@@ -197,23 +184,7 @@ static char sIdentifierAssociationKey;
|
||||
// System-default share menu
|
||||
NSSharingServicePickerTouchBarItem* servicesItem =
|
||||
[[NSSharingServicePickerTouchBarItem alloc] initWithIdentifier:aIdentifier];
|
||||
|
||||
// buttonImage needs to be set to nil while we wait for our icon to load.
|
||||
// Otherwise, the default Apple share icon is automatically loaded.
|
||||
servicesItem.buttonImage = nil;
|
||||
if ([input imageURI]) {
|
||||
RefPtr<nsTouchBarInputIcon> icon = [input icon];
|
||||
if (!icon) {
|
||||
icon = new nsTouchBarInputIcon(nil, servicesItem);
|
||||
[input setIcon:icon];
|
||||
}
|
||||
RefPtr<Document> document;
|
||||
nsresult rv = mTouchBarHelper->GetDocument(getter_AddRefs(document));
|
||||
if (!NS_FAILED(rv)) {
|
||||
icon->SetupIcon([input imageURI], document);
|
||||
}
|
||||
}
|
||||
|
||||
servicesItem.buttonImage = [input image];
|
||||
servicesItem.delegate = self;
|
||||
return servicesItem;
|
||||
}
|
||||
@@ -244,15 +215,35 @@ static char sIdentifierAssociationKey;
|
||||
|
||||
for (NSTouchBarItemIdentifier identifier in self.mappedLayoutItems) {
|
||||
TouchBarInput* input = self.mappedLayoutItems[identifier];
|
||||
RefPtr<nsTouchBarInputIcon> icon = [input icon];
|
||||
if (icon) {
|
||||
icon->ReleaseJSObjects();
|
||||
}
|
||||
[input setCallback:nil];
|
||||
[input setImageURI:nil];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - TouchBar Utilities
|
||||
|
||||
+ (NSImage*)getTouchBarIconNamed:(NSString*)aImageName {
|
||||
nsCOMPtr<nsIFile> resDir;
|
||||
nsAutoCString resPath;
|
||||
NSString* pathToImage;
|
||||
|
||||
nsresult rv = NS_GetSpecialDirectory(NS_GRE_DIR, getter_AddRefs(resDir));
|
||||
resDir->AppendNative(NS_LITERAL_CSTRING("res"));
|
||||
resDir->AppendNative(NS_LITERAL_CSTRING("touchbar"));
|
||||
|
||||
rv = resDir->GetNativePath(resPath);
|
||||
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
pathToImage = [NSString stringWithUTF8String:(const char*)resPath.get()];
|
||||
pathToImage = [pathToImage stringByAppendingPathComponent:aImageName];
|
||||
NSImage* image = [[[NSImage alloc] initWithContentsOfFile:pathToImage] autorelease];
|
||||
// A nil image will fail gracefully to a labelled button
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
#pragma mark - NSSharingServicePickerTouchBarItemDelegate
|
||||
|
||||
- (NSArray*)itemsForSharingServicePickerTouchBarItem:
|
||||
@@ -310,11 +301,8 @@ static char sIdentifierAssociationKey;
|
||||
- (NSString*)title {
|
||||
return mTitle;
|
||||
}
|
||||
- (nsCOMPtr<nsIURI>)imageURI {
|
||||
return mImageURI;
|
||||
}
|
||||
- (RefPtr<nsTouchBarInputIcon>)icon {
|
||||
return mIcon;
|
||||
- (NSImage*)image {
|
||||
return mImage;
|
||||
}
|
||||
- (NSString*)type {
|
||||
return mType;
|
||||
@@ -331,9 +319,6 @@ static char sIdentifierAssociationKey;
|
||||
- (nsCOMPtr<nsITouchBarInputCallback>)callback {
|
||||
return mCallback;
|
||||
}
|
||||
- (BOOL)isIconPositionSet {
|
||||
return mIsIconPositionSet;
|
||||
}
|
||||
- (void)setKey:(NSString*)aKey {
|
||||
[aKey retain];
|
||||
[mKey release];
|
||||
@@ -346,12 +331,10 @@ static char sIdentifierAssociationKey;
|
||||
mTitle = aTitle;
|
||||
}
|
||||
|
||||
- (void)setImageURI:(nsCOMPtr<nsIURI>)aImageURI {
|
||||
mImageURI = aImageURI;
|
||||
}
|
||||
|
||||
- (void)setIcon:(RefPtr<nsTouchBarInputIcon>)aIcon {
|
||||
mIcon = aIcon;
|
||||
- (void)setImage:(NSImage*)aImage {
|
||||
[aImage retain];
|
||||
[mImage release];
|
||||
mImage = aImage;
|
||||
}
|
||||
|
||||
- (void)setType:(NSString*)aType {
|
||||
@@ -380,13 +363,9 @@ static char sIdentifierAssociationKey;
|
||||
mCallback = aCallback;
|
||||
}
|
||||
|
||||
- (void)setIconPositionSet:(BOOL)aIsIconPositionSet {
|
||||
mIsIconPositionSet = aIsIconPositionSet;
|
||||
}
|
||||
|
||||
- (id)initWithKey:(NSString*)aKey
|
||||
title:(NSString*)aTitle
|
||||
imageURI:(nsCOMPtr<nsIURI>)aImageURI
|
||||
image:(NSString*)aImage
|
||||
type:(NSString*)aType
|
||||
callback:(nsCOMPtr<nsITouchBarInputCallback>)aCallback
|
||||
color:(uint32_t)aColor
|
||||
@@ -394,10 +373,9 @@ static char sIdentifierAssociationKey;
|
||||
if (self = [super init]) {
|
||||
[self setKey:aKey];
|
||||
[self setTitle:aTitle];
|
||||
[self setImageURI:aImageURI];
|
||||
[self setImage:[nsTouchBar getTouchBarIconNamed:aImage]];
|
||||
[self setType:aType];
|
||||
[self setCallback:aCallback];
|
||||
[self setIconPositionSet:false];
|
||||
if (aColor) {
|
||||
[self setColor:[NSColor colorWithDisplayP3Red:((aColor >> 16) & 0xFF) / 255.0
|
||||
green:((aColor >> 8) & 0xFF) / 255.0
|
||||
@@ -440,8 +418,8 @@ static char sIdentifierAssociationKey;
|
||||
return nil;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIURI> imageURI;
|
||||
rv = aInput->GetImage(getter_AddRefs(imageURI));
|
||||
nsAutoString imageStr;
|
||||
rv = aInput->GetImage(imageStr);
|
||||
if (NS_FAILED(rv)) {
|
||||
return nil;
|
||||
}
|
||||
@@ -472,7 +450,7 @@ static char sIdentifierAssociationKey;
|
||||
|
||||
return [self initWithKey:nsCocoaUtils::ToNSString(keyStr)
|
||||
title:nsCocoaUtils::ToNSString(titleStr)
|
||||
imageURI:imageURI
|
||||
image:nsCocoaUtils::ToNSString(imageStr)
|
||||
type:nsCocoaUtils::ToNSString(typeStr)
|
||||
callback:callback
|
||||
color:colorInt
|
||||
@@ -480,12 +458,9 @@ static char sIdentifierAssociationKey;
|
||||
}
|
||||
|
||||
- (void)dealloc {
|
||||
if (mIcon) {
|
||||
mIcon->Destroy();
|
||||
mIcon = nil;
|
||||
}
|
||||
[mKey release];
|
||||
[mTitle release];
|
||||
[mImage release];
|
||||
[mType release];
|
||||
[mColor release];
|
||||
[mNativeIdentifier release];
|
||||
|
||||
@@ -1,64 +0,0 @@
|
||||
/* -*- 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 on the macOS Touch Bar.
|
||||
*/
|
||||
|
||||
#ifndef nsTouchBarInputIcon_h_
|
||||
#define nsTouchBarInputIcon_h_
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
#include "mozilla/dom/Document.h"
|
||||
#include "nsIconLoaderService.h"
|
||||
#include "nsTouchBarNativeAPIDefines.h"
|
||||
|
||||
using namespace mozilla::dom;
|
||||
|
||||
class nsIconLoaderService;
|
||||
class nsIURI;
|
||||
class nsIPrincipal;
|
||||
class imgRequestProxy;
|
||||
|
||||
class nsTouchBarInputIcon : public nsIconLoaderObserver {
|
||||
public:
|
||||
nsTouchBarInputIcon(NSButton* aButton,
|
||||
NSSharingServicePickerTouchBarItem* aShareScrubber = nil);
|
||||
|
||||
private:
|
||||
virtual ~nsTouchBarInputIcon();
|
||||
|
||||
public:
|
||||
// SetupIcon succeeds if it was able to set up the icon, or if there should
|
||||
// be no icon, in which case it clears any existing icon but still succeeds.
|
||||
nsresult SetupIcon(nsCOMPtr<nsIURI> aIconURI, RefPtr<Document> aDocument);
|
||||
|
||||
// Overrides nsIconLoaderObserver::OnComplete. Handles the NSImage* created
|
||||
// by nsIconLoaderService.
|
||||
nsresult OnComplete(NSImage* aImage) override;
|
||||
|
||||
// Unless we take precautions, we may outlive the object that created us
|
||||
// (mTouchBar, which owns our native menu item (mTouchBarInput)).
|
||||
// Destroy() should be called from mTouchBar's destructor to prevent
|
||||
// this from happening.
|
||||
void Destroy();
|
||||
|
||||
void ReleaseJSObjects();
|
||||
|
||||
protected:
|
||||
nsIntRect mImageRegionRect;
|
||||
bool mSetIcon;
|
||||
NSButton* mButton;
|
||||
// We accept a mShareScrubber only as a special case since
|
||||
// NSSharingServicePickerTouchBarItem does not expose an NSButton* on which we
|
||||
// can set the `image` property.
|
||||
NSSharingServicePickerTouchBarItem* mShareScrubber;
|
||||
// The icon loader object should never outlive its creating
|
||||
// nsTouchBarInputIcon object.
|
||||
RefPtr<nsIconLoaderService> mIconLoader;
|
||||
};
|
||||
|
||||
#endif // nsTouchBarInputIcon_h_
|
||||
@@ -1,107 +0,0 @@
|
||||
/* -*- 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 on the macOS Touch Bar.
|
||||
*/
|
||||
|
||||
#include "nsTouchBarInputIcon.h"
|
||||
|
||||
#include "nsCocoaUtils.h"
|
||||
#include "nsComputedDOMStyle.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsGkAtoms.h"
|
||||
#include "nsINode.h"
|
||||
#include "nsNameSpaceManager.h"
|
||||
#include "nsObjCExceptions.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
static const uint32_t kIconSize = 16;
|
||||
static const CGFloat kHiDPIScalingFactor = 2.0f;
|
||||
|
||||
nsTouchBarInputIcon::nsTouchBarInputIcon(NSButton* aButton,
|
||||
NSSharingServicePickerTouchBarItem* aShareScrubber)
|
||||
: mSetIcon(false), mButton(aButton), mShareScrubber(aShareScrubber) {
|
||||
MOZ_COUNT_CTOR(nsTouchBarInputIcon);
|
||||
}
|
||||
|
||||
nsTouchBarInputIcon::~nsTouchBarInputIcon() {
|
||||
Destroy();
|
||||
MOZ_COUNT_DTOR(nsTouchBarInputIcon);
|
||||
}
|
||||
|
||||
// Called from nsTouchBar's destructor, to prevent us from outliving it
|
||||
// (as might otherwise happen if calls to our imgINotificationObserver methods
|
||||
// are still outstanding). nsTouchBar owns our mTouchBarInput.
|
||||
void nsTouchBarInputIcon::Destroy() {
|
||||
if (mIconLoader) {
|
||||
mIconLoader->Destroy();
|
||||
mIconLoader = nullptr;
|
||||
}
|
||||
|
||||
mButton = nil;
|
||||
mShareScrubber = nil;
|
||||
}
|
||||
|
||||
nsresult nsTouchBarInputIcon::SetupIcon(nsCOMPtr<nsIURI> aIconURI,
|
||||
RefPtr<mozilla::dom::Document> aDocument) {
|
||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
|
||||
|
||||
// Still don't have one, then something is wrong, get out of here.
|
||||
if (!(mButton || mShareScrubber)) {
|
||||
NS_ERROR("No Touch Bar button");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (!mIconLoader) {
|
||||
// We ask only for the HiDPI images since all Touch Bars are Retina
|
||||
// displays and we have no need for icons @1x.
|
||||
mIconLoader = new nsIconLoaderService(aDocument, &mImageRegionRect, this, kIconSize, kIconSize,
|
||||
kHiDPIScalingFactor);
|
||||
if (!mIconLoader) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
|
||||
if (!mSetIcon) {
|
||||
// Load placeholder icon.
|
||||
[mButton setImage:mIconLoader->GetNativeIconImage()];
|
||||
[mShareScrubber setButtonImage:mIconLoader->GetNativeIconImage()];
|
||||
}
|
||||
|
||||
nsresult rv = mIconLoader->LoadIcon(aIconURI);
|
||||
if (NS_FAILED(rv)) {
|
||||
// There is no icon for this menu item, as an error occurred while loading it.
|
||||
// An icon might have been set earlier or the place holder icon may have
|
||||
// been set. Clear it.
|
||||
[mButton setImage:nil];
|
||||
[mShareScrubber setButtonImage:nil];
|
||||
}
|
||||
|
||||
mSetIcon = true;
|
||||
|
||||
return rv;
|
||||
|
||||
NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
|
||||
}
|
||||
|
||||
void nsTouchBarInputIcon::ReleaseJSObjects() {
|
||||
if (mIconLoader) {
|
||||
mIconLoader->ReleaseJSObjects();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// nsIconLoaderObserver
|
||||
//
|
||||
|
||||
nsresult nsTouchBarInputIcon::OnComplete(NSImage* aImage) {
|
||||
[mButton setImage:aImage];
|
||||
[mShareScrubber setButtonImage:aImage];
|
||||
|
||||
[aImage release];
|
||||
return NS_OK;
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
/* 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/. */
|
||||
|
||||
#ifndef nsTouchBarNativeAPIDefines_h
|
||||
#define nsTouchBarNativeAPIDefines_h
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
#if !defined(MAC_OS_X_VERSION_10_12) || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_12
|
||||
@interface NSButton (NewConstructors)
|
||||
@property(nonatomic) BOOL imageHugsTitle;
|
||||
+ (NSButton*)buttonWithTitle:(NSString*)title target:(id)target action:(SEL)action;
|
||||
@end
|
||||
|
||||
@interface NSColor (DisplayP3Colors)
|
||||
+ (NSColor*)colorWithDisplayP3Red:(CGFloat)red
|
||||
green:(CGFloat)green
|
||||
blue:(CGFloat)blue
|
||||
alpha:(CGFloat)alpha;
|
||||
@end
|
||||
#endif // !defined(MAC_OS_X_VERSION_10_12)
|
||||
|
||||
#if !defined(MAC_OS_X_VERSION_10_12_2) || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_12_2
|
||||
@interface NSApplication (TouchBarMenu)
|
||||
- (IBAction)toggleTouchBarCustomizationPalette:(id)sender;
|
||||
@end
|
||||
|
||||
typedef NSString* NSTouchBarItemIdentifier;
|
||||
__attribute__((weak_import)) @interface NSTouchBarItem : NSObject
|
||||
- (instancetype)initWithIdentifier:(NSTouchBarItemIdentifier)aIdentifier;
|
||||
@end
|
||||
|
||||
@protocol NSSharingServicePickerTouchBarItemDelegate
|
||||
@end
|
||||
|
||||
__attribute__((weak_import)) @interface NSSharingServicePickerTouchBarItem : NSTouchBarItem
|
||||
@property(strong) id<NSSharingServicePickerTouchBarItemDelegate> delegate;
|
||||
@property(strong) NSImage* buttonImage;
|
||||
@end
|
||||
|
||||
__attribute__((weak_import)) @interface NSCustomTouchBarItem : NSTouchBarItem
|
||||
@property(strong) NSView* view;
|
||||
@property(strong) NSString* customizationLabel;
|
||||
@end
|
||||
|
||||
@protocol NSTouchBarDelegate
|
||||
@end
|
||||
|
||||
typedef NSString* NSTouchBarCustomizationIdentifier;
|
||||
__attribute__((weak_import)) @interface NSTouchBar : NSObject
|
||||
@property(strong) NSArray<NSTouchBarItemIdentifier>* defaultItemIdentifiers;
|
||||
@property(strong) id<NSTouchBarDelegate> delegate;
|
||||
@property(strong) NSTouchBarCustomizationIdentifier customizationIdentifier;
|
||||
@property(strong) NSArray<NSTouchBarItemIdentifier>* customizationAllowedItemIdentifiers;
|
||||
- (NSTouchBarItem*)itemForIdentifier:(NSTouchBarItemIdentifier)aIdentifier;
|
||||
@end
|
||||
|
||||
@interface NSButton (TouchBarButton)
|
||||
@property(strong) NSColor* bezelColor;
|
||||
@end
|
||||
#endif // !defined(MAC_OS_X_VERSION_10_12_2)
|
||||
#endif // nsTouchBarNativeAPIDefines_h
|
||||
@@ -7,7 +7,6 @@
|
||||
#include "nsTouchBar.h"
|
||||
#include "nsITouchBarInput.h"
|
||||
#include "nsTouchBarUpdater.h"
|
||||
#include "nsTouchBarNativeAPIDefines.h"
|
||||
|
||||
#include "nsCocoaWindow.h"
|
||||
#include "nsIArray.h"
|
||||
@@ -21,6 +20,9 @@ extern BOOL sTouchBarIsInitialized;
|
||||
@interface BaseWindow (NSTouchBarProvider)
|
||||
@property(strong) NSTouchBar* touchBar;
|
||||
@end
|
||||
@interface NSApplication (TouchBarMenu)
|
||||
- (IBAction)toggleTouchBarCustomizationPalette:(id)sender;
|
||||
@end
|
||||
#endif
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsTouchBarUpdater, nsITouchBarUpdater);
|
||||
|
||||
BIN
widget/cocoa/touchbar/back.pdf
Executable file
BIN
widget/cocoa/touchbar/back.pdf
Executable file
Binary file not shown.
BIN
widget/cocoa/touchbar/bookmark-filled.pdf
Executable file
BIN
widget/cocoa/touchbar/bookmark-filled.pdf
Executable file
Binary file not shown.
BIN
widget/cocoa/touchbar/bookmark.pdf
Executable file
BIN
widget/cocoa/touchbar/bookmark.pdf
Executable file
Binary file not shown.
BIN
widget/cocoa/touchbar/forward.pdf
Executable file
BIN
widget/cocoa/touchbar/forward.pdf
Executable file
Binary file not shown.
BIN
widget/cocoa/touchbar/fullscreen.pdf
Executable file
BIN
widget/cocoa/touchbar/fullscreen.pdf
Executable file
Binary file not shown.
BIN
widget/cocoa/touchbar/home.pdf
Executable file
BIN
widget/cocoa/touchbar/home.pdf
Executable file
Binary file not shown.
BIN
widget/cocoa/touchbar/new.pdf
Executable file
BIN
widget/cocoa/touchbar/new.pdf
Executable file
Binary file not shown.
BIN
widget/cocoa/touchbar/reader-mode.pdf
Executable file
BIN
widget/cocoa/touchbar/reader-mode.pdf
Executable file
Binary file not shown.
BIN
widget/cocoa/touchbar/refresh.pdf
Executable file
BIN
widget/cocoa/touchbar/refresh.pdf
Executable file
Binary file not shown.
BIN
widget/cocoa/touchbar/search.pdf
Executable file
BIN
widget/cocoa/touchbar/search.pdf
Executable file
Binary file not shown.
BIN
widget/cocoa/touchbar/share.pdf
Executable file
BIN
widget/cocoa/touchbar/share.pdf
Executable file
Binary file not shown.
BIN
widget/cocoa/touchbar/sidebar-left.pdf
Executable file
BIN
widget/cocoa/touchbar/sidebar-left.pdf
Executable file
Binary file not shown.
BIN
widget/cocoa/touchbar/sidebar-right.pdf
Executable file
BIN
widget/cocoa/touchbar/sidebar-right.pdf
Executable file
Binary file not shown.
@@ -6,8 +6,6 @@
|
||||
#include "nsISupports.idl"
|
||||
#include "nsITouchBarInput.idl"
|
||||
|
||||
webidl Document;
|
||||
|
||||
/**
|
||||
* Back-to-frontend communication for the Touch Bar
|
||||
*/
|
||||
@@ -24,12 +22,6 @@ interface nsITouchBarHelper : nsISupports
|
||||
*/
|
||||
readonly attribute AString activeTitle;
|
||||
|
||||
/**
|
||||
* The context in which this nsTouchBar exists. Required to create imgLoaders
|
||||
* to load our SVG icons.
|
||||
*/
|
||||
readonly attribute Document document;
|
||||
|
||||
/**
|
||||
* Returns all available Touch Bar Inputs in an nsIArray
|
||||
* of nsITouchBarInput objects.
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
|
||||
#include "nsIArray.idl"
|
||||
#include "nsISupports.idl"
|
||||
#include "nsIURI.idl"
|
||||
|
||||
[scriptable, function, uuid(001ab07c-1b3a-4dbf-a657-fada0065ff55)]
|
||||
interface nsITouchBarInputCallback : nsISupports
|
||||
@@ -27,9 +26,10 @@ interface nsITouchBarInput : nsISupports
|
||||
attribute AString title;
|
||||
|
||||
/**
|
||||
* The URI of an icon file.
|
||||
* The name of a icon file added to
|
||||
* /widget/cocoa/touchbar.
|
||||
*/
|
||||
attribute nsIURI image;
|
||||
attribute AString image;
|
||||
|
||||
/**
|
||||
* The type of the input.
|
||||
|
||||
Reference in New Issue
Block a user