Bug 1501665 Part 7: Add a new function to allow visual viewport size to be un-set. r=smaug

Once nsIPresShell::SetVisualViewportSize is called, we currently have
no way to restore the default viewport sizing behavior. This corrects that.
We need the default behavior to get correctly-placed scrollbars when
turning off meta viewport handling in Responsive Design Mode panes.

Differential Revision: https://phabricator.services.mozilla.com/D20593

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Brad Werth 2019-03-18 14:58:07 +00:00
Родитель 046007b94f
Коммит 1e6b91bfc7
2 изменённых файлов: 30 добавлений и 13 удалений

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

@ -10627,15 +10627,8 @@ void nsIPresShell::MarkFixedFramesForReflow(IntrinsicDirty aIntrinsicDirty) {
}
}
void nsIPresShell::SetVisualViewportSize(nscoord aWidth, nscoord aHeight) {
if (!mVisualViewportSizeSet || mVisualViewportSize.width != aWidth ||
mVisualViewportSize.height != aHeight) {
mVisualViewportSizeSet = true;
mVisualViewportSize.width = aWidth;
mVisualViewportSize.height = aHeight;
if (nsIScrollableFrame* rootScrollFrame =
GetRootScrollFrameAsScrollable()) {
void nsIPresShell::CompleteChangeToVisualViewportSize() {
if (nsIScrollableFrame* rootScrollFrame = GetRootScrollFrameAsScrollable()) {
rootScrollFrame->MarkScrollbarsDirtyForReflow();
}
MarkFixedFramesForReflow(nsIPresShell::eResize);
@ -10644,12 +10637,31 @@ void nsIPresShell::SetVisualViewportSize(nscoord aWidth, nscoord aHeight) {
window->VisualViewport()->PostResizeEvent();
}
if (nsIScrollableFrame* rootScrollFrame =
GetRootScrollFrameAsScrollable()) {
if (nsIScrollableFrame* rootScrollFrame = GetRootScrollFrameAsScrollable()) {
ScrollAnchorContainer* container = rootScrollFrame->Anchor();
container->UserScrolled();
}
}
void nsIPresShell::SetVisualViewportSize(nscoord aWidth, nscoord aHeight) {
if (!mVisualViewportSizeSet || mVisualViewportSize.width != aWidth ||
mVisualViewportSize.height != aHeight) {
mVisualViewportSizeSet = true;
mVisualViewportSize.width = aWidth;
mVisualViewportSize.height = aHeight;
CompleteChangeToVisualViewportSize();
}
}
void nsIPresShell::ResetVisualViewportSize() {
if (mVisualViewportSizeSet) {
mVisualViewportSizeSet = false;
mVisualViewportSize.width = 0;
mVisualViewportSize.height = 0;
CompleteChangeToVisualViewportSize();
}
}
bool nsIPresShell::SetVisualViewportOffset(

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

@ -1654,6 +1654,7 @@ class nsIPresShell : public nsStubDocumentObserver {
static void ClearMouseCapture(nsIFrame* aFrame);
void SetVisualViewportSize(nscoord aWidth, nscoord aHeight);
void ResetVisualViewportSize();
bool IsVisualViewportSizeSet() { return mVisualViewportSizeSet; }
nsSize GetVisualViewportSize() {
NS_ASSERTION(mVisualViewportSizeSet,
@ -1661,6 +1662,10 @@ class nsIPresShell : public nsStubDocumentObserver {
return mVisualViewportSize;
}
// This function handles all the work after VisualViewportSize is set
// or reset.
void CompleteChangeToVisualViewportSize();
/**
* The return value indicates whether the offset actually changed.
*/