Bug 1445787 - Correctly set the initial size of the ChildView we create for the popup contents. r?spohl draft
authorMarkus Stange <mstange@themasta.com>
Mon, 09 Apr 2018 16:25:14 -0400
changeset 779384 8eb93a9db33e20dbcf0d93381995688b0926b218
parent 779383 cf2498ab6164436f5a44c78a33625e1427685fdd
push id105761
push userbmo:mstange@themasta.com
push dateMon, 09 Apr 2018 20:26:26 +0000
reviewersspohl
bugs1445787
milestone61.0a1
Bug 1445787 - Correctly set the initial size of the ChildView we create for the popup contents. r?spohl Remote WebExtension panels can cause us to recreate the widget for a view that already has a size. In the past, popup widgets were always created with an initial size of 0x0, so setting the initial size of the ChildView to 0x0 resulted in correct behavior because the window would be resized to the correct size shortly afterwards, and resize the ChildView along with it via its auto resizing mask. When we recreate a widget which already has a known size, setting the initial size to 0x0 is wrong. We need to set the ChildView's size so that it fills the contentView of the popup window completely. MozReview-Commit-ID: 53d3AX3z5h2
widget/cocoa/nsCocoaWindow.mm
--- a/widget/cocoa/nsCocoaWindow.mm
+++ b/widget/cocoa/nsCocoaWindow.mm
@@ -549,20 +549,21 @@ nsCocoaWindow::CreatePopupContentView(co
 
   nsIWidget* thisAsWidget = static_cast<nsIWidget*>(this);
   nsresult rv = mPopupContentView->Create(thisAsWidget, nullptr, aRect,
                                           aInitData);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
-  ChildView* newContentView = (ChildView*)mPopupContentView->GetNativeData(NS_NATIVE_WIDGET);
-  [newContentView setFrame:NSZeroRect];
-  [newContentView setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
-  [[mWindow contentView] addSubview:newContentView];
+  NSView* contentView = [mWindow contentView];
+  ChildView* childView = (ChildView*)mPopupContentView->GetNativeData(NS_NATIVE_WIDGET);
+  [childView setFrame:[contentView bounds]];
+  [childView setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
+  [contentView addSubview:childView];
 
   return NS_OK;
 
   NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 void nsCocoaWindow::Destroy()
 {