Bug 1493976 - Reset the resolution to 1 when entering fullscreen mode. r=kats,xidorn

The previous resolution is restored when exiting fullscreen mode.

Depends on D9442

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Botond Ballo 2018-10-24 19:20:05 +00:00
parent dc9473c8e5
commit 9379bf655d
2 changed files with 32 additions and 1 deletions

View File

@ -1510,7 +1510,8 @@ nsIDocument::nsIDocument()
mIgnoreOpensDuringUnloadCounter(0),
mNumTrackersFound(0),
mNumTrackersBlocked(0),
mDocLWTheme(Doc_Theme_Uninitialized)
mDocLWTheme(Doc_Theme_Uninitialized),
mSavedResolution(1.0f)
{
SetIsInDocument();
SetIsConnected(true);
@ -11186,6 +11187,16 @@ nsIDocument::CleanupFullscreenState()
}
mFullscreenStack.Clear();
mFullscreenRoot = nullptr;
// Restore the zoom level that was in place prior to entering fullscreen.
if (nsIPresShell* shell = GetShell()) {
if (nsPresContext* context = shell->GetPresContext()) {
if (context->IsRootContentDocument()) {
shell->SetResolutionAndScaleTo(mSavedResolution);
}
}
}
UpdateViewportScrollbarOverrideForFullscreen(this);
}
@ -11589,6 +11600,23 @@ nsIDocument::ApplyFullscreen(UniquePtr<FullscreenRequest> aRequest)
nsIDocument* child = this;
while (true) {
child->SetFullscreenRoot(fullScreenRootDoc);
// When entering fullscreen, reset the RCD's zoom level to 1,
// otherwise the fullscreen content could be sized larger than the
// screen (since fullscreen is implemented using position:fixed and
// fixed elements are sized to the layout viewport).
// This also ensures that things like video controls aren't zoomed in
// when in fullscreen mode.
if (nsIPresShell* shell = child->GetShell()) {
if (nsPresContext* context = shell->GetPresContext()) {
if (context->IsRootContentDocument()) {
// Save the previous resolution so it can be restored.
child->mSavedResolution = shell->GetResolution();
shell->SetResolutionAndScaleTo(1.0f);
}
}
}
NS_ASSERTION(child->GetFullscreenRoot() == fullScreenRootDoc,
"Fullscreen root should be set!");
if (child == fullScreenRootDoc) {

View File

@ -4771,6 +4771,9 @@ protected:
// document lightweight theme for use with :-moz-lwtheme, :-moz-lwtheme-brighttext
// and :-moz-lwtheme-darktext
DocumentTheme mDocLWTheme;
// Pres shell resolution saved before entering fullscreen mode.
float mSavedResolution;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsIDocument, NS_IDOCUMENT_IID)