Commit 469fad0e authored by Emilio Cobos Álvarez's avatar Emilio Cobos Álvarez
Browse files

Bug 1807838 - Simplify AppWindow::SizeShellTo when sizing to the window shell. r=smaug

In this case we can do easier things than going through the shell and
assuming all sizes go through the window.

Differential Revision: https://phabricator.services.mozilla.com/D166367
parent 56ddcf4c
Loading
Loading
Loading
Loading
+9 −7
Original line number Diff line number Diff line
@@ -2228,11 +2228,18 @@ nsresult AppWindow::SetRootShellSize(int32_t aWidth, int32_t aHeight) {

NS_IMETHODIMP AppWindow::SizeShellTo(nsIDocShellTreeItem* aShellItem,
                                     int32_t aCX, int32_t aCY) {
  MOZ_ASSERT(aShellItem == mDocShell || aShellItem == mPrimaryContentShell);
  if (aShellItem == mDocShell) {
    auto newSize =
        LayoutDeviceIntSize(aCX, aCY) + GetOuterToInnerSizeDifference(mWindow);
    SetSize(newSize.width, newSize.height, /* aRepaint = */ true);
    return NS_OK;
  }

  // XXXTAB This is wrong, we should actually reflow based on the passed in
  // shell.  For now we are hacking and doing delta sizing.  This is bad
  // because it assumes all size we add will go to the shell which probably
  // won't happen.

  nsCOMPtr<nsIBaseWindow> shellAsWin(do_QueryInterface(aShellItem));
  NS_ENSURE_TRUE(shellAsWin, NS_ERROR_FAILURE);

@@ -2621,11 +2628,6 @@ void AppWindow::IntrinsicallySizeShell(const CSSIntSize& aWindowDiff,
    return;
  }
  RefPtr<nsDocShell> docShell = mDocShell;
  nsCOMPtr<nsIDocShellTreeOwner> treeOwner;
  docShell->GetTreeOwner(getter_AddRefs(treeOwner));
  if (!treeOwner) {
    return;
  }

  CSSIntCoord maxWidth = 0;
  CSSIntCoord maxHeight = 0;
@@ -2654,7 +2656,7 @@ void AppWindow::IntrinsicallySizeShell(const CSSIntSize& aWindowDiff,

  int32_t width = pc->CSSPixelsToDevPixels(size->width);
  int32_t height = pc->CSSPixelsToDevPixels(size->height);
  treeOwner->SizeShellTo(docShell, width, height);
  SizeShellTo(docShell, width, height);

  // Update specified size for the final LoadPositionFromXUL call.
  aSpecWidth = size->width + aWindowDiff.width;