зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1712750 - Make sure sanitize.xhtml gets to set its mozSubdialogReady. r=mtigley
The mozSubdialogReady was being set inside of sanitize.xhtml in its load event handler, which would be scheduled to run AFTER the SubDialog _onLoad handler (which is what awaits mozSubdialogReady). The only reason this wasn't more obvious is because the first time the dialog is opened, the SubDialog _onLoad handler awaits translation of the document, which gives sanitize.xhtml a chance to run its load event handler and set the mozSubdialogReady. Subsequent opens of the dialog wouldn't need to re-run translation due to document caching, and so the mozSubdialogReady wouldn't be waited for, resulting in incorrect dialog layout. Depends on D119329 Differential Revision: https://phabricator.services.mozilla.com/D119330
This commit is contained in:
Родитель
1cdf3f0759
Коммит
eaa75cbe8c
|
@ -20,8 +20,7 @@
|
|||
xmlns:html="http://www.w3.org/1999/xhtml"
|
||||
persist="lastSelected screenX screenY"
|
||||
data-l10n-id="dialog-title"
|
||||
data-l10n-attrs="style"
|
||||
onload="gSanitizePromptDialog.init();">
|
||||
data-l10n-attrs="style">
|
||||
<dialog buttons="accept,cancel">
|
||||
|
||||
<linkset>
|
||||
|
|
|
@ -30,7 +30,7 @@ var gSanitizePromptDialog = {
|
|||
return document.getElementById("sanitizeEverythingWarningBox");
|
||||
},
|
||||
|
||||
init() {
|
||||
async init() {
|
||||
// This is used by selectByTimespan() to determine if the window has loaded.
|
||||
this._inited = true;
|
||||
this._dialog = document.querySelector("dialog");
|
||||
|
@ -53,13 +53,9 @@ var gSanitizePromptDialog = {
|
|||
);
|
||||
let warningDesc = document.getElementById("sanitizeEverythingWarning");
|
||||
// Ensure we've translated and sized the warning.
|
||||
document.mozSubdialogReady = document.l10n
|
||||
.translateFragment(warningDesc)
|
||||
.then(() => {
|
||||
// And then ensure we've run layout.
|
||||
await document.l10n.translateFragment(warningDesc);
|
||||
let rootWin = window.browsingContext.topChromeWindow;
|
||||
return rootWin.promiseDocumentFlushed(() => {});
|
||||
});
|
||||
await rootWin.promiseDocumentFlushed(() => {});
|
||||
} else {
|
||||
this.warningBox.hidden = true;
|
||||
}
|
||||
|
@ -221,3 +217,20 @@ var gSanitizePromptDialog = {
|
|||
}
|
||||
},
|
||||
};
|
||||
|
||||
// We need to give the dialog an opportunity to set up the DOM
|
||||
// before its measured for the SubDialog it will be embedded in.
|
||||
// This is because the sanitizeEverythingWarningBox may or may
|
||||
// not be visible, depending on whether "Everything" is the default
|
||||
// choice in the menulist.
|
||||
document.mozSubdialogReady = new Promise(resolve => {
|
||||
window.addEventListener(
|
||||
"load",
|
||||
function() {
|
||||
gSanitizePromptDialog.init().then(resolve);
|
||||
},
|
||||
{
|
||||
once: true,
|
||||
}
|
||||
);
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче