Merge pull request #20492 from nicolo-ribaudo/simplify-markedcontent-text-layer

Simplify positioning of elements inside `markedContent`
This commit is contained in:
calixteman 2025-12-12 17:29:33 +01:00 committed by GitHub
commit ff4529d127
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 5 additions and 15 deletions

View File

@ -346,14 +346,8 @@ class TextLayer {
const divStyle = textDiv.style;
// Setting the style properties individually, rather than all at once,
// should be OK since the `textDiv` isn't appended to the document yet.
if (this.#container === this.#rootContainer) {
divStyle.left = `${((100 * left) / this.#pageWidth).toFixed(2)}%`;
divStyle.top = `${((100 * top) / this.#pageHeight).toFixed(2)}%`;
} else {
// We're in a marked content span, hence we can't use percents.
divStyle.left = `calc(var(--total-scale-factor) * ${left.toFixed(2)}px)`;
divStyle.top = `calc(var(--total-scale-factor) * ${top.toFixed(2)}px)`;
}
divStyle.left = `${((100 * left) / this.#pageWidth).toFixed(2)}%`;
divStyle.top = `${((100 * top) / this.#pageHeight).toFixed(2)}%`;
divStyle.setProperty("--font-height", `${fontHeight.toFixed(2)}px`);
divStyle.fontFamily = fontFamily;

View File

@ -59,14 +59,9 @@
scale(var(--min-font-size-inv));
}
/* Only necessary in Google Chrome, see issue 14205, and most unfortunately
* the problem doesn't show up in "text" reference tests. */
/*#if !MOZCENTRAL*/
span.markedContent {
top: 0;
height: 0;
.markedContent {
display: contents;
}
/*#endif*/
span[role="img"] {
user-select: none;

View File

@ -321,6 +321,7 @@ class TextLayerBuilder {
if (endDiv) {
endDiv.style.width = parentTextLayer.style.width;
endDiv.style.height = parentTextLayer.style.height;
endDiv.style.userSelect = "text";
anchor.parentElement.insertBefore(
endDiv,
modifyStart ? anchor : anchor.nextSibling