зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1612068 - Fix top-level document zoom when restoring from bfcache. r=nika
This still doesn't really fix subframes, but those are broken in trunk already. Fixing subframes could be done by making the zoom Top()-only, or by propagating to browsing contexts in the bfcache as well from DidSet(..). Differential Revision: https://phabricator.services.mozilla.com/D72034
This commit is contained in:
Родитель
d36c96ab4c
Коммит
1159b42442
|
@ -7361,9 +7361,13 @@ nsresult nsDocShell::RestoreFromHistory() {
|
|||
// But we depend on that device context when adjusting the view size
|
||||
// via mContentViewer->SetBounds(newBounds) below. So we need to
|
||||
// explicitly tell it to check for changed resolution here.
|
||||
if (presShell &&
|
||||
presShell->GetPresContext()->DeviceContext()->CheckDPIChange()) {
|
||||
presShell->BackingScaleFactorChanged();
|
||||
if (presShell) {
|
||||
RefPtr<nsPresContext> pc = presShell->GetPresContext();
|
||||
if (pc->DeviceContext()->CheckDPIChange()) {
|
||||
presShell->BackingScaleFactorChanged();
|
||||
}
|
||||
// Recompute zoom and text-zoom and such.
|
||||
pc->RecomputeBrowsingContextDependentData();
|
||||
}
|
||||
|
||||
nsViewManager* newVM = presShell ? presShell->GetViewManager() : nullptr;
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
<!doctype html>
|
||||
<script>
|
||||
window.addEventListener("pageshow", function(e) {
|
||||
window.opener.handlePageShow(e.persisted);
|
||||
});
|
||||
</script>
|
||||
<a href="?1">This is a very interesting page</a>
|
||||
<iframe srcdoc="And this is a nested frame"></iframe>
|
|
@ -428,5 +428,7 @@ skip-if = (headless && os == 'mac') # Headless Bug 1414103
|
|||
support-files =
|
||||
transformed_scrolling_repaints_3_window.html
|
||||
transformed_scrolling_repaints_3_window_frame.html
|
||||
[test_zoom_restore_bfcache.html]
|
||||
support-files = file_zoom_restore_bfcache.html
|
||||
|
||||
# *** Please maintain alphabetical ordering when adding new tests ***
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
<!doctype html>
|
||||
<meta charset="utf-8">
|
||||
<title>Test for zoom restoration when coming from the bfcache</title>
|
||||
<script src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script src="/tests/SimpleTest/paint_listener.js"></script>
|
||||
<link rel="stylesheet" href="/tests/SimpleTest/test.css"/>
|
||||
<script>
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
const originalDPR = window.devicePixelRatio;
|
||||
let loadCount = 0;
|
||||
let childWin;
|
||||
function handlePageShow(persisted) {
|
||||
ok(typeof persisted == "boolean", "Should get the persisted state from the pageshow event");
|
||||
is(persisted, loadCount == 2, "Should've gone into the bfcache after the back navigation");
|
||||
|
||||
if (loadCount == 0) {
|
||||
loadCount++;
|
||||
is(childWin.devicePixelRatio, originalDPR, "No zoom")
|
||||
childWin.document.querySelector("a").click(); // navigate away
|
||||
} else if (loadCount == 1) {
|
||||
loadCount++;
|
||||
is(childWin.devicePixelRatio, originalDPR, "No zoom (yet)")
|
||||
is(childWin.document.querySelector("iframe").contentWindow.devicePixelRatio, originalDPR, "No zoom on frame either");
|
||||
SpecialPowers.setFullZoom(childWin, 2);
|
||||
childWin.requestAnimationFrame(() => childWin.requestAnimationFrame(() => {
|
||||
is(childWin.devicePixelRatio, originalDPR * 2, "Zoomed");
|
||||
is(childWin.document.querySelector("iframe").contentWindow.devicePixelRatio, originalDPR * 2, "Zoomed iframe too");
|
||||
childWin.history.back();
|
||||
}));
|
||||
} else {
|
||||
childWin.requestAnimationFrame(() => childWin.requestAnimationFrame(() => {
|
||||
is(childWin.devicePixelRatio, originalDPR * 2, "Should preserve zoom when restored");
|
||||
todo_is(childWin.document.querySelector("iframe").contentWindow.devicePixelRatio, originalDPR * 2, "Should preserve zoom on frames too");
|
||||
childWin.close();
|
||||
SimpleTest.finish();
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
childWin = window.open('file_zoom_restore_bfcache.html', '_blank');
|
||||
</script>
|
Загрузка…
Ссылка в новой задаче