Bug 1786048 - Part 4: Remove cross process SizeShellTo. r=emilio

Because the parent process lacks information about the current shell
size, the child has to send both the current and the new shell size to
the parent. The parent then applies the delta to the window size. This
can produce different results for calls with the same arguments,
whenever a previous call did not have enough time to update the child
with its new size.

The implementation is replaced by applying the delta in the child.

Differential Revision: https://phabricator.services.mozilla.com/D160261
This commit is contained in:
Matthias Camenzind 2022-11-30 19:37:17 +00:00
Родитель 81ce314e5c
Коммит 1238151864
9 изменённых файлов: 17 добавлений и 93 удалений

Просмотреть файл

@ -453,16 +453,20 @@ nsDocShellTreeOwner::SizeShellTo(nsIDocShellTreeItem* aShellItem, int32_t aCX,
do_QueryInterface(webBrowserChrome);
if (browserChild) {
// The XUL window to resize is in the parent process, but there we
// won't be able to get aShellItem to do the hack in
// AppWindow::SizeShellTo, so let's send the width and height of
// aShellItem too.
// won't be able to get the size of aShellItem. We can ask the parent
// process to change our size instead.
nsCOMPtr<nsIBaseWindow> shellAsWin(do_QueryInterface(aShellItem));
NS_ENSURE_TRUE(shellAsWin, NS_ERROR_FAILURE);
int32_t width = 0;
int32_t height = 0;
shellAsWin->GetSize(&width, &height);
return browserChild->RemoteSizeShellTo(aCX, aCY, width, height);
LayoutDeviceIntSize shellSize;
shellAsWin->GetSize(&shellSize.width, &shellSize.height);
LayoutDeviceIntSize deltaSize = LayoutDeviceIntSize(aCX, aCY) - shellSize;
LayoutDeviceIntSize currentSize;
GetSize(&currentSize.width, &currentSize.height);
LayoutDeviceIntSize newSize = currentSize + deltaSize;
return SetSize(newSize.width, newSize.height, true);
}
// XXX: this is weird, but we used to call a method here
// (webBrowserChrome->SizeBrowserTo()) whose implementations all failed

Просмотреть файл

@ -22,9 +22,6 @@ interface nsIBrowserChild : nsISupports
[notxpcom] void sendRequestFocus(in boolean canFocus, in CallerType aCallerType);
[noscript] void remoteSizeShellTo(in int32_t width, in int32_t height,
in int32_t shellItemWidth, in int32_t shellItemHeight);
void remoteDropLinks(in Array<nsIDroppedLinkItem> links);
/**

Просмотреть файл

@ -576,20 +576,6 @@ BrowserChild::SetChromeFlags(uint32_t aChromeFlags) {
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
BrowserChild::RemoteSizeShellTo(int32_t aWidth, int32_t aHeight,
int32_t aShellItemWidth,
int32_t aShellItemHeight) {
nsCOMPtr<nsIDocShell> ourDocShell = do_GetInterface(WebNavigation());
nsCOMPtr<nsIBaseWindow> docShellAsWin(do_QueryInterface(ourDocShell));
NS_ENSURE_STATE(docShellAsWin);
bool sent =
SendSizeShellTo(0, aWidth, aHeight, aShellItemWidth, aShellItemHeight);
return sent ? NS_OK : NS_ERROR_FAILURE;
}
NS_IMETHODIMP
BrowserChild::RemoteDropLinks(
const nsTArray<RefPtr<nsIDroppedLinkItem>>& aLinks) {

Просмотреть файл

@ -809,26 +809,6 @@ mozilla::ipc::IPCResult BrowserParent::RecvMoveFocus(
return IPC_OK();
}
mozilla::ipc::IPCResult BrowserParent::RecvSizeShellTo(
const uint32_t& aFlags, const int32_t& aWidth, const int32_t& aHeight,
const int32_t& aShellItemWidth, const int32_t& aShellItemHeight) {
NS_ENSURE_TRUE(mFrameElement, IPC_OK());
nsCOMPtr<nsIDocShell> docShell = mFrameElement->OwnerDoc()->GetDocShell();
NS_ENSURE_TRUE(docShell, IPC_OK());
nsCOMPtr<nsIDocShellTreeOwner> treeOwner;
nsresult rv = docShell->GetTreeOwner(getter_AddRefs(treeOwner));
NS_ENSURE_SUCCESS(rv, IPC_OK());
nsCOMPtr<nsIAppWindow> appWin(do_GetInterface(treeOwner));
NS_ENSURE_TRUE(appWin, IPC_OK());
appWin->SizeShellToWithLimit(aWidth, aHeight, aShellItemWidth,
aShellItemHeight);
return IPC_OK();
}
mozilla::ipc::IPCResult BrowserParent::RecvDropLinks(
nsTArray<nsString>&& aLinks) {
nsCOMPtr<nsIBrowser> browser =

Просмотреть файл

@ -265,12 +265,6 @@ class BrowserParent final : public PBrowserParent,
mozilla::ipc::IPCResult RecvMoveFocus(const bool& aForward,
const bool& aForDocumentNavigation);
mozilla::ipc::IPCResult RecvSizeShellTo(const uint32_t& aFlags,
const int32_t& aWidth,
const int32_t& aHeight,
const int32_t& aShellItemWidth,
const int32_t& aShellItemHeight);
mozilla::ipc::IPCResult RecvDropLinks(nsTArray<nsString>&& aLinks);
// TODO: Use MOZ_CAN_RUN_SCRIPT when it gains IPDL support (bug 1539864)

Просмотреть файл

@ -242,21 +242,6 @@ parent:
*/
async MoveFocus(bool forward, bool forDocumentNavigation);
/**
* SizeShellTo request propagation to parent.
*
* aFlag Can indicate if one of the dimensions should be ignored.
* If only one dimension has changed it has to be indicated
* by the nsIEmbeddingSiteWindow::DIM_FLAGS_IGNORE_* flags.
* aShellItemWidth,
* aShellItemHeight On parent side we won't be able to decide the dimensions
* of the shell item parameter in the original SizeShellTo
* call so we send over its dimensions that will be used
* for the actual resize.
**/
async SizeShellTo(uint32_t aFlag, int32_t aWidth, int32_t aHeight,
int32_t aShellItemWidth, int32_t aShellItemHeight);
/**
* Called by the child to inform the parent that links are dropped into
* content area.

Просмотреть файл

@ -2745,6 +2745,10 @@ NS_IMETHODIMP AppWindow::SetXULBrowserWindow(
return NS_OK;
}
// Given the dimensions of some content area held within this XUL window, and
// assuming that that content area will change its dimensions in linear
// proportion to the dimensions of this XUL window, changes the size of the XUL
// window so that the content area reaches a particular size.
void AppWindow::SizeShellToWithLimit(int32_t aDesiredWidth,
int32_t aDesiredHeight,
int32_t shellItemWidth,

Просмотреть файл

@ -385,6 +385,8 @@ class AppWindow final : public nsIBaseWindow,
GetPrimaryRemoteTabSize(int32_t* aWidth, int32_t* aHeight);
nsresult GetPrimaryContentShellSize(int32_t* aWidth, int32_t* aHeight);
nsresult SetPrimaryRemoteTabSize(int32_t aWidth, int32_t aHeight);
void SizeShellToWithLimit(int32_t aDesiredWidth, int32_t aDesiredHeight,
int32_t shellItemWidth, int32_t shellItemHeight);
#ifndef MOZ_NEW_XULSTORE
nsCOMPtr<nsIXULStore> mLocalStore;
#endif

Просмотреть файл

@ -153,34 +153,6 @@ interface nsIAppWindow : nsISupports
*/
[noscript] void beforeStartLayout();
/**
* Given the dimensions of some content area held within this
* XUL window, and assuming that that content area will change
* its dimensions in linear proportion to the dimensions of this
* XUL window, changes the size of the XUL window so that the
* content area reaches a particular size.
*
* We need to supply the content area dimensions because sometimes
* the child's nsDocShellTreeOwner needs to propagate a SizeShellTo
* call to the parent. But the shellItem argument of the call will
* not be available on the parent side.
*
* Note: this is an internal method, other consumers should never call this.
*
* @param aDesiredWidth
* The desired width of the content area in device pixels.
* @param aDesiredHeight
* The desired height of the content area in device pixels.
* @param shellItemWidth
* The current width of the content area.
* @param shellItemHeight
* The current height of the content area.
*/
[noscript, notxpcom] void sizeShellToWithLimit(in int32_t aDesiredWidth,
in int32_t aDesiredHeight,
in int32_t shellItemWidth,
in int32_t shellItemHeight);
/**
* If the window was opened as a content window, this will return the initial
* nsIOpenWindowInfo to use.