Merge backout
authorChris Jones <jones.chris.g@gmail.com>
Thu, 19 Aug 2010 19:02:48 -0500
changeset 50963 4d836fb96f4c989eca956012f2a75e182b664d62
parent 50961 28070f8d44b57484024a709e54bd18fcf4078c02 (current diff)
parent 50962 300b24ea2b74a14586fe46ed54026d54f13cec25 (diff)
child 50965 0a51470adf6a2dc433fdb2fa5ee6ef5b5276143e
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone2.0b5pre
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
Merge backout
view/src/nsView.cpp
--- a/view/src/nsView.cpp
+++ b/view/src/nsView.cpp
@@ -683,75 +683,72 @@ nsresult nsView::CreateWidget(const nsII
     NS_ERROR("We already have a window for this view? BAD");
     ViewWrapper* wrapper = GetWrapperFor(mWindow);
     NS_IF_RELEASE(wrapper);
     mWindow->SetClientData(nsnull);
     mWindow->Destroy();
     NS_RELEASE(mWindow);
   }
 
-  nsresult rv = LoadWidget(aWindowIID);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-
   PRBool initDataPassedIn = PR_TRUE;
   nsWidgetInitData initData;
   if (!aWidgetInitData) {
     // No initData, we're a child window
     initDataPassedIn = PR_FALSE;
     initData.mWindowType = eWindowType_child;
     initData.clipChildren = PR_TRUE;
     initData.clipSiblings = PR_TRUE;
     aWidgetInitData = &initData;
   }
   aWidgetInitData->mContentType = aContentType;
 
   nsIntRect trect = CalcWidgetBounds(aWidgetInitData->mWindowType);
 
-  nsCOMPtr<nsIDeviceContext> dx;
-  mViewManager->GetDeviceContext(*getter_AddRefs(dx));
+  if (NS_OK == LoadWidget(aWindowIID))
+  {
+    nsCOMPtr<nsIDeviceContext> dx;
+    mViewManager->GetDeviceContext(*getter_AddRefs(dx));
 
-  if (aNative && aWidgetInitData->mWindowType != eWindowType_popup) {
-    mWindow->Create(nsnull, aNative, trect, ::HandleEvent, dx, nsnull, nsnull, aWidgetInitData);
-  }
-  else {
-    if (!initDataPassedIn && GetParent() && 
-        GetParent()->GetViewManager() != mViewManager)
-      initData.mListenForResizes = PR_TRUE;
-    if (aParentWidget) {
-      NS_ASSERTION(aWidgetInitData->mWindowType == eWindowType_popup,
-                   "popup widget type expected");
-      mWindow->Create(aParentWidget, nsnull, trect,
-                      ::HandleEvent, dx, nsnull, nsnull, aWidgetInitData);
-    }
-    else {
-      nsIWidget* parentWidget = GetParent() ? GetParent()->GetNearestWidget(nsnull)
-                                            : nsnull;
-      if (aWidgetInitData->mWindowType == eWindowType_popup) {
-        // Without a parent, we can't make a popup.  This can happen
-        // when printing
-        if (!parentWidget)
-          return NS_ERROR_FAILURE;
-        mWindow->Create(nsnull, parentWidget->GetNativeData(NS_NATIVE_WIDGET), trect,
-                        ::HandleEvent, dx, nsnull, nsnull, aWidgetInitData);
-      } else {
-        mWindow->Create(parentWidget, nsnull, trect,
+    if (aNative && aWidgetInitData->mWindowType != eWindowType_popup)
+      mWindow->Create(nsnull, aNative, trect, ::HandleEvent, dx, nsnull, nsnull, aWidgetInitData);
+    else
+    {
+      if (!initDataPassedIn && GetParent() && 
+          GetParent()->GetViewManager() != mViewManager)
+        initData.mListenForResizes = PR_TRUE;
+      if (aParentWidget) {
+        NS_ASSERTION(aWidgetInitData->mWindowType == eWindowType_popup,
+                     "popup widget type expected");
+        mWindow->Create(aParentWidget, nsnull, trect,
                         ::HandleEvent, dx, nsnull, nsnull, aWidgetInitData);
       }
+      else {
+        nsIWidget* parentWidget = GetParent() ? GetParent()->GetNearestWidget(nsnull)
+                                              : nsnull;
+        if (aWidgetInitData->mWindowType == eWindowType_popup) {
+          // Without a parent, we can't make a popup.  This can happen
+          // when printing
+          if (!parentWidget)
+            return NS_ERROR_FAILURE;
+          mWindow->Create(nsnull, parentWidget->GetNativeData(NS_NATIVE_WIDGET), trect,
+                          ::HandleEvent, dx, nsnull, nsnull, aWidgetInitData);
+        } else {
+          mWindow->Create(parentWidget, nsnull, trect,
+                          ::HandleEvent, dx, nsnull, nsnull, aWidgetInitData);
+        }
+      }
     }
+    if (aEnableDragDrop) {
+      mWindow->EnableDragDrop(PR_TRUE);
+    }
+      
+    // propagate the z-index to the widget.
+    UpdateNativeWidgetZIndexes(this, FindNonAutoZIndex(this));
   }
 
-  if (aEnableDragDrop) {
-    mWindow->EnableDragDrop(PR_TRUE);
-  }
-      
-  // propagate the z-index to the widget.
-  UpdateNativeWidgetZIndexes(this, FindNonAutoZIndex(this));
-
   //make sure visibility state is accurate
 
   if (aResetVisibility) {
     SetVisibility(GetVisibility());
   }
 
   return NS_OK;
 }
@@ -823,26 +820,30 @@ void nsView::SetZIndex(PRBool aAuto, PRI
   }
 }
 
 //
 // internal window creation functions
 //
 nsresult nsView::LoadWidget(const nsCID &aClassIID)
 {
-  NS_ABORT_IF_FALSE(!mWindow, "Already have a widget?");
+  ViewWrapper* wrapper = new ViewWrapper(this);
+  if (!wrapper)
+    return NS_ERROR_OUT_OF_MEMORY;
+  NS_ADDREF(wrapper); // Will be released in ~nsView
 
   nsresult rv = CallCreateInstance(aClassIID, &mWindow);
-  if (NS_FAILED(rv)) {
-    return rv;
+
+  if (NS_SUCCEEDED(rv)) {
+    // Set the widget's client data
+    mWindow->SetClientData(wrapper);
+  } else {
+    delete wrapper;
   }
 
-  ViewWrapper* wrapper = new ViewWrapper(this);
-  NS_ADDREF(wrapper); // Will be released in ~nsView
-  mWindow->SetClientData(wrapper);
   return rv;
 }
 
 EVENT_CALLBACK nsIView::AttachWidgetEventHandler(nsIWidget* aWidget)
 {
 #ifdef DEBUG
   void* data = nsnull;
   aWidget->GetClientData(data);