Backed out changeset 16d6b2e332e0 (bug 975468) for OSX debug non-unified bustage.
authorRyan VanderMeulen <ryanvm@gmail.com>
Thu, 13 Mar 2014 14:48:04 -0400
changeset 191649 ecedfea04ffc5ae69aa61dced95dbf5082322cb9
parent 191648 d7e998c17c498d724682113871bc61cc836fc23b
child 191650 fe40387eba1a40444f4fdbcc2dd7dde6a7d5c730
child 191656 63249d900cfb12cd995ddbbfed0c1ed3b6481496
push id474
push userasasaki@mozilla.com
push dateMon, 02 Jun 2014 21:01:02 +0000
treeherdermozilla-release@967f4cf1b31c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs975468
milestone30.0a1
backs out16d6b2e332e09ebba1fa623e300b28ceddd9c858
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backed out changeset 16d6b2e332e0 (bug 975468) for OSX debug non-unified bustage.
widget/cocoa/nsColorPicker.h
widget/cocoa/nsColorPicker.mm
--- a/widget/cocoa/nsColorPicker.h
+++ b/widget/cocoa/nsColorPicker.h
@@ -22,27 +22,21 @@ public:
   NS_DECL_ISUPPORTS
 
   NS_IMETHOD Init(nsIDOMWindow* aParent, const nsAString& aTitle,
                   const nsAString& aInitialColor);
   NS_IMETHOD Open(nsIColorPickerShownCallback* aCallback);
 
   // 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;
 };
 
 #endif // nsColorPicker_h_
--- a/widget/cocoa/nsColorPicker.mm
+++ b/widget/cocoa/nsColorPicker.mm
@@ -32,17 +32,16 @@ HexStrToInt(NSString* str)
 
 @interface NSColorPanelWrapper : NSObject <NSWindowDelegate>
 {
   NSColorPanel*  mColorPanel;
   nsColorPicker* mColorPicker;
 }
 - (id)initWithPicker:(nsColorPicker*)aPicker;
 - (void)open:(NSColor*)aInitialColor title:(NSString*)aTitle;
-- (void)retarget:(nsColorPicker*)aPicker;
 - (void)colorChanged:(NSColorPanel*)aPanel;
 @end
 
 @implementation NSColorPanelWrapper
 - (id)initWithPicker:(nsColorPicker*)aPicker
 {
   mColorPicker = aPicker;
   mColorPanel = [NSColorPanel sharedColorPanel];
@@ -66,22 +65,16 @@ HexStrToInt(NSString* str)
   mColorPicker->Update([mColorPanel color]);
 }
 
 - (void)windowWillClose:(NSNotification*)aNotification
 {
   mColorPicker->Done();
 }
 
-- (void)retarget:(nsColorPicker*)aPicker
-{
-  mColorPicker->DoneWithRetarget();
-  mColorPicker = aPicker;
-}
-
 - (void)dealloc
 {
   if ([mColorPanel delegate] == self) {
     [mColorPanel setTarget:nil];
     [mColorPanel setAction:nil];
     [mColorPanel setDelegate:nil];
   }
 
@@ -89,34 +82,25 @@ HexStrToInt(NSString* str)
   mColorPicker = nullptr;
 
   [super dealloc];
 }
 @end
 
 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;
 }
 
 /* static */ NSColor*
 nsColorPicker::GetNSColorFromHexString(const nsAString& aColor)
 {
   NSString* str = nsCocoaUtils::ToNSString(aColor);
 
@@ -141,38 +125,33 @@ nsColorPicker::GetHexStringFromNSColor(N
 }
 
 NS_IMETHODIMP
 nsColorPicker::Open(nsIColorPickerShownCallback* aCallback)
 {
   MOZ_ASSERT(aCallback);
   mCallback = aCallback;
 
-  [sColorPanelWrapper open:GetNSColorFromHexString(mColor)
+  [mColorPanel open:GetNSColorFromHexString(mColor)
               title:nsCocoaUtils::ToNSString(mTitle)];
 
   NS_ADDREF_THIS();
 
   return NS_OK;
 }
 
 void
 nsColorPicker::Update(NSColor* aColor)
 {
   GetHexStringFromNSColor(aColor, mColor);
   mCallback->Update(mColor);
 }
 
 void
-nsColorPicker::DoneWithRetarget()
+nsColorPicker::Done()
 {
   mCallback->Done(EmptyString());
   mCallback = nullptr;
+
+  [mColorPanel release];
+
   NS_RELEASE_THIS();
 }
-
-void
-nsColorPicker::Done()
-{
-  [sColorPanelWrapper release];
-  sColorPanelWrapper = nullptr;
-  DoneWithRetarget();
-}