Bug 1129774. Part 6: Remove aContext parameter from nsIWidget::CreateChild. r=jmathies draft
authorRobert O'Callahan <robert@ocallahan.org>
Thu, 05 Feb 2015 18:38:47 +1300
changeset 241010 012e98991a006c6a863ec491d2e98416870205b3
parent 241009 e3a5382708f04c3dd2960744b22279be35c94663
child 505227 b1af0a6d32d3ddab000b4fb5bd49a2e9510e2545
push id566
push userrocallahan@mozilla.com
push dateThu, 05 Feb 2015 05:39:41 +0000
reviewersjmathies
bugs1129774
milestone38.0a1
Bug 1129774. Part 6: Remove aContext parameter from nsIWidget::CreateChild. r=jmathies
view/nsView.cpp
widget/PuppetWidget.cpp
widget/PuppetWidget.h
widget/nsBaseWidget.cpp
widget/nsBaseWidget.h
widget/nsIWidget.h
--- a/view/nsView.cpp
+++ b/view/nsView.cpp
@@ -561,29 +561,26 @@ nsresult nsView::CreateWidget(nsWidgetIn
   bool initDataPassedIn = !!aWidgetInitData;
   aWidgetInitData = aWidgetInitData ? aWidgetInitData : &defaultInitData;
   defaultInitData.mListenForResizes =
     (!initDataPassedIn && GetParent() &&
      GetParent()->GetViewManager() != mViewManager);
 
   nsIntRect trect = CalcWidgetBounds(aWidgetInitData->mWindowType);
 
-  nsRefPtr<nsDeviceContext> dx = mViewManager->GetDeviceContext();
-
   nsIWidget* parentWidget =
     GetParent() ? GetParent()->GetNearestWidget(nullptr) : nullptr;
   if (!parentWidget) {
     NS_ERROR("nsView::CreateWidget without suitable parent widget??");
     return NS_ERROR_FAILURE;
   }
 
   // XXX: using aForceUseIWidgetParent=true to preserve previous
   // semantics.  It's not clear that it's actually needed.
-  mWindow = parentWidget->CreateChild(trect, dx, aWidgetInitData,
-                                      true).take();
+  mWindow = parentWidget->CreateChild(trect, aWidgetInitData, true).take();
   if (!mWindow) {
     return NS_ERROR_FAILURE;
   }
  
   InitializeWindow(aEnableDragDrop, aResetVisibility);
 
   return NS_OK;
 }
@@ -599,20 +596,18 @@ nsresult nsView::CreateWidgetForParent(n
                     "Use CreateWidgetForPopup");
   NS_ABORT_IF_FALSE(aParentWidget, "Parent widget required");
 
   DefaultWidgetInitData defaultInitData;
   aWidgetInitData = aWidgetInitData ? aWidgetInitData : &defaultInitData;
 
   nsIntRect trect = CalcWidgetBounds(aWidgetInitData->mWindowType);
 
-  nsRefPtr<nsDeviceContext> dx = mViewManager->GetDeviceContext();
-
   mWindow =
-    aParentWidget->CreateChild(trect, dx, aWidgetInitData).take();
+    aParentWidget->CreateChild(trect, aWidgetInitData).take();
   if (!mWindow) {
     return NS_ERROR_FAILURE;
   }
 
   InitializeWindow(aEnableDragDrop, aResetVisibility);
 
   return NS_OK;
 }
@@ -624,39 +619,35 @@ nsresult nsView::CreateWidgetForPopup(ns
 {
   AssertNoWindow();
   NS_ABORT_IF_FALSE(aWidgetInitData, "Widget init data required");
   NS_ABORT_IF_FALSE(aWidgetInitData->mWindowType == eWindowType_popup,
                     "Use one of the other CreateWidget methods");
 
   nsIntRect trect = CalcWidgetBounds(aWidgetInitData->mWindowType);
 
-  nsRefPtr<nsDeviceContext> dx = mViewManager->GetDeviceContext();
-
   // XXX/cjones: having these two separate creation cases seems ... um
   // ... unnecessary, but it's the way the old code did it.  Please
   // unify them by first finding a suitable parent nsIWidget, then
   // getting rid of aForceUseIWidgetParent.
   if (aParentWidget) {
     // XXX: using aForceUseIWidgetParent=true to preserve previous
     // semantics.  It's not clear that it's actually needed.
-    mWindow = aParentWidget->CreateChild(trect, dx, aWidgetInitData,
-                                         true).take();
+    mWindow = aParentWidget->CreateChild(trect, aWidgetInitData, true).take();
   }
   else {
     nsIWidget* nearestParent = GetParent() ? GetParent()->GetNearestWidget(nullptr)
                                            : nullptr;
     if (!nearestParent) {
       // Without a parent, we can't make a popup.  This can happen
       // when printing
       return NS_ERROR_FAILURE;
     }
 
-    mWindow =
-      nearestParent->CreateChild(trect, dx, aWidgetInitData).take();
+    mWindow = nearestParent->CreateChild(trect, aWidgetInitData).take();
   }
   if (!mWindow) {
     return NS_ERROR_FAILURE;
   }
 
   InitializeWindow(aEnableDragDrop, aResetVisibility);
 
   return NS_OK;
--- a/widget/PuppetWidget.cpp
+++ b/widget/PuppetWidget.cpp
@@ -133,17 +133,16 @@ PuppetWidget::InitIMEState()
     mTabChild->SendNotifyIMEFocus(false, &mIMEPreferenceOfParent, &chromeSeqno);
     mIMELastBlurSeqno = mIMELastReceivedSeqno = chromeSeqno;
     mNeedIMEStateInit = false;
   }
 }
 
 already_AddRefed<nsIWidget>
 PuppetWidget::CreateChild(const nsIntRect  &aRect,
-                          nsDeviceContext *aContext,
                           nsWidgetInitData *aInitData,
                           bool             aForceUseIWidgetParent)
 {
   bool isPopup = IsPopup(aInitData);
   nsCOMPtr<nsIWidget> widget = nsIWidget::CreatePuppetWidget(mTabChild);
   return ((widget &&
            NS_SUCCEEDED(widget->Create(isPopup ? nullptr: this, nullptr, aRect,
                                        aInitData))) ?
--- a/widget/PuppetWidget.h
+++ b/widget/PuppetWidget.h
@@ -60,17 +60,16 @@ public:
                     nsNativeWidget    aNativeParent,
                     const nsIntRect&  aRect,
                     nsWidgetInitData* aInitData = nullptr) MOZ_OVERRIDE;
 
   void InitIMEState();
 
   virtual already_AddRefed<nsIWidget>
   CreateChild(const nsIntRect  &aRect,
-              nsDeviceContext  *aContext,
               nsWidgetInitData *aInitData = nullptr,
               bool             aForceUseIWidgetParent = false) MOZ_OVERRIDE;
 
   NS_IMETHOD Destroy() MOZ_OVERRIDE;
 
   NS_IMETHOD Show(bool aState) MOZ_OVERRIDE;
 
   virtual bool IsVisible() const MOZ_OVERRIDE
--- a/widget/nsBaseWidget.cpp
+++ b/widget/nsBaseWidget.cpp
@@ -288,17 +288,16 @@ nsIWidgetListener* nsBaseWidget::GetWidg
 
 void nsBaseWidget::SetWidgetListener(nsIWidgetListener* aWidgetListener)
 {
   mWidgetListener = aWidgetListener;
 }
 
 already_AddRefed<nsIWidget>
 nsBaseWidget::CreateChild(const nsIntRect  &aRect,
-                          nsDeviceContext *aContext,
                           nsWidgetInitData *aInitData,
                           bool             aForceUseIWidgetParent)
 {
   nsIWidget* parent = this;
   nsNativeWidget nativeParent = nullptr;
 
   if (!aForceUseIWidgetParent) {
     // Use only either parent or nativeParent, not both, to match
--- a/widget/nsBaseWidget.h
+++ b/widget/nsBaseWidget.h
@@ -207,17 +207,16 @@ public:
   virtual nsIMEUpdatePreference GetIMEUpdatePreference() MOZ_OVERRIDE { return nsIMEUpdatePreference(); }
   NS_IMETHOD              OnDefaultButtonLoaded(const nsIntRect &aButtonRect) MOZ_OVERRIDE { return NS_ERROR_NOT_IMPLEMENTED; }
   NS_IMETHOD              OverrideSystemMouseScrollSpeed(double aOriginalDeltaX,
                                                          double aOriginalDeltaY,
                                                          double& aOverriddenDeltaX,
                                                          double& aOverriddenDeltaY) MOZ_OVERRIDE;
   virtual already_AddRefed<nsIWidget>
   CreateChild(const nsIntRect  &aRect,
-              nsDeviceContext *aContext,
               nsWidgetInitData *aInitData = nullptr,
               bool             aForceUseIWidgetParent = false) MOZ_OVERRIDE;
   NS_IMETHOD              AttachViewToTopLevel(bool aUseAttachedEvents) MOZ_OVERRIDE;
   virtual nsIWidgetListener* GetAttachedWidgetListener() MOZ_OVERRIDE;
   virtual void               SetAttachedWidgetListener(nsIWidgetListener* aListener) MOZ_OVERRIDE;
   NS_IMETHOD              RegisterTouchWindow() MOZ_OVERRIDE;
   NS_IMETHOD              UnregisterTouchWindow() MOZ_OVERRIDE;
   NS_IMETHOD_(TextEventDispatcher*) GetTextEventDispatcher() MOZ_OVERRIDE MOZ_FINAL;
--- a/widget/nsIWidget.h
+++ b/widget/nsIWidget.h
@@ -807,17 +807,16 @@ class nsIWidget : public nsISupports {
      *
      * |aForceUseIWidgetParent| forces |CreateChild()| to only use the
      * |nsIWidget*| this, not its native widget (if it exists), when
      * calling |Create()|.  This is a timid hack around poorly
      * understood code, and shouldn't be used in new code.
      */
     virtual already_AddRefed<nsIWidget>
     CreateChild(const nsIntRect  &aRect,
-                nsDeviceContext  *aContext,
                 nsWidgetInitData *aInitData = nullptr,
                 bool             aForceUseIWidgetParent = false) = 0;
 
     /**
      * Attach to a top level widget. 
      *
      * In cases where a top level chrome widget is being used as a content
      * container, attach a secondary listener and update the device