зеркало из https://github.com/mozilla/gecko-dev.git
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:
Родитель
5e8315e1d3
Коммит
be40d4df76
|
@ -718,7 +718,7 @@ interface nsIDocShell : nsIDocShellTreeItem
|
|||
* <meta name="viewport"> tag is respected in a specific docshell.
|
||||
* Possible values are listed above.
|
||||
*/
|
||||
[infallible] attribute nsIDocShell_MetaViewportOverride metaViewportOverride;
|
||||
[infallible, setter_can_run_script] attribute nsIDocShell_MetaViewportOverride metaViewportOverride;
|
||||
|
||||
/**
|
||||
* Attribute that determines whether tracking protection is enabled.
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -241,7 +241,7 @@ class PresShell final : public nsStubDocumentObserver,
|
|||
return mLastOverWindowPointerLocation;
|
||||
}
|
||||
|
||||
void Init(nsPresContext*, nsViewManager*);
|
||||
MOZ_CAN_RUN_SCRIPT void Init(nsPresContext*, nsViewManager*);
|
||||
|
||||
/**
|
||||
* All callers are responsible for calling |Destroy| after calling
|
||||
|
@ -355,6 +355,7 @@ class PresShell final : public nsStubDocumentObserver,
|
|||
MOZ_CAN_RUN_SCRIPT bool ResizeReflowIgnoreOverride(
|
||||
nscoord aWidth, nscoord aHeight,
|
||||
ResizeReflowOptions = ResizeReflowOptions::NoOption);
|
||||
MOZ_CAN_RUN_SCRIPT void ForceResizeReflowWithCurrentDimensions();
|
||||
|
||||
/**
|
||||
* Add this pres shell to the refresh driver to be observed for resize
|
||||
|
@ -396,7 +397,8 @@ class PresShell final : public nsStubDocumentObserver,
|
|||
* Note that the assumptions that determine whether we need a mobile viewport
|
||||
* manager may have changed.
|
||||
*/
|
||||
void MaybeRecreateMobileViewportManager(bool aAfterInitialization);
|
||||
MOZ_CAN_RUN_SCRIPT void MaybeRecreateMobileViewportManager(
|
||||
bool aAfterInitialization);
|
||||
|
||||
/**
|
||||
* Returns true if this document uses mobile viewport sizing (including
|
||||
|
|
|
@ -2876,10 +2876,7 @@ void nsPresContext::SetDynamicToolbarMaxHeight(ScreenIntCoord aHeight) {
|
|||
// PresShell::ResizeReflow ends up subtracting the new dynamic toolbar
|
||||
// height from the window dimensions and kick a reflow with the proper ICB
|
||||
// size.
|
||||
nscoord currentWidth, currentHeight;
|
||||
presShell->GetViewManager()->GetWindowDimensions(¤tWidth,
|
||||
¤tHeight);
|
||||
presShell->ResizeReflow(currentWidth, currentHeight);
|
||||
presShell->ForceResizeReflowWithCurrentDimensions();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче