A window opened maximized is laid out at its persisted *restored*
size: AppWindow::UpdateWindowStateFromMiscXULAttributes applies the sizemode
attribute from xulstore before initial layout, but the size persisted alongside
it is the un-maximized one (MaybeSavePersistentPositionAndSize stores
GetRestoredBounds()), and the widget only learns its real size from the OS
afterwards. gUIDensity.init() runs at browser-window-load in between, so
_shouldAutoCompact() measures that smaller size and latches uidensity="compact".
The window is then reflowed and painted at its real size while still carrying
compact, and only the DOM resize event that follows corrects the density: a
visible jump in toolbar height, corner rounding and content offset.
Measure the area such a window is about to fill instead. It is known up front
and gives the same answer before and after the maximize transition, so there is
nothing left to correct after the first paint. Unlike exempting a non-normal
sizemode from auto-compact outright, this keeps compact mode for users whose
screen is genuinely small enough to warrant it.
Differential Revision: https://phabricator.services.mozilla.com/D324960