Repository: mozilla/pdf.js
File: web/pdf_page_view.js (JavaScript)

Code before:
      viewport,
      annotationMode: this.#annotationMode,
      optionalContentConfigPromise: this._optionalContentConfigPromise,
      annotationCanvasMap: this._annotationCanvasMap,
      pageColors,
      isEditing: this.#isEditing,
    };
    const renderTask = (this.renderTask = pdfPage.render(renderContext));
    renderTask.onContinue = renderContinueCallback;

    const resultPromise = renderTask.promise.then(
      async () => {
        showCanvas?.(true);
        await this.#finishRenderTask(renderTask);

        this.structTreeLayer ||= new StructTreeLayerBuilder(
          pdfPage,
          viewport.rawDims
        );

        const textLayerPromise = this.#renderTextLayer();

        if (this.annotationLayer) {
          await this.#renderAnnotationLayer();

          if (this.#enableAutoLinking) {
            await this.#injectLinkAnnotations(textLayerPromise);
          }
        }

        const { annotationEditorUIManager } = this.#layerProperties;

        if (!annotationEditorUIManager) {
          return;
        }
        this.drawLayer ||= new DrawLayerBuilder({
          pageIndex: this.id,
        });
        await this.#renderDrawLayer();
        this.drawLayer.setParent(canvasWrapper);

        this.annotationEditorLayer ||= new AnnotationEditorLayerBuilder({
          uiManager: annotationEditorUIManager,
          pdfPage,
          l10n,
          structTreeLayer: this.structTreeLayer,
          accessibilityManager: this._accessibilityManager,
          annotationLayer: this.annotationLayer?.annotationLayer,
          textLayer: this.textLayer,
          drawLayer: this.drawLayer.getDrawLayer(),
          onAppend: annotationEditorLayerDiv => {

Review comment (suggestion):
Given that you are also checking if `this.#enableAutoLinking` is true inside `#injectLinkAnnotations`, this isn't really needed anymore.

Code after:
      optionalContentConfigPromise: this._optionalContentConfigPromise,
      annotationCanvasMap: this._annotationCanvasMap,
      pageColors,
      isEditing: this.#isEditing,
    };
    const renderTask = (this.renderTask = pdfPage.render(renderContext));
    renderTask.onContinue = renderContinueCallback;

    const resultPromise = renderTask.promise.then(
      async () => {
        showCanvas?.(true);
        await this.#finishRenderTask(renderTask);

        this.structTreeLayer ||= new StructTreeLayerBuilder(
          pdfPage,
          viewport.rawDims
        );

        const textLayerPromise = this.#renderTextLayer();

        if (this.annotationLayer) {
          await this.#renderAnnotationLayer();

          if (this.#enableAutoLinking && this.annotationLayer) {
            await this.#injectLinkAnnotations(textLayerPromise);
          }
        }

        const { annotationEditorUIManager } = this.#layerProperties;

        if (!annotationEditorUIManager) {
          return;
        }
        this.drawLayer ||= new DrawLayerBuilder({
          pageIndex: this.id,
        });
        await this.#renderDrawLayer();
        this.drawLayer.setParent(canvasWrapper);

        this.annotationEditorLayer ||= new AnnotationEditorLayerBuilder({
          uiManager: annotationEditorUIManager,
          pdfPage,
          l10n,
          structTreeLayer: this.structTreeLayer,
          accessibilityManager: this._accessibilityManager,
          annotationLayer: this.annotationLayer?.annotationLayer,
          textLayer: this.textLayer,
          drawLayer: this.drawLayer.getDrawLayer(),
          onAppend: annotationEditorLayerDiv => {
            this.#addLayer(annotationEditorLayerDiv, "annotationEditorLayer");
          },