[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:
parent
beff913813
commit
8e4ef6d89d
@ -2281,7 +2281,6 @@ class WorkerTransport {
|
|||||||
this.loadingTask = loadingTask;
|
this.loadingTask = loadingTask;
|
||||||
this.commonObjs = new PDFObjects();
|
this.commonObjs = new PDFObjects();
|
||||||
this.fontLoader = new FontLoader({
|
this.fontLoader = new FontLoader({
|
||||||
docId: loadingTask.docId,
|
|
||||||
onUnsupportedFeature: this._onUnsupportedFeature.bind(this),
|
onUnsupportedFeature: this._onUnsupportedFeature.bind(this),
|
||||||
ownerDocument: params.ownerDocument,
|
ownerDocument: params.ownerDocument,
|
||||||
styleElement: params.styleElement,
|
styleElement: params.styleElement,
|
||||||
|
@ -25,12 +25,10 @@ import {
|
|||||||
|
|
||||||
class FontLoader {
|
class FontLoader {
|
||||||
constructor({
|
constructor({
|
||||||
docId,
|
|
||||||
onUnsupportedFeature,
|
onUnsupportedFeature,
|
||||||
ownerDocument = globalThis.document,
|
ownerDocument = globalThis.document,
|
||||||
styleElement = null, // For testing only.
|
styleElement = null, // For testing only.
|
||||||
}) {
|
}) {
|
||||||
this.docId = docId;
|
|
||||||
this._onUnsupportedFeature = onUnsupportedFeature;
|
this._onUnsupportedFeature = onUnsupportedFeature;
|
||||||
this._document = ownerDocument;
|
this._document = ownerDocument;
|
||||||
|
|
||||||
@ -52,15 +50,13 @@ class FontLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
insertRule(rule) {
|
insertRule(rule) {
|
||||||
let styleElement = this.styleElement;
|
if (!this.styleElement) {
|
||||||
if (!styleElement) {
|
this.styleElement = this._document.createElement("style");
|
||||||
styleElement = this.styleElement = this._document.createElement("style");
|
|
||||||
styleElement.id = `PDFJS_FONT_STYLE_TAG_${this.docId}`;
|
|
||||||
this._document.documentElement
|
this._document.documentElement
|
||||||
.getElementsByTagName("head")[0]
|
.getElementsByTagName("head")[0]
|
||||||
.append(styleElement);
|
.append(this.styleElement);
|
||||||
}
|
}
|
||||||
const styleSheet = styleElement.sheet;
|
const styleSheet = this.styleElement.sheet;
|
||||||
styleSheet.insertRule(rule, styleSheet.cssRules.length);
|
styleSheet.insertRule(rule, styleSheet.cssRules.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user