mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-10 18:25:37 +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
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue