Skip to content

Commit 5cfe983

Browse files
committed
Fix up annotations
1 parent 0cbebd6 commit 5cfe983

3 files changed

Lines changed: 52 additions & 21 deletions

File tree

src/display/annotation_layer.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1267,6 +1267,9 @@ class TextAnnotationElement extends AnnotationElement {
12671267
"data-l10n-args",
12681268
JSON.stringify({ type: this.data.name })
12691269
);
1270+
if (this.data.name !== "NoIcon" || this.data.hasOwnCanvas) {
1271+
this.hasOwnCommentButton = true;
1272+
}
12701273

12711274
if (!this.data.popupRef && this.hasPopupData) {
12721275
this.hasOwnCommentButton = true;

src/display/api.js

Lines changed: 47 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1912,6 +1912,16 @@ class PDFPageProxy {
19121912
this._intentStates.clear();
19131913
this.objs.clear();
19141914
this.#pendingCleanup = false;
1915+
1916+
if (this._transport.rendererHandler) {
1917+
try {
1918+
this._transport.rendererHandler.send("cleanupPage", {
1919+
pageIndex: this._pageIndex,
1920+
});
1921+
} catch {
1922+
// Ignore errors if the renderer worker has been destroyed.
1923+
}
1924+
}
19151925
return true;
19161926
}
19171927

@@ -3442,25 +3452,43 @@ class InternalRenderTask {
34423452
},
34433453
configurable: true,
34443454
});
3445-
this.rendererHandler.send(
3446-
"init",
3447-
{
3448-
pageIndex: this._pageIndex,
3449-
canvas: offscreen,
3450-
map: this.annotationCanvasMap,
3451-
colors: this.pageColors,
3452-
taskID: this.taskID,
3453-
transform,
3454-
viewport,
3455-
transparency,
3456-
background,
3457-
renderingIntent,
3458-
optionalContentConfig: optionalContentConfigData,
3459-
optionalContentConfigState,
3460-
dependencyTracker,
3461-
},
3462-
[offscreen]
3463-
);
3455+
const initTransfers = [offscreen];
3456+
const initParams = {
3457+
pageIndex: this._pageIndex,
3458+
canvas: offscreen,
3459+
colors: this.pageColors,
3460+
taskID: this.taskID,
3461+
transform,
3462+
viewport,
3463+
transparency,
3464+
background,
3465+
renderingIntent,
3466+
optionalContentConfig: optionalContentConfigData,
3467+
optionalContentConfigState,
3468+
dependencyTracker,
3469+
};
3470+
3471+
if (this.annotationCanvasMap) {
3472+
const annotationCanvases = [];
3473+
for (const [id, canvas] of this.annotationCanvasMap) {
3474+
try {
3475+
const annotationCanvas = canvas.transferControlToOffscreen();
3476+
annotationCanvases.push([id, annotationCanvas]);
3477+
initTransfers.push(annotationCanvas);
3478+
} catch (ex) {
3479+
warn(
3480+
`Failed to transfer annotation canvas to worker: ${ex.message}. `
3481+
);
3482+
}
3483+
}
3484+
if (annotationCanvases.length > 0) {
3485+
initParams.annotationCanvases = annotationCanvases;
3486+
} else {
3487+
initParams.map = new Map();
3488+
}
3489+
}
3490+
3491+
this.rendererHandler.send("init", initParams, initTransfers);
34643492
} catch (ex) {
34653493
// If transferControlToOffscreen fails (e.g., canvas already
34663494
// has a context), fall back to main thread rendering

src/display/renderer_worker.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class RendererMessageHandler {
6969
({
7070
pageIndex,
7171
canvas,
72-
map,
72+
annotationCanvasMap,
7373
colors,
7474
taskID,
7575
transform,
@@ -102,7 +102,7 @@ class RendererMessageHandler {
102102
this.#canvasFactory,
103103
this.#filterFactory,
104104
{ optionalContentConfig },
105-
map,
105+
annotationCanvasMap,
106106
colors
107107
);
108108
gfx.beginDrawing({ transform, viewport, transparency, background });

0 commit comments

Comments
 (0)