mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 01:10:08 +02:00
Re-factor the OverlayManager
class to use a WeakMap
internally
This way we're able to store the `<dialog>` elements directly, which removes the need to use manually specified name-strings thus simplifying both the `OverlayManager` itself and its calling code.
This commit is contained in:
parent
f0aa08b464
commit
923bd52cdb
6 changed files with 48 additions and 66 deletions
|
@ -162,13 +162,11 @@ function requestAccessToLocalFile(fileUrl, overlayManager, callback) {
|
|||
reloadIfRuntimeIsUnavailable();
|
||||
});
|
||||
}
|
||||
if (!chromeFileAccessOverlayPromise) {
|
||||
chromeFileAccessOverlayPromise = overlayManager.register(
|
||||
"chromeFileAccessDialog",
|
||||
dialog,
|
||||
/* canForceClose = */ true
|
||||
);
|
||||
}
|
||||
chromeFileAccessOverlayPromise ||= overlayManager.register(
|
||||
dialog,
|
||||
/* canForceClose = */ true
|
||||
);
|
||||
|
||||
chromeFileAccessOverlayPromise.then(function () {
|
||||
const iconPath = chrome.runtime.getManifest().icons[48];
|
||||
document.getElementById("chrome-pdfjs-logo-bg").style.backgroundImage =
|
||||
|
@ -227,11 +225,11 @@ function requestAccessToLocalFile(fileUrl, overlayManager, callback) {
|
|||
originalUrl = "file:///fakepath/to/" + encodeURIComponent(file.name);
|
||||
}
|
||||
callback(URL.createObjectURL(file), file.size, originalUrl);
|
||||
overlayManager.close("chromeFileAccessOverlay");
|
||||
overlayManager.close(dialog);
|
||||
}
|
||||
};
|
||||
|
||||
overlayManager.open("chromeFileAccessDialog");
|
||||
overlayManager.open(dialog);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue