@sync-in/server 1.4.0 → 1.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +26 -0
- package/README.md +2 -1
- package/package.json +5 -5
- package/server/applications/comments/comments.controller.spec.js +103 -4
- package/server/applications/comments/comments.controller.spec.js.map +1 -1
- package/server/applications/comments/services/comments-manager.service.spec.js +409 -9
- package/server/applications/comments/services/comments-manager.service.spec.js.map +1 -1
- package/server/applications/files/adapters/files-indexer-mysql.service.spec.js +333 -0
- package/server/applications/files/adapters/files-indexer-mysql.service.spec.js.map +1 -0
- package/server/applications/files/constants/routes.js +6 -1
- package/server/applications/files/constants/routes.js.map +1 -1
- package/server/applications/files/files-only-office.controller.js +11 -0
- package/server/applications/files/files-only-office.controller.js.map +1 -1
- package/server/applications/files/files-only-office.controller.spec.js +97 -3
- package/server/applications/files/files-only-office.controller.spec.js.map +1 -1
- package/server/applications/files/files-tasks.controller.spec.js +91 -1
- package/server/applications/files/files-tasks.controller.spec.js.map +1 -1
- package/server/applications/files/files.controller.spec.js +268 -46
- package/server/applications/files/files.controller.spec.js.map +1 -1
- package/server/applications/files/guards/files-only-office.guard.spec.js +77 -1
- package/server/applications/files/guards/files-only-office.guard.spec.js.map +1 -1
- package/server/applications/files/services/files-only-office-manager.service.js +5 -0
- package/server/applications/files/services/files-only-office-manager.service.js.map +1 -1
- package/server/applications/links/links.controller.spec.js +91 -58
- package/server/applications/links/links.controller.spec.js.map +1 -1
- package/server/applications/links/services/links-manager.service.js +4 -6
- package/server/applications/links/services/links-manager.service.js.map +1 -1
- package/server/applications/links/services/links-manager.service.spec.js +378 -14
- package/server/applications/links/services/links-manager.service.spec.js.map +1 -1
- package/server/applications/links/services/links-queries.service.js +1 -1
- package/server/applications/links/services/links-queries.service.js.map +1 -1
- package/server/applications/notifications/notifications.controller.spec.js +56 -1
- package/server/applications/notifications/notifications.controller.spec.js.map +1 -1
- package/server/applications/notifications/services/notifications-manager.service.spec.js +461 -5
- package/server/applications/notifications/services/notifications-manager.service.spec.js.map +1 -1
- package/server/applications/shares/services/shares-manager.service.spec.js +590 -14
- package/server/applications/shares/services/shares-manager.service.spec.js.map +1 -1
- package/server/applications/sync/interceptors/sync-diff-gzip-body.interceptor.spec.js +120 -0
- package/server/applications/sync/interceptors/sync-diff-gzip-body.interceptor.spec.js.map +1 -0
- package/server/applications/sync/services/sync-clients-manager.service.spec.js +548 -8
- package/server/applications/sync/services/sync-clients-manager.service.spec.js.map +1 -1
- package/server/applications/sync/services/sync-manager.service.spec.js +837 -5
- package/server/applications/sync/services/sync-manager.service.spec.js.map +1 -1
- package/server/applications/sync/services/sync-paths-manager.service.spec.js +900 -7
- package/server/applications/sync/services/sync-paths-manager.service.spec.js.map +1 -1
- package/server/applications/users/services/admin-users-manager.service.js +22 -24
- package/server/applications/users/services/admin-users-manager.service.js.map +1 -1
- package/server/applications/users/services/admin-users-manager.service.spec.js +763 -17
- package/server/applications/users/services/admin-users-manager.service.spec.js.map +1 -1
- package/server/applications/users/services/users-manager.service.js +1 -1
- package/server/applications/users/services/users-manager.service.js.map +1 -1
- package/server/applications/users/services/users-manager.service.spec.js +938 -49
- package/server/applications/users/services/users-manager.service.spec.js.map +1 -1
- package/server/applications/webdav/decorators/if-header.decorator.js +4 -1
- package/server/applications/webdav/decorators/if-header.decorator.js.map +1 -1
- package/server/applications/webdav/filters/webdav.filter.spec.js +77 -0
- package/server/applications/webdav/filters/webdav.filter.spec.js.map +1 -0
- package/server/applications/webdav/guards/webdav-protocol.guard.js +3 -7
- package/server/applications/webdav/guards/webdav-protocol.guard.js.map +1 -1
- package/server/applications/webdav/guards/webdav-protocol.guard.spec.js +580 -0
- package/server/applications/webdav/guards/webdav-protocol.guard.spec.js.map +1 -0
- package/server/applications/webdav/services/webdav-methods.service.spec.js +1582 -3
- package/server/applications/webdav/services/webdav-methods.service.spec.js.map +1 -1
- package/server/applications/webdav/services/webdav-spaces.service.spec.js +390 -2
- package/server/applications/webdav/services/webdav-spaces.service.spec.js.map +1 -1
- package/server/applications/webdav/webdav.controller.js +2 -2
- package/server/applications/webdav/webdav.controller.js.map +1 -1
- package/server/authentication/guards/auth-basic.guard.js.map +1 -1
- package/server/authentication/guards/auth-digest.guard.js +1 -2
- package/server/authentication/guards/auth-digest.guard.js.map +1 -1
- package/server/authentication/guards/auth-local.guard.js.map +1 -1
- package/server/infrastructure/context/interceptors/context.interceptor.spec.js +135 -0
- package/server/infrastructure/context/interceptors/context.interceptor.spec.js.map +1 -0
- package/static/3rdpartylicenses.txt +26 -26
- package/static/assets/pdfjs/build/pdf.mjs +1177 -255
- package/static/assets/pdfjs/build/pdf.mjs.map +1 -1
- package/static/assets/pdfjs/build/pdf.sandbox.mjs +25 -2
- package/static/assets/pdfjs/build/pdf.sandbox.mjs.map +1 -1
- package/static/assets/pdfjs/build/pdf.worker.mjs +140 -16
- package/static/assets/pdfjs/build/pdf.worker.mjs.map +1 -1
- package/static/assets/pdfjs/version +1 -1
- package/static/assets/pdfjs/web/debugger.css +31 -0
- package/static/assets/pdfjs/web/debugger.mjs +144 -2
- package/static/assets/pdfjs/web/images/comment-editButton.svg +6 -1
- package/static/assets/pdfjs/web/locale/ach/viewer.ftl +0 -63
- package/static/assets/pdfjs/web/locale/af/viewer.ftl +0 -71
- package/static/assets/pdfjs/web/locale/an/viewer.ftl +0 -63
- package/static/assets/pdfjs/web/locale/ast/viewer.ftl +0 -60
- package/static/assets/pdfjs/web/locale/az/viewer.ftl +0 -63
- package/static/assets/pdfjs/web/locale/be/viewer.ftl +38 -0
- package/static/assets/pdfjs/web/locale/bg/viewer.ftl +0 -37
- package/static/assets/pdfjs/web/locale/bn/viewer.ftl +0 -63
- package/static/assets/pdfjs/web/locale/bo/viewer.ftl +0 -63
- package/static/assets/pdfjs/web/locale/br/viewer.ftl +0 -37
- package/static/assets/pdfjs/web/locale/brx/viewer.ftl +0 -63
- package/static/assets/pdfjs/web/locale/bs/viewer.ftl +22 -0
- package/static/assets/pdfjs/web/locale/ca/viewer.ftl +0 -54
- package/static/assets/pdfjs/web/locale/cak/viewer.ftl +0 -54
- package/static/assets/pdfjs/web/locale/ckb/viewer.ftl +0 -63
- package/static/assets/pdfjs/web/locale/cs/viewer.ftl +38 -0
- package/static/assets/pdfjs/web/locale/cy/viewer.ftl +38 -0
- package/static/assets/pdfjs/web/locale/da/viewer.ftl +38 -0
- package/static/assets/pdfjs/web/locale/de/viewer.ftl +38 -0
- package/static/assets/pdfjs/web/locale/dsb/viewer.ftl +38 -0
- package/static/assets/pdfjs/web/locale/el/viewer.ftl +38 -0
- package/static/assets/pdfjs/web/locale/en-CA/viewer.ftl +38 -0
- package/static/assets/pdfjs/web/locale/en-GB/viewer.ftl +38 -0
- package/static/assets/pdfjs/web/locale/en-US/viewer.ftl +25 -0
- package/static/assets/pdfjs/web/locale/eo/viewer.ftl +38 -0
- package/static/assets/pdfjs/web/locale/es-AR/viewer.ftl +38 -0
- package/static/assets/pdfjs/web/locale/es-CL/viewer.ftl +38 -0
- package/static/assets/pdfjs/web/locale/es-MX/viewer.ftl +0 -6
- package/static/assets/pdfjs/web/locale/et/viewer.ftl +0 -57
- package/static/assets/pdfjs/web/locale/fa/viewer.ftl +0 -37
- package/static/assets/pdfjs/web/locale/ff/viewer.ftl +0 -63
- package/static/assets/pdfjs/web/locale/fi/viewer.ftl +38 -0
- package/static/assets/pdfjs/web/locale/fr/viewer.ftl +38 -0
- package/static/assets/pdfjs/web/locale/fy-NL/viewer.ftl +38 -0
- package/static/assets/pdfjs/web/locale/ga-IE/viewer.ftl +0 -71
- package/static/assets/pdfjs/web/locale/gd/viewer.ftl +0 -54
- package/static/assets/pdfjs/web/locale/gl/viewer.ftl +8 -0
- package/static/assets/pdfjs/web/locale/gn/viewer.ftl +38 -0
- package/static/assets/pdfjs/web/locale/gu-IN/viewer.ftl +0 -63
- package/static/assets/pdfjs/web/locale/he/viewer.ftl +38 -0
- package/static/assets/pdfjs/web/locale/hi-IN/viewer.ftl +0 -60
- package/static/assets/pdfjs/web/locale/hsb/viewer.ftl +38 -0
- package/static/assets/pdfjs/web/locale/hu/viewer.ftl +38 -0
- package/static/assets/pdfjs/web/locale/hy-AM/viewer.ftl +0 -49
- package/static/assets/pdfjs/web/locale/hye/viewer.ftl +0 -60
- package/static/assets/pdfjs/web/locale/ia/viewer.ftl +38 -0
- package/static/assets/pdfjs/web/locale/is/viewer.ftl +0 -3
- package/static/assets/pdfjs/web/locale/it/viewer.ftl +31 -0
- package/static/assets/pdfjs/web/locale/ja/viewer.ftl +8 -0
- package/static/assets/pdfjs/web/locale/ka/viewer.ftl +48 -10
- package/static/assets/pdfjs/web/locale/kab/viewer.ftl +5 -0
- package/static/assets/pdfjs/web/locale/kk/viewer.ftl +8 -0
- package/static/assets/pdfjs/web/locale/km/viewer.ftl +0 -63
- package/static/assets/pdfjs/web/locale/kn/viewer.ftl +0 -71
- package/static/assets/pdfjs/web/locale/ko/viewer.ftl +38 -0
- package/static/assets/pdfjs/web/locale/lij/viewer.ftl +0 -63
- package/static/assets/pdfjs/web/locale/lo/viewer.ftl +0 -54
- package/static/assets/pdfjs/web/locale/lt/viewer.ftl +0 -60
- package/static/assets/pdfjs/web/locale/ltg/viewer.ftl +0 -63
- package/static/assets/pdfjs/web/locale/lv/viewer.ftl +0 -63
- package/static/assets/pdfjs/web/locale/meh/viewer.ftl +0 -75
- package/static/assets/pdfjs/web/locale/mk/viewer.ftl +0 -63
- package/static/assets/pdfjs/web/locale/ml/viewer.ftl +0 -3
- package/static/assets/pdfjs/web/locale/mr/viewer.ftl +0 -63
- package/static/assets/pdfjs/web/locale/ms/viewer.ftl +0 -63
- package/static/assets/pdfjs/web/locale/my/viewer.ftl +0 -71
- package/static/assets/pdfjs/web/locale/nb-NO/viewer.ftl +44 -6
- package/static/assets/pdfjs/web/locale/ne-NP/viewer.ftl +0 -71
- package/static/assets/pdfjs/web/locale/nl/viewer.ftl +38 -0
- package/static/assets/pdfjs/web/locale/nn-NO/viewer.ftl +45 -1
- package/static/assets/pdfjs/web/locale/oc/viewer.ftl +0 -31
- package/static/assets/pdfjs/web/locale/pa-IN/viewer.ftl +38 -0
- package/static/assets/pdfjs/web/locale/pl/viewer.ftl +39 -1
- package/static/assets/pdfjs/web/locale/pt-BR/viewer.ftl +38 -0
- package/static/assets/pdfjs/web/locale/ro/viewer.ftl +355 -1
- package/static/assets/pdfjs/web/locale/ru/viewer.ftl +38 -0
- package/static/assets/pdfjs/web/locale/sat/viewer.ftl +0 -54
- package/static/assets/pdfjs/web/locale/sc/viewer.ftl +0 -38
- package/static/assets/pdfjs/web/locale/scn/viewer.ftl +0 -92
- package/static/assets/pdfjs/web/locale/sco/viewer.ftl +0 -60
- package/static/assets/pdfjs/web/locale/si/viewer.ftl +0 -51
- package/static/assets/pdfjs/web/locale/sk/viewer.ftl +38 -0
- package/static/assets/pdfjs/web/locale/skr/viewer.ftl +0 -27
- package/static/assets/pdfjs/web/locale/sl/viewer.ftl +8 -0
- package/static/assets/pdfjs/web/locale/son/viewer.ftl +0 -71
- package/static/assets/pdfjs/web/locale/sr/viewer.ftl +0 -33
- package/static/assets/pdfjs/web/locale/sv-SE/viewer.ftl +38 -0
- package/static/assets/pdfjs/web/locale/szl/viewer.ftl +0 -63
- package/static/assets/pdfjs/web/locale/ta/viewer.ftl +0 -63
- package/static/assets/pdfjs/web/locale/te/viewer.ftl +0 -60
- package/static/assets/pdfjs/web/locale/tg/viewer.ftl +38 -0
- package/static/assets/pdfjs/web/locale/tl/viewer.ftl +0 -63
- package/static/assets/pdfjs/web/locale/tr/viewer.ftl +40 -2
- package/static/assets/pdfjs/web/locale/trs/viewer.ftl +0 -72
- package/static/assets/pdfjs/web/locale/ur/viewer.ftl +0 -60
- package/static/assets/pdfjs/web/locale/uz/viewer.ftl +0 -71
- package/static/assets/pdfjs/web/locale/vi/viewer.ftl +38 -0
- package/static/assets/pdfjs/web/locale/wo/viewer.ftl +0 -77
- package/static/assets/pdfjs/web/locale/xh/viewer.ftl +0 -71
- package/static/assets/pdfjs/web/locale/zh-CN/viewer.ftl +38 -0
- package/static/assets/pdfjs/web/locale/zh-TW/viewer.ftl +38 -0
- package/static/assets/pdfjs/web/viewer.css +649 -120
- package/static/assets/pdfjs/web/viewer.html +19 -0
- package/static/assets/pdfjs/web/viewer.mjs +489 -38
- package/static/assets/pdfjs/web/viewer.mjs.map +1 -1
- package/static/chunk-22EANI6R.js +1 -0
- package/static/{chunk-N2LYWNTC.js → chunk-2456KVFZ.js} +1 -1
- package/static/{chunk-YCINY2YI.js → chunk-2LVCLKCK.js} +1 -1
- package/static/{chunk-5YKWZT33.js → chunk-2V5S7DWD.js} +1 -1
- package/static/{chunk-3GC2BQZD.js → chunk-44YDXGNZ.js} +1 -1
- package/static/{chunk-W3QXNDI5.js → chunk-4LSJLWYV.js} +1 -1
- package/static/{chunk-T55FAU2O.js → chunk-4UT5VH7R.js} +1 -1
- package/static/{chunk-VMQMD36Z.js → chunk-5GOMMRRE.js} +1 -1
- package/static/{chunk-TXPODW5Q.js → chunk-5J4VRDKB.js} +1 -1
- package/static/{chunk-FQ4AFNGE.js → chunk-6PVKNZ7Q.js} +1 -1
- package/static/{chunk-XE5YHU5J.js → chunk-BIUNUYZ5.js} +1 -1
- package/static/{chunk-X43VWRFP.js → chunk-DFQKHCDR.js} +1 -1
- package/static/{chunk-TDQAEVZN.js → chunk-EE2TDTY4.js} +1 -1
- package/static/{chunk-MOVWEZ7J.js → chunk-ESNDJ5T6.js} +1 -1
- package/static/{chunk-TCFKH6K6.js → chunk-GDKKLLEU.js} +1 -1
- package/static/{chunk-VHYIXL7R.js → chunk-GSR2MCQG.js} +1 -1
- package/static/{chunk-LJIGRUEF.js → chunk-HR7KS5BR.js} +1 -1
- package/static/chunk-HW2H3ISM.js +559 -0
- package/static/{chunk-HZA7R43P.js → chunk-IMB3C547.js} +1 -1
- package/static/{chunk-B2Y2RNFP.js → chunk-J4ALHUDX.js} +1 -1
- package/static/{chunk-PF4K7MVG.js → chunk-KP6LSQTK.js} +1 -1
- package/static/{chunk-C23BPTJZ.js → chunk-LUZCOHFN.js} +1 -1
- package/static/{chunk-GBCYYDCI.js → chunk-MHSCCXVL.js} +1 -1
- package/static/{chunk-PY3BGNJN.js → chunk-OMRQYBXV.js} +1 -1
- package/static/chunk-P7CTJ5BG.js +27 -0
- package/static/{chunk-Y2CDUS4J.js → chunk-P7PX67IR.js} +4 -4
- package/static/{chunk-VMUOUCEI.js → chunk-PPO7DBVO.js} +1 -1
- package/static/{chunk-TTQ37MUV.js → chunk-RSS6GYNE.js} +1 -1
- package/static/{chunk-WWIC7UW3.js → chunk-SLGGINMR.js} +1 -1
- package/static/{chunk-KZQCFEPT.js → chunk-UHD5XD3G.js} +1 -1
- package/static/{chunk-TNW2CGK6.js → chunk-UPYYAJCJ.js} +1 -1
- package/static/{chunk-6F55D74O.js → chunk-VHYPQ3D4.js} +1 -1
- package/static/{chunk-DGVNNICG.js → chunk-YQSDS6BO.js} +1 -1
- package/static/{chunk-MTRNPGS4.js → chunk-ZC5NIT55.js} +1 -1
- package/static/index.html +1 -1
- package/static/main-FYD34UEC.js +7 -0
- package/static/chunk-RSNLYAN6.js +0 -560
- package/static/chunk-WHMS3PJ3.js +0 -24
- package/static/chunk-ZZ3LHYOY.js +0 -1
- package/static/main-7LDKYVXO.js +0 -10
|
@@ -21,9 +21,32 @@
|
|
|
21
21
|
*/
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
|
-
* pdfjsVersion = 5.4.
|
|
25
|
-
* pdfjsBuild =
|
|
24
|
+
* pdfjsVersion = 5.4.149
|
|
25
|
+
* pdfjsBuild = 9e2e9e209
|
|
26
26
|
*/
|
|
27
|
+
/******/ // The require scope
|
|
28
|
+
/******/ var __webpack_require__ = {};
|
|
29
|
+
/******/
|
|
30
|
+
/************************************************************************/
|
|
31
|
+
/******/ /* webpack/runtime/define property getters */
|
|
32
|
+
/******/ (() => {
|
|
33
|
+
/******/ // define getter functions for harmony exports
|
|
34
|
+
/******/ __webpack_require__.d = (exports, definition) => {
|
|
35
|
+
/******/ for(var key in definition) {
|
|
36
|
+
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
|
|
37
|
+
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
|
38
|
+
/******/ }
|
|
39
|
+
/******/ }
|
|
40
|
+
/******/ };
|
|
41
|
+
/******/ })();
|
|
42
|
+
/******/
|
|
43
|
+
/******/ /* webpack/runtime/hasOwnProperty shorthand */
|
|
44
|
+
/******/ (() => {
|
|
45
|
+
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
|
46
|
+
/******/ })();
|
|
47
|
+
/******/
|
|
48
|
+
/************************************************************************/
|
|
49
|
+
var __webpack_exports__ = {};
|
|
27
50
|
|
|
28
51
|
;// ./src/shared/util.js
|
|
29
52
|
const isNodeJS = typeof process === "object" && process + "" === "[object process]" && !process.versions.nw && !(process.versions.electron && process.type && process.type !== "browser");
|
|
@@ -56,6 +79,7 @@ const AnnotationEditorType = {
|
|
|
56
79
|
HIGHLIGHT: 9,
|
|
57
80
|
STAMP: 13,
|
|
58
81
|
INK: 15,
|
|
82
|
+
POPUP: 16,
|
|
59
83
|
SIGNATURE: 101,
|
|
60
84
|
COMMENT: 102
|
|
61
85
|
};
|
|
@@ -513,6 +537,9 @@ class Util {
|
|
|
513
537
|
static makeHexColor(r, g, b) {
|
|
514
538
|
return `#${hexNumbers[r]}${hexNumbers[g]}${hexNumbers[b]}`;
|
|
515
539
|
}
|
|
540
|
+
static domMatrixToTransform(dm) {
|
|
541
|
+
return [dm.a, dm.b, dm.c, dm.d, dm.e, dm.f];
|
|
542
|
+
}
|
|
516
543
|
static scaleMinMax(transform, minMax) {
|
|
517
544
|
let temp;
|
|
518
545
|
if (transform[0]) {
|
|
@@ -560,6 +587,9 @@ class Util {
|
|
|
560
587
|
static transform(m1, m2) {
|
|
561
588
|
return [m1[0] * m2[0] + m1[2] * m2[1], m1[1] * m2[0] + m1[3] * m2[1], m1[0] * m2[2] + m1[2] * m2[3], m1[1] * m2[2] + m1[3] * m2[3], m1[0] * m2[4] + m1[2] * m2[5] + m1[4], m1[1] * m2[4] + m1[3] * m2[5] + m1[5]];
|
|
562
589
|
}
|
|
590
|
+
static multiplyByDOMMatrix(m, md) {
|
|
591
|
+
return [m[0] * md.a + m[2] * md.b, m[1] * md.a + m[3] * md.b, m[0] * md.c + m[2] * md.d, m[1] * md.c + m[3] * md.d, m[0] * md.e + m[2] * md.f + m[4], m[1] * md.e + m[3] * md.f + m[5]];
|
|
592
|
+
}
|
|
563
593
|
static applyTransform(p, m, pos = 0) {
|
|
564
594
|
const p0 = p[pos];
|
|
565
595
|
const p1 = p[pos + 1];
|
|
@@ -1401,12 +1431,14 @@ class EditorToolbar {
|
|
|
1401
1431
|
editToolbar.classList.add("editToolbar", "hidden");
|
|
1402
1432
|
editToolbar.setAttribute("role", "toolbar");
|
|
1403
1433
|
const signal = this.#editor._uiManager._signal;
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1434
|
+
if (signal instanceof AbortSignal && !signal.aborted) {
|
|
1435
|
+
editToolbar.addEventListener("contextmenu", noContextMenu, {
|
|
1436
|
+
signal
|
|
1437
|
+
});
|
|
1438
|
+
editToolbar.addEventListener("pointerdown", EditorToolbar.#pointerDown, {
|
|
1439
|
+
signal
|
|
1440
|
+
});
|
|
1441
|
+
}
|
|
1410
1442
|
const buttons = this.#buttons = document.createElement("div");
|
|
1411
1443
|
buttons.className = "buttons";
|
|
1412
1444
|
editToolbar.append(buttons);
|
|
@@ -1437,6 +1469,9 @@ class EditorToolbar {
|
|
|
1437
1469
|
}
|
|
1438
1470
|
#addListenersToElement(element) {
|
|
1439
1471
|
const signal = this.#editor._uiManager._signal;
|
|
1472
|
+
if (!(signal instanceof AbortSignal) || signal.aborted) {
|
|
1473
|
+
return false;
|
|
1474
|
+
}
|
|
1440
1475
|
element.addEventListener("focusin", this.#focusIn.bind(this), {
|
|
1441
1476
|
capture: true,
|
|
1442
1477
|
signal
|
|
@@ -1448,6 +1483,7 @@ class EditorToolbar {
|
|
|
1448
1483
|
element.addEventListener("contextmenu", noContextMenu, {
|
|
1449
1484
|
signal
|
|
1450
1485
|
});
|
|
1486
|
+
return true;
|
|
1451
1487
|
}
|
|
1452
1488
|
hide() {
|
|
1453
1489
|
this.#toolbar.classList.add("hidden");
|
|
@@ -1464,15 +1500,16 @@ class EditorToolbar {
|
|
|
1464
1500
|
_uiManager
|
|
1465
1501
|
} = this.#editor;
|
|
1466
1502
|
const button = document.createElement("button");
|
|
1467
|
-
button.
|
|
1503
|
+
button.classList.add("basic", "deleteButton");
|
|
1468
1504
|
button.tabIndex = 0;
|
|
1469
1505
|
button.setAttribute("data-l10n-id", EditorToolbar.#l10nRemove[editorType]);
|
|
1470
|
-
this.#addListenersToElement(button)
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1506
|
+
if (this.#addListenersToElement(button)) {
|
|
1507
|
+
button.addEventListener("click", e => {
|
|
1508
|
+
_uiManager.delete();
|
|
1509
|
+
}, {
|
|
1510
|
+
signal: _uiManager._signal
|
|
1511
|
+
});
|
|
1512
|
+
}
|
|
1476
1513
|
this.#buttons.append(button);
|
|
1477
1514
|
}
|
|
1478
1515
|
get #divider() {
|
|
@@ -1495,7 +1532,7 @@ class EditorToolbar {
|
|
|
1495
1532
|
return;
|
|
1496
1533
|
}
|
|
1497
1534
|
this.#addListenersToElement(button);
|
|
1498
|
-
this.#buttons.
|
|
1535
|
+
this.#buttons.append(button, this.#divider);
|
|
1499
1536
|
this.#comment = comment;
|
|
1500
1537
|
comment.toolbar = this;
|
|
1501
1538
|
}
|
|
@@ -1543,7 +1580,7 @@ class EditorToolbar {
|
|
|
1543
1580
|
this.#colorPicker = null;
|
|
1544
1581
|
}
|
|
1545
1582
|
}
|
|
1546
|
-
class
|
|
1583
|
+
class FloatingToolbar {
|
|
1547
1584
|
#buttons = null;
|
|
1548
1585
|
#toolbar = null;
|
|
1549
1586
|
#uiManager;
|
|
@@ -1554,13 +1591,23 @@ class HighlightToolbar {
|
|
|
1554
1591
|
const editToolbar = this.#toolbar = document.createElement("div");
|
|
1555
1592
|
editToolbar.className = "editToolbar";
|
|
1556
1593
|
editToolbar.setAttribute("role", "toolbar");
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1594
|
+
const signal = this.#uiManager._signal;
|
|
1595
|
+
if (signal instanceof AbortSignal && !signal.aborted) {
|
|
1596
|
+
editToolbar.addEventListener("contextmenu", noContextMenu, {
|
|
1597
|
+
signal
|
|
1598
|
+
});
|
|
1599
|
+
}
|
|
1560
1600
|
const buttons = this.#buttons = document.createElement("div");
|
|
1561
1601
|
buttons.className = "buttons";
|
|
1562
1602
|
editToolbar.append(buttons);
|
|
1563
|
-
this.#
|
|
1603
|
+
if (this.#uiManager.hasCommentManager()) {
|
|
1604
|
+
this.#makeButton("commentButton", `pdfjs-comment-floating-button`, "pdfjs-comment-floating-button-label", () => {
|
|
1605
|
+
this.#uiManager.commentSelection("floating_button");
|
|
1606
|
+
});
|
|
1607
|
+
}
|
|
1608
|
+
this.#makeButton("highlightButton", `pdfjs-highlight-floating-button1`, "pdfjs-highlight-floating-button-label", () => {
|
|
1609
|
+
this.#uiManager.highlightSelection("floating_button");
|
|
1610
|
+
});
|
|
1564
1611
|
return editToolbar;
|
|
1565
1612
|
}
|
|
1566
1613
|
#getLastPoint(boxes, isLTR) {
|
|
@@ -1599,24 +1646,24 @@ class HighlightToolbar {
|
|
|
1599
1646
|
hide() {
|
|
1600
1647
|
this.#toolbar.remove();
|
|
1601
1648
|
}
|
|
1602
|
-
#
|
|
1649
|
+
#makeButton(buttonClass, l10nId, labelL10nId, clickHandler) {
|
|
1603
1650
|
const button = document.createElement("button");
|
|
1604
|
-
button.
|
|
1651
|
+
button.classList.add("basic", buttonClass);
|
|
1605
1652
|
button.tabIndex = 0;
|
|
1606
|
-
button.setAttribute("data-l10n-id",
|
|
1653
|
+
button.setAttribute("data-l10n-id", l10nId);
|
|
1607
1654
|
const span = document.createElement("span");
|
|
1608
1655
|
button.append(span);
|
|
1609
1656
|
span.className = "visuallyHidden";
|
|
1610
|
-
span.setAttribute("data-l10n-id",
|
|
1657
|
+
span.setAttribute("data-l10n-id", labelL10nId);
|
|
1611
1658
|
const signal = this.#uiManager._signal;
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
}
|
|
1659
|
+
if (signal instanceof AbortSignal && !signal.aborted) {
|
|
1660
|
+
button.addEventListener("contextmenu", noContextMenu, {
|
|
1661
|
+
signal
|
|
1662
|
+
});
|
|
1663
|
+
button.addEventListener("click", clickHandler, {
|
|
1664
|
+
signal
|
|
1665
|
+
});
|
|
1666
|
+
}
|
|
1620
1667
|
this.#buttons.append(button);
|
|
1621
1668
|
}
|
|
1622
1669
|
}
|
|
@@ -2009,6 +2056,7 @@ class ColorManager {
|
|
|
2009
2056
|
class AnnotationEditorUIManager {
|
|
2010
2057
|
#abortController = new AbortController();
|
|
2011
2058
|
#activeEditor = null;
|
|
2059
|
+
#allEditableAnnotations = null;
|
|
2012
2060
|
#allEditors = new Map();
|
|
2013
2061
|
#allLayers = new Map();
|
|
2014
2062
|
#altTextManager = null;
|
|
@@ -2032,9 +2080,10 @@ class AnnotationEditorUIManager {
|
|
|
2032
2080
|
#focusManagerAC = null;
|
|
2033
2081
|
#highlightColors = null;
|
|
2034
2082
|
#highlightWhenShiftUp = false;
|
|
2035
|
-
#
|
|
2083
|
+
#floatingToolbar = null;
|
|
2036
2084
|
#idManager = new IdManager();
|
|
2037
2085
|
#isEnabled = false;
|
|
2086
|
+
#isPointerDown = false;
|
|
2038
2087
|
#isWaiting = false;
|
|
2039
2088
|
#keyboardManagerAC = null;
|
|
2040
2089
|
#lastActiveElement = null;
|
|
@@ -2047,6 +2096,7 @@ class AnnotationEditorUIManager {
|
|
|
2047
2096
|
#signatureManager = null;
|
|
2048
2097
|
#pageColors = null;
|
|
2049
2098
|
#showAllStates = null;
|
|
2099
|
+
#pdfDocument = null;
|
|
2050
2100
|
#previousStates = {
|
|
2051
2101
|
isEditing: false,
|
|
2052
2102
|
isEmpty: true,
|
|
@@ -2129,6 +2179,7 @@ class AnnotationEditorUIManager {
|
|
|
2129
2179
|
this.#altTextManager = altTextManager;
|
|
2130
2180
|
this.#commentManager = commentManager;
|
|
2131
2181
|
this.#signatureManager = signatureManager;
|
|
2182
|
+
this.#pdfDocument = pdfDocument;
|
|
2132
2183
|
this._eventBus = eventBus;
|
|
2133
2184
|
eventBus._on("editingaction", this.onEditingAction.bind(this), {
|
|
2134
2185
|
signal
|
|
@@ -2148,6 +2199,18 @@ class AnnotationEditorUIManager {
|
|
|
2148
2199
|
eventBus._on("switchannotationeditorparams", evt => this.updateParams(evt.type, evt.value), {
|
|
2149
2200
|
signal
|
|
2150
2201
|
});
|
|
2202
|
+
window.addEventListener("pointerdown", () => {
|
|
2203
|
+
this.#isPointerDown = true;
|
|
2204
|
+
}, {
|
|
2205
|
+
capture: true,
|
|
2206
|
+
signal
|
|
2207
|
+
});
|
|
2208
|
+
window.addEventListener("pointerup", () => {
|
|
2209
|
+
this.#isPointerDown = false;
|
|
2210
|
+
}, {
|
|
2211
|
+
capture: true,
|
|
2212
|
+
signal
|
|
2213
|
+
});
|
|
2151
2214
|
this.#addSelectionListener();
|
|
2152
2215
|
this.#addDragAndDropListeners();
|
|
2153
2216
|
this.#addKeyboardManager();
|
|
@@ -2186,10 +2249,11 @@ class AnnotationEditorUIManager {
|
|
|
2186
2249
|
this.#altTextManager?.destroy();
|
|
2187
2250
|
this.#commentManager?.destroy();
|
|
2188
2251
|
this.#signatureManager?.destroy();
|
|
2189
|
-
this.#
|
|
2190
|
-
this.#
|
|
2252
|
+
this.#floatingToolbar?.hide();
|
|
2253
|
+
this.#floatingToolbar = null;
|
|
2191
2254
|
this.#mainHighlightColorPicker?.destroy();
|
|
2192
2255
|
this.#mainHighlightColorPicker = null;
|
|
2256
|
+
this.#allEditableAnnotations = null;
|
|
2193
2257
|
if (this.#focusMainContainerTimeoutId) {
|
|
2194
2258
|
clearTimeout(this.#focusMainContainerTimeoutId);
|
|
2195
2259
|
this.#focusMainContainerTimeoutId = null;
|
|
@@ -2199,6 +2263,7 @@ class AnnotationEditorUIManager {
|
|
|
2199
2263
|
this.#translationTimeoutId = null;
|
|
2200
2264
|
}
|
|
2201
2265
|
this._editorUndoBar?.destroy();
|
|
2266
|
+
this.#pdfDocument = null;
|
|
2202
2267
|
}
|
|
2203
2268
|
combinedSignal(ac) {
|
|
2204
2269
|
return AbortSignal.any([this._signal, ac.signal]);
|
|
@@ -2382,7 +2447,7 @@ class AnnotationEditorUIManager {
|
|
|
2382
2447
|
}
|
|
2383
2448
|
return null;
|
|
2384
2449
|
}
|
|
2385
|
-
highlightSelection(methodOfCreation = "") {
|
|
2450
|
+
highlightSelection(methodOfCreation = "", comment = false) {
|
|
2386
2451
|
const selection = document.getSelection();
|
|
2387
2452
|
if (!selection || selection.isCollapsed) {
|
|
2388
2453
|
return;
|
|
@@ -2404,7 +2469,7 @@ class AnnotationEditorUIManager {
|
|
|
2404
2469
|
const layer = this.#getLayerForTextLayer(textLayer);
|
|
2405
2470
|
const isNoneMode = this.#mode === AnnotationEditorType.NONE;
|
|
2406
2471
|
const callback = () => {
|
|
2407
|
-
layer?.createAndAddNewEditor({
|
|
2472
|
+
const editor = layer?.createAndAddNewEditor({
|
|
2408
2473
|
x: 0,
|
|
2409
2474
|
y: 0
|
|
2410
2475
|
}, false, {
|
|
@@ -2419,6 +2484,9 @@ class AnnotationEditorUIManager {
|
|
|
2419
2484
|
if (isNoneMode) {
|
|
2420
2485
|
this.showAllEditors("highlight", true, true);
|
|
2421
2486
|
}
|
|
2487
|
+
if (comment) {
|
|
2488
|
+
editor?.editComment();
|
|
2489
|
+
}
|
|
2422
2490
|
};
|
|
2423
2491
|
if (isNoneMode) {
|
|
2424
2492
|
this.switchToMode(AnnotationEditorType.HIGHLIGHT, callback);
|
|
@@ -2426,7 +2494,10 @@ class AnnotationEditorUIManager {
|
|
|
2426
2494
|
}
|
|
2427
2495
|
callback();
|
|
2428
2496
|
}
|
|
2429
|
-
|
|
2497
|
+
commentSelection(methodOfCreation = "") {
|
|
2498
|
+
this.highlightSelection(methodOfCreation, true);
|
|
2499
|
+
}
|
|
2500
|
+
#displayFloatingToolbar() {
|
|
2430
2501
|
const selection = document.getSelection();
|
|
2431
2502
|
if (!selection || selection.isCollapsed) {
|
|
2432
2503
|
return;
|
|
@@ -2437,8 +2508,8 @@ class AnnotationEditorUIManager {
|
|
|
2437
2508
|
if (!boxes) {
|
|
2438
2509
|
return;
|
|
2439
2510
|
}
|
|
2440
|
-
this.#
|
|
2441
|
-
this.#
|
|
2511
|
+
this.#floatingToolbar ||= new FloatingToolbar(this);
|
|
2512
|
+
this.#floatingToolbar.show(textLayer, boxes, this.direction === "ltr");
|
|
2442
2513
|
}
|
|
2443
2514
|
addToAnnotationStorage(editor) {
|
|
2444
2515
|
if (!editor.isEmpty() && this.#annotationStorage && !this.#annotationStorage.has(editor.id)) {
|
|
@@ -2461,7 +2532,7 @@ class AnnotationEditorUIManager {
|
|
|
2461
2532
|
const selection = document.getSelection();
|
|
2462
2533
|
if (!selection || selection.isCollapsed) {
|
|
2463
2534
|
if (this.#selectedTextNode) {
|
|
2464
|
-
this.#
|
|
2535
|
+
this.#floatingToolbar?.hide();
|
|
2465
2536
|
this.#selectedTextNode = null;
|
|
2466
2537
|
this.#dispatchUpdateStates({
|
|
2467
2538
|
hasSelectedText: false
|
|
@@ -2479,7 +2550,7 @@ class AnnotationEditorUIManager {
|
|
|
2479
2550
|
const textLayer = anchorElement.closest(".textLayer");
|
|
2480
2551
|
if (!textLayer) {
|
|
2481
2552
|
if (this.#selectedTextNode) {
|
|
2482
|
-
this.#
|
|
2553
|
+
this.#floatingToolbar?.hide();
|
|
2483
2554
|
this.#selectedTextNode = null;
|
|
2484
2555
|
this.#dispatchUpdateStates({
|
|
2485
2556
|
hasSelectedText: false
|
|
@@ -2487,7 +2558,7 @@ class AnnotationEditorUIManager {
|
|
|
2487
2558
|
}
|
|
2488
2559
|
return;
|
|
2489
2560
|
}
|
|
2490
|
-
this.#
|
|
2561
|
+
this.#floatingToolbar?.hide();
|
|
2491
2562
|
this.#selectedTextNode = anchorNode;
|
|
2492
2563
|
this.#dispatchUpdateStates({
|
|
2493
2564
|
hasSelectedText: true
|
|
@@ -2502,31 +2573,36 @@ class AnnotationEditorUIManager {
|
|
|
2502
2573
|
if (!this.isShiftKeyDown) {
|
|
2503
2574
|
const activeLayer = this.#mode === AnnotationEditorType.HIGHLIGHT ? this.#getLayerForTextLayer(textLayer) : null;
|
|
2504
2575
|
activeLayer?.toggleDrawing();
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2576
|
+
if (this.#isPointerDown) {
|
|
2577
|
+
const ac = new AbortController();
|
|
2578
|
+
const signal = this.combinedSignal(ac);
|
|
2579
|
+
const pointerup = e => {
|
|
2580
|
+
if (e.type === "pointerup" && e.button !== 0) {
|
|
2581
|
+
return;
|
|
2582
|
+
}
|
|
2583
|
+
ac.abort();
|
|
2584
|
+
activeLayer?.toggleDrawing(true);
|
|
2585
|
+
if (e.type === "pointerup") {
|
|
2586
|
+
this.#onSelectEnd("main_toolbar");
|
|
2587
|
+
}
|
|
2588
|
+
};
|
|
2589
|
+
window.addEventListener("pointerup", pointerup, {
|
|
2590
|
+
signal
|
|
2591
|
+
});
|
|
2592
|
+
window.addEventListener("blur", pointerup, {
|
|
2593
|
+
signal
|
|
2594
|
+
});
|
|
2595
|
+
} else {
|
|
2512
2596
|
activeLayer?.toggleDrawing(true);
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
}
|
|
2516
|
-
};
|
|
2517
|
-
window.addEventListener("pointerup", pointerup, {
|
|
2518
|
-
signal
|
|
2519
|
-
});
|
|
2520
|
-
window.addEventListener("blur", pointerup, {
|
|
2521
|
-
signal
|
|
2522
|
-
});
|
|
2597
|
+
this.#onSelectEnd("main_toolbar");
|
|
2598
|
+
}
|
|
2523
2599
|
}
|
|
2524
2600
|
}
|
|
2525
2601
|
#onSelectEnd(methodOfCreation = "") {
|
|
2526
2602
|
if (this.#mode === AnnotationEditorType.HIGHLIGHT) {
|
|
2527
2603
|
this.highlightSelection(methodOfCreation);
|
|
2528
2604
|
} else if (this.#enableHighlightFloatingButton) {
|
|
2529
|
-
this.#
|
|
2605
|
+
this.#displayFloatingToolbar();
|
|
2530
2606
|
}
|
|
2531
2607
|
}
|
|
2532
2608
|
#addSelectionListener() {
|
|
@@ -2772,6 +2848,9 @@ class AnnotationEditorUIManager {
|
|
|
2772
2848
|
case "highlightSelection":
|
|
2773
2849
|
this.highlightSelection("context_menu");
|
|
2774
2850
|
break;
|
|
2851
|
+
case "commentSelection":
|
|
2852
|
+
this.commentSelection("context_menu");
|
|
2853
|
+
break;
|
|
2775
2854
|
}
|
|
2776
2855
|
}
|
|
2777
2856
|
#dispatchUpdateStates(details) {
|
|
@@ -2856,6 +2935,9 @@ class AnnotationEditorUIManager {
|
|
|
2856
2935
|
}
|
|
2857
2936
|
this.#updateModeCapability = Promise.withResolvers();
|
|
2858
2937
|
this.#currentDrawingSession?.commitOrRemove();
|
|
2938
|
+
if (this.#mode === AnnotationEditorType.POPUP) {
|
|
2939
|
+
this.#commentManager?.hideSidebar();
|
|
2940
|
+
}
|
|
2859
2941
|
this.#mode = mode;
|
|
2860
2942
|
if (mode === AnnotationEditorType.NONE) {
|
|
2861
2943
|
this.setEditingState(false);
|
|
@@ -2867,6 +2949,10 @@ class AnnotationEditorUIManager {
|
|
|
2867
2949
|
if (mode === AnnotationEditorType.SIGNATURE) {
|
|
2868
2950
|
await this.#signatureManager?.loadSignatures();
|
|
2869
2951
|
}
|
|
2952
|
+
if (mode === AnnotationEditorType.POPUP) {
|
|
2953
|
+
this.#allEditableAnnotations ||= await this.#pdfDocument.getAnnotationsByType(new Set(this.#editorTypes.map(editorClass => editorClass._editorType)));
|
|
2954
|
+
this.#commentManager?.showSidebar(this.#allEditableAnnotations);
|
|
2955
|
+
}
|
|
2870
2956
|
this.setEditingState(true);
|
|
2871
2957
|
await this.#enableAll();
|
|
2872
2958
|
this.unselectAll();
|
|
@@ -3786,6 +3872,9 @@ class Comment {
|
|
|
3786
3872
|
comment.tabIndex = "0";
|
|
3787
3873
|
comment.setAttribute("data-l10n-id", "pdfjs-editor-edit-comment-button");
|
|
3788
3874
|
const signal = this.#editor._uiManager._signal;
|
|
3875
|
+
if (!(signal instanceof AbortSignal) || signal.aborted) {
|
|
3876
|
+
return comment;
|
|
3877
|
+
}
|
|
3789
3878
|
comment.addEventListener("contextmenu", noContextMenu, {
|
|
3790
3879
|
signal
|
|
3791
3880
|
});
|
|
@@ -4762,7 +4851,6 @@ class AnnotationEditor {
|
|
|
4762
4851
|
}
|
|
4763
4852
|
this._editToolbar = new EditorToolbar(this);
|
|
4764
4853
|
this.div.append(this._editToolbar.render());
|
|
4765
|
-
this._editToolbar.addButton("comment", this.addCommentButton());
|
|
4766
4854
|
const {
|
|
4767
4855
|
toolbarButtons
|
|
4768
4856
|
} = this;
|
|
@@ -4771,6 +4859,7 @@ class AnnotationEditor {
|
|
|
4771
4859
|
await this._editToolbar.addButton(name, tool);
|
|
4772
4860
|
}
|
|
4773
4861
|
}
|
|
4862
|
+
this._editToolbar.addButton("comment", this.addCommentButton());
|
|
4774
4863
|
this._editToolbar.addButton("delete");
|
|
4775
4864
|
return this._editToolbar;
|
|
4776
4865
|
}
|
|
@@ -4869,9 +4958,18 @@ class AnnotationEditor {
|
|
|
4869
4958
|
}
|
|
4870
4959
|
addComment(serialized) {
|
|
4871
4960
|
if (this.hasEditedComment) {
|
|
4961
|
+
const DEFAULT_POPUP_WIDTH = 180;
|
|
4962
|
+
const DEFAULT_POPUP_HEIGHT = 100;
|
|
4963
|
+
const [,,, trY] = serialized.rect;
|
|
4964
|
+
const [pageWidth] = this.pageDimensions;
|
|
4965
|
+
const [pageX] = this.pageTranslation;
|
|
4966
|
+
const blX = pageX + pageWidth + 1;
|
|
4967
|
+
const blY = trY - DEFAULT_POPUP_HEIGHT;
|
|
4968
|
+
const trX = blX + DEFAULT_POPUP_WIDTH;
|
|
4872
4969
|
serialized.popup = {
|
|
4873
4970
|
contents: this.comment.text,
|
|
4874
|
-
deleted: this.comment.deleted
|
|
4971
|
+
deleted: this.comment.deleted,
|
|
4972
|
+
rect: [blX, blY, trX, trY]
|
|
4875
4973
|
};
|
|
4876
4974
|
}
|
|
4877
4975
|
}
|
|
@@ -5115,6 +5213,9 @@ class AnnotationEditor {
|
|
|
5115
5213
|
throw new Error("Invalid rotation");
|
|
5116
5214
|
}
|
|
5117
5215
|
}
|
|
5216
|
+
getPDFRect() {
|
|
5217
|
+
return this.getRect(0, 0);
|
|
5218
|
+
}
|
|
5118
5219
|
onceAdded(focus) {}
|
|
5119
5220
|
isEmpty() {
|
|
5120
5221
|
return false;
|
|
@@ -5493,6 +5594,10 @@ class AnnotationEditor {
|
|
|
5493
5594
|
this.#disabled = true;
|
|
5494
5595
|
}
|
|
5495
5596
|
renderAnnotationElement(annotation) {
|
|
5597
|
+
if (this.deleted) {
|
|
5598
|
+
annotation.hide();
|
|
5599
|
+
return null;
|
|
5600
|
+
}
|
|
5496
5601
|
let content = annotation.container.querySelector(".annotationContent");
|
|
5497
5602
|
if (!content) {
|
|
5498
5603
|
content = document.createElement("div");
|
|
@@ -7129,6 +7234,475 @@ class NodeWasmFactory extends BaseWasmFactory {
|
|
|
7129
7234
|
}
|
|
7130
7235
|
}
|
|
7131
7236
|
|
|
7237
|
+
;// ./src/display/canvas_dependency_tracker.js
|
|
7238
|
+
|
|
7239
|
+
const FORCED_DEPENDENCY_LABEL = "__forcedDependency";
|
|
7240
|
+
class CanvasDependencyTracker {
|
|
7241
|
+
#simple = {
|
|
7242
|
+
__proto__: null
|
|
7243
|
+
};
|
|
7244
|
+
#incremental = {
|
|
7245
|
+
__proto__: null,
|
|
7246
|
+
transform: [],
|
|
7247
|
+
moveText: [],
|
|
7248
|
+
sameLineText: [],
|
|
7249
|
+
[FORCED_DEPENDENCY_LABEL]: []
|
|
7250
|
+
};
|
|
7251
|
+
#namedDependencies = new Map();
|
|
7252
|
+
#savesStack = [];
|
|
7253
|
+
#markedContentStack = [];
|
|
7254
|
+
#baseTransformStack = [[1, 0, 0, 1, 0, 0]];
|
|
7255
|
+
#clipBox = [-Infinity, -Infinity, Infinity, Infinity];
|
|
7256
|
+
#pendingBBox = new Float64Array([Infinity, Infinity, -Infinity, -Infinity]);
|
|
7257
|
+
#pendingBBoxIdx = -1;
|
|
7258
|
+
#pendingDependencies = new Set();
|
|
7259
|
+
#operations = new Map();
|
|
7260
|
+
#fontBBoxTrustworthy = new Map();
|
|
7261
|
+
#canvasWidth;
|
|
7262
|
+
#canvasHeight;
|
|
7263
|
+
constructor(canvas) {
|
|
7264
|
+
this.#canvasWidth = canvas.width;
|
|
7265
|
+
this.#canvasHeight = canvas.height;
|
|
7266
|
+
}
|
|
7267
|
+
save(opIdx) {
|
|
7268
|
+
this.#simple = {
|
|
7269
|
+
__proto__: this.#simple
|
|
7270
|
+
};
|
|
7271
|
+
this.#incremental = {
|
|
7272
|
+
__proto__: this.#incremental,
|
|
7273
|
+
transform: {
|
|
7274
|
+
__proto__: this.#incremental.transform
|
|
7275
|
+
},
|
|
7276
|
+
moveText: {
|
|
7277
|
+
__proto__: this.#incremental.moveText
|
|
7278
|
+
},
|
|
7279
|
+
sameLineText: {
|
|
7280
|
+
__proto__: this.#incremental.sameLineText
|
|
7281
|
+
},
|
|
7282
|
+
[FORCED_DEPENDENCY_LABEL]: {
|
|
7283
|
+
__proto__: this.#incremental[FORCED_DEPENDENCY_LABEL]
|
|
7284
|
+
}
|
|
7285
|
+
};
|
|
7286
|
+
this.#clipBox = {
|
|
7287
|
+
__proto__: this.#clipBox
|
|
7288
|
+
};
|
|
7289
|
+
this.#savesStack.push([opIdx, null]);
|
|
7290
|
+
return this;
|
|
7291
|
+
}
|
|
7292
|
+
restore(opIdx) {
|
|
7293
|
+
const previous = Object.getPrototypeOf(this.#simple);
|
|
7294
|
+
if (previous === null) {
|
|
7295
|
+
return this;
|
|
7296
|
+
}
|
|
7297
|
+
this.#simple = previous;
|
|
7298
|
+
this.#incremental = Object.getPrototypeOf(this.#incremental);
|
|
7299
|
+
this.#clipBox = Object.getPrototypeOf(this.#clipBox);
|
|
7300
|
+
const lastPair = this.#savesStack.pop();
|
|
7301
|
+
if (lastPair !== undefined) {
|
|
7302
|
+
lastPair[1] = opIdx;
|
|
7303
|
+
}
|
|
7304
|
+
return this;
|
|
7305
|
+
}
|
|
7306
|
+
recordOpenMarker(idx) {
|
|
7307
|
+
this.#savesStack.push([idx, null]);
|
|
7308
|
+
return this;
|
|
7309
|
+
}
|
|
7310
|
+
getOpenMarker() {
|
|
7311
|
+
if (this.#savesStack.length === 0) {
|
|
7312
|
+
return null;
|
|
7313
|
+
}
|
|
7314
|
+
return this.#savesStack.at(-1)[0];
|
|
7315
|
+
}
|
|
7316
|
+
recordCloseMarker(idx) {
|
|
7317
|
+
const lastPair = this.#savesStack.pop();
|
|
7318
|
+
if (lastPair !== undefined) {
|
|
7319
|
+
lastPair[1] = idx;
|
|
7320
|
+
}
|
|
7321
|
+
return this;
|
|
7322
|
+
}
|
|
7323
|
+
beginMarkedContent(opIdx) {
|
|
7324
|
+
this.#markedContentStack.push([opIdx, null]);
|
|
7325
|
+
return this;
|
|
7326
|
+
}
|
|
7327
|
+
endMarkedContent(opIdx) {
|
|
7328
|
+
const lastPair = this.#markedContentStack.pop();
|
|
7329
|
+
if (lastPair !== undefined) {
|
|
7330
|
+
lastPair[1] = opIdx;
|
|
7331
|
+
}
|
|
7332
|
+
return this;
|
|
7333
|
+
}
|
|
7334
|
+
pushBaseTransform(ctx) {
|
|
7335
|
+
this.#baseTransformStack.push(Util.multiplyByDOMMatrix(this.#baseTransformStack.at(-1), ctx.getTransform()));
|
|
7336
|
+
return this;
|
|
7337
|
+
}
|
|
7338
|
+
popBaseTransform() {
|
|
7339
|
+
if (this.#baseTransformStack.length > 1) {
|
|
7340
|
+
this.#baseTransformStack.pop();
|
|
7341
|
+
}
|
|
7342
|
+
return this;
|
|
7343
|
+
}
|
|
7344
|
+
recordSimpleData(name, idx) {
|
|
7345
|
+
this.#simple[name] = idx;
|
|
7346
|
+
return this;
|
|
7347
|
+
}
|
|
7348
|
+
recordIncrementalData(name, idx) {
|
|
7349
|
+
this.#incremental[name].push(idx);
|
|
7350
|
+
return this;
|
|
7351
|
+
}
|
|
7352
|
+
resetIncrementalData(name, idx) {
|
|
7353
|
+
this.#incremental[name].length = 0;
|
|
7354
|
+
return this;
|
|
7355
|
+
}
|
|
7356
|
+
recordNamedData(name, idx) {
|
|
7357
|
+
this.#namedDependencies.set(name, idx);
|
|
7358
|
+
return this;
|
|
7359
|
+
}
|
|
7360
|
+
recordFutureForcedDependency(name, idx) {
|
|
7361
|
+
this.recordIncrementalData(FORCED_DEPENDENCY_LABEL, idx);
|
|
7362
|
+
return this;
|
|
7363
|
+
}
|
|
7364
|
+
inheritSimpleDataAsFutureForcedDependencies(names) {
|
|
7365
|
+
for (const name of names) {
|
|
7366
|
+
if (name in this.#simple) {
|
|
7367
|
+
this.recordFutureForcedDependency(name, this.#simple[name]);
|
|
7368
|
+
}
|
|
7369
|
+
}
|
|
7370
|
+
return this;
|
|
7371
|
+
}
|
|
7372
|
+
inheritPendingDependenciesAsFutureForcedDependencies() {
|
|
7373
|
+
for (const dep of this.#pendingDependencies) {
|
|
7374
|
+
this.recordFutureForcedDependency(FORCED_DEPENDENCY_LABEL, dep);
|
|
7375
|
+
}
|
|
7376
|
+
return this;
|
|
7377
|
+
}
|
|
7378
|
+
resetBBox(idx) {
|
|
7379
|
+
this.#pendingBBoxIdx = idx;
|
|
7380
|
+
this.#pendingBBox[0] = Infinity;
|
|
7381
|
+
this.#pendingBBox[1] = Infinity;
|
|
7382
|
+
this.#pendingBBox[2] = -Infinity;
|
|
7383
|
+
this.#pendingBBox[3] = -Infinity;
|
|
7384
|
+
return this;
|
|
7385
|
+
}
|
|
7386
|
+
get hasPendingBBox() {
|
|
7387
|
+
return this.#pendingBBoxIdx !== -1;
|
|
7388
|
+
}
|
|
7389
|
+
recordClipBox(idx, ctx, minX, maxX, minY, maxY) {
|
|
7390
|
+
const transform = Util.multiplyByDOMMatrix(this.#baseTransformStack.at(-1), ctx.getTransform());
|
|
7391
|
+
const clipBox = [Infinity, Infinity, -Infinity, -Infinity];
|
|
7392
|
+
Util.axialAlignedBoundingBox([minX, minY, maxX, maxY], transform, clipBox);
|
|
7393
|
+
const intersection = Util.intersect(this.#clipBox, clipBox);
|
|
7394
|
+
if (intersection) {
|
|
7395
|
+
this.#clipBox[0] = intersection[0];
|
|
7396
|
+
this.#clipBox[1] = intersection[1];
|
|
7397
|
+
this.#clipBox[2] = intersection[2];
|
|
7398
|
+
this.#clipBox[3] = intersection[3];
|
|
7399
|
+
} else {
|
|
7400
|
+
this.#clipBox[0] = this.#clipBox[1] = Infinity;
|
|
7401
|
+
this.#clipBox[2] = this.#clipBox[3] = -Infinity;
|
|
7402
|
+
}
|
|
7403
|
+
return this;
|
|
7404
|
+
}
|
|
7405
|
+
recordBBox(idx, ctx, minX, maxX, minY, maxY) {
|
|
7406
|
+
const clipBox = this.#clipBox;
|
|
7407
|
+
if (clipBox[0] === Infinity) {
|
|
7408
|
+
return this;
|
|
7409
|
+
}
|
|
7410
|
+
const transform = Util.multiplyByDOMMatrix(this.#baseTransformStack.at(-1), ctx.getTransform());
|
|
7411
|
+
if (clipBox[0] === -Infinity) {
|
|
7412
|
+
Util.axialAlignedBoundingBox([minX, minY, maxX, maxY], transform, this.#pendingBBox);
|
|
7413
|
+
return this;
|
|
7414
|
+
}
|
|
7415
|
+
const bbox = [Infinity, Infinity, -Infinity, -Infinity];
|
|
7416
|
+
Util.axialAlignedBoundingBox([minX, minY, maxX, maxY], transform, bbox);
|
|
7417
|
+
this.#pendingBBox[0] = Math.min(this.#pendingBBox[0], Math.max(bbox[0], clipBox[0]));
|
|
7418
|
+
this.#pendingBBox[1] = Math.min(this.#pendingBBox[1], Math.max(bbox[1], clipBox[1]));
|
|
7419
|
+
this.#pendingBBox[2] = Math.max(this.#pendingBBox[2], Math.min(bbox[2], clipBox[2]));
|
|
7420
|
+
this.#pendingBBox[3] = Math.max(this.#pendingBBox[3], Math.min(bbox[3], clipBox[3]));
|
|
7421
|
+
return this;
|
|
7422
|
+
}
|
|
7423
|
+
recordCharacterBBox(idx, ctx, font, scale = 1, x = 0, y = 0, getMeasure) {
|
|
7424
|
+
const fontBBox = font.bbox;
|
|
7425
|
+
let isBBoxTrustworthy;
|
|
7426
|
+
let computedBBox;
|
|
7427
|
+
if (fontBBox) {
|
|
7428
|
+
isBBoxTrustworthy = fontBBox[2] !== fontBBox[0] && fontBBox[3] !== fontBBox[1] && this.#fontBBoxTrustworthy.get(font);
|
|
7429
|
+
if (isBBoxTrustworthy !== false) {
|
|
7430
|
+
computedBBox = [0, 0, 0, 0];
|
|
7431
|
+
Util.axialAlignedBoundingBox(fontBBox, font.fontMatrix, computedBBox);
|
|
7432
|
+
if (scale !== 1 || x !== 0 || y !== 0) {
|
|
7433
|
+
Util.scaleMinMax([scale, 0, 0, -scale, x, y], computedBBox);
|
|
7434
|
+
}
|
|
7435
|
+
if (isBBoxTrustworthy) {
|
|
7436
|
+
return this.recordBBox(idx, ctx, computedBBox[0], computedBBox[2], computedBBox[1], computedBBox[3]);
|
|
7437
|
+
}
|
|
7438
|
+
}
|
|
7439
|
+
}
|
|
7440
|
+
if (!getMeasure) {
|
|
7441
|
+
return this.recordFullPageBBox(idx);
|
|
7442
|
+
}
|
|
7443
|
+
const measure = getMeasure();
|
|
7444
|
+
if (fontBBox && computedBBox && isBBoxTrustworthy === undefined) {
|
|
7445
|
+
isBBoxTrustworthy = computedBBox[0] <= x - measure.actualBoundingBoxLeft && computedBBox[2] >= x + measure.actualBoundingBoxRight && computedBBox[1] <= y - measure.actualBoundingBoxAscent && computedBBox[3] >= y + measure.actualBoundingBoxDescent;
|
|
7446
|
+
this.#fontBBoxTrustworthy.set(font, isBBoxTrustworthy);
|
|
7447
|
+
if (isBBoxTrustworthy) {
|
|
7448
|
+
return this.recordBBox(idx, ctx, computedBBox[0], computedBBox[2], computedBBox[1], computedBBox[3]);
|
|
7449
|
+
}
|
|
7450
|
+
}
|
|
7451
|
+
return this.recordBBox(idx, ctx, x - measure.actualBoundingBoxLeft, x + measure.actualBoundingBoxRight, y - measure.actualBoundingBoxAscent, y + measure.actualBoundingBoxDescent);
|
|
7452
|
+
}
|
|
7453
|
+
recordFullPageBBox(idx) {
|
|
7454
|
+
this.#pendingBBox[0] = Math.max(0, this.#clipBox[0]);
|
|
7455
|
+
this.#pendingBBox[1] = Math.max(0, this.#clipBox[1]);
|
|
7456
|
+
this.#pendingBBox[2] = Math.min(this.#canvasWidth, this.#clipBox[2]);
|
|
7457
|
+
this.#pendingBBox[3] = Math.min(this.#canvasHeight, this.#clipBox[3]);
|
|
7458
|
+
return this;
|
|
7459
|
+
}
|
|
7460
|
+
getSimpleIndex(dependencyName) {
|
|
7461
|
+
return this.#simple[dependencyName];
|
|
7462
|
+
}
|
|
7463
|
+
recordDependencies(idx, dependencyNames) {
|
|
7464
|
+
const pendingDependencies = this.#pendingDependencies;
|
|
7465
|
+
const simple = this.#simple;
|
|
7466
|
+
const incremental = this.#incremental;
|
|
7467
|
+
for (const name of dependencyNames) {
|
|
7468
|
+
if (name in this.#simple) {
|
|
7469
|
+
pendingDependencies.add(simple[name]);
|
|
7470
|
+
} else if (name in incremental) {
|
|
7471
|
+
incremental[name].forEach(pendingDependencies.add, pendingDependencies);
|
|
7472
|
+
}
|
|
7473
|
+
}
|
|
7474
|
+
return this;
|
|
7475
|
+
}
|
|
7476
|
+
copyDependenciesFromIncrementalOperation(idx, name) {
|
|
7477
|
+
const operations = this.#operations;
|
|
7478
|
+
const pendingDependencies = this.#pendingDependencies;
|
|
7479
|
+
for (const depIdx of this.#incremental[name]) {
|
|
7480
|
+
operations.get(depIdx).dependencies.forEach(pendingDependencies.add, pendingDependencies.add(depIdx));
|
|
7481
|
+
}
|
|
7482
|
+
return this;
|
|
7483
|
+
}
|
|
7484
|
+
recordNamedDependency(idx, name) {
|
|
7485
|
+
if (this.#namedDependencies.has(name)) {
|
|
7486
|
+
this.#pendingDependencies.add(this.#namedDependencies.get(name));
|
|
7487
|
+
}
|
|
7488
|
+
return this;
|
|
7489
|
+
}
|
|
7490
|
+
recordOperation(idx, preserveBbox = false) {
|
|
7491
|
+
this.recordDependencies(idx, [FORCED_DEPENDENCY_LABEL]);
|
|
7492
|
+
const dependencies = new Set(this.#pendingDependencies);
|
|
7493
|
+
const pairs = this.#savesStack.concat(this.#markedContentStack);
|
|
7494
|
+
const bbox = this.#pendingBBoxIdx === idx ? {
|
|
7495
|
+
minX: this.#pendingBBox[0],
|
|
7496
|
+
minY: this.#pendingBBox[1],
|
|
7497
|
+
maxX: this.#pendingBBox[2],
|
|
7498
|
+
maxY: this.#pendingBBox[3]
|
|
7499
|
+
} : null;
|
|
7500
|
+
this.#operations.set(idx, {
|
|
7501
|
+
bbox,
|
|
7502
|
+
pairs,
|
|
7503
|
+
dependencies
|
|
7504
|
+
});
|
|
7505
|
+
if (!preserveBbox) {
|
|
7506
|
+
this.#pendingBBoxIdx = -1;
|
|
7507
|
+
}
|
|
7508
|
+
this.#pendingDependencies.clear();
|
|
7509
|
+
return this;
|
|
7510
|
+
}
|
|
7511
|
+
bboxToClipBoxDropOperation(idx) {
|
|
7512
|
+
if (this.#pendingBBoxIdx !== -1) {
|
|
7513
|
+
this.#pendingBBoxIdx = -1;
|
|
7514
|
+
this.#clipBox[0] = Math.max(this.#clipBox[0], this.#pendingBBox[0]);
|
|
7515
|
+
this.#clipBox[1] = Math.max(this.#clipBox[1], this.#pendingBBox[1]);
|
|
7516
|
+
this.#clipBox[2] = Math.min(this.#clipBox[2], this.#pendingBBox[2]);
|
|
7517
|
+
this.#clipBox[3] = Math.min(this.#clipBox[3], this.#pendingBBox[3]);
|
|
7518
|
+
}
|
|
7519
|
+
this.#pendingDependencies.clear();
|
|
7520
|
+
return this;
|
|
7521
|
+
}
|
|
7522
|
+
_takePendingDependencies() {
|
|
7523
|
+
const pendingDependencies = this.#pendingDependencies;
|
|
7524
|
+
this.#pendingDependencies = new Set();
|
|
7525
|
+
return pendingDependencies;
|
|
7526
|
+
}
|
|
7527
|
+
_extractOperation(idx) {
|
|
7528
|
+
const operation = this.#operations.get(idx);
|
|
7529
|
+
this.#operations.delete(idx);
|
|
7530
|
+
return operation;
|
|
7531
|
+
}
|
|
7532
|
+
_pushPendingDependencies(dependencies) {
|
|
7533
|
+
for (const dep of dependencies) {
|
|
7534
|
+
this.#pendingDependencies.add(dep);
|
|
7535
|
+
}
|
|
7536
|
+
}
|
|
7537
|
+
take() {
|
|
7538
|
+
this.#fontBBoxTrustworthy.clear();
|
|
7539
|
+
return Array.from(this.#operations, ([idx, {
|
|
7540
|
+
bbox,
|
|
7541
|
+
pairs,
|
|
7542
|
+
dependencies
|
|
7543
|
+
}]) => {
|
|
7544
|
+
pairs.forEach(pair => pair.forEach(dependencies.add, dependencies));
|
|
7545
|
+
dependencies.delete(idx);
|
|
7546
|
+
return {
|
|
7547
|
+
minX: (bbox?.minX ?? 0) / this.#canvasWidth,
|
|
7548
|
+
maxX: (bbox?.maxX ?? this.#canvasWidth) / this.#canvasWidth,
|
|
7549
|
+
minY: (bbox?.minY ?? 0) / this.#canvasHeight,
|
|
7550
|
+
maxY: (bbox?.maxY ?? this.#canvasHeight) / this.#canvasHeight,
|
|
7551
|
+
dependencies: Array.from(dependencies).sort((a, b) => a - b),
|
|
7552
|
+
idx
|
|
7553
|
+
};
|
|
7554
|
+
});
|
|
7555
|
+
}
|
|
7556
|
+
}
|
|
7557
|
+
class CanvasNestedDependencyTracker {
|
|
7558
|
+
#dependencyTracker;
|
|
7559
|
+
#opIdx;
|
|
7560
|
+
#nestingLevel = 0;
|
|
7561
|
+
#outerDependencies;
|
|
7562
|
+
#savesLevel = 0;
|
|
7563
|
+
constructor(dependencyTracker, opIdx) {
|
|
7564
|
+
if (dependencyTracker instanceof CanvasNestedDependencyTracker) {
|
|
7565
|
+
return dependencyTracker;
|
|
7566
|
+
}
|
|
7567
|
+
this.#dependencyTracker = dependencyTracker;
|
|
7568
|
+
this.#outerDependencies = dependencyTracker._takePendingDependencies();
|
|
7569
|
+
this.#opIdx = opIdx;
|
|
7570
|
+
}
|
|
7571
|
+
save(opIdx) {
|
|
7572
|
+
this.#savesLevel++;
|
|
7573
|
+
this.#dependencyTracker.save(this.#opIdx);
|
|
7574
|
+
return this;
|
|
7575
|
+
}
|
|
7576
|
+
restore(opIdx) {
|
|
7577
|
+
if (this.#savesLevel > 0) {
|
|
7578
|
+
this.#dependencyTracker.restore(this.#opIdx);
|
|
7579
|
+
this.#savesLevel--;
|
|
7580
|
+
}
|
|
7581
|
+
return this;
|
|
7582
|
+
}
|
|
7583
|
+
recordOpenMarker(idx) {
|
|
7584
|
+
this.#nestingLevel++;
|
|
7585
|
+
return this;
|
|
7586
|
+
}
|
|
7587
|
+
getOpenMarker() {
|
|
7588
|
+
return this.#nestingLevel > 0 ? this.#opIdx : this.#dependencyTracker.getOpenMarker();
|
|
7589
|
+
}
|
|
7590
|
+
recordCloseMarker(idx) {
|
|
7591
|
+
this.#nestingLevel--;
|
|
7592
|
+
return this;
|
|
7593
|
+
}
|
|
7594
|
+
beginMarkedContent(opIdx) {
|
|
7595
|
+
return this;
|
|
7596
|
+
}
|
|
7597
|
+
endMarkedContent(opIdx) {
|
|
7598
|
+
return this;
|
|
7599
|
+
}
|
|
7600
|
+
pushBaseTransform(ctx) {
|
|
7601
|
+
this.#dependencyTracker.pushBaseTransform(ctx);
|
|
7602
|
+
return this;
|
|
7603
|
+
}
|
|
7604
|
+
popBaseTransform() {
|
|
7605
|
+
this.#dependencyTracker.popBaseTransform();
|
|
7606
|
+
return this;
|
|
7607
|
+
}
|
|
7608
|
+
recordSimpleData(name, idx) {
|
|
7609
|
+
this.#dependencyTracker.recordSimpleData(name, this.#opIdx);
|
|
7610
|
+
return this;
|
|
7611
|
+
}
|
|
7612
|
+
recordIncrementalData(name, idx) {
|
|
7613
|
+
this.#dependencyTracker.recordIncrementalData(name, this.#opIdx);
|
|
7614
|
+
return this;
|
|
7615
|
+
}
|
|
7616
|
+
resetIncrementalData(name, idx) {
|
|
7617
|
+
this.#dependencyTracker.resetIncrementalData(name, this.#opIdx);
|
|
7618
|
+
return this;
|
|
7619
|
+
}
|
|
7620
|
+
recordNamedData(name, idx) {
|
|
7621
|
+
return this;
|
|
7622
|
+
}
|
|
7623
|
+
recordFutureForcedDependency(name, idx) {
|
|
7624
|
+
this.#dependencyTracker.recordFutureForcedDependency(name, this.#opIdx);
|
|
7625
|
+
return this;
|
|
7626
|
+
}
|
|
7627
|
+
inheritSimpleDataAsFutureForcedDependencies(names) {
|
|
7628
|
+
this.#dependencyTracker.inheritSimpleDataAsFutureForcedDependencies(names);
|
|
7629
|
+
return this;
|
|
7630
|
+
}
|
|
7631
|
+
inheritPendingDependenciesAsFutureForcedDependencies() {
|
|
7632
|
+
this.#dependencyTracker.inheritPendingDependenciesAsFutureForcedDependencies();
|
|
7633
|
+
return this;
|
|
7634
|
+
}
|
|
7635
|
+
resetBBox(idx) {
|
|
7636
|
+
if (!this.#dependencyTracker.hasPendingBBox) {
|
|
7637
|
+
this.#dependencyTracker.resetBBox(this.#opIdx);
|
|
7638
|
+
}
|
|
7639
|
+
return this;
|
|
7640
|
+
}
|
|
7641
|
+
get hasPendingBBox() {
|
|
7642
|
+
return this.#dependencyTracker.hasPendingBBox;
|
|
7643
|
+
}
|
|
7644
|
+
recordClipBox(idx, ctx, minX, maxX, minY, maxY) {
|
|
7645
|
+
this.#dependencyTracker.recordClipBox(this.#opIdx, ctx, minX, maxX, minY, maxY);
|
|
7646
|
+
return this;
|
|
7647
|
+
}
|
|
7648
|
+
recordBBox(idx, ctx, minX, maxX, minY, maxY) {
|
|
7649
|
+
this.#dependencyTracker.recordBBox(this.#opIdx, ctx, minX, maxX, minY, maxY);
|
|
7650
|
+
return this;
|
|
7651
|
+
}
|
|
7652
|
+
recordCharacterBBox(idx, ctx, font, scale, x, y, getMeasure) {
|
|
7653
|
+
this.#dependencyTracker.recordCharacterBBox(this.#opIdx, ctx, font, scale, x, y, getMeasure);
|
|
7654
|
+
return this;
|
|
7655
|
+
}
|
|
7656
|
+
recordFullPageBBox(idx) {
|
|
7657
|
+
this.#dependencyTracker.recordFullPageBBox(this.#opIdx);
|
|
7658
|
+
return this;
|
|
7659
|
+
}
|
|
7660
|
+
getSimpleIndex(dependencyName) {
|
|
7661
|
+
return this.#dependencyTracker.getSimpleIndex(dependencyName);
|
|
7662
|
+
}
|
|
7663
|
+
recordDependencies(idx, dependencyNames) {
|
|
7664
|
+
this.#dependencyTracker.recordDependencies(this.#opIdx, dependencyNames);
|
|
7665
|
+
return this;
|
|
7666
|
+
}
|
|
7667
|
+
copyDependenciesFromIncrementalOperation(idx, name) {
|
|
7668
|
+
this.#dependencyTracker.copyDependenciesFromIncrementalOperation(this.#opIdx, name);
|
|
7669
|
+
return this;
|
|
7670
|
+
}
|
|
7671
|
+
recordNamedDependency(idx, name) {
|
|
7672
|
+
this.#dependencyTracker.recordNamedDependency(this.#opIdx, name);
|
|
7673
|
+
return this;
|
|
7674
|
+
}
|
|
7675
|
+
recordOperation(idx) {
|
|
7676
|
+
this.#dependencyTracker.recordOperation(this.#opIdx, true);
|
|
7677
|
+
const operation = this.#dependencyTracker._extractOperation(this.#opIdx);
|
|
7678
|
+
for (const depIdx of operation.dependencies) {
|
|
7679
|
+
this.#outerDependencies.add(depIdx);
|
|
7680
|
+
}
|
|
7681
|
+
this.#outerDependencies.delete(this.#opIdx);
|
|
7682
|
+
this.#outerDependencies.delete(null);
|
|
7683
|
+
return this;
|
|
7684
|
+
}
|
|
7685
|
+
bboxToClipBoxDropOperation(idx) {
|
|
7686
|
+
this.#dependencyTracker.bboxToClipBoxDropOperation(this.#opIdx);
|
|
7687
|
+
return this;
|
|
7688
|
+
}
|
|
7689
|
+
recordNestedDependencies() {
|
|
7690
|
+
this.#dependencyTracker._pushPendingDependencies(this.#outerDependencies);
|
|
7691
|
+
}
|
|
7692
|
+
take() {
|
|
7693
|
+
throw new Error("Unreachable");
|
|
7694
|
+
}
|
|
7695
|
+
}
|
|
7696
|
+
const Dependencies = {
|
|
7697
|
+
stroke: ["path", "transform", "filter", "strokeColor", "strokeAlpha", "lineWidth", "lineCap", "lineJoin", "miterLimit", "dash"],
|
|
7698
|
+
fill: ["path", "transform", "filter", "fillColor", "fillAlpha", "globalCompositeOperation", "SMask"],
|
|
7699
|
+
imageXObject: ["transform", "SMask", "filter", "fillAlpha", "strokeAlpha", "globalCompositeOperation"],
|
|
7700
|
+
rawFillPath: ["filter", "fillColor", "fillAlpha"],
|
|
7701
|
+
showText: ["transform", "leading", "charSpacing", "wordSpacing", "hScale", "textRise", "moveText", "textMatrix", "font", "filter", "fillColor", "textRenderingMode", "SMask", "fillAlpha", "strokeAlpha", "globalCompositeOperation"],
|
|
7702
|
+
transform: ["transform"],
|
|
7703
|
+
transformAndFill: ["transform", "fillColor"]
|
|
7704
|
+
};
|
|
7705
|
+
|
|
7132
7706
|
;// ./src/display/pattern_helper.js
|
|
7133
7707
|
|
|
7134
7708
|
|
|
@@ -7513,12 +8087,14 @@ class TilingPattern {
|
|
|
7513
8087
|
graphics.groupLevel = owner.groupLevel;
|
|
7514
8088
|
this.setFillAndStrokeStyleToContext(graphics, paintType, color);
|
|
7515
8089
|
tmpCtx.translate(-dimx.scale * x0, -dimy.scale * y0);
|
|
7516
|
-
graphics.transform(dimx.scale, 0, 0, dimy.scale, 0, 0);
|
|
8090
|
+
graphics.transform(0, dimx.scale, 0, 0, dimy.scale, 0, 0);
|
|
7517
8091
|
tmpCtx.save();
|
|
8092
|
+
graphics.dependencyTracker?.save();
|
|
7518
8093
|
this.clipBbox(graphics, x0, y0, x1, y1);
|
|
7519
8094
|
graphics.baseTransform = getCurrentTransform(graphics.ctx);
|
|
7520
8095
|
graphics.executeOperatorList(operatorList);
|
|
7521
8096
|
graphics.endDrawing();
|
|
8097
|
+
graphics.dependencyTracker?.restore().recordNestedDependencies?.();
|
|
7522
8098
|
tmpCtx.restore();
|
|
7523
8099
|
if (redrawHorizontally || redrawVertically) {
|
|
7524
8100
|
const image = tmpCanvas.canvas;
|
|
@@ -7732,6 +8308,7 @@ function grayToRGBA(src, dest) {
|
|
|
7732
8308
|
|
|
7733
8309
|
|
|
7734
8310
|
|
|
8311
|
+
|
|
7735
8312
|
const MIN_FONT_SIZE = 16;
|
|
7736
8313
|
const MAX_FONT_SIZE = 100;
|
|
7737
8314
|
const EXECUTION_TIME = 15;
|
|
@@ -7926,7 +8503,8 @@ class CanvasExtraState {
|
|
|
7926
8503
|
lineWidth = 1;
|
|
7927
8504
|
activeSMask = null;
|
|
7928
8505
|
transferMaps = "none";
|
|
7929
|
-
constructor(width, height) {
|
|
8506
|
+
constructor(width, height, preInit) {
|
|
8507
|
+
preInit?.(this);
|
|
7930
8508
|
this.clipBox = new Float32Array([0, 0, width, height]);
|
|
7931
8509
|
this.minMax = MIN_MAX_INIT.slice();
|
|
7932
8510
|
}
|
|
@@ -8138,7 +8716,7 @@ class CanvasGraphics {
|
|
|
8138
8716
|
constructor(canvasCtx, commonObjs, objs, canvasFactory, filterFactory, {
|
|
8139
8717
|
optionalContentConfig,
|
|
8140
8718
|
markedContentStack = null
|
|
8141
|
-
}, annotationCanvasMap, pageColors) {
|
|
8719
|
+
}, annotationCanvasMap, pageColors, dependencyTracker) {
|
|
8142
8720
|
this.ctx = canvasCtx;
|
|
8143
8721
|
this.current = new CanvasExtraState(this.ctx.canvas.width, this.ctx.canvas.height);
|
|
8144
8722
|
this.stateStack = [];
|
|
@@ -8171,9 +8749,11 @@ class CanvasGraphics {
|
|
|
8171
8749
|
this._cachedScaleForStroking = [-1, 0];
|
|
8172
8750
|
this._cachedGetSinglePixelWidth = null;
|
|
8173
8751
|
this._cachedBitmapsMap = new Map();
|
|
8752
|
+
this.dependencyTracker = dependencyTracker ?? null;
|
|
8174
8753
|
}
|
|
8175
|
-
getObject(data, fallback = null) {
|
|
8754
|
+
getObject(opIdx, data, fallback = null) {
|
|
8176
8755
|
if (typeof data === "string") {
|
|
8756
|
+
this.dependencyTracker?.recordNamedDependency(opIdx, data);
|
|
8177
8757
|
return data.startsWith("g_") ? this.commonObjs.get(data) : this.objs.get(data);
|
|
8178
8758
|
}
|
|
8179
8759
|
return fallback;
|
|
@@ -8209,7 +8789,7 @@ class CanvasGraphics {
|
|
|
8209
8789
|
this.viewportScale = viewport.scale;
|
|
8210
8790
|
this.baseTransform = getCurrentTransform(this.ctx);
|
|
8211
8791
|
}
|
|
8212
|
-
executeOperatorList(operatorList, executionStartIdx, continueCallback, stepper) {
|
|
8792
|
+
executeOperatorList(operatorList, executionStartIdx, continueCallback, stepper, filteredOperationIndexes) {
|
|
8213
8793
|
const argsArray = operatorList.argsArray;
|
|
8214
8794
|
const fnArray = operatorList.fnArray;
|
|
8215
8795
|
let i = executionStartIdx || 0;
|
|
@@ -8222,21 +8802,29 @@ class CanvasGraphics {
|
|
|
8222
8802
|
let steps = 0;
|
|
8223
8803
|
const commonObjs = this.commonObjs;
|
|
8224
8804
|
const objs = this.objs;
|
|
8225
|
-
let fnId;
|
|
8805
|
+
let fnId, fnArgs;
|
|
8226
8806
|
while (true) {
|
|
8227
8807
|
if (stepper !== undefined && i === stepper.nextBreakPoint) {
|
|
8228
8808
|
stepper.breakIt(i, continueCallback);
|
|
8229
8809
|
return i;
|
|
8230
8810
|
}
|
|
8231
|
-
|
|
8232
|
-
|
|
8233
|
-
|
|
8234
|
-
|
|
8235
|
-
|
|
8236
|
-
|
|
8237
|
-
|
|
8238
|
-
|
|
8239
|
-
|
|
8811
|
+
if (!filteredOperationIndexes || filteredOperationIndexes.has(i)) {
|
|
8812
|
+
fnId = fnArray[i];
|
|
8813
|
+
fnArgs = argsArray[i] ?? null;
|
|
8814
|
+
if (fnId !== OPS.dependency) {
|
|
8815
|
+
if (fnArgs === null) {
|
|
8816
|
+
this[fnId](i);
|
|
8817
|
+
} else {
|
|
8818
|
+
this[fnId](i, ...fnArgs);
|
|
8819
|
+
}
|
|
8820
|
+
} else {
|
|
8821
|
+
for (const depObjId of fnArgs) {
|
|
8822
|
+
this.dependencyTracker?.recordNamedData(depObjId, i);
|
|
8823
|
+
const objsPool = depObjId.startsWith("g_") ? commonObjs : objs;
|
|
8824
|
+
if (!objsPool.has(depObjId)) {
|
|
8825
|
+
objsPool.get(depObjId, continueCallback);
|
|
8826
|
+
return i;
|
|
8827
|
+
}
|
|
8240
8828
|
}
|
|
8241
8829
|
}
|
|
8242
8830
|
}
|
|
@@ -8329,7 +8917,7 @@ class CanvasGraphics {
|
|
|
8329
8917
|
paintHeight
|
|
8330
8918
|
};
|
|
8331
8919
|
}
|
|
8332
|
-
_createMaskCanvas(img) {
|
|
8920
|
+
_createMaskCanvas(opIdx, img) {
|
|
8333
8921
|
const ctx = this.ctx;
|
|
8334
8922
|
const {
|
|
8335
8923
|
width,
|
|
@@ -8351,6 +8939,7 @@ class CanvasGraphics {
|
|
|
8351
8939
|
if (cachedImage && !isPatternFill) {
|
|
8352
8940
|
const offsetX = Math.round(Math.min(currentTransform[0], currentTransform[2]) + currentTransform[4]);
|
|
8353
8941
|
const offsetY = Math.round(Math.min(currentTransform[1], currentTransform[3]) + currentTransform[5]);
|
|
8942
|
+
this.dependencyTracker?.recordDependencies(opIdx, Dependencies.transformAndFill);
|
|
8354
8943
|
return {
|
|
8355
8944
|
canvas: cachedImage,
|
|
8356
8945
|
offsetX,
|
|
@@ -8393,79 +8982,90 @@ class CanvasGraphics {
|
|
|
8393
8982
|
this.cachedCanvases.delete("fillCanvas");
|
|
8394
8983
|
cache.set(cacheKey, fillCanvas.canvas);
|
|
8395
8984
|
}
|
|
8985
|
+
this.dependencyTracker?.recordDependencies(opIdx, Dependencies.transformAndFill);
|
|
8396
8986
|
return {
|
|
8397
8987
|
canvas: fillCanvas.canvas,
|
|
8398
8988
|
offsetX: Math.round(offsetX),
|
|
8399
8989
|
offsetY: Math.round(offsetY)
|
|
8400
8990
|
};
|
|
8401
8991
|
}
|
|
8402
|
-
setLineWidth(width) {
|
|
8992
|
+
setLineWidth(opIdx, width) {
|
|
8993
|
+
this.dependencyTracker?.recordSimpleData("lineWidth", opIdx);
|
|
8403
8994
|
if (width !== this.current.lineWidth) {
|
|
8404
8995
|
this._cachedScaleForStroking[0] = -1;
|
|
8405
8996
|
}
|
|
8406
8997
|
this.current.lineWidth = width;
|
|
8407
8998
|
this.ctx.lineWidth = width;
|
|
8408
8999
|
}
|
|
8409
|
-
setLineCap(style) {
|
|
9000
|
+
setLineCap(opIdx, style) {
|
|
9001
|
+
this.dependencyTracker?.recordSimpleData("lineCap", opIdx);
|
|
8410
9002
|
this.ctx.lineCap = LINE_CAP_STYLES[style];
|
|
8411
9003
|
}
|
|
8412
|
-
setLineJoin(style) {
|
|
9004
|
+
setLineJoin(opIdx, style) {
|
|
9005
|
+
this.dependencyTracker?.recordSimpleData("lineJoin", opIdx);
|
|
8413
9006
|
this.ctx.lineJoin = LINE_JOIN_STYLES[style];
|
|
8414
9007
|
}
|
|
8415
|
-
setMiterLimit(limit) {
|
|
9008
|
+
setMiterLimit(opIdx, limit) {
|
|
9009
|
+
this.dependencyTracker?.recordSimpleData("miterLimit", opIdx);
|
|
8416
9010
|
this.ctx.miterLimit = limit;
|
|
8417
9011
|
}
|
|
8418
|
-
setDash(dashArray, dashPhase) {
|
|
9012
|
+
setDash(opIdx, dashArray, dashPhase) {
|
|
9013
|
+
this.dependencyTracker?.recordSimpleData("dash", opIdx);
|
|
8419
9014
|
const ctx = this.ctx;
|
|
8420
9015
|
if (ctx.setLineDash !== undefined) {
|
|
8421
9016
|
ctx.setLineDash(dashArray);
|
|
8422
9017
|
ctx.lineDashOffset = dashPhase;
|
|
8423
9018
|
}
|
|
8424
9019
|
}
|
|
8425
|
-
setRenderingIntent(intent) {}
|
|
8426
|
-
setFlatness(flatness) {}
|
|
8427
|
-
setGState(states) {
|
|
9020
|
+
setRenderingIntent(opIdx, intent) {}
|
|
9021
|
+
setFlatness(opIdx, flatness) {}
|
|
9022
|
+
setGState(opIdx, states) {
|
|
8428
9023
|
for (const [key, value] of states) {
|
|
8429
9024
|
switch (key) {
|
|
8430
9025
|
case "LW":
|
|
8431
|
-
this.setLineWidth(value);
|
|
9026
|
+
this.setLineWidth(opIdx, value);
|
|
8432
9027
|
break;
|
|
8433
9028
|
case "LC":
|
|
8434
|
-
this.setLineCap(value);
|
|
9029
|
+
this.setLineCap(opIdx, value);
|
|
8435
9030
|
break;
|
|
8436
9031
|
case "LJ":
|
|
8437
|
-
this.setLineJoin(value);
|
|
9032
|
+
this.setLineJoin(opIdx, value);
|
|
8438
9033
|
break;
|
|
8439
9034
|
case "ML":
|
|
8440
|
-
this.setMiterLimit(value);
|
|
9035
|
+
this.setMiterLimit(opIdx, value);
|
|
8441
9036
|
break;
|
|
8442
9037
|
case "D":
|
|
8443
|
-
this.setDash(value[0], value[1]);
|
|
9038
|
+
this.setDash(opIdx, value[0], value[1]);
|
|
8444
9039
|
break;
|
|
8445
9040
|
case "RI":
|
|
8446
|
-
this.setRenderingIntent(value);
|
|
9041
|
+
this.setRenderingIntent(opIdx, value);
|
|
8447
9042
|
break;
|
|
8448
9043
|
case "FL":
|
|
8449
|
-
this.setFlatness(value);
|
|
9044
|
+
this.setFlatness(opIdx, value);
|
|
8450
9045
|
break;
|
|
8451
9046
|
case "Font":
|
|
8452
|
-
this.setFont(value[0], value[1]);
|
|
9047
|
+
this.setFont(opIdx, value[0], value[1]);
|
|
8453
9048
|
break;
|
|
8454
9049
|
case "CA":
|
|
9050
|
+
this.dependencyTracker?.recordSimpleData("strokeAlpha", opIdx);
|
|
8455
9051
|
this.current.strokeAlpha = value;
|
|
8456
9052
|
break;
|
|
8457
9053
|
case "ca":
|
|
9054
|
+
this.dependencyTracker?.recordSimpleData("fillAlpha", opIdx);
|
|
8458
9055
|
this.ctx.globalAlpha = this.current.fillAlpha = value;
|
|
8459
9056
|
break;
|
|
8460
9057
|
case "BM":
|
|
9058
|
+
this.dependencyTracker?.recordSimpleData("globalCompositeOperation", opIdx);
|
|
8461
9059
|
this.ctx.globalCompositeOperation = value;
|
|
8462
9060
|
break;
|
|
8463
9061
|
case "SMask":
|
|
9062
|
+
this.dependencyTracker?.recordSimpleData("SMask", opIdx);
|
|
8464
9063
|
this.current.activeSMask = value ? this.tempSMask : null;
|
|
8465
9064
|
this.tempSMask = null;
|
|
8466
9065
|
this.checkSMaskState();
|
|
8467
9066
|
break;
|
|
8468
9067
|
case "TR":
|
|
9068
|
+
this.dependencyTracker?.recordSimpleData("filter", opIdx);
|
|
8469
9069
|
this.ctx.filter = this.current.transferMaps = this.filterFactory.addFilter(value);
|
|
8470
9070
|
break;
|
|
8471
9071
|
}
|
|
@@ -8482,7 +9082,7 @@ class CanvasGraphics {
|
|
|
8482
9082
|
this.endSMaskMode();
|
|
8483
9083
|
}
|
|
8484
9084
|
}
|
|
8485
|
-
beginSMaskMode() {
|
|
9085
|
+
beginSMaskMode(opIdx) {
|
|
8486
9086
|
if (this.inSMaskMode) {
|
|
8487
9087
|
throw new Error("beginSMaskMode called while already in smask mode");
|
|
8488
9088
|
}
|
|
@@ -8495,7 +9095,7 @@ class CanvasGraphics {
|
|
|
8495
9095
|
ctx.setTransform(this.suspendedCtx.getTransform());
|
|
8496
9096
|
copyCtxState(this.suspendedCtx, ctx);
|
|
8497
9097
|
mirrorContextOperations(ctx, this.suspendedCtx);
|
|
8498
|
-
this.setGState([["BM", "source-over"]]);
|
|
9098
|
+
this.setGState(opIdx, [["BM", "source-over"]]);
|
|
8499
9099
|
}
|
|
8500
9100
|
endSMaskMode() {
|
|
8501
9101
|
if (!this.inSMaskMode) {
|
|
@@ -8585,7 +9185,7 @@ class CanvasGraphics {
|
|
|
8585
9185
|
layerCtx.drawImage(maskCanvas, maskX, maskY, width, height, layerOffsetX, layerOffsetY, width, height);
|
|
8586
9186
|
layerCtx.restore();
|
|
8587
9187
|
}
|
|
8588
|
-
save() {
|
|
9188
|
+
save(opIdx) {
|
|
8589
9189
|
if (this.inSMaskMode) {
|
|
8590
9190
|
copyCtxState(this.ctx, this.suspendedCtx);
|
|
8591
9191
|
}
|
|
@@ -8593,8 +9193,10 @@ class CanvasGraphics {
|
|
|
8593
9193
|
const old = this.current;
|
|
8594
9194
|
this.stateStack.push(old);
|
|
8595
9195
|
this.current = old.clone();
|
|
9196
|
+
this.dependencyTracker?.save(opIdx);
|
|
8596
9197
|
}
|
|
8597
|
-
restore() {
|
|
9198
|
+
restore(opIdx) {
|
|
9199
|
+
this.dependencyTracker?.restore(opIdx);
|
|
8598
9200
|
if (this.stateStack.length === 0) {
|
|
8599
9201
|
if (this.inSMaskMode) {
|
|
8600
9202
|
this.endSMaskMode();
|
|
@@ -8611,18 +9213,23 @@ class CanvasGraphics {
|
|
|
8611
9213
|
this._cachedScaleForStroking[0] = -1;
|
|
8612
9214
|
this._cachedGetSinglePixelWidth = null;
|
|
8613
9215
|
}
|
|
8614
|
-
transform(a, b, c, d, e, f) {
|
|
9216
|
+
transform(opIdx, a, b, c, d, e, f) {
|
|
9217
|
+
this.dependencyTracker?.recordIncrementalData("transform", opIdx);
|
|
8615
9218
|
this.ctx.transform(a, b, c, d, e, f);
|
|
8616
9219
|
this._cachedScaleForStroking[0] = -1;
|
|
8617
9220
|
this._cachedGetSinglePixelWidth = null;
|
|
8618
9221
|
}
|
|
8619
|
-
constructPath(op, data, minMax) {
|
|
9222
|
+
constructPath(opIdx, op, data, minMax) {
|
|
8620
9223
|
let [path] = data;
|
|
8621
9224
|
if (!minMax) {
|
|
8622
9225
|
path ||= data[0] = new Path2D();
|
|
8623
|
-
this[op](path);
|
|
9226
|
+
this[op](opIdx, path);
|
|
8624
9227
|
return;
|
|
8625
9228
|
}
|
|
9229
|
+
if (this.dependencyTracker !== null) {
|
|
9230
|
+
const outerExtraSize = op === OPS.stroke ? this.current.lineWidth / 2 : 0;
|
|
9231
|
+
this.dependencyTracker.resetBBox(opIdx).recordBBox(opIdx, this.ctx, minMax[0] - outerExtraSize, minMax[2] + outerExtraSize, minMax[1] - outerExtraSize, minMax[3] + outerExtraSize).recordDependencies(opIdx, ["transform"]);
|
|
9232
|
+
}
|
|
8626
9233
|
if (!(path instanceof Path2D)) {
|
|
8627
9234
|
const path2d = data[0] = new Path2D();
|
|
8628
9235
|
for (let i = 0, ii = path.length; i < ii;) {
|
|
@@ -8647,12 +9254,13 @@ class CanvasGraphics {
|
|
|
8647
9254
|
path = path2d;
|
|
8648
9255
|
}
|
|
8649
9256
|
Util.axialAlignedBoundingBox(minMax, getCurrentTransform(this.ctx), this.current.minMax);
|
|
8650
|
-
this[op](path);
|
|
9257
|
+
this[op](opIdx, path);
|
|
9258
|
+
this._pathStartIdx = opIdx;
|
|
8651
9259
|
}
|
|
8652
|
-
closePath() {
|
|
9260
|
+
closePath(opIdx) {
|
|
8653
9261
|
this.ctx.closePath();
|
|
8654
9262
|
}
|
|
8655
|
-
stroke(path, consumePath = true) {
|
|
9263
|
+
stroke(opIdx, path, consumePath = true) {
|
|
8656
9264
|
const ctx = this.ctx;
|
|
8657
9265
|
const strokeColor = this.current.strokeColor;
|
|
8658
9266
|
ctx.globalAlpha = this.current.strokeAlpha;
|
|
@@ -8672,21 +9280,23 @@ class CanvasGraphics {
|
|
|
8672
9280
|
this.rescaleAndStroke(path, true);
|
|
8673
9281
|
}
|
|
8674
9282
|
}
|
|
9283
|
+
this.dependencyTracker?.recordDependencies(opIdx, Dependencies.stroke);
|
|
8675
9284
|
if (consumePath) {
|
|
8676
|
-
this.consumePath(path, this.current.getClippedPathBoundingBox(PathType.STROKE, getCurrentTransform(this.ctx)));
|
|
9285
|
+
this.consumePath(opIdx, path, this.current.getClippedPathBoundingBox(PathType.STROKE, getCurrentTransform(this.ctx)));
|
|
8677
9286
|
}
|
|
8678
9287
|
ctx.globalAlpha = this.current.fillAlpha;
|
|
8679
9288
|
}
|
|
8680
|
-
closeStroke(path) {
|
|
8681
|
-
this.stroke(path);
|
|
9289
|
+
closeStroke(opIdx, path) {
|
|
9290
|
+
this.stroke(opIdx, path);
|
|
8682
9291
|
}
|
|
8683
|
-
fill(path, consumePath = true) {
|
|
9292
|
+
fill(opIdx, path, consumePath = true) {
|
|
8684
9293
|
const ctx = this.ctx;
|
|
8685
9294
|
const fillColor = this.current.fillColor;
|
|
8686
9295
|
const isPatternFill = this.current.patternFill;
|
|
8687
9296
|
let needRestore = false;
|
|
8688
9297
|
if (isPatternFill) {
|
|
8689
9298
|
const baseTransform = fillColor.isModifyingCurrentTransform() ? ctx.getTransform() : null;
|
|
9299
|
+
this.dependencyTracker?.save(opIdx);
|
|
8690
9300
|
ctx.save();
|
|
8691
9301
|
ctx.fillStyle = fillColor.getPattern(ctx, this, getCurrentTransformInverse(ctx), PathType.FILL);
|
|
8692
9302
|
if (baseTransform) {
|
|
@@ -8705,87 +9315,106 @@ class CanvasGraphics {
|
|
|
8705
9315
|
ctx.fill(path);
|
|
8706
9316
|
}
|
|
8707
9317
|
}
|
|
9318
|
+
this.dependencyTracker?.recordDependencies(opIdx, Dependencies.fill);
|
|
8708
9319
|
if (needRestore) {
|
|
8709
9320
|
ctx.restore();
|
|
9321
|
+
this.dependencyTracker?.restore(opIdx);
|
|
8710
9322
|
}
|
|
8711
9323
|
if (consumePath) {
|
|
8712
|
-
this.consumePath(path, intersect);
|
|
9324
|
+
this.consumePath(opIdx, path, intersect);
|
|
8713
9325
|
}
|
|
8714
9326
|
}
|
|
8715
|
-
eoFill(path) {
|
|
9327
|
+
eoFill(opIdx, path) {
|
|
8716
9328
|
this.pendingEOFill = true;
|
|
8717
|
-
this.fill(path);
|
|
9329
|
+
this.fill(opIdx, path);
|
|
8718
9330
|
}
|
|
8719
|
-
fillStroke(path) {
|
|
8720
|
-
this.fill(path, false);
|
|
8721
|
-
this.stroke(path, false);
|
|
8722
|
-
this.consumePath(path);
|
|
9331
|
+
fillStroke(opIdx, path) {
|
|
9332
|
+
this.fill(opIdx, path, false);
|
|
9333
|
+
this.stroke(opIdx, path, false);
|
|
9334
|
+
this.consumePath(opIdx, path);
|
|
8723
9335
|
}
|
|
8724
|
-
eoFillStroke(path) {
|
|
9336
|
+
eoFillStroke(opIdx, path) {
|
|
8725
9337
|
this.pendingEOFill = true;
|
|
8726
|
-
this.fillStroke(path);
|
|
9338
|
+
this.fillStroke(opIdx, path);
|
|
8727
9339
|
}
|
|
8728
|
-
closeFillStroke(path) {
|
|
8729
|
-
this.fillStroke(path);
|
|
9340
|
+
closeFillStroke(opIdx, path) {
|
|
9341
|
+
this.fillStroke(opIdx, path);
|
|
8730
9342
|
}
|
|
8731
|
-
closeEOFillStroke(path) {
|
|
9343
|
+
closeEOFillStroke(opIdx, path) {
|
|
8732
9344
|
this.pendingEOFill = true;
|
|
8733
|
-
this.fillStroke(path);
|
|
9345
|
+
this.fillStroke(opIdx, path);
|
|
8734
9346
|
}
|
|
8735
|
-
endPath(path) {
|
|
8736
|
-
this.consumePath(path);
|
|
9347
|
+
endPath(opIdx, path) {
|
|
9348
|
+
this.consumePath(opIdx, path);
|
|
8737
9349
|
}
|
|
8738
|
-
rawFillPath(path) {
|
|
9350
|
+
rawFillPath(opIdx, path) {
|
|
8739
9351
|
this.ctx.fill(path);
|
|
9352
|
+
this.dependencyTracker?.recordDependencies(opIdx, Dependencies.rawFillPath).recordOperation(opIdx);
|
|
8740
9353
|
}
|
|
8741
|
-
clip() {
|
|
9354
|
+
clip(opIdx) {
|
|
9355
|
+
this.dependencyTracker?.recordFutureForcedDependency("clipMode", opIdx);
|
|
8742
9356
|
this.pendingClip = NORMAL_CLIP;
|
|
8743
9357
|
}
|
|
8744
|
-
eoClip() {
|
|
9358
|
+
eoClip(opIdx) {
|
|
9359
|
+
this.dependencyTracker?.recordFutureForcedDependency("clipMode", opIdx);
|
|
8745
9360
|
this.pendingClip = EO_CLIP;
|
|
8746
9361
|
}
|
|
8747
|
-
beginText() {
|
|
9362
|
+
beginText(opIdx) {
|
|
8748
9363
|
this.current.textMatrix = null;
|
|
8749
9364
|
this.current.textMatrixScale = 1;
|
|
8750
9365
|
this.current.x = this.current.lineX = 0;
|
|
8751
9366
|
this.current.y = this.current.lineY = 0;
|
|
9367
|
+
this.dependencyTracker?.recordOpenMarker(opIdx).resetIncrementalData("sameLineText").resetIncrementalData("moveText", opIdx);
|
|
8752
9368
|
}
|
|
8753
|
-
endText() {
|
|
9369
|
+
endText(opIdx) {
|
|
8754
9370
|
const paths = this.pendingTextPaths;
|
|
8755
9371
|
const ctx = this.ctx;
|
|
8756
|
-
if (
|
|
8757
|
-
|
|
9372
|
+
if (this.dependencyTracker) {
|
|
9373
|
+
const {
|
|
9374
|
+
dependencyTracker
|
|
9375
|
+
} = this;
|
|
9376
|
+
if (paths !== undefined) {
|
|
9377
|
+
dependencyTracker.recordFutureForcedDependency("textClip", dependencyTracker.getOpenMarker()).recordFutureForcedDependency("textClip", opIdx);
|
|
9378
|
+
}
|
|
9379
|
+
dependencyTracker.recordCloseMarker(opIdx);
|
|
8758
9380
|
}
|
|
8759
|
-
|
|
8760
|
-
|
|
8761
|
-
|
|
8762
|
-
|
|
8763
|
-
|
|
8764
|
-
|
|
8765
|
-
|
|
8766
|
-
|
|
8767
|
-
|
|
8768
|
-
|
|
8769
|
-
|
|
9381
|
+
if (paths !== undefined) {
|
|
9382
|
+
const newPath = new Path2D();
|
|
9383
|
+
const invTransf = ctx.getTransform().invertSelf();
|
|
9384
|
+
for (const {
|
|
9385
|
+
transform,
|
|
9386
|
+
x,
|
|
9387
|
+
y,
|
|
9388
|
+
fontSize,
|
|
9389
|
+
path
|
|
9390
|
+
} of paths) {
|
|
9391
|
+
if (!path) {
|
|
9392
|
+
continue;
|
|
9393
|
+
}
|
|
9394
|
+
newPath.addPath(path, new DOMMatrix(transform).preMultiplySelf(invTransf).translate(x, y).scale(fontSize, -fontSize));
|
|
8770
9395
|
}
|
|
8771
|
-
|
|
9396
|
+
ctx.clip(newPath);
|
|
8772
9397
|
}
|
|
8773
|
-
ctx.clip(newPath);
|
|
8774
9398
|
delete this.pendingTextPaths;
|
|
8775
9399
|
}
|
|
8776
|
-
setCharSpacing(spacing) {
|
|
9400
|
+
setCharSpacing(opIdx, spacing) {
|
|
9401
|
+
this.dependencyTracker?.recordSimpleData("charSpacing", opIdx);
|
|
8777
9402
|
this.current.charSpacing = spacing;
|
|
8778
9403
|
}
|
|
8779
|
-
setWordSpacing(spacing) {
|
|
9404
|
+
setWordSpacing(opIdx, spacing) {
|
|
9405
|
+
this.dependencyTracker?.recordSimpleData("wordSpacing", opIdx);
|
|
8780
9406
|
this.current.wordSpacing = spacing;
|
|
8781
9407
|
}
|
|
8782
|
-
setHScale(scale) {
|
|
9408
|
+
setHScale(opIdx, scale) {
|
|
9409
|
+
this.dependencyTracker?.recordSimpleData("hScale", opIdx);
|
|
8783
9410
|
this.current.textHScale = scale / 100;
|
|
8784
9411
|
}
|
|
8785
|
-
setLeading(leading) {
|
|
9412
|
+
setLeading(opIdx, leading) {
|
|
9413
|
+
this.dependencyTracker?.recordSimpleData("leading", opIdx);
|
|
8786
9414
|
this.current.leading = -leading;
|
|
8787
9415
|
}
|
|
8788
|
-
setFont(fontRefName, size) {
|
|
9416
|
+
setFont(opIdx, fontRefName, size) {
|
|
9417
|
+
this.dependencyTracker?.recordSimpleData("font", opIdx).recordNamedDependency(opIdx, fontRefName);
|
|
8789
9418
|
const fontObj = this.commonObjs.get(fontRefName);
|
|
8790
9419
|
const current = this.current;
|
|
8791
9420
|
if (!fontObj) {
|
|
@@ -8824,21 +9453,25 @@ class CanvasGraphics {
|
|
|
8824
9453
|
this.current.fontSizeScale = size / browserFontSize;
|
|
8825
9454
|
this.ctx.font = `${italic} ${bold} ${browserFontSize}px ${typeface}`;
|
|
8826
9455
|
}
|
|
8827
|
-
setTextRenderingMode(mode) {
|
|
9456
|
+
setTextRenderingMode(opIdx, mode) {
|
|
9457
|
+
this.dependencyTracker?.recordSimpleData("textRenderingMode", opIdx);
|
|
8828
9458
|
this.current.textRenderingMode = mode;
|
|
8829
9459
|
}
|
|
8830
|
-
setTextRise(rise) {
|
|
9460
|
+
setTextRise(opIdx, rise) {
|
|
9461
|
+
this.dependencyTracker?.recordSimpleData("textRise", opIdx);
|
|
8831
9462
|
this.current.textRise = rise;
|
|
8832
9463
|
}
|
|
8833
|
-
moveText(x, y) {
|
|
9464
|
+
moveText(opIdx, x, y) {
|
|
9465
|
+
this.dependencyTracker?.resetIncrementalData("sameLineText").recordIncrementalData("moveText", opIdx);
|
|
8834
9466
|
this.current.x = this.current.lineX += x;
|
|
8835
9467
|
this.current.y = this.current.lineY += y;
|
|
8836
9468
|
}
|
|
8837
|
-
setLeadingMoveText(x, y) {
|
|
8838
|
-
this.setLeading(-y);
|
|
8839
|
-
this.moveText(x, y);
|
|
9469
|
+
setLeadingMoveText(opIdx, x, y) {
|
|
9470
|
+
this.setLeading(opIdx, -y);
|
|
9471
|
+
this.moveText(opIdx, x, y);
|
|
8840
9472
|
}
|
|
8841
|
-
setTextMatrix(matrix) {
|
|
9473
|
+
setTextMatrix(opIdx, matrix) {
|
|
9474
|
+
this.dependencyTracker?.recordSimpleData("textMatrix", opIdx);
|
|
8842
9475
|
const {
|
|
8843
9476
|
current
|
|
8844
9477
|
} = this;
|
|
@@ -8847,15 +9480,16 @@ class CanvasGraphics {
|
|
|
8847
9480
|
current.x = current.lineX = 0;
|
|
8848
9481
|
current.y = current.lineY = 0;
|
|
8849
9482
|
}
|
|
8850
|
-
nextLine() {
|
|
8851
|
-
this.moveText(0, this.current.leading);
|
|
9483
|
+
nextLine(opIdx) {
|
|
9484
|
+
this.moveText(opIdx, 0, this.current.leading);
|
|
9485
|
+
this.dependencyTracker?.recordIncrementalData("moveText", this.dependencyTracker.getSimpleIndex("leading") ?? opIdx);
|
|
8852
9486
|
}
|
|
8853
9487
|
#getScaledPath(path, currentTransform, transform) {
|
|
8854
9488
|
const newPath = new Path2D();
|
|
8855
9489
|
newPath.addPath(path, new DOMMatrix(transform).invertSelf().multiplySelf(currentTransform));
|
|
8856
9490
|
return newPath;
|
|
8857
9491
|
}
|
|
8858
|
-
paintChar(character, x, y, patternFillTransform, patternStrokeTransform) {
|
|
9492
|
+
paintChar(opIdx, character, x, y, patternFillTransform, patternStrokeTransform) {
|
|
8859
9493
|
const ctx = this.ctx;
|
|
8860
9494
|
const current = this.current;
|
|
8861
9495
|
const font = current.font;
|
|
@@ -8873,12 +9507,14 @@ class CanvasGraphics {
|
|
|
8873
9507
|
ctx.save();
|
|
8874
9508
|
ctx.translate(x, y);
|
|
8875
9509
|
ctx.scale(fontSize, -fontSize);
|
|
9510
|
+
this.dependencyTracker?.recordCharacterBBox(opIdx, ctx, font);
|
|
8876
9511
|
let currentTransform;
|
|
8877
9512
|
if (fillStrokeMode === TextRenderingMode.FILL || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
|
|
8878
9513
|
if (patternFillTransform) {
|
|
8879
9514
|
currentTransform = ctx.getTransform();
|
|
8880
9515
|
ctx.setTransform(...patternFillTransform);
|
|
8881
|
-
|
|
9516
|
+
const scaledPath = this.#getScaledPath(path, currentTransform, patternFillTransform);
|
|
9517
|
+
ctx.fill(scaledPath);
|
|
8882
9518
|
} else {
|
|
8883
9519
|
ctx.fill(path);
|
|
8884
9520
|
}
|
|
@@ -8907,8 +9543,12 @@ class CanvasGraphics {
|
|
|
8907
9543
|
} else {
|
|
8908
9544
|
if (fillStrokeMode === TextRenderingMode.FILL || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
|
|
8909
9545
|
ctx.fillText(character, x, y);
|
|
9546
|
+
this.dependencyTracker?.recordCharacterBBox(opIdx, ctx, font, fontSize, x, y, () => ctx.measureText(character));
|
|
8910
9547
|
}
|
|
8911
9548
|
if (fillStrokeMode === TextRenderingMode.STROKE || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
|
|
9549
|
+
if (this.dependencyTracker) {
|
|
9550
|
+
this.dependencyTracker?.recordCharacterBBox(opIdx, ctx, font, fontSize, x, y, () => ctx.measureText(character)).recordDependencies(opIdx, Dependencies.stroke);
|
|
9551
|
+
}
|
|
8912
9552
|
ctx.strokeText(character, x, y);
|
|
8913
9553
|
}
|
|
8914
9554
|
}
|
|
@@ -8921,6 +9561,7 @@ class CanvasGraphics {
|
|
|
8921
9561
|
fontSize,
|
|
8922
9562
|
path
|
|
8923
9563
|
});
|
|
9564
|
+
this.dependencyTracker?.recordCharacterBBox(opIdx, ctx, font, fontSize, x, y);
|
|
8924
9565
|
}
|
|
8925
9566
|
}
|
|
8926
9567
|
get isFontSubpixelAAEnabled() {
|
|
@@ -8939,14 +9580,23 @@ class CanvasGraphics {
|
|
|
8939
9580
|
}
|
|
8940
9581
|
return shadow(this, "isFontSubpixelAAEnabled", enabled);
|
|
8941
9582
|
}
|
|
8942
|
-
showText(glyphs) {
|
|
9583
|
+
showText(opIdx, glyphs) {
|
|
9584
|
+
if (this.dependencyTracker) {
|
|
9585
|
+
this.dependencyTracker.recordDependencies(opIdx, Dependencies.showText).copyDependenciesFromIncrementalOperation(opIdx, "sameLineText").resetBBox(opIdx);
|
|
9586
|
+
if (this.current.textRenderingMode & TextRenderingMode.ADD_TO_PATH_FLAG) {
|
|
9587
|
+
this.dependencyTracker.recordFutureForcedDependency("textClip", opIdx).inheritPendingDependenciesAsFutureForcedDependencies();
|
|
9588
|
+
}
|
|
9589
|
+
}
|
|
8943
9590
|
const current = this.current;
|
|
8944
9591
|
const font = current.font;
|
|
8945
9592
|
if (font.isType3Font) {
|
|
8946
|
-
|
|
9593
|
+
this.showType3Text(opIdx, glyphs);
|
|
9594
|
+
this.dependencyTracker?.recordOperation(opIdx).recordIncrementalData("sameLineText", opIdx);
|
|
9595
|
+
return undefined;
|
|
8947
9596
|
}
|
|
8948
9597
|
const fontSize = current.fontSize;
|
|
8949
9598
|
if (fontSize === 0) {
|
|
9599
|
+
this.dependencyTracker?.recordOperation(opIdx);
|
|
8950
9600
|
return undefined;
|
|
8951
9601
|
}
|
|
8952
9602
|
const ctx = this.ctx;
|
|
@@ -9008,7 +9658,12 @@ class CanvasGraphics {
|
|
|
9008
9658
|
chars.push(glyph.unicode);
|
|
9009
9659
|
width += glyph.width;
|
|
9010
9660
|
}
|
|
9011
|
-
|
|
9661
|
+
const joinedChars = chars.join("");
|
|
9662
|
+
ctx.fillText(joinedChars, 0, 0);
|
|
9663
|
+
if (this.dependencyTracker !== null) {
|
|
9664
|
+
const measure = ctx.measureText(joinedChars);
|
|
9665
|
+
this.dependencyTracker.recordBBox(opIdx, this.ctx, -measure.actualBoundingBoxLeft, measure.actualBoundingBoxRight, -measure.actualBoundingBoxAscent, measure.actualBoundingBoxDescent).recordOperation(opIdx).recordIncrementalData("sameLineText", opIdx);
|
|
9666
|
+
}
|
|
9012
9667
|
current.x += width * widthAdvanceScale * textHScale;
|
|
9013
9668
|
ctx.restore();
|
|
9014
9669
|
this.compose();
|
|
@@ -9039,8 +9694,10 @@ class CanvasGraphics {
|
|
|
9039
9694
|
scaledX = x / fontSizeScale;
|
|
9040
9695
|
scaledY = 0;
|
|
9041
9696
|
}
|
|
9697
|
+
let measure;
|
|
9042
9698
|
if (font.remeasure && width > 0) {
|
|
9043
|
-
|
|
9699
|
+
measure = ctx.measureText(character);
|
|
9700
|
+
const measuredWidth = measure.width * 1000 / fontSize * fontSizeScale;
|
|
9044
9701
|
if (width < measuredWidth && this.isFontSubpixelAAEnabled) {
|
|
9045
9702
|
const characterScaleX = width / measuredWidth;
|
|
9046
9703
|
restoreNeeded = true;
|
|
@@ -9054,12 +9711,15 @@ class CanvasGraphics {
|
|
|
9054
9711
|
if (this.contentVisible && (glyph.isInFont || font.missingFile)) {
|
|
9055
9712
|
if (simpleFillText && !accent) {
|
|
9056
9713
|
ctx.fillText(character, scaledX, scaledY);
|
|
9714
|
+
this.dependencyTracker?.recordCharacterBBox(opIdx, ctx, measure ? {
|
|
9715
|
+
bbox: null
|
|
9716
|
+
} : font, fontSize / fontSizeScale, scaledX, scaledY, () => measure ?? ctx.measureText(character));
|
|
9057
9717
|
} else {
|
|
9058
|
-
this.paintChar(character, scaledX, scaledY, patternFillTransform, patternStrokeTransform);
|
|
9718
|
+
this.paintChar(opIdx, character, scaledX, scaledY, patternFillTransform, patternStrokeTransform);
|
|
9059
9719
|
if (accent) {
|
|
9060
9720
|
const scaledAccentX = scaledX + fontSize * accent.offset.x / fontSizeScale;
|
|
9061
9721
|
const scaledAccentY = scaledY - fontSize * accent.offset.y / fontSizeScale;
|
|
9062
|
-
this.paintChar(accent.fontChar, scaledAccentX, scaledAccentY, patternFillTransform, patternStrokeTransform);
|
|
9722
|
+
this.paintChar(opIdx, accent.fontChar, scaledAccentX, scaledAccentY, patternFillTransform, patternStrokeTransform);
|
|
9063
9723
|
}
|
|
9064
9724
|
}
|
|
9065
9725
|
}
|
|
@@ -9076,9 +9736,10 @@ class CanvasGraphics {
|
|
|
9076
9736
|
}
|
|
9077
9737
|
ctx.restore();
|
|
9078
9738
|
this.compose();
|
|
9739
|
+
this.dependencyTracker?.recordOperation(opIdx).recordIncrementalData("sameLineText", opIdx);
|
|
9079
9740
|
return undefined;
|
|
9080
9741
|
}
|
|
9081
|
-
showType3Text(glyphs) {
|
|
9742
|
+
showType3Text(opIdx, glyphs) {
|
|
9082
9743
|
const ctx = this.ctx;
|
|
9083
9744
|
const current = this.current;
|
|
9084
9745
|
const font = current.font;
|
|
@@ -9103,6 +9764,8 @@ class CanvasGraphics {
|
|
|
9103
9764
|
}
|
|
9104
9765
|
ctx.translate(current.x, current.y + current.textRise);
|
|
9105
9766
|
ctx.scale(textHScale, fontDirection);
|
|
9767
|
+
const dependencyTracker = this.dependencyTracker;
|
|
9768
|
+
this.dependencyTracker = dependencyTracker ? new CanvasNestedDependencyTracker(dependencyTracker, opIdx) : null;
|
|
9106
9769
|
for (i = 0; i < glyphsLength; ++i) {
|
|
9107
9770
|
glyph = glyphs[i];
|
|
9108
9771
|
if (typeof glyph === "number") {
|
|
@@ -9129,15 +9792,20 @@ class CanvasGraphics {
|
|
|
9129
9792
|
current.x += width * textHScale;
|
|
9130
9793
|
}
|
|
9131
9794
|
ctx.restore();
|
|
9795
|
+
if (dependencyTracker) {
|
|
9796
|
+
this.dependencyTracker.recordNestedDependencies();
|
|
9797
|
+
this.dependencyTracker = dependencyTracker;
|
|
9798
|
+
}
|
|
9132
9799
|
}
|
|
9133
|
-
setCharWidth(xWidth, yWidth) {}
|
|
9134
|
-
setCharWidthAndBounds(xWidth, yWidth, llx, lly, urx, ury) {
|
|
9800
|
+
setCharWidth(opIdx, xWidth, yWidth) {}
|
|
9801
|
+
setCharWidthAndBounds(opIdx, xWidth, yWidth, llx, lly, urx, ury) {
|
|
9135
9802
|
const clip = new Path2D();
|
|
9136
9803
|
clip.rect(llx, lly, urx - llx, ury - lly);
|
|
9137
9804
|
this.ctx.clip(clip);
|
|
9138
|
-
this.
|
|
9805
|
+
this.dependencyTracker?.recordBBox(opIdx, this.ctx, llx, urx, lly, ury).recordClipBox(opIdx, this.ctx, llx, urx, lly, ury);
|
|
9806
|
+
this.endPath(opIdx);
|
|
9139
9807
|
}
|
|
9140
|
-
getColorN_Pattern(IR) {
|
|
9808
|
+
getColorN_Pattern(opIdx, IR) {
|
|
9141
9809
|
let pattern;
|
|
9142
9810
|
if (IR[0] === "TilingPattern") {
|
|
9143
9811
|
const baseTransform = this.baseTransform || getCurrentTransform(this.ctx);
|
|
@@ -9145,44 +9813,50 @@ class CanvasGraphics {
|
|
|
9145
9813
|
createCanvasGraphics: ctx => new CanvasGraphics(ctx, this.commonObjs, this.objs, this.canvasFactory, this.filterFactory, {
|
|
9146
9814
|
optionalContentConfig: this.optionalContentConfig,
|
|
9147
9815
|
markedContentStack: this.markedContentStack
|
|
9148
|
-
})
|
|
9816
|
+
}, undefined, undefined, this.dependencyTracker ? new CanvasNestedDependencyTracker(this.dependencyTracker, opIdx) : null)
|
|
9149
9817
|
};
|
|
9150
9818
|
pattern = new TilingPattern(IR, this.ctx, canvasGraphicsFactory, baseTransform);
|
|
9151
9819
|
} else {
|
|
9152
|
-
pattern = this._getPattern(IR[1], IR[2]);
|
|
9820
|
+
pattern = this._getPattern(opIdx, IR[1], IR[2]);
|
|
9153
9821
|
}
|
|
9154
9822
|
return pattern;
|
|
9155
9823
|
}
|
|
9156
|
-
setStrokeColorN() {
|
|
9157
|
-
this.
|
|
9824
|
+
setStrokeColorN(opIdx, ...args) {
|
|
9825
|
+
this.dependencyTracker?.recordSimpleData("strokeColor", opIdx);
|
|
9826
|
+
this.current.strokeColor = this.getColorN_Pattern(opIdx, args);
|
|
9158
9827
|
this.current.patternStroke = true;
|
|
9159
9828
|
}
|
|
9160
|
-
setFillColorN() {
|
|
9161
|
-
this.
|
|
9829
|
+
setFillColorN(opIdx, ...args) {
|
|
9830
|
+
this.dependencyTracker?.recordSimpleData("fillColor", opIdx);
|
|
9831
|
+
this.current.fillColor = this.getColorN_Pattern(opIdx, args);
|
|
9162
9832
|
this.current.patternFill = true;
|
|
9163
9833
|
}
|
|
9164
|
-
setStrokeRGBColor(color) {
|
|
9834
|
+
setStrokeRGBColor(opIdx, color) {
|
|
9835
|
+
this.dependencyTracker?.recordSimpleData("strokeColor", opIdx);
|
|
9165
9836
|
this.ctx.strokeStyle = this.current.strokeColor = color;
|
|
9166
9837
|
this.current.patternStroke = false;
|
|
9167
9838
|
}
|
|
9168
|
-
setStrokeTransparent() {
|
|
9839
|
+
setStrokeTransparent(opIdx) {
|
|
9840
|
+
this.dependencyTracker?.recordSimpleData("strokeColor", opIdx);
|
|
9169
9841
|
this.ctx.strokeStyle = this.current.strokeColor = "transparent";
|
|
9170
9842
|
this.current.patternStroke = false;
|
|
9171
9843
|
}
|
|
9172
|
-
setFillRGBColor(color) {
|
|
9844
|
+
setFillRGBColor(opIdx, color) {
|
|
9845
|
+
this.dependencyTracker?.recordSimpleData("fillColor", opIdx);
|
|
9173
9846
|
this.ctx.fillStyle = this.current.fillColor = color;
|
|
9174
9847
|
this.current.patternFill = false;
|
|
9175
9848
|
}
|
|
9176
|
-
setFillTransparent() {
|
|
9849
|
+
setFillTransparent(opIdx) {
|
|
9850
|
+
this.dependencyTracker?.recordSimpleData("fillColor", opIdx);
|
|
9177
9851
|
this.ctx.fillStyle = this.current.fillColor = "transparent";
|
|
9178
9852
|
this.current.patternFill = false;
|
|
9179
9853
|
}
|
|
9180
|
-
_getPattern(objId, matrix = null) {
|
|
9854
|
+
_getPattern(opIdx, objId, matrix = null) {
|
|
9181
9855
|
let pattern;
|
|
9182
9856
|
if (this.cachedPatterns.has(objId)) {
|
|
9183
9857
|
pattern = this.cachedPatterns.get(objId);
|
|
9184
9858
|
} else {
|
|
9185
|
-
pattern = getShadingPattern(this.getObject(objId));
|
|
9859
|
+
pattern = getShadingPattern(this.getObject(opIdx, objId));
|
|
9186
9860
|
this.cachedPatterns.set(objId, pattern);
|
|
9187
9861
|
}
|
|
9188
9862
|
if (matrix) {
|
|
@@ -9190,13 +9864,13 @@ class CanvasGraphics {
|
|
|
9190
9864
|
}
|
|
9191
9865
|
return pattern;
|
|
9192
9866
|
}
|
|
9193
|
-
shadingFill(objId) {
|
|
9867
|
+
shadingFill(opIdx, objId) {
|
|
9194
9868
|
if (!this.contentVisible) {
|
|
9195
9869
|
return;
|
|
9196
9870
|
}
|
|
9197
9871
|
const ctx = this.ctx;
|
|
9198
|
-
this.save();
|
|
9199
|
-
const pattern = this._getPattern(objId);
|
|
9872
|
+
this.save(opIdx);
|
|
9873
|
+
const pattern = this._getPattern(opIdx, objId);
|
|
9200
9874
|
ctx.fillStyle = pattern.getPattern(ctx, this, getCurrentTransformInverse(ctx), PathType.SHADING);
|
|
9201
9875
|
const inv = getCurrentTransformInverse(ctx);
|
|
9202
9876
|
if (inv) {
|
|
@@ -9211,8 +9885,9 @@ class CanvasGraphics {
|
|
|
9211
9885
|
} else {
|
|
9212
9886
|
this.ctx.fillRect(-1e10, -1e10, 2e10, 2e10);
|
|
9213
9887
|
}
|
|
9888
|
+
this.dependencyTracker?.resetBBox(opIdx).recordFullPageBBox(opIdx).recordDependencies(opIdx, Dependencies.transform).recordDependencies(opIdx, Dependencies.fill).recordOperation(opIdx);
|
|
9214
9889
|
this.compose(this.current.getClippedPathBoundingBox());
|
|
9215
|
-
this.restore();
|
|
9890
|
+
this.restore(opIdx);
|
|
9216
9891
|
}
|
|
9217
9892
|
beginInlineImage() {
|
|
9218
9893
|
unreachable("Should not call beginInlineImage");
|
|
@@ -9220,14 +9895,14 @@ class CanvasGraphics {
|
|
|
9220
9895
|
beginImageData() {
|
|
9221
9896
|
unreachable("Should not call beginImageData");
|
|
9222
9897
|
}
|
|
9223
|
-
paintFormXObjectBegin(matrix, bbox) {
|
|
9898
|
+
paintFormXObjectBegin(opIdx, matrix, bbox) {
|
|
9224
9899
|
if (!this.contentVisible) {
|
|
9225
9900
|
return;
|
|
9226
9901
|
}
|
|
9227
|
-
this.save();
|
|
9902
|
+
this.save(opIdx);
|
|
9228
9903
|
this.baseTransformStack.push(this.baseTransform);
|
|
9229
9904
|
if (matrix) {
|
|
9230
|
-
this.transform(...matrix);
|
|
9905
|
+
this.transform(opIdx, ...matrix);
|
|
9231
9906
|
}
|
|
9232
9907
|
this.baseTransform = getCurrentTransform(this.ctx);
|
|
9233
9908
|
if (bbox) {
|
|
@@ -9236,21 +9911,22 @@ class CanvasGraphics {
|
|
|
9236
9911
|
const clip = new Path2D();
|
|
9237
9912
|
clip.rect(x0, y0, x1 - x0, y1 - y0);
|
|
9238
9913
|
this.ctx.clip(clip);
|
|
9239
|
-
this.
|
|
9914
|
+
this.dependencyTracker?.recordClipBox(opIdx, this.ctx, x0, x1, y0, y1);
|
|
9915
|
+
this.endPath(opIdx);
|
|
9240
9916
|
}
|
|
9241
9917
|
}
|
|
9242
|
-
paintFormXObjectEnd() {
|
|
9918
|
+
paintFormXObjectEnd(opIdx) {
|
|
9243
9919
|
if (!this.contentVisible) {
|
|
9244
9920
|
return;
|
|
9245
9921
|
}
|
|
9246
|
-
this.restore();
|
|
9922
|
+
this.restore(opIdx);
|
|
9247
9923
|
this.baseTransform = this.baseTransformStack.pop();
|
|
9248
9924
|
}
|
|
9249
|
-
beginGroup(group) {
|
|
9925
|
+
beginGroup(opIdx, group) {
|
|
9250
9926
|
if (!this.contentVisible) {
|
|
9251
9927
|
return;
|
|
9252
9928
|
}
|
|
9253
|
-
this.save();
|
|
9929
|
+
this.save(opIdx);
|
|
9254
9930
|
if (this.inSMaskMode) {
|
|
9255
9931
|
this.endSMaskMode();
|
|
9256
9932
|
this.current.activeSMask = null;
|
|
@@ -9306,18 +9982,20 @@ class CanvasGraphics {
|
|
|
9306
9982
|
transferMap: group.smask.transferMap || null,
|
|
9307
9983
|
startTransformInverse: null
|
|
9308
9984
|
});
|
|
9309
|
-
}
|
|
9985
|
+
}
|
|
9986
|
+
if (!group.smask || this.dependencyTracker) {
|
|
9310
9987
|
currentCtx.setTransform(1, 0, 0, 1, 0, 0);
|
|
9311
9988
|
currentCtx.translate(offsetX, offsetY);
|
|
9312
9989
|
currentCtx.save();
|
|
9313
9990
|
}
|
|
9314
9991
|
copyCtxState(currentCtx, groupCtx);
|
|
9315
9992
|
this.ctx = groupCtx;
|
|
9316
|
-
this.
|
|
9993
|
+
this.dependencyTracker?.inheritSimpleDataAsFutureForcedDependencies(["fillAlpha", "strokeAlpha", "globalCompositeOperation"]).pushBaseTransform(currentCtx);
|
|
9994
|
+
this.setGState(opIdx, [["BM", "source-over"], ["ca", 1], ["CA", 1]]);
|
|
9317
9995
|
this.groupStack.push(currentCtx);
|
|
9318
9996
|
this.groupLevel++;
|
|
9319
9997
|
}
|
|
9320
|
-
endGroup(group) {
|
|
9998
|
+
endGroup(opIdx, group) {
|
|
9321
9999
|
if (!this.contentVisible) {
|
|
9322
10000
|
return;
|
|
9323
10001
|
}
|
|
@@ -9326,13 +10004,17 @@ class CanvasGraphics {
|
|
|
9326
10004
|
const ctx = this.groupStack.pop();
|
|
9327
10005
|
this.ctx = ctx;
|
|
9328
10006
|
this.ctx.imageSmoothingEnabled = false;
|
|
10007
|
+
this.dependencyTracker?.popBaseTransform();
|
|
9329
10008
|
if (group.smask) {
|
|
9330
10009
|
this.tempSMask = this.smaskStack.pop();
|
|
9331
|
-
this.restore();
|
|
10010
|
+
this.restore(opIdx);
|
|
10011
|
+
if (this.dependencyTracker) {
|
|
10012
|
+
this.ctx.restore();
|
|
10013
|
+
}
|
|
9332
10014
|
} else {
|
|
9333
10015
|
this.ctx.restore();
|
|
9334
10016
|
const currentMtx = getCurrentTransform(this.ctx);
|
|
9335
|
-
this.restore();
|
|
10017
|
+
this.restore(opIdx);
|
|
9336
10018
|
this.ctx.save();
|
|
9337
10019
|
this.ctx.setTransform(...currentMtx);
|
|
9338
10020
|
const dirtyBox = MIN_MAX_INIT.slice();
|
|
@@ -9342,11 +10024,11 @@ class CanvasGraphics {
|
|
|
9342
10024
|
this.compose(dirtyBox);
|
|
9343
10025
|
}
|
|
9344
10026
|
}
|
|
9345
|
-
beginAnnotation(id, rect, transform, matrix, hasOwnCanvas) {
|
|
10027
|
+
beginAnnotation(opIdx, id, rect, transform, matrix, hasOwnCanvas) {
|
|
9346
10028
|
this.#restoreInitialState();
|
|
9347
10029
|
resetCtxToDefault(this.ctx);
|
|
9348
10030
|
this.ctx.save();
|
|
9349
|
-
this.save();
|
|
10031
|
+
this.save(opIdx);
|
|
9350
10032
|
if (this.baseTransform) {
|
|
9351
10033
|
this.ctx.setTransform(...this.baseTransform);
|
|
9352
10034
|
}
|
|
@@ -9380,17 +10062,17 @@ class CanvasGraphics {
|
|
|
9380
10062
|
resetCtxToDefault(this.ctx);
|
|
9381
10063
|
} else {
|
|
9382
10064
|
resetCtxToDefault(this.ctx);
|
|
9383
|
-
this.endPath();
|
|
10065
|
+
this.endPath(opIdx);
|
|
9384
10066
|
const clip = new Path2D();
|
|
9385
10067
|
clip.rect(rect[0], rect[1], width, height);
|
|
9386
10068
|
this.ctx.clip(clip);
|
|
9387
10069
|
}
|
|
9388
10070
|
}
|
|
9389
10071
|
this.current = new CanvasExtraState(this.ctx.canvas.width, this.ctx.canvas.height);
|
|
9390
|
-
this.transform(...transform);
|
|
9391
|
-
this.transform(...matrix);
|
|
10072
|
+
this.transform(opIdx, ...transform);
|
|
10073
|
+
this.transform(opIdx, ...matrix);
|
|
9392
10074
|
}
|
|
9393
|
-
endAnnotation() {
|
|
10075
|
+
endAnnotation(opIdx) {
|
|
9394
10076
|
if (this.annotationCanvas) {
|
|
9395
10077
|
this.ctx.restore();
|
|
9396
10078
|
this.#drawFilter();
|
|
@@ -9399,47 +10081,52 @@ class CanvasGraphics {
|
|
|
9399
10081
|
delete this.annotationCanvas;
|
|
9400
10082
|
}
|
|
9401
10083
|
}
|
|
9402
|
-
paintImageMaskXObject(img) {
|
|
10084
|
+
paintImageMaskXObject(opIdx, img) {
|
|
9403
10085
|
if (!this.contentVisible) {
|
|
9404
10086
|
return;
|
|
9405
10087
|
}
|
|
9406
10088
|
const count = img.count;
|
|
9407
|
-
img = this.getObject(img.data, img);
|
|
10089
|
+
img = this.getObject(opIdx, img.data, img);
|
|
9408
10090
|
img.count = count;
|
|
9409
10091
|
const ctx = this.ctx;
|
|
9410
|
-
const mask = this._createMaskCanvas(img);
|
|
10092
|
+
const mask = this._createMaskCanvas(opIdx, img);
|
|
9411
10093
|
const maskCanvas = mask.canvas;
|
|
9412
10094
|
ctx.save();
|
|
9413
10095
|
ctx.setTransform(1, 0, 0, 1, 0, 0);
|
|
9414
10096
|
ctx.drawImage(maskCanvas, mask.offsetX, mask.offsetY);
|
|
10097
|
+
this.dependencyTracker?.resetBBox(opIdx).recordBBox(opIdx, this.ctx, mask.offsetX, mask.offsetX + maskCanvas.width, mask.offsetY, mask.offsetY + maskCanvas.height).recordOperation(opIdx);
|
|
9415
10098
|
ctx.restore();
|
|
9416
10099
|
this.compose();
|
|
9417
10100
|
}
|
|
9418
|
-
paintImageMaskXObjectRepeat(img, scaleX, skewX = 0, skewY = 0, scaleY, positions) {
|
|
10101
|
+
paintImageMaskXObjectRepeat(opIdx, img, scaleX, skewX = 0, skewY = 0, scaleY, positions) {
|
|
9419
10102
|
if (!this.contentVisible) {
|
|
9420
10103
|
return;
|
|
9421
10104
|
}
|
|
9422
|
-
img = this.getObject(img.data, img);
|
|
10105
|
+
img = this.getObject(opIdx, img.data, img);
|
|
9423
10106
|
const ctx = this.ctx;
|
|
9424
10107
|
ctx.save();
|
|
9425
10108
|
const currentTransform = getCurrentTransform(ctx);
|
|
9426
10109
|
ctx.transform(scaleX, skewX, skewY, scaleY, 0, 0);
|
|
9427
|
-
const mask = this._createMaskCanvas(img);
|
|
10110
|
+
const mask = this._createMaskCanvas(opIdx, img);
|
|
9428
10111
|
ctx.setTransform(1, 0, 0, 1, mask.offsetX - currentTransform[4], mask.offsetY - currentTransform[5]);
|
|
10112
|
+
this.dependencyTracker?.resetBBox(opIdx);
|
|
9429
10113
|
for (let i = 0, ii = positions.length; i < ii; i += 2) {
|
|
9430
10114
|
const trans = Util.transform(currentTransform, [scaleX, skewX, skewY, scaleY, positions[i], positions[i + 1]]);
|
|
9431
10115
|
ctx.drawImage(mask.canvas, trans[4], trans[5]);
|
|
10116
|
+
this.dependencyTracker?.recordBBox(opIdx, this.ctx, trans[4], trans[4] + mask.canvas.width, trans[5], trans[5] + mask.canvas.height);
|
|
9432
10117
|
}
|
|
9433
10118
|
ctx.restore();
|
|
9434
10119
|
this.compose();
|
|
10120
|
+
this.dependencyTracker?.recordOperation(opIdx);
|
|
9435
10121
|
}
|
|
9436
|
-
paintImageMaskXObjectGroup(images) {
|
|
10122
|
+
paintImageMaskXObjectGroup(opIdx, images) {
|
|
9437
10123
|
if (!this.contentVisible) {
|
|
9438
10124
|
return;
|
|
9439
10125
|
}
|
|
9440
10126
|
const ctx = this.ctx;
|
|
9441
10127
|
const fillColor = this.current.fillColor;
|
|
9442
10128
|
const isPatternFill = this.current.patternFill;
|
|
10129
|
+
this.dependencyTracker?.resetBBox(opIdx).recordDependencies(opIdx, Dependencies.transformAndFill);
|
|
9443
10130
|
for (const image of images) {
|
|
9444
10131
|
const {
|
|
9445
10132
|
data,
|
|
@@ -9450,7 +10137,7 @@ class CanvasGraphics {
|
|
|
9450
10137
|
const maskCanvas = this.cachedCanvases.getCanvas("maskCanvas", width, height);
|
|
9451
10138
|
const maskCtx = maskCanvas.context;
|
|
9452
10139
|
maskCtx.save();
|
|
9453
|
-
const img = this.getObject(data, image);
|
|
10140
|
+
const img = this.getObject(opIdx, data, image);
|
|
9454
10141
|
putBinaryImageMask(maskCtx, img);
|
|
9455
10142
|
maskCtx.globalCompositeOperation = "source-in";
|
|
9456
10143
|
maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this, getCurrentTransformInverse(ctx), PathType.FILL) : fillColor;
|
|
@@ -9460,26 +10147,28 @@ class CanvasGraphics {
|
|
|
9460
10147
|
ctx.transform(...transform);
|
|
9461
10148
|
ctx.scale(1, -1);
|
|
9462
10149
|
drawImageAtIntegerCoords(ctx, maskCanvas.canvas, 0, 0, width, height, 0, -1, 1, 1);
|
|
10150
|
+
this.dependencyTracker?.recordBBox(opIdx, ctx, 0, width, 0, height);
|
|
9463
10151
|
ctx.restore();
|
|
9464
10152
|
}
|
|
9465
10153
|
this.compose();
|
|
10154
|
+
this.dependencyTracker?.recordOperation(opIdx);
|
|
9466
10155
|
}
|
|
9467
|
-
paintImageXObject(objId) {
|
|
10156
|
+
paintImageXObject(opIdx, objId) {
|
|
9468
10157
|
if (!this.contentVisible) {
|
|
9469
10158
|
return;
|
|
9470
10159
|
}
|
|
9471
|
-
const imgData = this.getObject(objId);
|
|
10160
|
+
const imgData = this.getObject(opIdx, objId);
|
|
9472
10161
|
if (!imgData) {
|
|
9473
10162
|
warn("Dependent image isn't ready yet");
|
|
9474
10163
|
return;
|
|
9475
10164
|
}
|
|
9476
|
-
this.paintInlineImageXObject(imgData);
|
|
10165
|
+
this.paintInlineImageXObject(opIdx, imgData);
|
|
9477
10166
|
}
|
|
9478
|
-
paintImageXObjectRepeat(objId, scaleX, scaleY, positions) {
|
|
10167
|
+
paintImageXObjectRepeat(opIdx, objId, scaleX, scaleY, positions) {
|
|
9479
10168
|
if (!this.contentVisible) {
|
|
9480
10169
|
return;
|
|
9481
10170
|
}
|
|
9482
|
-
const imgData = this.getObject(objId);
|
|
10171
|
+
const imgData = this.getObject(opIdx, objId);
|
|
9483
10172
|
if (!imgData) {
|
|
9484
10173
|
warn("Dependent image isn't ready yet");
|
|
9485
10174
|
return;
|
|
@@ -9496,7 +10185,7 @@ class CanvasGraphics {
|
|
|
9496
10185
|
h: height
|
|
9497
10186
|
});
|
|
9498
10187
|
}
|
|
9499
|
-
this.paintInlineImageXObjectGroup(imgData, map);
|
|
10188
|
+
this.paintInlineImageXObjectGroup(opIdx, imgData, map);
|
|
9500
10189
|
}
|
|
9501
10190
|
applyTransferMapsToCanvas(ctx) {
|
|
9502
10191
|
if (this.current.transferMaps !== "none") {
|
|
@@ -9522,14 +10211,14 @@ class CanvasGraphics {
|
|
|
9522
10211
|
tmpCtx.filter = "none";
|
|
9523
10212
|
return tmpCanvas.canvas;
|
|
9524
10213
|
}
|
|
9525
|
-
paintInlineImageXObject(imgData) {
|
|
10214
|
+
paintInlineImageXObject(opIdx, imgData) {
|
|
9526
10215
|
if (!this.contentVisible) {
|
|
9527
10216
|
return;
|
|
9528
10217
|
}
|
|
9529
10218
|
const width = imgData.width;
|
|
9530
10219
|
const height = imgData.height;
|
|
9531
10220
|
const ctx = this.ctx;
|
|
9532
|
-
this.save();
|
|
10221
|
+
this.save(opIdx);
|
|
9533
10222
|
const {
|
|
9534
10223
|
filter
|
|
9535
10224
|
} = ctx;
|
|
@@ -9550,11 +10239,12 @@ class CanvasGraphics {
|
|
|
9550
10239
|
}
|
|
9551
10240
|
const scaled = this._scaleImage(imgToPaint, getCurrentTransformInverse(ctx));
|
|
9552
10241
|
ctx.imageSmoothingEnabled = getImageSmoothingEnabled(getCurrentTransform(ctx), imgData.interpolate);
|
|
10242
|
+
this.dependencyTracker?.resetBBox(opIdx).recordBBox(opIdx, ctx, 0, width, -height, 0).recordDependencies(opIdx, Dependencies.imageXObject).recordOperation(opIdx);
|
|
9553
10243
|
drawImageAtIntegerCoords(ctx, scaled.img, 0, 0, scaled.paintWidth, scaled.paintHeight, 0, -height, width, height);
|
|
9554
10244
|
this.compose();
|
|
9555
|
-
this.restore();
|
|
10245
|
+
this.restore(opIdx);
|
|
9556
10246
|
}
|
|
9557
|
-
paintInlineImageXObjectGroup(imgData, map) {
|
|
10247
|
+
paintInlineImageXObjectGroup(opIdx, imgData, map) {
|
|
9558
10248
|
if (!this.contentVisible) {
|
|
9559
10249
|
return;
|
|
9560
10250
|
}
|
|
@@ -9570,30 +10260,36 @@ class CanvasGraphics {
|
|
|
9570
10260
|
putBinaryImageData(tmpCtx, imgData);
|
|
9571
10261
|
imgToPaint = this.applyTransferMapsToCanvas(tmpCtx);
|
|
9572
10262
|
}
|
|
10263
|
+
this.dependencyTracker?.resetBBox(opIdx);
|
|
9573
10264
|
for (const entry of map) {
|
|
9574
10265
|
ctx.save();
|
|
9575
10266
|
ctx.transform(...entry.transform);
|
|
9576
10267
|
ctx.scale(1, -1);
|
|
9577
10268
|
drawImageAtIntegerCoords(ctx, imgToPaint, entry.x, entry.y, entry.w, entry.h, 0, -1, 1, 1);
|
|
10269
|
+
this.dependencyTracker?.recordBBox(opIdx, ctx, 0, 1, -1, 0);
|
|
9578
10270
|
ctx.restore();
|
|
9579
10271
|
}
|
|
10272
|
+
this.dependencyTracker?.recordOperation(opIdx);
|
|
9580
10273
|
this.compose();
|
|
9581
10274
|
}
|
|
9582
|
-
paintSolidColorImageMask() {
|
|
10275
|
+
paintSolidColorImageMask(opIdx) {
|
|
9583
10276
|
if (!this.contentVisible) {
|
|
9584
10277
|
return;
|
|
9585
10278
|
}
|
|
10279
|
+
this.dependencyTracker?.resetBBox(opIdx).recordBBox(opIdx, this.ctx, 0, 1, 0, 1).recordDependencies(opIdx, Dependencies.fill).recordOperation(opIdx);
|
|
9586
10280
|
this.ctx.fillRect(0, 0, 1, 1);
|
|
9587
10281
|
this.compose();
|
|
9588
10282
|
}
|
|
9589
|
-
markPoint(tag) {}
|
|
9590
|
-
markPointProps(tag, properties) {}
|
|
9591
|
-
beginMarkedContent(tag) {
|
|
10283
|
+
markPoint(opIdx, tag) {}
|
|
10284
|
+
markPointProps(opIdx, tag, properties) {}
|
|
10285
|
+
beginMarkedContent(opIdx, tag) {
|
|
10286
|
+
this.dependencyTracker?.beginMarkedContent(opIdx);
|
|
9592
10287
|
this.markedContentStack.push({
|
|
9593
10288
|
visible: true
|
|
9594
10289
|
});
|
|
9595
10290
|
}
|
|
9596
|
-
beginMarkedContentProps(tag, properties) {
|
|
10291
|
+
beginMarkedContentProps(opIdx, tag, properties) {
|
|
10292
|
+
this.dependencyTracker?.beginMarkedContent(opIdx);
|
|
9597
10293
|
if (tag === "OC") {
|
|
9598
10294
|
this.markedContentStack.push({
|
|
9599
10295
|
visible: this.optionalContentConfig.isVisible(properties)
|
|
@@ -9605,13 +10301,14 @@ class CanvasGraphics {
|
|
|
9605
10301
|
}
|
|
9606
10302
|
this.contentVisible = this.isContentVisible();
|
|
9607
10303
|
}
|
|
9608
|
-
endMarkedContent() {
|
|
10304
|
+
endMarkedContent(opIdx) {
|
|
10305
|
+
this.dependencyTracker?.endMarkedContent(opIdx);
|
|
9609
10306
|
this.markedContentStack.pop();
|
|
9610
10307
|
this.contentVisible = this.isContentVisible();
|
|
9611
10308
|
}
|
|
9612
|
-
beginCompat() {}
|
|
9613
|
-
endCompat() {}
|
|
9614
|
-
consumePath(path, clipBox) {
|
|
10309
|
+
beginCompat(opIdx) {}
|
|
10310
|
+
endCompat(opIdx) {}
|
|
10311
|
+
consumePath(opIdx, path, clipBox) {
|
|
9615
10312
|
const isEmpty = this.current.isEmptyClip();
|
|
9616
10313
|
if (this.pendingClip) {
|
|
9617
10314
|
this.current.updateClipFromPath();
|
|
@@ -9629,6 +10326,9 @@ class CanvasGraphics {
|
|
|
9629
10326
|
}
|
|
9630
10327
|
}
|
|
9631
10328
|
this.pendingClip = null;
|
|
10329
|
+
this.dependencyTracker?.bboxToClipBoxDropOperation(opIdx).recordFutureForcedDependency("clipPath", opIdx);
|
|
10330
|
+
} else {
|
|
10331
|
+
this.dependencyTracker?.recordOperation(opIdx);
|
|
9632
10332
|
}
|
|
9633
10333
|
this.current.startNewPathAndClipBox(this.current.clipBox);
|
|
9634
10334
|
}
|
|
@@ -11848,6 +12548,7 @@ class XfaText {
|
|
|
11848
12548
|
|
|
11849
12549
|
|
|
11850
12550
|
|
|
12551
|
+
|
|
11851
12552
|
|
|
11852
12553
|
|
|
11853
12554
|
const RENDERING_CANCELLED_TIMEOUT = 100;
|
|
@@ -11935,7 +12636,7 @@ function getDocument(src = {}) {
|
|
|
11935
12636
|
}
|
|
11936
12637
|
const docParams = {
|
|
11937
12638
|
docId,
|
|
11938
|
-
apiVersion: "5.4.
|
|
12639
|
+
apiVersion: "5.4.149",
|
|
11939
12640
|
data,
|
|
11940
12641
|
password,
|
|
11941
12642
|
disableAutoFetch,
|
|
@@ -12161,6 +12862,9 @@ class PDFDocumentProxy {
|
|
|
12161
12862
|
getAttachments() {
|
|
12162
12863
|
return this._transport.getAttachments();
|
|
12163
12864
|
}
|
|
12865
|
+
getAnnotationsByType(types, pageIndexesToSkip) {
|
|
12866
|
+
return this._transport.getAnnotationsByType(types, pageIndexesToSkip);
|
|
12867
|
+
}
|
|
12164
12868
|
getJSActions() {
|
|
12165
12869
|
return this._transport.getDocJSActions();
|
|
12166
12870
|
}
|
|
@@ -12230,6 +12934,7 @@ class PDFPageProxy {
|
|
|
12230
12934
|
this.objs = new PDFObjects();
|
|
12231
12935
|
this._intentStates = new Map();
|
|
12232
12936
|
this.destroyed = false;
|
|
12937
|
+
this.recordedGroups = null;
|
|
12233
12938
|
}
|
|
12234
12939
|
get pageNumber() {
|
|
12235
12940
|
return this._pageIndex + 1;
|
|
@@ -12295,7 +13000,9 @@ class PDFPageProxy {
|
|
|
12295
13000
|
annotationCanvasMap = null,
|
|
12296
13001
|
pageColors = null,
|
|
12297
13002
|
printAnnotationStorage = null,
|
|
12298
|
-
isEditing = false
|
|
13003
|
+
isEditing = false,
|
|
13004
|
+
recordOperations = false,
|
|
13005
|
+
filteredOperationIndexes = null
|
|
12299
13006
|
}) {
|
|
12300
13007
|
this._stats?.time("Overall");
|
|
12301
13008
|
const intentArgs = this._transport.getRenderingIntent(intent, annotationMode, printAnnotationStorage, isEditing);
|
|
@@ -12326,8 +13033,20 @@ class PDFPageProxy {
|
|
|
12326
13033
|
this._stats?.time("Page Request");
|
|
12327
13034
|
this._pumpOperatorList(intentArgs);
|
|
12328
13035
|
}
|
|
13036
|
+
const shouldRecordOperations = !this.recordedGroups && (recordOperations || this._pdfBug && globalThis.StepperManager?.enabled);
|
|
12329
13037
|
const complete = error => {
|
|
12330
13038
|
intentState.renderTasks.delete(internalRenderTask);
|
|
13039
|
+
if (shouldRecordOperations) {
|
|
13040
|
+
const recordedGroups = internalRenderTask.gfx?.dependencyTracker.take();
|
|
13041
|
+
if (recordedGroups) {
|
|
13042
|
+
internalRenderTask.stepper?.setOperatorGroups(recordedGroups);
|
|
13043
|
+
if (recordOperations) {
|
|
13044
|
+
this.recordedGroups = recordedGroups;
|
|
13045
|
+
}
|
|
13046
|
+
} else if (recordOperations) {
|
|
13047
|
+
this.recordedGroups = [];
|
|
13048
|
+
}
|
|
13049
|
+
}
|
|
12331
13050
|
if (intentPrint) {
|
|
12332
13051
|
this.#pendingCleanup = true;
|
|
12333
13052
|
}
|
|
@@ -12354,6 +13073,7 @@ class PDFPageProxy {
|
|
|
12354
13073
|
params: {
|
|
12355
13074
|
canvas,
|
|
12356
13075
|
canvasContext,
|
|
13076
|
+
dependencyTracker: shouldRecordOperations ? new CanvasDependencyTracker(canvas) : null,
|
|
12357
13077
|
viewport,
|
|
12358
13078
|
transform,
|
|
12359
13079
|
background
|
|
@@ -12368,7 +13088,8 @@ class PDFPageProxy {
|
|
|
12368
13088
|
useRequestAnimationFrame: !intentPrint,
|
|
12369
13089
|
pdfBug: this._pdfBug,
|
|
12370
13090
|
pageColors,
|
|
12371
|
-
enableHWA: this._transport.enableHWA
|
|
13091
|
+
enableHWA: this._transport.enableHWA,
|
|
13092
|
+
filteredOperationIndexes
|
|
12372
13093
|
});
|
|
12373
13094
|
(intentState.renderTasks ||= new Set()).add(internalRenderTask);
|
|
12374
13095
|
const renderTask = internalRenderTask.task;
|
|
@@ -13314,6 +14035,12 @@ class WorkerTransport {
|
|
|
13314
14035
|
getAttachments() {
|
|
13315
14036
|
return this.messageHandler.sendWithPromise("GetAttachments", null);
|
|
13316
14037
|
}
|
|
14038
|
+
getAnnotationsByType(types, pageIndexesToSkip) {
|
|
14039
|
+
return this.messageHandler.sendWithPromise("GetAnnotationsByType", {
|
|
14040
|
+
types,
|
|
14041
|
+
pageIndexesToSkip
|
|
14042
|
+
});
|
|
14043
|
+
}
|
|
13317
14044
|
getDocJSActions() {
|
|
13318
14045
|
return this.#cacheSimpleMethod("GetDocJSActions");
|
|
13319
14046
|
}
|
|
@@ -13423,7 +14150,8 @@ class InternalRenderTask {
|
|
|
13423
14150
|
useRequestAnimationFrame = false,
|
|
13424
14151
|
pdfBug = false,
|
|
13425
14152
|
pageColors = null,
|
|
13426
|
-
enableHWA = false
|
|
14153
|
+
enableHWA = false,
|
|
14154
|
+
filteredOperationIndexes = null
|
|
13427
14155
|
}) {
|
|
13428
14156
|
this.callback = callback;
|
|
13429
14157
|
this.params = params;
|
|
@@ -13451,6 +14179,8 @@ class InternalRenderTask {
|
|
|
13451
14179
|
this._canvas = params.canvas;
|
|
13452
14180
|
this._canvasContext = params.canvas ? null : params.canvasContext;
|
|
13453
14181
|
this._enableHWA = enableHWA;
|
|
14182
|
+
this._dependencyTracker = params.dependencyTracker;
|
|
14183
|
+
this._filteredOperationIndexes = filteredOperationIndexes;
|
|
13454
14184
|
}
|
|
13455
14185
|
get completed() {
|
|
13456
14186
|
return this.capability.promise.catch(function () {});
|
|
@@ -13476,7 +14206,8 @@ class InternalRenderTask {
|
|
|
13476
14206
|
const {
|
|
13477
14207
|
viewport,
|
|
13478
14208
|
transform,
|
|
13479
|
-
background
|
|
14209
|
+
background,
|
|
14210
|
+
dependencyTracker
|
|
13480
14211
|
} = this.params;
|
|
13481
14212
|
const canvasContext = this._canvasContext || this._canvas.getContext("2d", {
|
|
13482
14213
|
alpha: false,
|
|
@@ -13484,7 +14215,7 @@ class InternalRenderTask {
|
|
|
13484
14215
|
});
|
|
13485
14216
|
this.gfx = new CanvasGraphics(canvasContext, this.commonObjs, this.objs, this.canvasFactory, this.filterFactory, {
|
|
13486
14217
|
optionalContentConfig
|
|
13487
|
-
}, this.annotationCanvasMap, this.pageColors);
|
|
14218
|
+
}, this.annotationCanvasMap, this.pageColors, dependencyTracker);
|
|
13488
14219
|
this.gfx.beginDrawing({
|
|
13489
14220
|
transform,
|
|
13490
14221
|
viewport,
|
|
@@ -13544,7 +14275,7 @@ class InternalRenderTask {
|
|
|
13544
14275
|
if (this.cancelled) {
|
|
13545
14276
|
return;
|
|
13546
14277
|
}
|
|
13547
|
-
this.operatorListIdx = this.gfx.executeOperatorList(this.operatorList, this.operatorListIdx, this._continueBound, this.stepper);
|
|
14278
|
+
this.operatorListIdx = this.gfx.executeOperatorList(this.operatorList, this.operatorListIdx, this._continueBound, this.stepper, this._filteredOperationIndexes);
|
|
13548
14279
|
if (this.operatorListIdx === this.operatorList.argsArray.length) {
|
|
13549
14280
|
this.running = false;
|
|
13550
14281
|
if (this.operatorList.lastChunk) {
|
|
@@ -13555,8 +14286,8 @@ class InternalRenderTask {
|
|
|
13555
14286
|
}
|
|
13556
14287
|
}
|
|
13557
14288
|
}
|
|
13558
|
-
const version = "5.4.
|
|
13559
|
-
const build = "
|
|
14289
|
+
const version = "5.4.149";
|
|
14290
|
+
const build = "9e2e9e209";
|
|
13560
14291
|
|
|
13561
14292
|
;// ./src/display/editor/color_picker.js
|
|
13562
14293
|
|
|
@@ -14235,6 +14966,7 @@ class AnnotationElement {
|
|
|
14235
14966
|
this.renderForms = parameters.renderForms;
|
|
14236
14967
|
this.svgFactory = parameters.svgFactory;
|
|
14237
14968
|
this.annotationStorage = parameters.annotationStorage;
|
|
14969
|
+
this.enableComment = parameters.enableComment;
|
|
14238
14970
|
this.enableScripting = parameters.enableScripting;
|
|
14239
14971
|
this.hasJSActions = parameters.hasJSActions;
|
|
14240
14972
|
this._fieldObjects = parameters.fieldObjects;
|
|
@@ -14258,6 +14990,84 @@ class AnnotationElement {
|
|
|
14258
14990
|
get hasPopupData() {
|
|
14259
14991
|
return AnnotationElement._hasPopupData(this.data);
|
|
14260
14992
|
}
|
|
14993
|
+
get hasCommentButton() {
|
|
14994
|
+
return this.enableComment && this._isEditable && this.hasPopupElement;
|
|
14995
|
+
}
|
|
14996
|
+
get commentButtonPosition() {
|
|
14997
|
+
const {
|
|
14998
|
+
quadPoints,
|
|
14999
|
+
rect
|
|
15000
|
+
} = this.data;
|
|
15001
|
+
let maxX = -Infinity;
|
|
15002
|
+
let maxY = -Infinity;
|
|
15003
|
+
if (quadPoints?.length >= 8) {
|
|
15004
|
+
for (let i = 0; i < quadPoints.length; i += 8) {
|
|
15005
|
+
if (quadPoints[i + 1] > maxY) {
|
|
15006
|
+
maxY = quadPoints[i + 1];
|
|
15007
|
+
maxX = quadPoints[i + 2];
|
|
15008
|
+
} else if (quadPoints[i + 1] === maxY) {
|
|
15009
|
+
maxX = Math.max(maxX, quadPoints[i + 2]);
|
|
15010
|
+
}
|
|
15011
|
+
}
|
|
15012
|
+
return [maxX, maxY];
|
|
15013
|
+
}
|
|
15014
|
+
if (rect) {
|
|
15015
|
+
return [rect[2], rect[3]];
|
|
15016
|
+
}
|
|
15017
|
+
return null;
|
|
15018
|
+
}
|
|
15019
|
+
get commentButtonColor() {
|
|
15020
|
+
if (!this.data.color) {
|
|
15021
|
+
return null;
|
|
15022
|
+
}
|
|
15023
|
+
const [r, g, b] = this.data.color;
|
|
15024
|
+
const opacity = this.data.opacity ?? 1;
|
|
15025
|
+
const oppositeOpacity = 255 * (1 - opacity);
|
|
15026
|
+
return this.#changeLightness(Math.min(r + oppositeOpacity, 255), Math.min(g + oppositeOpacity, 255), Math.min(b + oppositeOpacity, 255));
|
|
15027
|
+
}
|
|
15028
|
+
#changeLightness(r, g, b) {
|
|
15029
|
+
r /= 255;
|
|
15030
|
+
g /= 255;
|
|
15031
|
+
b /= 255;
|
|
15032
|
+
const max = Math.max(r, g, b);
|
|
15033
|
+
const min = Math.min(r, g, b);
|
|
15034
|
+
const l = (max + min) / 2;
|
|
15035
|
+
const newL = ((1 + Math.sqrt(l)) / 2 * 100).toFixed(2);
|
|
15036
|
+
if (max === min) {
|
|
15037
|
+
return `hsl(0, 0%, ${newL}%)`;
|
|
15038
|
+
}
|
|
15039
|
+
const d = max - min;
|
|
15040
|
+
let h;
|
|
15041
|
+
if (max === r) {
|
|
15042
|
+
h = (g - b) / d + (g < b ? 6 : 0);
|
|
15043
|
+
} else if (max === g) {
|
|
15044
|
+
h = (b - r) / d + 2;
|
|
15045
|
+
} else {
|
|
15046
|
+
h = (r - g) / d + 4;
|
|
15047
|
+
}
|
|
15048
|
+
h = (h * 60).toFixed(2);
|
|
15049
|
+
const s = (d / (1 - Math.abs(2 * l - 1)) * 100).toFixed(2);
|
|
15050
|
+
return `hsl(${h}, ${s}%, ${newL}%)`;
|
|
15051
|
+
}
|
|
15052
|
+
_normalizePoint(point) {
|
|
15053
|
+
const {
|
|
15054
|
+
page: {
|
|
15055
|
+
view
|
|
15056
|
+
},
|
|
15057
|
+
viewport: {
|
|
15058
|
+
rawDims: {
|
|
15059
|
+
pageWidth,
|
|
15060
|
+
pageHeight,
|
|
15061
|
+
pageX,
|
|
15062
|
+
pageY
|
|
15063
|
+
}
|
|
15064
|
+
}
|
|
15065
|
+
} = this.parent;
|
|
15066
|
+
point[1] = view[3] - point[1] + view[1];
|
|
15067
|
+
point[0] = 100 * (point[0] - pageX) / pageWidth;
|
|
15068
|
+
point[1] = 100 * (point[1] - pageY) / pageHeight;
|
|
15069
|
+
return point;
|
|
15070
|
+
}
|
|
14261
15071
|
updateEdited(params) {
|
|
14262
15072
|
if (!this.container) {
|
|
14263
15073
|
return;
|
|
@@ -14343,7 +15153,8 @@ class AnnotationElement {
|
|
|
14343
15153
|
const {
|
|
14344
15154
|
style
|
|
14345
15155
|
} = container;
|
|
14346
|
-
style.zIndex = this.parent.zIndex
|
|
15156
|
+
style.zIndex = this.parent.zIndex;
|
|
15157
|
+
this.parent.zIndex += 2;
|
|
14347
15158
|
if (data.alternativeText) {
|
|
14348
15159
|
container.title = data.alternativeText;
|
|
14349
15160
|
}
|
|
@@ -15922,7 +16733,8 @@ class PopupAnnotationElement extends AnnotationElement {
|
|
|
15922
16733
|
parentRect: this.data.parentRect || null,
|
|
15923
16734
|
parent: this.parent,
|
|
15924
16735
|
elements: this.elements,
|
|
15925
|
-
open: this.data.open
|
|
16736
|
+
open: this.data.open,
|
|
16737
|
+
eventBus: this.linkService.eventBus
|
|
15926
16738
|
});
|
|
15927
16739
|
const elementIds = [];
|
|
15928
16740
|
for (const element of this.elements) {
|
|
@@ -15945,12 +16757,16 @@ class PopupElement {
|
|
|
15945
16757
|
#contentsObj = null;
|
|
15946
16758
|
#dateObj = null;
|
|
15947
16759
|
#elements = null;
|
|
16760
|
+
#eventBus = null;
|
|
15948
16761
|
#parent = null;
|
|
15949
16762
|
#parentRect = null;
|
|
15950
16763
|
#pinned = false;
|
|
15951
16764
|
#popup = null;
|
|
15952
16765
|
#popupAbortController = null;
|
|
15953
16766
|
#position = null;
|
|
16767
|
+
#commentButton = null;
|
|
16768
|
+
#commentButtonPosition = null;
|
|
16769
|
+
#commentButtonColor = null;
|
|
15954
16770
|
#rect = null;
|
|
15955
16771
|
#richText = null;
|
|
15956
16772
|
#titleObj = null;
|
|
@@ -15967,7 +16783,8 @@ class PopupElement {
|
|
|
15967
16783
|
parent,
|
|
15968
16784
|
rect,
|
|
15969
16785
|
parentRect,
|
|
15970
|
-
open
|
|
16786
|
+
open,
|
|
16787
|
+
eventBus = null
|
|
15971
16788
|
}) {
|
|
15972
16789
|
this.#container = container;
|
|
15973
16790
|
this.#titleObj = titleObj;
|
|
@@ -15978,6 +16795,7 @@ class PopupElement {
|
|
|
15978
16795
|
this.#rect = rect;
|
|
15979
16796
|
this.#parentRect = parentRect;
|
|
15980
16797
|
this.#elements = elements;
|
|
16798
|
+
this.#eventBus = eventBus;
|
|
15981
16799
|
this.#dateObj = PDFDateString.toDateObject(modificationDate);
|
|
15982
16800
|
this.trigger = elements.flatMap(e => e.getElementsToTriggerPopup());
|
|
15983
16801
|
this.#addEventListeners();
|
|
@@ -16011,6 +16829,65 @@ class PopupElement {
|
|
|
16011
16829
|
signal
|
|
16012
16830
|
});
|
|
16013
16831
|
}
|
|
16832
|
+
this.#renderCommentButton();
|
|
16833
|
+
}
|
|
16834
|
+
#setCommentButtonPosition() {
|
|
16835
|
+
const element = this.#elements.find(e => e.hasCommentButton);
|
|
16836
|
+
if (!element) {
|
|
16837
|
+
return;
|
|
16838
|
+
}
|
|
16839
|
+
this.#commentButtonPosition = element._normalizePoint(element.commentButtonPosition);
|
|
16840
|
+
this.#commentButtonColor = element.commentButtonColor;
|
|
16841
|
+
}
|
|
16842
|
+
#renderCommentButton() {
|
|
16843
|
+
if (this.#commentButton) {
|
|
16844
|
+
return;
|
|
16845
|
+
}
|
|
16846
|
+
if (!this.#commentButtonPosition) {
|
|
16847
|
+
this.#setCommentButtonPosition();
|
|
16848
|
+
}
|
|
16849
|
+
if (!this.#commentButtonPosition) {
|
|
16850
|
+
return;
|
|
16851
|
+
}
|
|
16852
|
+
const button = this.#commentButton = document.createElement("button");
|
|
16853
|
+
button.className = "annotationCommentButton";
|
|
16854
|
+
const parentContainer = this.#elements[0].container;
|
|
16855
|
+
button.style.zIndex = parentContainer.style.zIndex + 1;
|
|
16856
|
+
button.tabIndex = 0;
|
|
16857
|
+
const {
|
|
16858
|
+
signal
|
|
16859
|
+
} = this.#popupAbortController;
|
|
16860
|
+
button.addEventListener("hover", this.#boundToggle, {
|
|
16861
|
+
signal
|
|
16862
|
+
});
|
|
16863
|
+
button.addEventListener("keydown", this.#boundKeyDown, {
|
|
16864
|
+
signal
|
|
16865
|
+
});
|
|
16866
|
+
button.addEventListener("click", () => {
|
|
16867
|
+
const [{
|
|
16868
|
+
data: {
|
|
16869
|
+
id: editId
|
|
16870
|
+
},
|
|
16871
|
+
annotationEditorType: mode
|
|
16872
|
+
}] = this.#elements;
|
|
16873
|
+
this.#eventBus?.dispatch("switchannotationeditormode", {
|
|
16874
|
+
source: this,
|
|
16875
|
+
editId,
|
|
16876
|
+
mode,
|
|
16877
|
+
editComment: true
|
|
16878
|
+
});
|
|
16879
|
+
}, {
|
|
16880
|
+
signal
|
|
16881
|
+
});
|
|
16882
|
+
const {
|
|
16883
|
+
style
|
|
16884
|
+
} = button;
|
|
16885
|
+
style.left = `calc(${this.#commentButtonPosition[0]}%)`;
|
|
16886
|
+
style.top = `calc(${this.#commentButtonPosition[1]}% - var(--comment-button-dim))`;
|
|
16887
|
+
if (this.#commentButtonColor) {
|
|
16888
|
+
style.backgroundColor = this.#commentButtonColor;
|
|
16889
|
+
}
|
|
16890
|
+
parentContainer.after(button);
|
|
16014
16891
|
}
|
|
16015
16892
|
render() {
|
|
16016
16893
|
if (this.#popup) {
|
|
@@ -16600,6 +17477,33 @@ class InkAnnotationElement extends AnnotationElement {
|
|
|
16600
17477
|
addHighlightArea() {
|
|
16601
17478
|
this.container.classList.add("highlightArea");
|
|
16602
17479
|
}
|
|
17480
|
+
get commentButtonPosition() {
|
|
17481
|
+
const {
|
|
17482
|
+
inkLists,
|
|
17483
|
+
rect
|
|
17484
|
+
} = this.data;
|
|
17485
|
+
if (inkLists?.length >= 1) {
|
|
17486
|
+
let maxX = -Infinity;
|
|
17487
|
+
let maxY = -Infinity;
|
|
17488
|
+
for (const inkList of inkLists) {
|
|
17489
|
+
for (let i = 0, ii = inkList.length; i < ii; i += 2) {
|
|
17490
|
+
if (inkList[i + 1] > maxY) {
|
|
17491
|
+
maxY = inkList[i + 1];
|
|
17492
|
+
maxX = inkList[i];
|
|
17493
|
+
} else if (inkList[i + 1] === maxY) {
|
|
17494
|
+
maxX = Math.max(maxX, inkList[i]);
|
|
17495
|
+
}
|
|
17496
|
+
}
|
|
17497
|
+
}
|
|
17498
|
+
if (maxX !== Infinity) {
|
|
17499
|
+
return [maxX, maxY];
|
|
17500
|
+
}
|
|
17501
|
+
}
|
|
17502
|
+
if (rect) {
|
|
17503
|
+
return [rect[2], rect[3]];
|
|
17504
|
+
}
|
|
17505
|
+
return null;
|
|
17506
|
+
}
|
|
16603
17507
|
}
|
|
16604
17508
|
class HighlightAnnotationElement extends AnnotationElement {
|
|
16605
17509
|
constructor(parameters) {
|
|
@@ -16851,6 +17755,7 @@ class AnnotationLayer {
|
|
|
16851
17755
|
renderForms: params.renderForms !== false,
|
|
16852
17756
|
svgFactory: new DOMSVGFactory(),
|
|
16853
17757
|
annotationStorage: params.annotationStorage || new AnnotationStorage(),
|
|
17758
|
+
enableComment: params.enableComment === true,
|
|
16854
17759
|
enableScripting: params.enableScripting === true,
|
|
16855
17760
|
hasJSActions: params.hasJSActions,
|
|
16856
17761
|
fieldObjects: params.fieldObjects,
|
|
@@ -17497,6 +18402,10 @@ class FreeTextEditor extends AnnotationEditor {
|
|
|
17497
18402
|
get contentDiv() {
|
|
17498
18403
|
return this.editorDiv;
|
|
17499
18404
|
}
|
|
18405
|
+
getPDFRect() {
|
|
18406
|
+
const padding = FreeTextEditor._internalPadding * this.parentScale;
|
|
18407
|
+
return this.getRect(padding, padding);
|
|
18408
|
+
}
|
|
17500
18409
|
static async deserialize(data, parent, uiManager) {
|
|
17501
18410
|
let initialData = null;
|
|
17502
18411
|
if (data instanceof FreeTextAnnotationElement) {
|
|
@@ -17556,8 +18465,7 @@ class FreeTextEditor extends AnnotationEditor {
|
|
|
17556
18465
|
if (this.deleted) {
|
|
17557
18466
|
return this.serializeDeleted();
|
|
17558
18467
|
}
|
|
17559
|
-
const
|
|
17560
|
-
const rect = this.getRect(padding, padding);
|
|
18468
|
+
const rect = this.getPDFRect();
|
|
17561
18469
|
const color = AnnotationEditor._colorManager.convert(this.isAttachedToDOM ? getComputedStyle(this.editorDiv).color : this.#color);
|
|
17562
18470
|
const serialized = {
|
|
17563
18471
|
annotationType: AnnotationEditorType.FREETEXT,
|
|
@@ -17591,6 +18499,9 @@ class FreeTextEditor extends AnnotationEditor {
|
|
|
17591
18499
|
}
|
|
17592
18500
|
renderAnnotationElement(annotation) {
|
|
17593
18501
|
const content = super.renderAnnotationElement(annotation);
|
|
18502
|
+
if (!content) {
|
|
18503
|
+
return null;
|
|
18504
|
+
}
|
|
17594
18505
|
const {
|
|
17595
18506
|
style
|
|
17596
18507
|
} = content;
|
|
@@ -17602,9 +18513,8 @@ class FreeTextEditor extends AnnotationEditor {
|
|
|
17602
18513
|
div.append(line ? document.createTextNode(line) : document.createElement("br"));
|
|
17603
18514
|
content.append(div);
|
|
17604
18515
|
}
|
|
17605
|
-
const padding = FreeTextEditor._internalPadding * this.parentScale;
|
|
17606
18516
|
const params = {
|
|
17607
|
-
rect: this.
|
|
18517
|
+
rect: this.getPDFRect()
|
|
17608
18518
|
};
|
|
17609
18519
|
params.popup = this.hasEditedComment ? this.comment : {
|
|
17610
18520
|
text: this.#content
|
|
@@ -19087,7 +19997,7 @@ class HighlightEditor extends AnnotationEditor {
|
|
|
19087
19997
|
if (this.deleted) {
|
|
19088
19998
|
return this.serializeDeleted();
|
|
19089
19999
|
}
|
|
19090
|
-
const rect = this.
|
|
20000
|
+
const rect = this.getPDFRect();
|
|
19091
20001
|
const color = AnnotationEditor._colorManager.convert(this._uiManager.getNonHCMColor(this.color));
|
|
19092
20002
|
const serialized = {
|
|
19093
20003
|
annotationType: AnnotationEditorType.HIGHLIGHT,
|
|
@@ -19115,8 +20025,12 @@ class HighlightEditor extends AnnotationEditor {
|
|
|
19115
20025
|
return this.hasEditedComment || serialized.color.some((c, i) => c !== color[i]);
|
|
19116
20026
|
}
|
|
19117
20027
|
renderAnnotationElement(annotation) {
|
|
20028
|
+
if (this.deleted) {
|
|
20029
|
+
annotation.hide();
|
|
20030
|
+
return null;
|
|
20031
|
+
}
|
|
19118
20032
|
const params = {
|
|
19119
|
-
rect: this.
|
|
20033
|
+
rect: this.getPDFRect()
|
|
19120
20034
|
};
|
|
19121
20035
|
if (this.hasEditedComment) {
|
|
19122
20036
|
params.popup = this.comment;
|
|
@@ -19762,7 +20676,7 @@ class DrawingEditor extends AnnotationEditor {
|
|
|
19762
20676
|
}
|
|
19763
20677
|
renderAnnotationElement(annotation) {
|
|
19764
20678
|
annotation.updateEdited({
|
|
19765
|
-
rect: this.
|
|
20679
|
+
rect: this.getPDFRect()
|
|
19766
20680
|
});
|
|
19767
20681
|
return null;
|
|
19768
20682
|
}
|
|
@@ -20645,6 +21559,10 @@ class InkEditor extends DrawingEditor {
|
|
|
20645
21559
|
return this.hasEditedComment || this._hasBeenMoved || this._hasBeenResized || serialized.color.some((c, i) => c !== color[i]) || serialized.thickness !== thickness || serialized.opacity !== opacity || serialized.pageIndex !== pageIndex;
|
|
20646
21560
|
}
|
|
20647
21561
|
renderAnnotationElement(annotation) {
|
|
21562
|
+
if (this.deleted) {
|
|
21563
|
+
annotation.hide();
|
|
21564
|
+
return null;
|
|
21565
|
+
}
|
|
20648
21566
|
const {
|
|
20649
21567
|
points,
|
|
20650
21568
|
rect
|
|
@@ -22276,7 +23194,7 @@ class StampEditor extends AnnotationEditor {
|
|
|
22276
23194
|
annotationType: AnnotationEditorType.STAMP,
|
|
22277
23195
|
bitmapId: this.#bitmapId,
|
|
22278
23196
|
pageIndex: this.pageIndex,
|
|
22279
|
-
rect: this.
|
|
23197
|
+
rect: this.getPDFRect(),
|
|
22280
23198
|
rotation: this.rotation,
|
|
22281
23199
|
isSvg: this.#isSvg,
|
|
22282
23200
|
structTreeParentId: this._structTreeParentId
|
|
@@ -22346,8 +23264,12 @@ class StampEditor extends AnnotationEditor {
|
|
|
22346
23264
|
};
|
|
22347
23265
|
}
|
|
22348
23266
|
renderAnnotationElement(annotation) {
|
|
23267
|
+
if (this.deleted) {
|
|
23268
|
+
annotation.hide();
|
|
23269
|
+
return null;
|
|
23270
|
+
}
|
|
22349
23271
|
const params = {
|
|
22350
|
-
rect: this.
|
|
23272
|
+
rect: this.getPDFRect()
|
|
22351
23273
|
};
|
|
22352
23274
|
if (this.hasEditedComment) {
|
|
22353
23275
|
params.popup = this.comment;
|