Bug 1561227 Part 3: Make RDM UI save and restore resolution when responding to a full zoom change. r=mtigley

This change makes the RDM content frame script listen to the new
PreFullZoomChange event, and treat that as a trigger to save the
existing resolution. The content window will send 2 resize events
as it adjusts to the new RDM pane size set by the front end. After
these events are received, the resolution is restored and a new
event is fired that indicates the work of zooming is complete.

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Brad Werth 2019-10-24 16:49:01 +00:00
Родитель ada23c0648
Коммит 21b357260e
1 изменённых файлов: 32 добавлений и 0 удалений

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

@ -28,6 +28,9 @@ var global = this;
addMessageListener("ResponsiveMode:Stop", stopResponsiveMode);
addMessageListener("ResponsiveMode:IsActive", isActive);
// Track the resolution and re-apply it after a full zoom change.
let resolutionBeforeFullZoom = 0;
function debug(msg) {
// dump(`RDM CHILD: ${msg}\n`);
}
@ -60,6 +63,16 @@ var global = this;
startOnResize();
}
addEventListener("PreFullZoomChange", onPreFullZoomChange);
addEventListener(
"mozupdatedremoteframedimensions",
onUpdatedRemoteFrameDimensions,
{
capture: true,
mozSystemGroup: true,
}
);
// At this point, a content viewer might not be loaded for this
// docshell. setDocumentInRDMPane and makeScrollbarsFloating will be
// triggered by onLocationChange.
@ -71,6 +84,20 @@ var global = this;
sendAsyncMessage("ResponsiveMode:Start:Done");
}
function onPreFullZoomChange(event) {
if (event.originalTarget == content.document) {
resolutionBeforeFullZoom = content.windowUtils.getResolution();
}
}
function onUpdatedRemoteFrameDimensions(event) {
if (event.originalTarget == content.document) {
content.windowUtils.setResolutionAndScaleTo(resolutionBeforeFullZoom);
const e = new CustomEvent("ZoomComplete", { bubbles: true });
content.dispatchEvent(e);
}
}
function onResize() {
// Send both a content-resize event and a viewport-resize event, since both
// may have changed.
@ -136,6 +163,11 @@ var global = this;
restoreScrollbars();
setDocumentInRDMPane(false);
stopOnResize();
removeEventListener("PreFullZoomChange", onPreFullZoomChange);
removeEventListener(
"mozupdatedremoteframedimensions",
onUpdatedRemoteFrameDimensions
);
sendAsyncMessage("ResponsiveMode:Stop:Done");
}