Bug 1444373 - Update mBounds on mPopupContentView every time mBounds on the containing window changes. r=spohl
authorMarkus Stange <mstange@themasta.com>
Mon, 09 Apr 2018 17:31:49 -0400
changeset 779691 49a092b664a6361c2898dc0707a642631f87be78
parent 779690 0d9149c03ebc16852adf5c91240cfdddfdc3b9de
child 779692 74863f508a8ca7f8513d713a5e4ea381efac1173
push id105836
push userbmo:ato@sny.no
push dateTue, 10 Apr 2018 12:07:22 +0000
reviewersspohl
bugs1444373
milestone61.0a1
Bug 1444373 - Update mBounds on mPopupContentView every time mBounds on the containing window changes. r=spohl MozReview-Commit-ID: GpwXVOQNgIj
widget/cocoa/nsChildView.h
widget/cocoa/nsChildView.mm
widget/cocoa/nsCocoaWindow.mm
--- a/widget/cocoa/nsChildView.h
+++ b/widget/cocoa/nsChildView.h
@@ -330,16 +330,23 @@ public:
 
   virtual void            Enable(bool aState) override;
   virtual bool            IsEnabled() const override;
   virtual nsresult        SetFocus(bool aRaise) override;
   virtual LayoutDeviceIntRect GetBounds() override;
   virtual LayoutDeviceIntRect GetClientBounds() override;
   virtual LayoutDeviceIntRect GetScreenBounds() override;
 
+  // Refresh mBounds with up-to-date values from [mView frame].
+  // Only called if this nsChildView is the popup content view of a popup window.
+  // For popup windows, the nsIWidget interface to Gecko is provided by
+  // nsCocoaWindow, not by nsChildView. So nsCocoaWindow manages resize requests
+  // from Gecko, fires resize events, and resizes the native NSWindow and NSView.
+  void UpdateBoundsFromView();
+
   // Returns the "backing scale factor" of the view's window, which is the
   // ratio of pixels in the window's backing store to Cocoa points. Prior to
   // HiDPI support in OS X 10.7, this was always 1.0, but in HiDPI mode it
   // will be 2.0 (and might potentially other values as screen resolutions
   // evolve). This gives the relationship between what Gecko calls "device
   // pixels" and the Cocoa "points" coordinate system.
   CGFloat                 BackingScaleFactor() const;
 
--- a/widget/cocoa/nsChildView.mm
+++ b/widget/cocoa/nsChildView.mm
@@ -2753,16 +2753,22 @@ nsChildView::TrackScrollEventAsSwipe(con
 }
 
 void
 nsChildView::SwipeFinished()
 {
   mSwipeTracker = nullptr;
 }
 
+void
+nsChildView::UpdateBoundsFromView()
+{
+  mBounds = CocoaPointsToDevPixels([mView frame]);
+}
+
 already_AddRefed<gfx::DrawTarget>
 nsChildView::StartRemoteDrawingInRegion(LayoutDeviceIntRegion& aInvalidRegion,
                                         BufferMode* aBufferMode)
 {
   // should have created the GLPresenter in InitCompositor.
   MOZ_ASSERT(mGLPresenter);
   if (!mGLPresenter) {
     mGLPresenter = GLPresenter::CreateForWindow(this);
--- a/widget/cocoa/nsCocoaWindow.mm
+++ b/widget/cocoa/nsCocoaWindow.mm
@@ -1701,16 +1701,20 @@ void
 nsCocoaWindow::UpdateBounds()
 {
   NSRect frame = NSZeroRect;
   if (mWindow) {
     frame = [mWindow frame];
   }
   mBounds =
     nsCocoaUtils::CocoaRectToGeckoRectDevPix(frame, BackingScaleFactor());
+
+  if (mPopupContentView) {
+    mPopupContentView->UpdateBoundsFromView();
+  }
 }
 
 LayoutDeviceIntRect
 nsCocoaWindow::GetScreenBounds()
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_RETURN;
 
 #ifdef DEBUG