Skip to content

Commit ff4529d

Browse files
authored
Merge pull request #20492 from nicolo-ribaudo/simplify-markedcontent-text-layer
Simplify positioning of elements inside `markedContent`
2 parents f824f38 + 7e0c939 commit ff4529d

3 files changed

Lines changed: 5 additions & 15 deletions

File tree

src/display/text_layer.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -346,14 +346,8 @@ class TextLayer {
346346
const divStyle = textDiv.style;
347347
// Setting the style properties individually, rather than all at once,
348348
// should be OK since the `textDiv` isn't appended to the document yet.
349-
if (this.#container === this.#rootContainer) {
350-
divStyle.left = `${((100 * left) / this.#pageWidth).toFixed(2)}%`;
351-
divStyle.top = `${((100 * top) / this.#pageHeight).toFixed(2)}%`;
352-
} else {
353-
// We're in a marked content span, hence we can't use percents.
354-
divStyle.left = `calc(var(--total-scale-factor) * ${left.toFixed(2)}px)`;
355-
divStyle.top = `calc(var(--total-scale-factor) * ${top.toFixed(2)}px)`;
356-
}
349+
divStyle.left = `${((100 * left) / this.#pageWidth).toFixed(2)}%`;
350+
divStyle.top = `${((100 * top) / this.#pageHeight).toFixed(2)}%`;
357351
divStyle.setProperty("--font-height", `${fontHeight.toFixed(2)}px`);
358352
divStyle.fontFamily = fontFamily;
359353

web/text_layer_builder.css

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,9 @@
5959
scale(var(--min-font-size-inv));
6060
}
6161

62-
/* Only necessary in Google Chrome, see issue 14205, and most unfortunately
63-
* the problem doesn't show up in "text" reference tests. */
64-
/*#if !MOZCENTRAL*/
65-
span.markedContent {
66-
top: 0;
67-
height: 0;
62+
.markedContent {
63+
display: contents;
6864
}
69-
/*#endif*/
7065

7166
span[role="img"] {
7267
user-select: none;

web/text_layer_builder.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,7 @@ class TextLayerBuilder {
321321
if (endDiv) {
322322
endDiv.style.width = parentTextLayer.style.width;
323323
endDiv.style.height = parentTextLayer.style.height;
324+
endDiv.style.userSelect = "text";
324325
anchor.parentElement.insertBefore(
325326
endDiv,
326327
modifyStart ? anchor : anchor.nextSibling

0 commit comments

Comments
 (0)