зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset 16d6b2e332e0 (bug 975468) for OSX debug non-unified bustage.
This commit is contained in:
Родитель
75c94ab14f
Коммит
fbf37b0473
|
@ -27,21 +27,15 @@ public:
|
|||
|
||||
// For NSColorPanelWrapper.
|
||||
void Update(NSColor* aColor);
|
||||
// Call this method if you are done with this input, but the color picker needs to
|
||||
// stay open as it will be associated to another input
|
||||
void DoneWithRetarget();
|
||||
// Same as DoneWithRetarget + clean the static instance of sColorPanelWrapper,
|
||||
// as it is not needed anymore for now
|
||||
void Done();
|
||||
|
||||
private:
|
||||
static NSColor* GetNSColorFromHexString(const nsAString& aColor);
|
||||
static void GetHexStringFromNSColor(NSColor* aColor, nsAString& aResult);
|
||||
|
||||
static NSColorPanelWrapper* sColorPanelWrapper;
|
||||
|
||||
nsString mTitle;
|
||||
nsString mColor;
|
||||
NSColorPanelWrapper* mColorPanel;
|
||||
nsCOMPtr<nsIColorPickerShownCallback> mCallback;
|
||||
};
|
||||
|
||||
|
|
|
@ -37,7 +37,6 @@ HexStrToInt(NSString* str)
|
|||
}
|
||||
- (id)initWithPicker:(nsColorPicker*)aPicker;
|
||||
- (void)open:(NSColor*)aInitialColor title:(NSString*)aTitle;
|
||||
- (void)retarget:(nsColorPicker*)aPicker;
|
||||
- (void)colorChanged:(NSColorPanel*)aPanel;
|
||||
@end
|
||||
|
||||
|
@ -71,12 +70,6 @@ HexStrToInt(NSString* str)
|
|||
mColorPicker->Done();
|
||||
}
|
||||
|
||||
- (void)retarget:(nsColorPicker*)aPicker
|
||||
{
|
||||
mColorPicker->DoneWithRetarget();
|
||||
mColorPicker = aPicker;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
if ([mColorPanel delegate] == self) {
|
||||
|
@ -94,24 +87,15 @@ HexStrToInt(NSString* str)
|
|||
|
||||
NS_IMPL_ISUPPORTS1(nsColorPicker, nsIColorPicker)
|
||||
|
||||
NSColorPanelWrapper* nsColorPicker::sColorPanelWrapper = nullptr;
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsColorPicker::Init(nsIDOMWindow* aParent, const nsAString& aTitle,
|
||||
const nsAString& aInitialColor)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread(),
|
||||
"Color pickers can only be opened from main thread currently");
|
||||
mTitle = aTitle;
|
||||
mColor = aInitialColor;
|
||||
|
||||
if (sColorPanelWrapper) {
|
||||
// Update current wrapper to target the new input instead
|
||||
[sColorPanelWrapper retarget:this];
|
||||
} else {
|
||||
// Create a brand new color panel wrapper
|
||||
sColorPanelWrapper = [[NSColorPanelWrapper alloc] initWithPicker:this];
|
||||
}
|
||||
mColorPanel = [[NSColorPanelWrapper alloc] initWithPicker:this];
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -146,7 +130,7 @@ nsColorPicker::Open(nsIColorPickerShownCallback* aCallback)
|
|||
MOZ_ASSERT(aCallback);
|
||||
mCallback = aCallback;
|
||||
|
||||
[sColorPanelWrapper open:GetNSColorFromHexString(mColor)
|
||||
[mColorPanel open:GetNSColorFromHexString(mColor)
|
||||
title:nsCocoaUtils::ToNSString(mTitle)];
|
||||
|
||||
NS_ADDREF_THIS();
|
||||
|
@ -162,17 +146,12 @@ nsColorPicker::Update(NSColor* aColor)
|
|||
}
|
||||
|
||||
void
|
||||
nsColorPicker::DoneWithRetarget()
|
||||
nsColorPicker::Done()
|
||||
{
|
||||
mCallback->Done(EmptyString());
|
||||
mCallback = nullptr;
|
||||
|
||||
[mColorPanel release];
|
||||
|
||||
NS_RELEASE_THIS();
|
||||
}
|
||||
|
||||
void
|
||||
nsColorPicker::Done()
|
||||
{
|
||||
[sColorPanelWrapper release];
|
||||
sColorPanelWrapper = nullptr;
|
||||
DoneWithRetarget();
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче