Bug 1609446 - Make default window-constraints always show the content. r=mats,mstange

This code is used to determine the sizes of the top-level windows. However the
code doesn't cause quite desirable behavior (see the bug, and comment 15).

This patch does two things:

 * Unifies the html / xul code-paths. This shouldn't change behavior (because
   GetXULMinSize returns the fixed min-* property if present anyways), but
   makes the patch a bit simpler.

 * Makes the min-width of the XUL window be the pref size instead of the
   min-size (for the cases where you have no explicit min-width). This looks a
   bit counter intuitive, but it's the only way to guarantee that the content
   will be shown. This matches the sizing algorithm that dialogs use by default
   (via calling window.sizeToContent()), while allowing to undersize the window
   via a fixed min-width property.

This in turn makes sizeToContent() work "by default" on XUL windows, avoiding
having to make JS listen to everything that possibly could change the layout of
the document (like resolution changes).

Differential Revision: https://phabricator.services.mozilla.com/D70209
This commit is contained in:
Emilio Cobos Álvarez
2020-04-15 01:44:25 +00:00
parent c3f4d8dbee
commit f125fdcce4
6 changed files with 85 additions and 33 deletions

View File

@@ -3136,8 +3136,10 @@ nsresult nsDocumentViewer::GetContentSizeInternal(int32_t* aWidth,
// Ceil instead of rounding here, so we can actually guarantee showing all the
// content.
*aWidth = std::ceil(presContext->AppUnitsToFloatDevPixels(shellArea.width));
*aHeight = std::ceil(presContext->AppUnitsToFloatDevPixels(shellArea.height));
auto devOuterSize = LayoutDeviceIntSize::FromAppUnitsToOutside(
shellArea, presContext->AppUnitsPerDevPixel());
*aWidth = devOuterSize.width;
*aHeight = devOuterSize.height;
return NS_OK;
}