1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-19 06:38:07 +02:00

Add new bounding-box helpers in Util to reduce code duplication

Currently we have a `Util`-helper for computing the bounding-box of a Bézier curve, however for simple points and rectangles we repeat virtually identical code in many spots throughout the code-base.

 - Introduce new `Util.pointBoundingBox` and `Util.rectBoundingBox` helpers.

 - Remove the "fallback" from `Util.bezierBoundingBox` and only support passing in a `minMax`-array, since there's only a single call-site using the other format and it could be easily updated.
This commit is contained in:
Jonas Jenwald 2025-03-23 12:09:51 +01:00
parent 19b4adac03
commit b85f0903ca
7 changed files with 71 additions and 95 deletions

View file

@ -59,11 +59,7 @@ function calculateLinkPosition(range, pdfPageView) {
quadPoints[i + 2] = quadPoints[i + 6] = normalized[2];
quadPoints[i + 5] = quadPoints[i + 7] = normalized[1];
rect[0] = Math.min(rect[0], normalized[0]);
rect[1] = Math.min(rect[1], normalized[1]);
rect[2] = Math.max(rect[2], normalized[2]);
rect[3] = Math.max(rect[3], normalized[3]);
Util.rectBoundingBox(...normalized, rect);
i += 8;
}
return { quadPoints, rect };