mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 09:20:06 +02:00
Stop duplicating the platform
getter in multiple files
Currently both of the `AnnotationElement` and `KeyboardManager` classes contain *identical* `platform` getters, which seems like unnecessary duplication. With the pre-processor we can also limit the feature-testing to only GENERIC builds, since `navigator` should always be available in browsers.
This commit is contained in:
parent
5d79cc5bee
commit
82d127883d
5 changed files with 24 additions and 27 deletions
|
@ -738,6 +738,19 @@ class FeatureTest {
|
|||
typeof OffscreenCanvas !== "undefined"
|
||||
);
|
||||
}
|
||||
|
||||
static get platform() {
|
||||
if (
|
||||
(typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) &&
|
||||
typeof navigator === "undefined"
|
||||
) {
|
||||
return shadow(this, "platform", { isWin: false, isMac: false });
|
||||
}
|
||||
return shadow(this, "platform", {
|
||||
isWin: navigator.platform.includes("Win"),
|
||||
isMac: navigator.platform.includes("Mac"),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const hexNumbers = [...Array(256).keys()].map(n =>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue