Compare commits

..

No commits in common. "3da8901f2661a41f4b43688830f73a8a361b4924" and "2da54ffb596d50934810d73080fea03f95853fd3" have entirely different histories.

4 changed files with 28 additions and 36 deletions

View File

@ -332,13 +332,8 @@ pdfjs-editor-highlight-editor =
# “Drawing” is a noun, the string is used on the editor for drawings. # “Drawing” is a noun, the string is used on the editor for drawings.
pdfjs-editor-ink-editor = pdfjs-editor-ink-editor =
.aria-label = Drawing editor .aria-label = Drawing editor
pdfjs-editor-signature-editor =
# Used when a signature editor is selected/hovered. .aria-label = Signature editor
# Variables:
# $description (String) - a string describing/labeling the signature.
pdfjs-editor-signature-editor1 =
.aria-description = Signature editor: { $description }
pdfjs-editor-stamp-editor = pdfjs-editor-stamp-editor =
.aria-label = Image editor .aria-label = Image editor

View File

@ -1699,7 +1699,10 @@ class MarkupAnnotation extends Annotation {
fillAlpha, fillAlpha,
pointsCallback, pointsCallback,
}) { }) {
const bbox = (this.data.rect = [Infinity, Infinity, -Infinity, -Infinity]); let minX = Number.MAX_VALUE;
let minY = Number.MAX_VALUE;
let maxX = Number.MIN_VALUE;
let maxY = Number.MIN_VALUE;
const buffer = ["q"]; const buffer = ["q"];
if (extra) { if (extra) {
@ -1729,8 +1732,14 @@ class MarkupAnnotation extends Annotation {
]); ]);
for (let i = 0, ii = pointsArray.length; i < ii; i += 8) { for (let i = 0, ii = pointsArray.length; i < ii; i += 8) {
const points = pointsCallback(buffer, pointsArray.subarray(i, i + 8)); const [mX, MX, mY, MY] = pointsCallback(
Util.rectBoundingBox(...points, bbox); buffer,
pointsArray.subarray(i, i + 8)
);
minX = Math.min(minX, mX);
maxX = Math.max(maxX, MX);
minY = Math.min(minY, mY);
maxY = Math.max(maxY, MY);
} }
buffer.push("Q"); buffer.push("Q");
@ -1762,6 +1771,7 @@ class MarkupAnnotation extends Annotation {
const appearanceDict = new Dict(xref); const appearanceDict = new Dict(xref);
appearanceDict.set("Resources", resources); appearanceDict.set("Resources", resources);
const bbox = (this.data.rect = [minX, minY, maxX, maxY]);
appearanceDict.set("BBox", bbox); appearanceDict.set("BBox", bbox);
this.appearance = new StringStream("/GS0 gs /Fm0 Do"); this.appearance = new StringStream("/GS0 gs /Fm0 Do");
@ -4152,8 +4162,8 @@ class LineAnnotation extends MarkupAnnotation {
); );
return [ return [
points[0] - borderWidth, points[0] - borderWidth,
points[7] - borderWidth,
points[2] + borderWidth, points[2] + borderWidth,
points[7] - borderWidth,
points[3] + borderWidth, points[3] + borderWidth,
]; ];
}, },
@ -4204,7 +4214,7 @@ class SquareAnnotation extends MarkupAnnotation {
} else { } else {
buffer.push("S"); buffer.push("S");
} }
return [points[0], points[7], points[2], points[3]]; return [points[0], points[2], points[7], points[3]];
}, },
}); });
} }
@ -4268,7 +4278,7 @@ class CircleAnnotation extends MarkupAnnotation {
} else { } else {
buffer.push("S"); buffer.push("S");
} }
return [points[0], points[7], points[2], points[3]]; return [points[0], points[2], points[7], points[3]];
}, },
}); });
} }
@ -4339,7 +4349,7 @@ class PolylineAnnotation extends MarkupAnnotation {
); );
} }
buffer.push("S"); buffer.push("S");
return [points[0], points[7], points[2], points[3]]; return [points[0], points[2], points[7], points[3]];
}, },
}); });
} }
@ -4446,7 +4456,7 @@ class InkAnnotation extends MarkupAnnotation {
} }
buffer.push("S"); buffer.push("S");
} }
return [points[0], points[7], points[2], points[3]]; return [points[0], points[2], points[7], points[3]];
}, },
}); });
} }
@ -4678,7 +4688,7 @@ class HighlightAnnotation extends MarkupAnnotation {
`${points[4]} ${points[5]} l`, `${points[4]} ${points[5]} l`,
"f" "f"
); );
return [points[0], points[7], points[2], points[3]]; return [points[0], points[2], points[7], points[3]];
}, },
}); });
} }
@ -4803,7 +4813,7 @@ class UnderlineAnnotation extends MarkupAnnotation {
`${points[6]} ${points[7] + 1.3} l`, `${points[6]} ${points[7] + 1.3} l`,
"S" "S"
); );
return [points[0], points[7], points[2], points[3]]; return [points[0], points[2], points[7], points[3]];
}, },
}); });
} }
@ -4847,7 +4857,7 @@ class SquigglyAnnotation extends MarkupAnnotation {
buffer.push(`${x} ${y + shift} l`); buffer.push(`${x} ${y + shift} l`);
} while (x < xEnd); } while (x < xEnd);
buffer.push("S"); buffer.push("S");
return [points[4], y - 2 * dy, xEnd, y + 2 * dy]; return [points[4], xEnd, y - 2 * dy, y + 2 * dy];
}, },
}); });
} }
@ -4886,7 +4896,7 @@ class StrikeOutAnnotation extends MarkupAnnotation {
`${(points[3] + points[7]) / 2} l`, `${(points[3] + points[7]) / 2} l`,
"S" "S"
); );
return [points[0], points[7], points[2], points[3]]; return [points[0], points[2], points[7], points[3]];
}, },
}); });
} }

View File

@ -79,7 +79,7 @@ class SignatureEditor extends DrawingEditor {
this._willKeepAspectRatio = true; this._willKeepAspectRatio = true;
this.#signatureData = params.signatureData || null; this.#signatureData = params.signatureData || null;
this.#description = null; this.#description = null;
this.defaultL10nId = "pdfjs-editor-signature-editor1"; this.defaultL10nId = "pdfjs-editor-signature-editor";
} }
/** @inheritdoc */ /** @inheritdoc */
@ -158,13 +158,6 @@ class SignatureEditor extends DrawingEditor {
super.render(); super.render();
if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("MOZCENTRAL")) {
// TODO: remove this check once
// https://github.com/projectfluent/fluent.js/pull/640
// is merged and released.
this.div.setAttribute("data-l10n-attrs", "aria-description");
}
if (this._drawId === null) { if (this._drawId === null) {
if (this.#signatureData) { if (this.#signatureData) {
const { const {
@ -190,12 +183,6 @@ class SignatureEditor extends DrawingEditor {
}); });
this.addSignature(outline, heightInPage, description, uuid); this.addSignature(outline, heightInPage, description, uuid);
} else { } else {
// Avoid Firefox crashing (with a local build) because the description
// parameter is missing.
this.div.setAttribute(
"data-l10n-args",
JSON.stringify({ description: "" })
);
this.div.hidden = true; this.div.hidden = true;
this._uiManager.getSignature(this); this._uiManager.getSignature(this);
} }
@ -272,7 +259,7 @@ class SignatureEditor extends DrawingEditor {
const { outline } = (this.#signatureData = data); const { outline } = (this.#signatureData = data);
this.#isExtracted = outline instanceof ContourDrawOutline; this.#isExtracted = outline instanceof ContourDrawOutline;
this.#description = description; this.#description = description;
this.div.setAttribute("data-l10n-args", JSON.stringify({ description })); this.div.setAttribute("aria-description", description);
let drawingOptions; let drawingOptions;
if (this.#isExtracted) { if (this.#isExtracted) {
drawingOptions = SignatureEditor.getDefaultDrawingOptions(); drawingOptions = SignatureEditor.getDefaultDrawingOptions();

View File

@ -184,9 +184,9 @@ describe("Signature Editor", () => {
`.altText.editDescription[title="Hello World"]` `.altText.editDescription[title="Hello World"]`
); );
// Check the aria description. // Check the aria label.
await page.waitForSelector( await page.waitForSelector(
`${editorSelector}[aria-description="Signature editor: \u2068Hello World\u2069"]` `${editorSelector}[aria-description="Hello World"]`
); );
// Edit the description. // Edit the description.