[api-minor] Stop setting an id on the styleElement used with CSS font-loading

This is yet another small piece of clean-up of the `FontLoader`-code, since we've not used this `id`-property for anything ever since PR 6571 (which landed almost seven years ago). Furthermore, by default we're also not even using that code-path now since the Font Loading API will always be used when available.

*Please note:* This is tagged `[api-minor]` since it's technically observable from the outside, however no user ought to be directly interacting with these CSS font rules.
This commit is contained in:
Jonas Jenwald 2022-10-02 11:26:08 +02:00
parent beff913813
commit 8e4ef6d89d
2 changed files with 4 additions and 9 deletions

View File

@ -2281,7 +2281,6 @@ class WorkerTransport {
this.loadingTask = loadingTask;
this.commonObjs = new PDFObjects();
this.fontLoader = new FontLoader({
docId: loadingTask.docId,
onUnsupportedFeature: this._onUnsupportedFeature.bind(this),
ownerDocument: params.ownerDocument,
styleElement: params.styleElement,

View File

@ -25,12 +25,10 @@ import {
class FontLoader {
constructor({
docId,
onUnsupportedFeature,
ownerDocument = globalThis.document,
styleElement = null, // For testing only.
}) {
this.docId = docId;
this._onUnsupportedFeature = onUnsupportedFeature;
this._document = ownerDocument;
@ -52,15 +50,13 @@ class FontLoader {
}
insertRule(rule) {
let styleElement = this.styleElement;
if (!styleElement) {
styleElement = this.styleElement = this._document.createElement("style");
styleElement.id = `PDFJS_FONT_STYLE_TAG_${this.docId}`;
if (!this.styleElement) {
this.styleElement = this._document.createElement("style");
this._document.documentElement
.getElementsByTagName("head")[0]
.append(styleElement);
.append(this.styleElement);
}
const styleSheet = styleElement.sheet;
const styleSheet = this.styleElement.sheet;
styleSheet.insertRule(rule, styleSheet.cssRules.length);
}