[Editor] Fix the dimensions of the annotation editor layer (follow-up of #16794)
This commit is contained in:
parent
de1f31aae8
commit
400699687e
@ -22,6 +22,7 @@ import {
|
|||||||
} from "./base_factory.js";
|
} from "./base_factory.js";
|
||||||
import {
|
import {
|
||||||
BaseException,
|
BaseException,
|
||||||
|
FeatureTest,
|
||||||
shadow,
|
shadow,
|
||||||
stringToBytes,
|
stringToBytes,
|
||||||
Util,
|
Util,
|
||||||
@ -967,8 +968,6 @@ function getCurrentTransformInverse(ctx) {
|
|||||||
return [a, b, c, d, e, f];
|
return [a, b, c, d, e, f];
|
||||||
}
|
}
|
||||||
|
|
||||||
const useRound = globalThis.CSS?.supports?.("width: round(1.5px, 1px)");
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {HTMLDivElement} div
|
* @param {HTMLDivElement} div
|
||||||
* @param {PageViewport} viewport
|
* @param {PageViewport} viewport
|
||||||
@ -984,6 +983,7 @@ function setLayerDimensions(
|
|||||||
if (viewport instanceof PageViewport) {
|
if (viewport instanceof PageViewport) {
|
||||||
const { pageWidth, pageHeight } = viewport.rawDims;
|
const { pageWidth, pageHeight } = viewport.rawDims;
|
||||||
const { style } = div;
|
const { style } = div;
|
||||||
|
const useRound = FeatureTest.isCSSRoundSupported;
|
||||||
|
|
||||||
const w = `var(--scale-factor) * ${pageWidth}px`,
|
const w = `var(--scale-factor) * ${pageWidth}px`,
|
||||||
h = `var(--scale-factor) * ${pageHeight}px`;
|
h = `var(--scale-factor) * ${pageHeight}px`;
|
||||||
|
@ -373,9 +373,15 @@ class AnnotationEditor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get parentDimensions() {
|
get parentDimensions() {
|
||||||
const { realScale } = this._uiManager.viewParameters;
|
const {
|
||||||
const [pageWidth, pageHeight] = this.pageDimensions;
|
parentScale,
|
||||||
return [pageWidth * realScale, pageHeight * realScale];
|
pageDimensions: [pageWidth, pageHeight],
|
||||||
|
} = this;
|
||||||
|
const scaledWidth = pageWidth * parentScale;
|
||||||
|
const scaledHeight = pageHeight * parentScale;
|
||||||
|
return FeatureTest.isCSSRoundSupported
|
||||||
|
? [Math.round(scaledWidth), Math.round(scaledHeight)]
|
||||||
|
: [scaledWidth, scaledHeight];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -625,6 +625,14 @@ class FeatureTest {
|
|||||||
isMac: navigator.platform.includes("Mac"),
|
isMac: navigator.platform.includes("Mac"),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static get isCSSRoundSupported() {
|
||||||
|
return shadow(
|
||||||
|
this,
|
||||||
|
"isCSSRoundSupported",
|
||||||
|
globalThis.CSS?.supports?.("width: round(1.5px, 1px)")
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const hexNumbers = [...Array(256).keys()].map(n =>
|
const hexNumbers = [...Array(256).keys()].map(n =>
|
||||||
|
Loading…
Reference in New Issue
Block a user