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:
Jonas Jenwald 2022-11-29 12:14:40 +01:00
parent 5d79cc5bee
commit 82d127883d
5 changed files with 24 additions and 27 deletions

View file

@ -22,6 +22,7 @@ import {
AnnotationBorderStyleType,
AnnotationType,
assert,
FeatureTest,
LINE_FACTOR,
shadow,
unreachable,
@ -563,15 +564,6 @@ class AnnotationElement {
}
return fields;
}
static get platform() {
const platform = typeof navigator !== "undefined" ? navigator.platform : "";
return shadow(this, "platform", {
isWin: platform.includes("Win"),
isMac: platform.includes("Mac"),
});
}
}
class LinkAnnotationElement extends AnnotationElement {
@ -904,7 +896,7 @@ class WidgetAnnotationElement extends AnnotationElement {
}
_getKeyModifier(event) {
const { isWin, isMac } = AnnotationElement.platform;
const { isWin, isMac } = FeatureTest.platform;
return (isWin && event.ctrlKey) || (isMac && event.metaKey);
}