Bug 1757410 - Ensure MobileViewportManager::UpdateSizesBeforeReflow gets called with up-to-date app-units-per-dev-pixel and CV bounds in UIResolutionChangedInternal. r=emilio

Before this change, BrowserChild::RecvUIResolutionChanged calls
UIResolutionChangedSync first, then updates CV bounds. With the setup, when
UIResolutionChangedInternal gets called, the CV bounds hasn't yet been updated
so that UpdateSizesBeforeReflow doesn't get the proper metrics.

This change consists of three parts;

1) Use UIResolutionChangedSync instead of UIResolutionChanged in
   nsDocumentViewer::SetBoundsWithFlags which calls
   nsPresContext::AppUnitsPerDevPixel which needs to be actually updated by
   UIResolutionChangedSync.
2) Move the UIResolutionChangedSync call in RecvUIResolutionChanged after
   the SetPositionAndSize in the function.
3) Add a UpdateSizesBeforeReflow call in UIResolutionChangedInternal

As for 1), nsDocumentViewer::SetBoundsWithFlags  calls
nsPresContext::AppUnitsPerDevPixel so that UIResolutionChangedInternal needs to be
called synchronously rather than asynchronously.

As for 2), SetPositionAndSize gets called only if the BrowserChild size is changed,
so we need to call UIResolutionChangedSync in other cases.

Differential Revision: https://phabricator.services.mozilla.com/D153687
This commit is contained in:
Hiroyuki Ikezoe 2022-08-15 03:39:20 +00:00
Родитель 174b12bfa0
Коммит c0d588b85a
3 изменённых файлов: 14 добавлений и 9 удалений

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

@ -3243,12 +3243,6 @@ mozilla::ipc::IPCResult BrowserChild::RecvUIResolutionChanged(
if (aDpi > 0) {
mPuppetWidget->UpdateBackingScaleCache(aDpi, aRounding, aScale);
}
nsCOMPtr<Document> document(GetTopLevelDocument());
RefPtr<nsPresContext> presContext =
document ? document->GetPresContext() : nullptr;
if (presContext) {
presContext->UIResolutionChangedSync();
}
ScreenIntSize screenSize = GetInnerSize();
if (mHasValidInnerSize && oldScreenSize != screenSize) {
@ -3264,6 +3258,13 @@ mozilla::ipc::IPCResult BrowserChild::RecvUIResolutionChanged(
screenSize.width, screenSize.height, true);
}
nsCOMPtr<Document> document(GetTopLevelDocument());
RefPtr<nsPresContext> presContext =
document ? document->GetPresContext() : nullptr;
if (presContext) {
presContext->UIResolutionChangedSync();
}
return IPC_OK();
}

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

@ -1980,7 +1980,7 @@ nsDocumentViewer::SetBoundsWithFlags(const nsIntRect& aBounds,
// of windows/widgets competing to handle the notifications.
// (See bug 1154125.)
if (mPresContext->DeviceContext()->CheckDPIChange()) {
mPresContext->UIResolutionChanged();
mPresContext->UIResolutionChangedSync();
}
int32_t p2a = mPresContext->AppUnitsPerDevPixel();

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

@ -1755,8 +1755,12 @@ void nsPresContext::UIResolutionChangedInternal() {
AppUnitsPerDevPixelChanged();
}
if (GetPresShell()) {
GetPresShell()->RefreshZoomConstraintsForScreenSizeChange();
if (mPresShell) {
mPresShell->RefreshZoomConstraintsForScreenSizeChange();
if (RefPtr<MobileViewportManager> mvm =
mPresShell->GetMobileViewportManager()) {
mvm->UpdateSizesBeforeReflow();
}
}
// Recursively notify all remote leaf descendants of the change.