Bug 1814668 - Fix viewport size invalidation on MVM changes. r=hiro
The MVM doesn't change the document viewer bounds nor the view manager bounds (maybe it used to?). Right now when exiting RDM, depending on the order of operations (if MVM reset is the last thing to happen) we end up with a wrong viewport size, because nsDocShell::SetSize is short-circuited here[1]. Instead, force a resize reflow with the current dimensions which is what the dynamic toolbar code also does, for example. [1]: https://searchfox.org/mozilla-central/rev/5ccb73c0217d1710b10d6e6e297cf3396d10ec23/view/nsViewManager.cpp#172 Differential Revision: https://phabricator.services.mozilla.com/D169806
This commit is contained in:
@@ -1947,6 +1947,13 @@ void PresShell::RefreshZoomConstraintsForScreenSizeChange() {
|
||||
}
|
||||
}
|
||||
|
||||
void PresShell::ForceResizeReflowWithCurrentDimensions() {
|
||||
nscoord currentWidth = 0;
|
||||
nscoord currentHeight = 0;
|
||||
mViewManager->GetWindowDimensions(¤tWidth, ¤tHeight);
|
||||
ResizeReflow(currentWidth, currentHeight);
|
||||
}
|
||||
|
||||
void PresShell::ResizeReflow(nscoord aWidth, nscoord aHeight,
|
||||
ResizeReflowOptions aOptions) {
|
||||
if (mZoomConstraintsClient) {
|
||||
@@ -11071,15 +11078,8 @@ void PresShell::MaybeRecreateMobileViewportManager(bool aAfterInitialization) {
|
||||
ResolutionChangeOrigin::MainThreadRestore);
|
||||
|
||||
if (aAfterInitialization) {
|
||||
// Force a reflow to our correct size by going back to the docShell
|
||||
// and asking it to reassert its size. This is necessary because
|
||||
// everything underneath the docShell, like the ViewManager, has been
|
||||
// altered by the MobileViewportManager in an irreversible way.
|
||||
nsDocShell* docShell =
|
||||
static_cast<nsDocShell*>(GetPresContext()->GetDocShell());
|
||||
int32_t width, height;
|
||||
docShell->GetSize(&width, &height);
|
||||
docShell->SetSize(width, height, false);
|
||||
// Force a reflow to our correct view manager size.
|
||||
ForceResizeReflowWithCurrentDimensions();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user