pdfjs-dist 2.0.943 → 2.4.456

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.

Potentially problematic release.


This version of pdfjs-dist might be problematic. Click here for more details.

Files changed (192) hide show
  1. package/CODE_OF_CONDUCT.md +15 -0
  2. package/README.md +4 -0
  3. package/bower.json +1 -1
  4. package/build/pdf.js +8286 -14230
  5. package/build/pdf.js.map +1 -1
  6. package/build/pdf.min.js +22 -1
  7. package/build/pdf.worker.entry.js +5 -3
  8. package/build/pdf.worker.js +25500 -26628
  9. package/build/pdf.worker.js.map +1 -1
  10. package/build/pdf.worker.min.js +22 -1
  11. package/es5/build/pdf.js +25473 -0
  12. package/es5/build/pdf.js.map +1 -0
  13. package/{lib/shared/global_scope.js → es5/build/pdf.worker.entry.js} +5 -10
  14. package/es5/build/pdf.worker.js +57878 -0
  15. package/es5/build/pdf.worker.js.map +1 -0
  16. package/es5/web/images/annotation-check.svg +11 -0
  17. package/es5/web/images/annotation-comment.svg +16 -0
  18. package/es5/web/images/annotation-help.svg +26 -0
  19. package/es5/web/images/annotation-insert.svg +10 -0
  20. package/es5/web/images/annotation-key.svg +11 -0
  21. package/es5/web/images/annotation-newparagraph.svg +11 -0
  22. package/es5/web/images/annotation-noicon.svg +7 -0
  23. package/es5/web/images/annotation-note.svg +42 -0
  24. package/es5/web/images/annotation-paragraph.svg +16 -0
  25. package/es5/web/images/loading-icon.gif +0 -0
  26. package/es5/web/images/shadow.png +0 -0
  27. package/es5/web/images/texture.png +0 -0
  28. package/es5/web/pdf_viewer.css +407 -0
  29. package/es5/web/pdf_viewer.js +7757 -0
  30. package/es5/web/pdf_viewer.js.map +1 -0
  31. package/image_decoders/pdf.image_decoders.js +2887 -4094
  32. package/image_decoders/pdf.image_decoders.js.map +1 -1
  33. package/image_decoders/pdf.image_decoders.min.js +22 -1
  34. package/lib/README.md +7 -0
  35. package/lib/core/annotation.js +855 -778
  36. package/lib/core/arithmetic_decoder.js +325 -311
  37. package/lib/core/bidi.js +117 -50
  38. package/lib/core/ccitt.js +251 -89
  39. package/lib/core/ccitt_stream.js +26 -16
  40. package/lib/core/cff_parser.js +525 -197
  41. package/lib/core/charsets.js +6 -5
  42. package/lib/core/chunked_stream.js +541 -406
  43. package/lib/core/cmap.js +368 -253
  44. package/lib/core/colorspace.js +781 -800
  45. package/lib/core/core_utils.js +152 -0
  46. package/lib/core/crypto.js +609 -422
  47. package/lib/core/document.js +649 -481
  48. package/lib/core/encodings.js +33 -24
  49. package/lib/core/evaluator.js +1471 -736
  50. package/lib/core/font_renderer.js +289 -149
  51. package/lib/core/fonts.js +1067 -413
  52. package/lib/core/function.js +517 -287
  53. package/lib/core/glyphlist.js +4529 -4527
  54. package/lib/core/image.js +232 -114
  55. package/lib/core/image_utils.js +94 -0
  56. package/lib/core/jbig2.js +711 -342
  57. package/lib/core/jbig2_stream.js +31 -19
  58. package/lib/core/jpeg_stream.js +151 -26
  59. package/lib/core/jpg.js +433 -181
  60. package/lib/core/jpx.js +551 -143
  61. package/lib/core/jpx_stream.js +40 -28
  62. package/lib/core/metrics.js +2931 -2931
  63. package/lib/core/murmurhash3.js +104 -97
  64. package/lib/core/obj.js +1561 -1053
  65. package/lib/core/operator_list.js +192 -64
  66. package/lib/core/parser.js +1162 -864
  67. package/lib/core/pattern.js +224 -75
  68. package/lib/core/pdf_manager.js +154 -285
  69. package/lib/core/primitives.js +145 -69
  70. package/lib/core/ps_parser.js +212 -162
  71. package/lib/core/standard_fonts.js +245 -244
  72. package/lib/core/stream.js +353 -81
  73. package/lib/core/type1_parser.js +218 -68
  74. package/lib/core/unicode.js +1682 -1655
  75. package/lib/core/worker.js +233 -302
  76. package/lib/core/worker_stream.js +168 -0
  77. package/lib/display/annotation_layer.js +808 -862
  78. package/lib/display/api.js +1778 -1462
  79. package/lib/display/api_compatibility.js +14 -9
  80. package/lib/display/canvas.js +463 -140
  81. package/lib/display/content_disposition.js +86 -58
  82. package/lib/display/display_utils.js +524 -0
  83. package/lib/display/fetch_stream.js +202 -274
  84. package/lib/display/font_loader.js +311 -333
  85. package/lib/display/metadata.js +98 -88
  86. package/lib/display/network.js +343 -347
  87. package/lib/display/network_utils.js +46 -26
  88. package/lib/display/node_stream.js +326 -404
  89. package/lib/display/pattern_helper.js +168 -69
  90. package/lib/display/svg.js +1296 -885
  91. package/lib/display/text_layer.js +229 -103
  92. package/lib/display/transport_stream.js +290 -250
  93. package/lib/display/webgl.js +116 -83
  94. package/lib/display/worker_options.js +6 -5
  95. package/lib/display/xml_parser.js +358 -337
  96. package/lib/examples/node/domstubs.js +95 -39
  97. package/lib/pdf.js +49 -31
  98. package/lib/pdf.worker.js +7 -5
  99. package/lib/shared/compatibility.js +3 -145
  100. package/lib/shared/is_node.js +8 -7
  101. package/lib/shared/message_handler.js +367 -314
  102. package/lib/shared/util.js +421 -415
  103. package/lib/test/unit/annotation_spec.js +1570 -690
  104. package/lib/test/unit/api_spec.js +855 -493
  105. package/lib/test/unit/bidi_spec.js +12 -12
  106. package/lib/test/unit/cff_parser_spec.js +88 -61
  107. package/lib/test/unit/clitests_helper.js +9 -12
  108. package/lib/test/unit/cmap_spec.js +140 -88
  109. package/lib/test/unit/colorspace_spec.js +204 -152
  110. package/lib/test/unit/core_utils_spec.js +211 -0
  111. package/lib/test/unit/crypto_spec.js +194 -182
  112. package/lib/test/unit/custom_spec.js +50 -64
  113. package/lib/test/unit/display_svg_spec.js +53 -38
  114. package/lib/test/unit/display_utils_spec.js +263 -0
  115. package/lib/test/unit/document_spec.js +17 -22
  116. package/lib/test/unit/encodings_spec.js +15 -57
  117. package/lib/test/unit/evaluator_spec.js +90 -83
  118. package/lib/test/unit/fetch_stream_spec.js +111 -0
  119. package/lib/test/unit/function_spec.js +219 -205
  120. package/lib/test/unit/jasmine-boot.js +68 -39
  121. package/lib/test/unit/message_handler_spec.js +187 -160
  122. package/lib/test/unit/metadata_spec.js +87 -34
  123. package/lib/test/unit/murmurhash3_spec.js +13 -13
  124. package/lib/test/unit/network_spec.js +26 -59
  125. package/lib/test/unit/network_utils_spec.js +187 -121
  126. package/lib/test/unit/node_stream_spec.js +98 -90
  127. package/lib/test/unit/parser_spec.js +173 -131
  128. package/lib/test/unit/pdf_find_controller_spec.js +148 -67
  129. package/lib/test/unit/pdf_find_utils_spec.js +35 -34
  130. package/lib/test/unit/pdf_history_spec.js +45 -33
  131. package/lib/test/unit/primitives_spec.js +161 -126
  132. package/lib/test/unit/stream_spec.js +22 -15
  133. package/lib/test/unit/test_utils.js +149 -98
  134. package/lib/test/unit/testreporter.js +36 -18
  135. package/lib/test/unit/type1_parser_spec.js +46 -44
  136. package/lib/test/unit/ui_utils_spec.js +388 -372
  137. package/lib/test/unit/unicode_spec.js +49 -46
  138. package/lib/test/unit/util_spec.js +144 -248
  139. package/lib/web/annotation_layer_builder.js +75 -95
  140. package/lib/web/app.js +1538 -1147
  141. package/lib/web/app_options.js +116 -104
  142. package/lib/web/base_viewer.js +950 -775
  143. package/lib/web/chromecom.js +217 -225
  144. package/lib/web/debugger.js +236 -148
  145. package/lib/web/download_manager.js +50 -50
  146. package/lib/web/firefox_print_service.js +51 -33
  147. package/lib/web/firefoxcom.js +225 -352
  148. package/lib/web/genericcom.js +30 -93
  149. package/lib/web/genericl10n.js +26 -143
  150. package/lib/web/grab_to_pan.js +57 -33
  151. package/lib/web/interfaces.js +105 -232
  152. package/lib/web/overlay_manager.js +73 -227
  153. package/lib/web/password_prompt.js +44 -62
  154. package/lib/web/pdf_attachment_viewer.js +118 -123
  155. package/lib/web/pdf_cursor_tools.js +89 -93
  156. package/lib/web/pdf_document_properties.js +242 -281
  157. package/lib/web/pdf_find_bar.js +157 -163
  158. package/lib/web/pdf_find_controller.js +598 -454
  159. package/lib/web/pdf_find_utils.js +32 -16
  160. package/lib/web/pdf_history.js +481 -355
  161. package/lib/web/pdf_link_service.js +355 -323
  162. package/lib/web/pdf_outline_viewer.js +167 -152
  163. package/lib/web/pdf_page_view.js +511 -457
  164. package/lib/web/pdf_presentation_mode.js +347 -335
  165. package/lib/web/pdf_print_service.js +133 -103
  166. package/lib/web/pdf_rendering_queue.js +98 -100
  167. package/lib/web/pdf_sidebar.js +323 -299
  168. package/lib/web/pdf_sidebar_resizer.js +107 -108
  169. package/lib/web/pdf_single_page_viewer.js +94 -146
  170. package/lib/web/pdf_thumbnail_view.js +319 -269
  171. package/lib/web/pdf_thumbnail_viewer.js +219 -199
  172. package/lib/web/pdf_viewer.component.js +111 -32
  173. package/lib/web/pdf_viewer.js +61 -101
  174. package/lib/web/preferences.js +87 -272
  175. package/lib/web/secondary_toolbar.js +207 -220
  176. package/lib/web/text_layer_builder.js +322 -322
  177. package/lib/web/toolbar.js +227 -180
  178. package/lib/web/ui_utils.js +476 -421
  179. package/lib/web/view_history.js +59 -208
  180. package/lib/web/viewer_compatibility.js +9 -6
  181. package/package.json +2 -9
  182. package/web/pdf_viewer.css +36 -22
  183. package/web/pdf_viewer.js +4407 -4516
  184. package/web/pdf_viewer.js.map +1 -1
  185. package/webpack.js +14 -5
  186. package/external/streams/streams-lib.js +0 -3962
  187. package/external/url/url-lib.js +0 -627
  188. package/lib/display/dom_utils.js +0 -441
  189. package/lib/shared/streams_polyfill.js +0 -39
  190. package/lib/shared/url_polyfill.js +0 -50
  191. package/lib/test/unit/dom_utils_spec.js +0 -89
  192. package/lib/web/dom_events.js +0 -140
@@ -2,7 +2,7 @@
2
2
  * @licstart The following is the entire license notice for the
3
3
  * Javascript code in this page
4
4
  *
5
- * Copyright 2018 Mozilla Foundation
5
+ * Copyright 2020 Mozilla Foundation
6
6
  *
7
7
  * Licensed under the Apache License, Version 2.0 (the "License");
8
8
  * you may not use this file except in compliance with the License.
@@ -19,16 +19,16 @@
19
19
  * @licend The above is the entire license notice for the
20
20
  * Javascript code in this page
21
21
  */
22
- 'use strict';
22
+ "use strict";
23
23
 
24
24
  Object.defineProperty(exports, "__esModule", {
25
25
  value: true
26
26
  });
27
- exports.CanvasGraphics = undefined;
27
+ exports.CanvasGraphics = void 0;
28
28
 
29
- var _util = require('../shared/util');
29
+ var _util = require("../shared/util.js");
30
30
 
31
- var _pattern_helper = require('./pattern_helper');
31
+ var _pattern_helper = require("./pattern_helper.js");
32
32
 
33
33
  var MIN_FONT_SIZE = 16;
34
34
  var MAX_FONT_SIZE = 100;
@@ -37,11 +37,7 @@ var MIN_WIDTH_FACTOR = 0.65;
37
37
  var COMPILE_TYPE3_GLYPHS = true;
38
38
  var MAX_SIZE_TO_COMPILE = 1000;
39
39
  var FULL_CHUNK_HEIGHT = 16;
40
- var IsLittleEndianCached = {
41
- get value() {
42
- return (0, _util.shadow)(IsLittleEndianCached, 'value', (0, _util.isLittleEndian)());
43
- }
44
- };
40
+
45
41
  function addContextCurrentTransform(ctx) {
46
42
  if (!ctx.mozCurrentTransform) {
47
43
  ctx._originalSave = ctx.save;
@@ -53,12 +49,12 @@ function addContextCurrentTransform(ctx) {
53
49
  ctx._originalSetTransform = ctx.setTransform;
54
50
  ctx._transformMatrix = ctx._transformMatrix || [1, 0, 0, 1, 0, 0];
55
51
  ctx._transformStack = [];
56
- Object.defineProperty(ctx, 'mozCurrentTransform', {
52
+ Object.defineProperty(ctx, "mozCurrentTransform", {
57
53
  get: function getCurrentTransform() {
58
54
  return this._transformMatrix;
59
55
  }
60
56
  });
61
- Object.defineProperty(ctx, 'mozCurrentTransformInverse', {
57
+ Object.defineProperty(ctx, "mozCurrentTransformInverse", {
62
58
  get: function getCurrentTransformInverse() {
63
59
  var m = this._transformMatrix;
64
60
  var a = m[0],
@@ -72,59 +68,79 @@ function addContextCurrentTransform(ctx) {
72
68
  return [d / ad_bc, b / bc_ad, c / bc_ad, a / ad_bc, (d * e - c * f) / bc_ad, (b * e - a * f) / ad_bc];
73
69
  }
74
70
  });
71
+
75
72
  ctx.save = function ctxSave() {
76
73
  var old = this._transformMatrix;
74
+
77
75
  this._transformStack.push(old);
76
+
78
77
  this._transformMatrix = old.slice(0, 6);
78
+
79
79
  this._originalSave();
80
80
  };
81
+
81
82
  ctx.restore = function ctxRestore() {
82
83
  var prev = this._transformStack.pop();
84
+
83
85
  if (prev) {
84
86
  this._transformMatrix = prev;
87
+
85
88
  this._originalRestore();
86
89
  }
87
90
  };
91
+
88
92
  ctx.translate = function ctxTranslate(x, y) {
89
93
  var m = this._transformMatrix;
90
94
  m[4] = m[0] * x + m[2] * y + m[4];
91
95
  m[5] = m[1] * x + m[3] * y + m[5];
96
+
92
97
  this._originalTranslate(x, y);
93
98
  };
99
+
94
100
  ctx.scale = function ctxScale(x, y) {
95
101
  var m = this._transformMatrix;
96
102
  m[0] = m[0] * x;
97
103
  m[1] = m[1] * x;
98
104
  m[2] = m[2] * y;
99
105
  m[3] = m[3] * y;
106
+
100
107
  this._originalScale(x, y);
101
108
  };
109
+
102
110
  ctx.transform = function ctxTransform(a, b, c, d, e, f) {
103
111
  var m = this._transformMatrix;
104
112
  this._transformMatrix = [m[0] * a + m[2] * b, m[1] * a + m[3] * b, m[0] * c + m[2] * d, m[1] * c + m[3] * d, m[0] * e + m[2] * f + m[4], m[1] * e + m[3] * f + m[5]];
113
+
105
114
  ctx._originalTransform(a, b, c, d, e, f);
106
115
  };
116
+
107
117
  ctx.setTransform = function ctxSetTransform(a, b, c, d, e, f) {
108
118
  this._transformMatrix = [a, b, c, d, e, f];
119
+
109
120
  ctx._originalSetTransform(a, b, c, d, e, f);
110
121
  };
122
+
111
123
  ctx.rotate = function ctxRotate(angle) {
112
124
  var cosValue = Math.cos(angle);
113
125
  var sinValue = Math.sin(angle);
114
126
  var m = this._transformMatrix;
115
127
  this._transformMatrix = [m[0] * cosValue + m[2] * sinValue, m[1] * cosValue + m[3] * sinValue, m[0] * -sinValue + m[2] * cosValue, m[1] * -sinValue + m[3] * cosValue, m[4], m[5]];
128
+
116
129
  this._originalRotate(angle);
117
130
  };
118
131
  }
119
132
  }
133
+
120
134
  var CachedCanvases = function CachedCanvasesClosure() {
121
135
  function CachedCanvases(canvasFactory) {
122
136
  this.canvasFactory = canvasFactory;
123
137
  this.cache = Object.create(null);
124
138
  }
139
+
125
140
  CachedCanvases.prototype = {
126
141
  getCanvas: function CachedCanvases_getCanvas(id, width, height, trackTransform) {
127
142
  var canvasEntry;
143
+
128
144
  if (this.cache[id] !== undefined) {
129
145
  canvasEntry = this.cache[id];
130
146
  this.canvasFactory.reset(canvasEntry, width, height);
@@ -133,21 +149,26 @@ var CachedCanvases = function CachedCanvasesClosure() {
133
149
  canvasEntry = this.canvasFactory.create(width, height);
134
150
  this.cache[id] = canvasEntry;
135
151
  }
152
+
136
153
  if (trackTransform) {
137
154
  addContextCurrentTransform(canvasEntry.context);
138
155
  }
156
+
139
157
  return canvasEntry;
140
158
  },
141
- clear: function clear() {
159
+
160
+ clear() {
142
161
  for (var id in this.cache) {
143
162
  var canvasEntry = this.cache[id];
144
163
  this.canvasFactory.destroy(canvasEntry);
145
164
  delete this.cache[id];
146
165
  }
147
166
  }
167
+
148
168
  };
149
169
  return CachedCanvases;
150
170
  }();
171
+
151
172
  function compileType3Glyph(imgData) {
152
173
  var POINT_TO_PROCESS_LIMIT = 1000;
153
174
  var width = imgData.width,
@@ -163,96 +184,126 @@ function compileType3Glyph(imgData) {
163
184
  var data = new Uint8Array(lineSize * height),
164
185
  pos = 0,
165
186
  ii;
187
+
166
188
  for (i = 0, ii = data0.length; i < ii; i++) {
167
189
  var mask = 128,
168
190
  elem = data0[i];
191
+
169
192
  while (mask > 0) {
170
193
  data[pos++] = elem & mask ? 0 : 255;
171
194
  mask >>= 1;
172
195
  }
173
196
  }
197
+
174
198
  var count = 0;
175
199
  pos = 0;
200
+
176
201
  if (data[pos] !== 0) {
177
202
  points[0] = 1;
178
203
  ++count;
179
204
  }
205
+
180
206
  for (j = 1; j < width; j++) {
181
207
  if (data[pos] !== data[pos + 1]) {
182
208
  points[j] = data[pos] ? 2 : 1;
183
209
  ++count;
184
210
  }
211
+
185
212
  pos++;
186
213
  }
214
+
187
215
  if (data[pos] !== 0) {
188
216
  points[j] = 2;
189
217
  ++count;
190
218
  }
219
+
191
220
  for (i = 1; i < height; i++) {
192
221
  pos = i * lineSize;
193
222
  j0 = i * width1;
223
+
194
224
  if (data[pos - lineSize] !== data[pos]) {
195
225
  points[j0] = data[pos] ? 1 : 8;
196
226
  ++count;
197
227
  }
228
+
198
229
  var sum = (data[pos] ? 4 : 0) + (data[pos - lineSize] ? 8 : 0);
230
+
199
231
  for (j = 1; j < width; j++) {
200
232
  sum = (sum >> 2) + (data[pos + 1] ? 4 : 0) + (data[pos - lineSize + 1] ? 8 : 0);
233
+
201
234
  if (POINT_TYPES[sum]) {
202
235
  points[j0 + j] = POINT_TYPES[sum];
203
236
  ++count;
204
237
  }
238
+
205
239
  pos++;
206
240
  }
241
+
207
242
  if (data[pos - lineSize] !== data[pos]) {
208
243
  points[j0 + j] = data[pos] ? 2 : 4;
209
244
  ++count;
210
245
  }
246
+
211
247
  if (count > POINT_TO_PROCESS_LIMIT) {
212
248
  return null;
213
249
  }
214
250
  }
251
+
215
252
  pos = lineSize * (height - 1);
216
253
  j0 = i * width1;
254
+
217
255
  if (data[pos] !== 0) {
218
256
  points[j0] = 8;
219
257
  ++count;
220
258
  }
259
+
221
260
  for (j = 1; j < width; j++) {
222
261
  if (data[pos] !== data[pos + 1]) {
223
262
  points[j0 + j] = data[pos] ? 4 : 8;
224
263
  ++count;
225
264
  }
265
+
226
266
  pos++;
227
267
  }
268
+
228
269
  if (data[pos] !== 0) {
229
270
  points[j0 + j] = 4;
230
271
  ++count;
231
272
  }
273
+
232
274
  if (count > POINT_TO_PROCESS_LIMIT) {
233
275
  return null;
234
276
  }
277
+
235
278
  var steps = new Int32Array([0, width1, -1, 0, -width1, 0, 0, 0, 1]);
236
279
  var outlines = [];
280
+
237
281
  for (i = 0; count && i <= height; i++) {
238
282
  var p = i * width1;
239
283
  var end = p + width;
284
+
240
285
  while (p < end && !points[p]) {
241
286
  p++;
242
287
  }
288
+
243
289
  if (p === end) {
244
290
  continue;
245
291
  }
292
+
246
293
  var coords = [p % width1, i];
247
294
  var type = points[p],
248
295
  p0 = p,
249
296
  pp;
297
+
250
298
  do {
251
299
  var step = steps[type];
300
+
252
301
  do {
253
302
  p += step;
254
303
  } while (!points[p]);
304
+
255
305
  pp = points[p];
306
+
256
307
  if (pp !== 5 && pp !== 10) {
257
308
  type = pp;
258
309
  points[p] = 0;
@@ -260,31 +311,42 @@ function compileType3Glyph(imgData) {
260
311
  type = pp & 0x33 * type >> 4;
261
312
  points[p] &= type >> 2 | type << 2;
262
313
  }
314
+
263
315
  coords.push(p % width1);
264
316
  coords.push(p / width1 | 0);
265
- --count;
317
+
318
+ if (!points[p]) {
319
+ --count;
320
+ }
266
321
  } while (p0 !== p);
322
+
267
323
  outlines.push(coords);
268
324
  --i;
269
325
  }
270
- var drawOutline = function drawOutline(c) {
326
+
327
+ var drawOutline = function (c) {
271
328
  c.save();
272
329
  c.scale(1 / width, -1 / height);
273
330
  c.translate(0, -height);
274
331
  c.beginPath();
332
+
275
333
  for (var i = 0, ii = outlines.length; i < ii; i++) {
276
334
  var o = outlines[i];
277
335
  c.moveTo(o[0], o[1]);
336
+
278
337
  for (var j = 2, jj = o.length; j < jj; j += 2) {
279
338
  c.lineTo(o[j], o[j + 1]);
280
339
  }
281
340
  }
341
+
282
342
  c.fill();
283
343
  c.beginPath();
284
344
  c.restore();
285
345
  };
346
+
286
347
  return drawOutline;
287
348
  }
349
+
288
350
  var CanvasExtraState = function CanvasExtraStateClosure() {
289
351
  function CanvasExtraState() {
290
352
  this.alphaIsShape = false;
@@ -303,8 +365,8 @@ var CanvasExtraState = function CanvasExtraStateClosure() {
303
365
  this.textHScale = 1;
304
366
  this.textRenderingMode = _util.TextRenderingMode.FILL;
305
367
  this.textRise = 0;
306
- this.fillColor = '#000000';
307
- this.strokeColor = '#000000';
368
+ this.fillColor = "#000000";
369
+ this.strokeColor = "#000000";
308
370
  this.patternFill = false;
309
371
  this.fillAlpha = 1;
310
372
  this.strokeAlpha = 1;
@@ -312,6 +374,7 @@ var CanvasExtraState = function CanvasExtraStateClosure() {
312
374
  this.activeSMask = null;
313
375
  this.resumeSMaskCtx = null;
314
376
  }
377
+
315
378
  CanvasExtraState.prototype = {
316
379
  clone: function CanvasExtraState_clone() {
317
380
  return Object.create(this);
@@ -323,9 +386,11 @@ var CanvasExtraState = function CanvasExtraStateClosure() {
323
386
  };
324
387
  return CanvasExtraState;
325
388
  }();
389
+
326
390
  var CanvasGraphics = function CanvasGraphicsClosure() {
327
391
  var EXECUTION_TIME = 15;
328
392
  var EXECUTION_STEPS = 10;
393
+
329
394
  function CanvasGraphics(canvasCtx, commonObjs, objs, canvasFactory, webGLContext, imageLayer) {
330
395
  this.ctx = canvasCtx;
331
396
  this.current = new CanvasExtraState();
@@ -348,16 +413,20 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
348
413
  this.smaskCounter = 0;
349
414
  this.tempSMask = null;
350
415
  this.cachedCanvases = new CachedCanvases(this.canvasFactory);
416
+
351
417
  if (canvasCtx) {
352
418
  addContextCurrentTransform(canvasCtx);
353
419
  }
420
+
354
421
  this._cachedGetSinglePixelWidth = null;
355
422
  }
423
+
356
424
  function putBinaryImageData(ctx, imgData) {
357
- if (typeof ImageData !== 'undefined' && imgData instanceof ImageData) {
425
+ if (typeof ImageData !== "undefined" && imgData instanceof ImageData) {
358
426
  ctx.putImageData(imgData, 0, 0);
359
427
  return;
360
428
  }
429
+
361
430
  var height = imgData.height,
362
431
  width = imgData.width;
363
432
  var partialChunkHeight = height % FULL_CHUNK_HEIGHT;
@@ -369,16 +438,19 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
369
438
  var src = imgData.data;
370
439
  var dest = chunkImgData.data;
371
440
  var i, j, thisChunkHeight, elemsInThisChunk;
441
+
372
442
  if (imgData.kind === _util.ImageKind.GRAYSCALE_1BPP) {
373
443
  var srcLength = src.byteLength;
374
444
  var dest32 = new Uint32Array(dest.buffer, 0, dest.byteLength >> 2);
375
445
  var dest32DataLength = dest32.length;
376
446
  var fullSrcDiff = width + 7 >> 3;
377
- var white = 0xFFFFFFFF;
378
- var black = IsLittleEndianCached.value ? 0xFF000000 : 0x000000FF;
447
+ var white = 0xffffffff;
448
+ var black = _util.IsLittleEndianCached.value ? 0xff000000 : 0x000000ff;
449
+
379
450
  for (i = 0; i < totalChunks; i++) {
380
451
  thisChunkHeight = i < fullChunks ? FULL_CHUNK_HEIGHT : partialChunkHeight;
381
452
  destPos = 0;
453
+
382
454
  for (j = 0; j < thisChunkHeight; j++) {
383
455
  var srcDiff = srcLength - srcPos;
384
456
  var k = 0;
@@ -386,6 +458,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
386
458
  var kEndUnrolled = kEnd & ~7;
387
459
  var mask = 0;
388
460
  var srcByte = 0;
461
+
389
462
  for (; k < kEndUnrolled; k += 8) {
390
463
  srcByte = src[srcPos++];
391
464
  dest32[destPos++] = srcByte & 128 ? white : black;
@@ -397,29 +470,35 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
397
470
  dest32[destPos++] = srcByte & 2 ? white : black;
398
471
  dest32[destPos++] = srcByte & 1 ? white : black;
399
472
  }
473
+
400
474
  for (; k < kEnd; k++) {
401
475
  if (mask === 0) {
402
476
  srcByte = src[srcPos++];
403
477
  mask = 128;
404
478
  }
479
+
405
480
  dest32[destPos++] = srcByte & mask ? white : black;
406
481
  mask >>= 1;
407
482
  }
408
483
  }
484
+
409
485
  while (destPos < dest32DataLength) {
410
486
  dest32[destPos++] = 0;
411
487
  }
488
+
412
489
  ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
413
490
  }
414
491
  } else if (imgData.kind === _util.ImageKind.RGBA_32BPP) {
415
492
  j = 0;
416
493
  elemsInThisChunk = width * FULL_CHUNK_HEIGHT * 4;
494
+
417
495
  for (i = 0; i < fullChunks; i++) {
418
496
  dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));
419
497
  srcPos += elemsInThisChunk;
420
498
  ctx.putImageData(chunkImgData, 0, j);
421
499
  j += FULL_CHUNK_HEIGHT;
422
500
  }
501
+
423
502
  if (i < totalChunks) {
424
503
  elemsInThisChunk = width * partialChunkHeight * 4;
425
504
  dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));
@@ -428,24 +507,29 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
428
507
  } else if (imgData.kind === _util.ImageKind.RGB_24BPP) {
429
508
  thisChunkHeight = FULL_CHUNK_HEIGHT;
430
509
  elemsInThisChunk = width * thisChunkHeight;
510
+
431
511
  for (i = 0; i < totalChunks; i++) {
432
512
  if (i >= fullChunks) {
433
513
  thisChunkHeight = partialChunkHeight;
434
514
  elemsInThisChunk = width * thisChunkHeight;
435
515
  }
516
+
436
517
  destPos = 0;
518
+
437
519
  for (j = elemsInThisChunk; j--;) {
438
520
  dest[destPos++] = src[srcPos++];
439
521
  dest[destPos++] = src[srcPos++];
440
522
  dest[destPos++] = src[srcPos++];
441
523
  dest[destPos++] = 255;
442
524
  }
525
+
443
526
  ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
444
527
  }
445
528
  } else {
446
- throw new Error('bad image kind: ' + imgData.kind);
529
+ throw new Error(`bad image kind: ${imgData.kind}`);
447
530
  }
448
531
  }
532
+
449
533
  function putBinaryImageMask(ctx, imgData) {
450
534
  var height = imgData.height,
451
535
  width = imgData.width;
@@ -456,57 +540,71 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
456
540
  var srcPos = 0;
457
541
  var src = imgData.data;
458
542
  var dest = chunkImgData.data;
543
+
459
544
  for (var i = 0; i < totalChunks; i++) {
460
545
  var thisChunkHeight = i < fullChunks ? FULL_CHUNK_HEIGHT : partialChunkHeight;
461
546
  var destPos = 3;
547
+
462
548
  for (var j = 0; j < thisChunkHeight; j++) {
463
549
  var mask = 0;
550
+
464
551
  for (var k = 0; k < width; k++) {
465
552
  if (!mask) {
466
553
  var elem = src[srcPos++];
467
554
  mask = 128;
468
555
  }
556
+
469
557
  dest[destPos] = elem & mask ? 0 : 255;
470
558
  destPos += 4;
471
559
  mask >>= 1;
472
560
  }
473
561
  }
562
+
474
563
  ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
475
564
  }
476
565
  }
566
+
477
567
  function copyCtxState(sourceCtx, destCtx) {
478
- var properties = ['strokeStyle', 'fillStyle', 'fillRule', 'globalAlpha', 'lineWidth', 'lineCap', 'lineJoin', 'miterLimit', 'globalCompositeOperation', 'font'];
568
+ var properties = ["strokeStyle", "fillStyle", "fillRule", "globalAlpha", "lineWidth", "lineCap", "lineJoin", "miterLimit", "globalCompositeOperation", "font"];
569
+
479
570
  for (var i = 0, ii = properties.length; i < ii; i++) {
480
571
  var property = properties[i];
572
+
481
573
  if (sourceCtx[property] !== undefined) {
482
574
  destCtx[property] = sourceCtx[property];
483
575
  }
484
576
  }
577
+
485
578
  if (sourceCtx.setLineDash !== undefined) {
486
579
  destCtx.setLineDash(sourceCtx.getLineDash());
487
580
  destCtx.lineDashOffset = sourceCtx.lineDashOffset;
488
581
  }
489
582
  }
583
+
490
584
  function resetCtxToDefault(ctx) {
491
- ctx.strokeStyle = '#000000';
492
- ctx.fillStyle = '#000000';
493
- ctx.fillRule = 'nonzero';
585
+ ctx.strokeStyle = "#000000";
586
+ ctx.fillStyle = "#000000";
587
+ ctx.fillRule = "nonzero";
494
588
  ctx.globalAlpha = 1;
495
589
  ctx.lineWidth = 1;
496
- ctx.lineCap = 'butt';
497
- ctx.lineJoin = 'miter';
590
+ ctx.lineCap = "butt";
591
+ ctx.lineJoin = "miter";
498
592
  ctx.miterLimit = 10;
499
- ctx.globalCompositeOperation = 'source-over';
500
- ctx.font = '10px sans-serif';
593
+ ctx.globalCompositeOperation = "source-over";
594
+ ctx.font = "10px sans-serif";
595
+
501
596
  if (ctx.setLineDash !== undefined) {
502
597
  ctx.setLineDash([]);
503
598
  ctx.lineDashOffset = 0;
504
599
  }
505
600
  }
601
+
506
602
  function composeSMaskBackdrop(bytes, r0, g0, b0) {
507
603
  var length = bytes.length;
604
+
508
605
  for (var i = 3; i < length; i += 4) {
509
606
  var alpha = bytes[i];
607
+
510
608
  if (alpha === 0) {
511
609
  bytes[i - 3] = r0;
512
610
  bytes[i - 2] = g0;
@@ -519,99 +617,117 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
519
617
  }
520
618
  }
521
619
  }
620
+
522
621
  function composeSMaskAlpha(maskData, layerData, transferMap) {
523
622
  var length = maskData.length;
524
623
  var scale = 1 / 255;
624
+
525
625
  for (var i = 3; i < length; i += 4) {
526
626
  var alpha = transferMap ? transferMap[maskData[i]] : maskData[i];
527
627
  layerData[i] = layerData[i] * alpha * scale | 0;
528
628
  }
529
629
  }
630
+
530
631
  function composeSMaskLuminosity(maskData, layerData, transferMap) {
531
632
  var length = maskData.length;
633
+
532
634
  for (var i = 3; i < length; i += 4) {
533
635
  var y = maskData[i - 3] * 77 + maskData[i - 2] * 152 + maskData[i - 1] * 28;
534
636
  layerData[i] = transferMap ? layerData[i] * transferMap[y >> 8] >> 8 : layerData[i] * y >> 16;
535
637
  }
536
638
  }
639
+
537
640
  function genericComposeSMask(maskCtx, layerCtx, width, height, subtype, backdrop, transferMap) {
538
641
  var hasBackdrop = !!backdrop;
539
642
  var r0 = hasBackdrop ? backdrop[0] : 0;
540
643
  var g0 = hasBackdrop ? backdrop[1] : 0;
541
644
  var b0 = hasBackdrop ? backdrop[2] : 0;
542
645
  var composeFn;
543
- if (subtype === 'Luminosity') {
646
+
647
+ if (subtype === "Luminosity") {
544
648
  composeFn = composeSMaskLuminosity;
545
649
  } else {
546
650
  composeFn = composeSMaskAlpha;
547
651
  }
652
+
548
653
  var PIXELS_TO_PROCESS = 1048576;
549
654
  var chunkSize = Math.min(height, Math.ceil(PIXELS_TO_PROCESS / width));
655
+
550
656
  for (var row = 0; row < height; row += chunkSize) {
551
657
  var chunkHeight = Math.min(chunkSize, height - row);
552
658
  var maskData = maskCtx.getImageData(0, row, width, chunkHeight);
553
659
  var layerData = layerCtx.getImageData(0, row, width, chunkHeight);
660
+
554
661
  if (hasBackdrop) {
555
662
  composeSMaskBackdrop(maskData.data, r0, g0, b0);
556
663
  }
664
+
557
665
  composeFn(maskData.data, layerData.data, transferMap);
558
666
  maskCtx.putImageData(layerData, 0, row);
559
667
  }
560
668
  }
669
+
561
670
  function composeSMask(ctx, smask, layerCtx, webGLContext) {
562
671
  var mask = smask.canvas;
563
672
  var maskCtx = smask.context;
564
673
  ctx.setTransform(smask.scaleX, 0, 0, smask.scaleY, smask.offsetX, smask.offsetY);
565
674
  var backdrop = smask.backdrop || null;
675
+
566
676
  if (!smask.transferMap && webGLContext.isEnabled) {
567
- var composed = webGLContext.composeSMask({
677
+ const composed = webGLContext.composeSMask({
568
678
  layer: layerCtx.canvas,
569
- mask: mask,
679
+ mask,
570
680
  properties: {
571
681
  subtype: smask.subtype,
572
- backdrop: backdrop
682
+ backdrop
573
683
  }
574
684
  });
575
685
  ctx.setTransform(1, 0, 0, 1, 0, 0);
576
686
  ctx.drawImage(composed, smask.offsetX, smask.offsetY);
577
687
  return;
578
688
  }
689
+
579
690
  genericComposeSMask(maskCtx, layerCtx, mask.width, mask.height, smask.subtype, backdrop, smask.transferMap);
580
691
  ctx.drawImage(mask, 0, 0);
581
692
  }
582
- var LINE_CAP_STYLES = ['butt', 'round', 'square'];
583
- var LINE_JOIN_STYLES = ['miter', 'round', 'bevel'];
693
+
694
+ var LINE_CAP_STYLES = ["butt", "round", "square"];
695
+ var LINE_JOIN_STYLES = ["miter", "round", "bevel"];
584
696
  var NORMAL_CLIP = {};
585
697
  var EO_CLIP = {};
586
698
  CanvasGraphics.prototype = {
587
- beginDrawing: function beginDrawing(_ref) {
588
- var transform = _ref.transform,
589
- viewport = _ref.viewport,
590
- transparency = _ref.transparency,
591
- _ref$background = _ref.background,
592
- background = _ref$background === undefined ? null : _ref$background;
593
-
699
+ beginDrawing({
700
+ transform,
701
+ viewport,
702
+ transparency = false,
703
+ background = null
704
+ }) {
594
705
  var width = this.ctx.canvas.width;
595
706
  var height = this.ctx.canvas.height;
596
707
  this.ctx.save();
597
- this.ctx.fillStyle = background || 'rgb(255, 255, 255)';
708
+ this.ctx.fillStyle = background || "rgb(255, 255, 255)";
598
709
  this.ctx.fillRect(0, 0, width, height);
599
710
  this.ctx.restore();
711
+
600
712
  if (transparency) {
601
- var transparentCanvas = this.cachedCanvases.getCanvas('transparent', width, height, true);
713
+ var transparentCanvas = this.cachedCanvases.getCanvas("transparent", width, height, true);
602
714
  this.compositeCtx = this.ctx;
603
715
  this.transparentCanvas = transparentCanvas.canvas;
604
716
  this.ctx = transparentCanvas.context;
605
717
  this.ctx.save();
606
718
  this.ctx.transform.apply(this.ctx, this.compositeCtx.mozCurrentTransform);
607
719
  }
720
+
608
721
  this.ctx.save();
609
722
  resetCtxToDefault(this.ctx);
723
+
610
724
  if (transform) {
611
725
  this.ctx.transform.apply(this.ctx, transform);
612
726
  }
727
+
613
728
  this.ctx.transform.apply(this.ctx, viewport.transform);
614
729
  this.baseTransform = this.ctx.mozCurrentTransform.slice();
730
+
615
731
  if (this.imageLayer) {
616
732
  this.imageLayer.beginLayout();
617
733
  }
@@ -622,44 +738,51 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
622
738
  var fnArray = operatorList.fnArray;
623
739
  var i = executionStartIdx || 0;
624
740
  var argsArrayLen = argsArray.length;
741
+
625
742
  if (argsArrayLen === i) {
626
743
  return i;
627
744
  }
628
- var chunkOperations = argsArrayLen - i > EXECUTION_STEPS && typeof continueCallback === 'function';
745
+
746
+ var chunkOperations = argsArrayLen - i > EXECUTION_STEPS && typeof continueCallback === "function";
629
747
  var endTime = chunkOperations ? Date.now() + EXECUTION_TIME : 0;
630
748
  var steps = 0;
631
749
  var commonObjs = this.commonObjs;
632
750
  var objs = this.objs;
633
751
  var fnId;
752
+
634
753
  while (true) {
635
754
  if (stepper !== undefined && i === stepper.nextBreakPoint) {
636
755
  stepper.breakIt(i, continueCallback);
637
756
  return i;
638
757
  }
758
+
639
759
  fnId = fnArray[i];
760
+
640
761
  if (fnId !== _util.OPS.dependency) {
641
762
  this[fnId].apply(this, argsArray[i]);
642
763
  } else {
643
- var deps = argsArray[i];
644
- for (var n = 0, nn = deps.length; n < nn; n++) {
645
- var depObjId = deps[n];
646
- var common = depObjId[0] === 'g' && depObjId[1] === '_';
647
- var objsPool = common ? commonObjs : objs;
648
- if (!objsPool.isResolved(depObjId)) {
764
+ for (const depObjId of argsArray[i]) {
765
+ const objsPool = depObjId.startsWith("g_") ? commonObjs : objs;
766
+
767
+ if (!objsPool.has(depObjId)) {
649
768
  objsPool.get(depObjId, continueCallback);
650
769
  return i;
651
770
  }
652
771
  }
653
772
  }
773
+
654
774
  i++;
775
+
655
776
  if (i === argsArrayLen) {
656
777
  return i;
657
778
  }
779
+
658
780
  if (chunkOperations && ++steps > EXECUTION_STEPS) {
659
781
  if (Date.now() > endTime) {
660
782
  continueCallback();
661
783
  return i;
662
784
  }
785
+
663
786
  steps = 0;
664
787
  }
665
788
  }
@@ -668,7 +791,9 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
668
791
  if (this.current.activeSMask !== null) {
669
792
  this.endSMaskGroup();
670
793
  }
794
+
671
795
  this.ctx.restore();
796
+
672
797
  if (this.transparentCanvas) {
673
798
  this.ctx = this.compositeCtx;
674
799
  this.ctx.save();
@@ -677,8 +802,10 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
677
802
  this.ctx.restore();
678
803
  this.transparentCanvas = null;
679
804
  }
805
+
680
806
  this.cachedCanvases.clear();
681
807
  this.webGLContext.clear();
808
+
682
809
  if (this.imageLayer) {
683
810
  this.imageLayer.endLayout();
684
811
  }
@@ -698,54 +825,70 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
698
825
  },
699
826
  setDash: function CanvasGraphics_setDash(dashArray, dashPhase) {
700
827
  var ctx = this.ctx;
828
+
701
829
  if (ctx.setLineDash !== undefined) {
702
830
  ctx.setLineDash(dashArray);
703
831
  ctx.lineDashOffset = dashPhase;
704
832
  }
705
833
  },
706
- setRenderingIntent: function CanvasGraphics_setRenderingIntent(intent) {},
707
- setFlatness: function CanvasGraphics_setFlatness(flatness) {},
834
+
835
+ setRenderingIntent(intent) {},
836
+
837
+ setFlatness(flatness) {},
838
+
708
839
  setGState: function CanvasGraphics_setGState(states) {
709
840
  for (var i = 0, ii = states.length; i < ii; i++) {
710
841
  var state = states[i];
711
842
  var key = state[0];
712
843
  var value = state[1];
844
+
713
845
  switch (key) {
714
- case 'LW':
846
+ case "LW":
715
847
  this.setLineWidth(value);
716
848
  break;
717
- case 'LC':
849
+
850
+ case "LC":
718
851
  this.setLineCap(value);
719
852
  break;
720
- case 'LJ':
853
+
854
+ case "LJ":
721
855
  this.setLineJoin(value);
722
856
  break;
723
- case 'ML':
857
+
858
+ case "ML":
724
859
  this.setMiterLimit(value);
725
860
  break;
726
- case 'D':
861
+
862
+ case "D":
727
863
  this.setDash(value[0], value[1]);
728
864
  break;
729
- case 'RI':
865
+
866
+ case "RI":
730
867
  this.setRenderingIntent(value);
731
868
  break;
732
- case 'FL':
869
+
870
+ case "FL":
733
871
  this.setFlatness(value);
734
872
  break;
735
- case 'Font':
873
+
874
+ case "Font":
736
875
  this.setFont(value[0], value[1]);
737
876
  break;
738
- case 'CA':
877
+
878
+ case "CA":
739
879
  this.current.strokeAlpha = state[1];
740
880
  break;
741
- case 'ca':
881
+
882
+ case "ca":
742
883
  this.current.fillAlpha = state[1];
743
884
  this.ctx.globalAlpha = state[1];
744
885
  break;
745
- case 'BM':
886
+
887
+ case "BM":
746
888
  this.ctx.globalCompositeOperation = value;
747
889
  break;
748
- case 'SMask':
890
+
891
+ case "SMask":
749
892
  if (this.current.activeSMask) {
750
893
  if (this.stateStack.length > 0 && this.stateStack[this.stateStack.length - 1].activeSMask === this.current.activeSMask) {
751
894
  this.suspendSMaskGroup();
@@ -753,10 +896,13 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
753
896
  this.endSMaskGroup();
754
897
  }
755
898
  }
899
+
756
900
  this.current.activeSMask = value ? this.tempSMask : null;
901
+
757
902
  if (this.current.activeSMask) {
758
903
  this.beginSMaskGroup();
759
904
  }
905
+
760
906
  this.tempSMask = null;
761
907
  break;
762
908
  }
@@ -766,7 +912,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
766
912
  var activeSMask = this.current.activeSMask;
767
913
  var drawnWidth = activeSMask.canvas.width;
768
914
  var drawnHeight = activeSMask.canvas.height;
769
- var cacheId = 'smaskGroupAt' + this.groupLevel;
915
+ var cacheId = "smaskGroupAt" + this.groupLevel;
770
916
  var scratchCanvas = this.cachedCanvases.getCanvas(cacheId, drawnWidth, drawnHeight, true);
771
917
  var currentCtx = this.ctx;
772
918
  var currentTransform = currentCtx.mozCurrentTransform;
@@ -778,7 +924,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
778
924
  activeSMask.startTransformInverse = groupCtx.mozCurrentTransformInverse;
779
925
  copyCtxState(currentCtx, groupCtx);
780
926
  this.ctx = groupCtx;
781
- this.setGState([['BM', 'source-over'], ['ca', 1], ['CA', 1]]);
927
+ this.setGState([["BM", "source-over"], ["ca", 1], ["CA", 1]]);
782
928
  this.groupStack.push(currentCtx);
783
929
  this.groupLevel++;
784
930
  },
@@ -791,7 +937,9 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
791
937
  this.ctx.save();
792
938
  copyCtxState(groupCtx, this.ctx);
793
939
  this.current.resumeSMaskCtx = groupCtx;
940
+
794
941
  var deltaTransform = _util.Util.transform(this.current.activeSMask.startTransformInverse, groupCtx.mozCurrentTransform);
942
+
795
943
  this.ctx.transform.apply(this.ctx, deltaTransform);
796
944
  groupCtx.save();
797
945
  groupCtx.setTransform(1, 0, 0, 1, 0, 0);
@@ -812,7 +960,9 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
812
960
  composeSMask(this.ctx, this.current.activeSMask, groupCtx, this.webGLContext);
813
961
  this.ctx.restore();
814
962
  copyCtxState(groupCtx, this.ctx);
963
+
815
964
  var deltaTransform = _util.Util.transform(this.current.activeSMask.startTransformInverse, groupCtx.mozCurrentTransform);
965
+
816
966
  this.ctx.transform.apply(this.ctx, deltaTransform);
817
967
  },
818
968
  save: function CanvasGraphics_save() {
@@ -826,9 +976,11 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
826
976
  if (this.current.resumeSMaskCtx) {
827
977
  this.resumeSMaskGroup();
828
978
  }
979
+
829
980
  if (this.current.activeSMask !== null && (this.stateStack.length === 0 || this.stateStack[this.stateStack.length - 1].activeSMask !== this.current.activeSMask)) {
830
981
  this.endSMaskGroup();
831
982
  }
983
+
832
984
  if (this.stateStack.length !== 0) {
833
985
  this.current = this.stateStack.pop();
834
986
  this.ctx.restore();
@@ -845,6 +997,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
845
997
  var current = this.current;
846
998
  var x = current.x,
847
999
  y = current.y;
1000
+
848
1001
  for (var i = 0, j = 0, ii = ops.length; i < ii; i++) {
849
1002
  switch (ops[i] | 0) {
850
1003
  case _util.OPS.rectangle:
@@ -852,12 +1005,15 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
852
1005
  y = args[j++];
853
1006
  var width = args[j++];
854
1007
  var height = args[j++];
1008
+
855
1009
  if (width === 0) {
856
1010
  width = this.getSinglePixelWidth();
857
1011
  }
1012
+
858
1013
  if (height === 0) {
859
1014
  height = this.getSinglePixelWidth();
860
1015
  }
1016
+
861
1017
  var xw = x + width;
862
1018
  var yh = y + height;
863
1019
  this.ctx.moveTo(x, y);
@@ -867,61 +1023,76 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
867
1023
  this.ctx.lineTo(x, y);
868
1024
  this.ctx.closePath();
869
1025
  break;
1026
+
870
1027
  case _util.OPS.moveTo:
871
1028
  x = args[j++];
872
1029
  y = args[j++];
873
1030
  ctx.moveTo(x, y);
874
1031
  break;
1032
+
875
1033
  case _util.OPS.lineTo:
876
1034
  x = args[j++];
877
1035
  y = args[j++];
878
1036
  ctx.lineTo(x, y);
879
1037
  break;
1038
+
880
1039
  case _util.OPS.curveTo:
881
1040
  x = args[j + 4];
882
1041
  y = args[j + 5];
883
1042
  ctx.bezierCurveTo(args[j], args[j + 1], args[j + 2], args[j + 3], x, y);
884
1043
  j += 6;
885
1044
  break;
1045
+
886
1046
  case _util.OPS.curveTo2:
887
1047
  ctx.bezierCurveTo(x, y, args[j], args[j + 1], args[j + 2], args[j + 3]);
888
1048
  x = args[j + 2];
889
1049
  y = args[j + 3];
890
1050
  j += 4;
891
1051
  break;
1052
+
892
1053
  case _util.OPS.curveTo3:
893
1054
  x = args[j + 2];
894
1055
  y = args[j + 3];
895
1056
  ctx.bezierCurveTo(args[j], args[j + 1], x, y, x, y);
896
1057
  j += 4;
897
1058
  break;
1059
+
898
1060
  case _util.OPS.closePath:
899
1061
  ctx.closePath();
900
1062
  break;
901
1063
  }
902
1064
  }
1065
+
903
1066
  current.setCurrentPoint(x, y);
904
1067
  },
905
1068
  closePath: function CanvasGraphics_closePath() {
906
1069
  this.ctx.closePath();
907
1070
  },
908
1071
  stroke: function CanvasGraphics_stroke(consumePath) {
909
- consumePath = typeof consumePath !== 'undefined' ? consumePath : true;
1072
+ consumePath = typeof consumePath !== "undefined" ? consumePath : true;
910
1073
  var ctx = this.ctx;
911
1074
  var strokeColor = this.current.strokeColor;
912
- ctx.lineWidth = Math.max(this.getSinglePixelWidth() * MIN_WIDTH_FACTOR, this.current.lineWidth);
913
1075
  ctx.globalAlpha = this.current.strokeAlpha;
914
- if (strokeColor && strokeColor.hasOwnProperty('type') && strokeColor.type === 'Pattern') {
1076
+
1077
+ if (strokeColor && strokeColor.hasOwnProperty("type") && strokeColor.type === "Pattern") {
915
1078
  ctx.save();
1079
+ const transform = ctx.mozCurrentTransform;
1080
+
1081
+ const scale = _util.Util.singularValueDecompose2dScale(transform)[0];
1082
+
916
1083
  ctx.strokeStyle = strokeColor.getPattern(ctx, this);
1084
+ ctx.lineWidth = Math.max(this.getSinglePixelWidth() * MIN_WIDTH_FACTOR, this.current.lineWidth * scale);
917
1085
  ctx.stroke();
918
1086
  ctx.restore();
919
1087
  } else {
1088
+ ctx.lineWidth = Math.max(this.getSinglePixelWidth() * MIN_WIDTH_FACTOR, this.current.lineWidth);
920
1089
  ctx.stroke();
921
1090
  }
1091
+
922
1092
  if (consumePath) {
923
1093
  this.consumePath();
924
1094
  }
1095
+
925
1096
  ctx.globalAlpha = this.current.fillAlpha;
926
1097
  },
927
1098
  closeStroke: function CanvasGraphics_closeStroke() {
@@ -929,28 +1100,34 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
929
1100
  this.stroke();
930
1101
  },
931
1102
  fill: function CanvasGraphics_fill(consumePath) {
932
- consumePath = typeof consumePath !== 'undefined' ? consumePath : true;
1103
+ consumePath = typeof consumePath !== "undefined" ? consumePath : true;
933
1104
  var ctx = this.ctx;
934
1105
  var fillColor = this.current.fillColor;
935
1106
  var isPatternFill = this.current.patternFill;
936
1107
  var needRestore = false;
1108
+
937
1109
  if (isPatternFill) {
938
1110
  ctx.save();
1111
+
939
1112
  if (this.baseTransform) {
940
1113
  ctx.setTransform.apply(ctx, this.baseTransform);
941
1114
  }
1115
+
942
1116
  ctx.fillStyle = fillColor.getPattern(ctx, this);
943
1117
  needRestore = true;
944
1118
  }
1119
+
945
1120
  if (this.pendingEOFill) {
946
- ctx.fill('evenodd');
1121
+ ctx.fill("evenodd");
947
1122
  this.pendingEOFill = false;
948
1123
  } else {
949
1124
  ctx.fill();
950
1125
  }
1126
+
951
1127
  if (needRestore) {
952
1128
  ctx.restore();
953
1129
  }
1130
+
954
1131
  if (consumePath) {
955
1132
  this.consumePath();
956
1133
  }
@@ -995,18 +1172,22 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
995
1172
  endText: function CanvasGraphics_endText() {
996
1173
  var paths = this.pendingTextPaths;
997
1174
  var ctx = this.ctx;
1175
+
998
1176
  if (paths === undefined) {
999
1177
  ctx.beginPath();
1000
1178
  return;
1001
1179
  }
1180
+
1002
1181
  ctx.save();
1003
1182
  ctx.beginPath();
1183
+
1004
1184
  for (var i = 0; i < paths.length; i++) {
1005
1185
  var path = paths[i];
1006
1186
  ctx.setTransform.apply(ctx, path.transform);
1007
1187
  ctx.translate(path.x, path.y);
1008
1188
  path.addToPath(ctx, path.fontSize);
1009
1189
  }
1190
+
1010
1191
  ctx.restore();
1011
1192
  ctx.clip();
1012
1193
  ctx.beginPath();
@@ -1027,32 +1208,52 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
1027
1208
  setFont: function CanvasGraphics_setFont(fontRefName, size) {
1028
1209
  var fontObj = this.commonObjs.get(fontRefName);
1029
1210
  var current = this.current;
1211
+
1030
1212
  if (!fontObj) {
1031
- throw new Error('Can\'t find font for ' + fontRefName);
1213
+ throw new Error(`Can't find font for ${fontRefName}`);
1032
1214
  }
1215
+
1033
1216
  current.fontMatrix = fontObj.fontMatrix ? fontObj.fontMatrix : _util.FONT_IDENTITY_MATRIX;
1217
+
1034
1218
  if (current.fontMatrix[0] === 0 || current.fontMatrix[3] === 0) {
1035
- (0, _util.warn)('Invalid font matrix for font ' + fontRefName);
1219
+ (0, _util.warn)("Invalid font matrix for font " + fontRefName);
1036
1220
  }
1221
+
1037
1222
  if (size < 0) {
1038
1223
  size = -size;
1039
1224
  current.fontDirection = -1;
1040
1225
  } else {
1041
1226
  current.fontDirection = 1;
1042
1227
  }
1228
+
1043
1229
  this.current.font = fontObj;
1044
1230
  this.current.fontSize = size;
1231
+
1045
1232
  if (fontObj.isType3Font) {
1046
1233
  return;
1047
1234
  }
1048
- var name = fontObj.loadedName || 'sans-serif';
1049
- var bold = fontObj.black ? '900' : fontObj.bold ? 'bold' : 'normal';
1050
- var italic = fontObj.italic ? 'italic' : 'normal';
1051
- var typeface = '"' + name + '", ' + fontObj.fallbackName;
1052
- var browserFontSize = size < MIN_FONT_SIZE ? MIN_FONT_SIZE : size > MAX_FONT_SIZE ? MAX_FONT_SIZE : size;
1235
+
1236
+ var name = fontObj.loadedName || "sans-serif";
1237
+ let bold = "normal";
1238
+
1239
+ if (fontObj.black) {
1240
+ bold = "900";
1241
+ } else if (fontObj.bold) {
1242
+ bold = "bold";
1243
+ }
1244
+
1245
+ var italic = fontObj.italic ? "italic" : "normal";
1246
+ var typeface = `"${name}", ${fontObj.fallbackName}`;
1247
+ let browserFontSize = size;
1248
+
1249
+ if (size < MIN_FONT_SIZE) {
1250
+ browserFontSize = MIN_FONT_SIZE;
1251
+ } else if (size > MAX_FONT_SIZE) {
1252
+ browserFontSize = MAX_FONT_SIZE;
1253
+ }
1254
+
1053
1255
  this.current.fontSizeScale = size / browserFontSize;
1054
- var rule = italic + ' ' + bold + ' ' + browserFontSize + 'px ' + typeface;
1055
- this.ctx.font = rule;
1256
+ this.ctx.font = `${italic} ${bold} ${browserFontSize}px ${typeface}`;
1056
1257
  },
1057
1258
  setTextRenderingMode: function CanvasGraphics_setTextRenderingMode(mode) {
1058
1259
  this.current.textRenderingMode = mode;
@@ -1077,7 +1278,8 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
1077
1278
  nextLine: function CanvasGraphics_nextLine() {
1078
1279
  this.moveText(0, this.current.leading);
1079
1280
  },
1080
- paintChar: function paintChar(character, x, y, patternTransform) {
1281
+
1282
+ paintChar(character, x, y, patternTransform) {
1081
1283
  var ctx = this.ctx;
1082
1284
  var current = this.current;
1083
1285
  var font = current.font;
@@ -1085,70 +1287,87 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
1085
1287
  var fontSize = current.fontSize / current.fontSizeScale;
1086
1288
  var fillStrokeMode = textRenderingMode & _util.TextRenderingMode.FILL_STROKE_MASK;
1087
1289
  var isAddToPathSet = !!(textRenderingMode & _util.TextRenderingMode.ADD_TO_PATH_FLAG);
1088
- var patternFill = current.patternFill && font.data;
1290
+ const patternFill = current.patternFill && font.data;
1089
1291
  var addToPath;
1292
+
1090
1293
  if (font.disableFontFace || isAddToPathSet || patternFill) {
1091
1294
  addToPath = font.getPathGenerator(this.commonObjs, character);
1092
1295
  }
1296
+
1093
1297
  if (font.disableFontFace || patternFill) {
1094
1298
  ctx.save();
1095
1299
  ctx.translate(x, y);
1096
1300
  ctx.beginPath();
1097
1301
  addToPath(ctx, fontSize);
1302
+
1098
1303
  if (patternTransform) {
1099
1304
  ctx.setTransform.apply(ctx, patternTransform);
1100
1305
  }
1306
+
1101
1307
  if (fillStrokeMode === _util.TextRenderingMode.FILL || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) {
1102
1308
  ctx.fill();
1103
1309
  }
1310
+
1104
1311
  if (fillStrokeMode === _util.TextRenderingMode.STROKE || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) {
1105
1312
  ctx.stroke();
1106
1313
  }
1314
+
1107
1315
  ctx.restore();
1108
1316
  } else {
1109
1317
  if (fillStrokeMode === _util.TextRenderingMode.FILL || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) {
1110
1318
  ctx.fillText(character, x, y);
1111
1319
  }
1320
+
1112
1321
  if (fillStrokeMode === _util.TextRenderingMode.STROKE || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) {
1113
1322
  ctx.strokeText(character, x, y);
1114
1323
  }
1115
1324
  }
1325
+
1116
1326
  if (isAddToPathSet) {
1117
1327
  var paths = this.pendingTextPaths || (this.pendingTextPaths = []);
1118
1328
  paths.push({
1119
1329
  transform: ctx.mozCurrentTransform,
1120
- x: x,
1121
- y: y,
1122
- fontSize: fontSize,
1123
- addToPath: addToPath
1330
+ x,
1331
+ y,
1332
+ fontSize,
1333
+ addToPath
1124
1334
  });
1125
1335
  }
1126
1336
  },
1127
1337
 
1128
1338
  get isFontSubpixelAAEnabled() {
1129
- var ctx = this.canvasFactory.create(10, 10).context;
1339
+ const {
1340
+ context: ctx
1341
+ } = this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled", 10, 10);
1130
1342
  ctx.scale(1.5, 1);
1131
- ctx.fillText('I', 0, 10);
1343
+ ctx.fillText("I", 0, 10);
1132
1344
  var data = ctx.getImageData(0, 0, 10, 10).data;
1133
1345
  var enabled = false;
1346
+
1134
1347
  for (var i = 3; i < data.length; i += 4) {
1135
1348
  if (data[i] > 0 && data[i] < 255) {
1136
1349
  enabled = true;
1137
1350
  break;
1138
1351
  }
1139
1352
  }
1140
- return (0, _util.shadow)(this, 'isFontSubpixelAAEnabled', enabled);
1353
+
1354
+ return (0, _util.shadow)(this, "isFontSubpixelAAEnabled", enabled);
1141
1355
  },
1356
+
1142
1357
  showText: function CanvasGraphics_showText(glyphs) {
1143
1358
  var current = this.current;
1144
1359
  var font = current.font;
1360
+
1145
1361
  if (font.isType3Font) {
1146
1362
  return this.showType3Text(glyphs);
1147
1363
  }
1364
+
1148
1365
  var fontSize = current.fontSize;
1366
+
1149
1367
  if (fontSize === 0) {
1150
- return;
1368
+ return undefined;
1151
1369
  }
1370
+
1152
1371
  var ctx = this.ctx;
1153
1372
  var fontSizeScale = current.fontSizeScale;
1154
1373
  var charSpacing = current.charSpacing;
@@ -1162,25 +1381,31 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
1162
1381
  var widthAdvanceScale = fontSize * current.fontMatrix[0];
1163
1382
  var simpleFillText = current.textRenderingMode === _util.TextRenderingMode.FILL && !font.disableFontFace && !current.patternFill;
1164
1383
  ctx.save();
1165
- var patternTransform = void 0;
1384
+ let patternTransform;
1385
+
1166
1386
  if (current.patternFill) {
1167
1387
  ctx.save();
1168
- var pattern = current.fillColor.getPattern(ctx, this);
1388
+ const pattern = current.fillColor.getPattern(ctx, this);
1169
1389
  patternTransform = ctx.mozCurrentTransform;
1170
1390
  ctx.restore();
1171
1391
  ctx.fillStyle = pattern;
1172
1392
  }
1393
+
1173
1394
  ctx.transform.apply(ctx, current.textMatrix);
1174
1395
  ctx.translate(current.x, current.y + current.textRise);
1396
+
1175
1397
  if (fontDirection > 0) {
1176
1398
  ctx.scale(textHScale, -1);
1177
1399
  } else {
1178
1400
  ctx.scale(textHScale, 1);
1179
1401
  }
1402
+
1180
1403
  var lineWidth = current.lineWidth;
1181
1404
  var scale = current.textMatrixScale;
1405
+
1182
1406
  if (scale === 0 || lineWidth === 0) {
1183
1407
  var fillStrokeMode = current.textRenderingMode & _util.TextRenderingMode.FILL_STROKE_MASK;
1408
+
1184
1409
  if (fillStrokeMode === _util.TextRenderingMode.STROKE || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) {
1185
1410
  this._cachedGetSinglePixelWidth = null;
1186
1411
  lineWidth = this.getSinglePixelWidth() * MIN_WIDTH_FACTOR;
@@ -1188,25 +1413,31 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
1188
1413
  } else {
1189
1414
  lineWidth /= scale;
1190
1415
  }
1416
+
1191
1417
  if (fontSizeScale !== 1.0) {
1192
1418
  ctx.scale(fontSizeScale, fontSizeScale);
1193
1419
  lineWidth /= fontSizeScale;
1194
1420
  }
1421
+
1195
1422
  ctx.lineWidth = lineWidth;
1196
1423
  var x = 0,
1197
1424
  i;
1425
+
1198
1426
  for (i = 0; i < glyphsLength; ++i) {
1199
1427
  var glyph = glyphs[i];
1428
+
1200
1429
  if ((0, _util.isNum)(glyph)) {
1201
1430
  x += spacingDir * glyph * fontSize / 1000;
1202
1431
  continue;
1203
1432
  }
1433
+
1204
1434
  var restoreNeeded = false;
1205
1435
  var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
1206
1436
  var character = glyph.fontChar;
1207
1437
  var accent = glyph.accent;
1208
1438
  var scaledX, scaledY, scaledAccentX, scaledAccentY;
1209
1439
  var width = glyph.width;
1440
+
1210
1441
  if (vertical) {
1211
1442
  var vmetric, vx, vy;
1212
1443
  vmetric = glyph.vmetric || defaultVMetrics;
@@ -1220,8 +1451,10 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
1220
1451
  scaledX = x / fontSizeScale;
1221
1452
  scaledY = 0;
1222
1453
  }
1454
+
1223
1455
  if (font.remeasure && width > 0) {
1224
1456
  var measuredWidth = ctx.measureText(character).width * 1000 / fontSize * fontSizeScale;
1457
+
1225
1458
  if (width < measuredWidth && this.isFontSubpixelAAEnabled) {
1226
1459
  var characterScaleX = width / measuredWidth;
1227
1460
  restoreNeeded = true;
@@ -1232,11 +1465,13 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
1232
1465
  scaledX += (width - measuredWidth) / 2000 * fontSize / fontSizeScale;
1233
1466
  }
1234
1467
  }
1468
+
1235
1469
  if (glyph.isInFont || font.missingFile) {
1236
1470
  if (simpleFillText && !accent) {
1237
1471
  ctx.fillText(character, scaledX, scaledY);
1238
1472
  } else {
1239
1473
  this.paintChar(character, scaledX, scaledY, patternTransform);
1474
+
1240
1475
  if (accent) {
1241
1476
  scaledAccentX = scaledX + accent.offset.x / fontSizeScale;
1242
1477
  scaledAccentY = scaledY - accent.offset.y / fontSizeScale;
@@ -1244,17 +1479,28 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
1244
1479
  }
1245
1480
  }
1246
1481
  }
1247
- var charWidth = width * widthAdvanceScale + spacing * fontDirection;
1482
+
1483
+ var charWidth;
1484
+
1485
+ if (vertical) {
1486
+ charWidth = width * widthAdvanceScale - spacing * fontDirection;
1487
+ } else {
1488
+ charWidth = width * widthAdvanceScale + spacing * fontDirection;
1489
+ }
1490
+
1248
1491
  x += charWidth;
1492
+
1249
1493
  if (restoreNeeded) {
1250
1494
  ctx.restore();
1251
1495
  }
1252
1496
  }
1497
+
1253
1498
  if (vertical) {
1254
- current.y -= x * textHScale;
1499
+ current.y -= x;
1255
1500
  } else {
1256
1501
  current.x += x * textHScale;
1257
1502
  }
1503
+
1258
1504
  ctx.restore();
1259
1505
  },
1260
1506
  showType3Text: function CanvasGraphics_showType3Text(glyphs) {
@@ -1271,39 +1517,49 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
1271
1517
  var glyphsLength = glyphs.length;
1272
1518
  var isTextInvisible = current.textRenderingMode === _util.TextRenderingMode.INVISIBLE;
1273
1519
  var i, glyph, width, spacingLength;
1520
+
1274
1521
  if (isTextInvisible || fontSize === 0) {
1275
1522
  return;
1276
1523
  }
1524
+
1277
1525
  this._cachedGetSinglePixelWidth = null;
1278
1526
  ctx.save();
1279
1527
  ctx.transform.apply(ctx, current.textMatrix);
1280
1528
  ctx.translate(current.x, current.y);
1281
1529
  ctx.scale(textHScale, fontDirection);
1530
+
1282
1531
  for (i = 0; i < glyphsLength; ++i) {
1283
1532
  glyph = glyphs[i];
1533
+
1284
1534
  if ((0, _util.isNum)(glyph)) {
1285
1535
  spacingLength = spacingDir * glyph * fontSize / 1000;
1286
1536
  this.ctx.translate(spacingLength, 0);
1287
1537
  current.x += spacingLength * textHScale;
1288
1538
  continue;
1289
1539
  }
1540
+
1290
1541
  var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
1291
1542
  var operatorList = font.charProcOperatorList[glyph.operatorListId];
1543
+
1292
1544
  if (!operatorList) {
1293
- (0, _util.warn)('Type3 character "' + glyph.operatorListId + '" is not available.');
1545
+ (0, _util.warn)(`Type3 character "${glyph.operatorListId}" is not available.`);
1294
1546
  continue;
1295
1547
  }
1548
+
1296
1549
  this.processingType3 = glyph;
1297
1550
  this.save();
1298
1551
  ctx.scale(fontSize, fontSize);
1299
1552
  ctx.transform.apply(ctx, fontMatrix);
1300
1553
  this.executeOperatorList(operatorList);
1301
1554
  this.restore();
1555
+
1302
1556
  var transformed = _util.Util.applyTransform([glyph.width, 0], fontMatrix);
1557
+
1303
1558
  width = transformed[0] * fontSize + spacing;
1304
1559
  ctx.translate(width, 0);
1305
1560
  current.x += width * textHScale;
1306
1561
  }
1562
+
1307
1563
  ctx.restore();
1308
1564
  this.processingType3 = null;
1309
1565
  },
@@ -1314,21 +1570,21 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
1314
1570
  this.endPath();
1315
1571
  },
1316
1572
  getColorN_Pattern: function CanvasGraphics_getColorN_Pattern(IR) {
1317
- var _this = this;
1318
-
1319
1573
  var pattern;
1320
- if (IR[0] === 'TilingPattern') {
1574
+
1575
+ if (IR[0] === "TilingPattern") {
1321
1576
  var color = IR[1];
1322
1577
  var baseTransform = this.baseTransform || this.ctx.mozCurrentTransform.slice();
1323
1578
  var canvasGraphicsFactory = {
1324
- createCanvasGraphics: function createCanvasGraphics(ctx) {
1325
- return new CanvasGraphics(ctx, _this.commonObjs, _this.objs, _this.canvasFactory, _this.webGLContext);
1579
+ createCanvasGraphics: ctx => {
1580
+ return new CanvasGraphics(ctx, this.commonObjs, this.objs, this.canvasFactory, this.webGLContext);
1326
1581
  }
1327
1582
  };
1328
1583
  pattern = new _pattern_helper.TilingPattern(IR, color, this.ctx, canvasGraphicsFactory, baseTransform);
1329
1584
  } else {
1330
1585
  pattern = (0, _pattern_helper.getShadingPatternFromIR)(IR);
1331
1586
  }
1587
+
1332
1588
  return pattern;
1333
1589
  },
1334
1590
  setStrokeColorN: function CanvasGraphics_setStrokeColorN() {
@@ -1340,11 +1596,13 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
1340
1596
  },
1341
1597
  setStrokeRGBColor: function CanvasGraphics_setStrokeRGBColor(r, g, b) {
1342
1598
  var color = _util.Util.makeCssRgb(r, g, b);
1599
+
1343
1600
  this.ctx.strokeStyle = color;
1344
1601
  this.current.strokeColor = color;
1345
1602
  },
1346
1603
  setFillRGBColor: function CanvasGraphics_setFillRGBColor(r, g, b) {
1347
1604
  var color = _util.Util.makeCssRgb(r, g, b);
1605
+
1348
1606
  this.ctx.fillStyle = color;
1349
1607
  this.current.fillColor = color;
1350
1608
  this.current.patternFill = false;
@@ -1355,14 +1613,20 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
1355
1613
  var pattern = (0, _pattern_helper.getShadingPatternFromIR)(patternIR);
1356
1614
  ctx.fillStyle = pattern.getPattern(ctx, this, true);
1357
1615
  var inv = ctx.mozCurrentTransformInverse;
1616
+
1358
1617
  if (inv) {
1359
1618
  var canvas = ctx.canvas;
1360
1619
  var width = canvas.width;
1361
1620
  var height = canvas.height;
1621
+
1362
1622
  var bl = _util.Util.applyTransform([0, 0], inv);
1623
+
1363
1624
  var br = _util.Util.applyTransform([0, height], inv);
1625
+
1364
1626
  var ul = _util.Util.applyTransform([width, 0], inv);
1627
+
1365
1628
  var ur = _util.Util.applyTransform([width, height], inv);
1629
+
1366
1630
  var x0 = Math.min(bl[0], br[0], ul[0], ur[0]);
1367
1631
  var y0 = Math.min(bl[1], br[1], ul[1], ur[1]);
1368
1632
  var x1 = Math.max(bl[0], br[0], ul[0], ur[0]);
@@ -1371,22 +1635,26 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
1371
1635
  } else {
1372
1636
  this.ctx.fillRect(-1e10, -1e10, 2e10, 2e10);
1373
1637
  }
1638
+
1374
1639
  this.restore();
1375
1640
  },
1376
1641
  beginInlineImage: function CanvasGraphics_beginInlineImage() {
1377
- (0, _util.unreachable)('Should not call beginInlineImage');
1642
+ (0, _util.unreachable)("Should not call beginInlineImage");
1378
1643
  },
1379
1644
  beginImageData: function CanvasGraphics_beginImageData() {
1380
- (0, _util.unreachable)('Should not call beginImageData');
1645
+ (0, _util.unreachable)("Should not call beginImageData");
1381
1646
  },
1382
1647
  paintFormXObjectBegin: function CanvasGraphics_paintFormXObjectBegin(matrix, bbox) {
1383
1648
  this.save();
1384
1649
  this.baseTransformStack.push(this.baseTransform);
1650
+
1385
1651
  if (Array.isArray(matrix) && matrix.length === 6) {
1386
1652
  this.transform.apply(this, matrix);
1387
1653
  }
1654
+
1388
1655
  this.baseTransform = this.ctx.mozCurrentTransform;
1389
- if (Array.isArray(bbox) && bbox.length === 4) {
1656
+
1657
+ if (bbox) {
1390
1658
  var width = bbox[2] - bbox[0];
1391
1659
  var height = bbox[3] - bbox[1];
1392
1660
  this.ctx.rect(bbox[0], bbox[1], width, height);
@@ -1401,20 +1669,27 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
1401
1669
  beginGroup: function CanvasGraphics_beginGroup(group) {
1402
1670
  this.save();
1403
1671
  var currentCtx = this.ctx;
1672
+
1404
1673
  if (!group.isolated) {
1405
- (0, _util.info)('TODO: Support non-isolated groups.');
1674
+ (0, _util.info)("TODO: Support non-isolated groups.");
1406
1675
  }
1676
+
1407
1677
  if (group.knockout) {
1408
- (0, _util.warn)('Knockout groups not supported.');
1678
+ (0, _util.warn)("Knockout groups not supported.");
1409
1679
  }
1680
+
1410
1681
  var currentTransform = currentCtx.mozCurrentTransform;
1682
+
1411
1683
  if (group.matrix) {
1412
1684
  currentCtx.transform.apply(currentCtx, group.matrix);
1413
1685
  }
1686
+
1414
1687
  if (!group.bbox) {
1415
- throw new Error('Bounding box is required.');
1688
+ throw new Error("Bounding box is required.");
1416
1689
  }
1690
+
1417
1691
  var bounds = _util.Util.getAxialAlignedBoundingBox(group.bbox, currentCtx.mozCurrentTransform);
1692
+
1418
1693
  var canvasBounds = [0, 0, currentCtx.canvas.width, currentCtx.canvas.height];
1419
1694
  bounds = _util.Util.intersect(bounds, canvasBounds) || [0, 0, 0, 0];
1420
1695
  var offsetX = Math.floor(bounds[0]);
@@ -1423,31 +1698,37 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
1423
1698
  var drawnHeight = Math.max(Math.ceil(bounds[3]) - offsetY, 1);
1424
1699
  var scaleX = 1,
1425
1700
  scaleY = 1;
1701
+
1426
1702
  if (drawnWidth > MAX_GROUP_SIZE) {
1427
1703
  scaleX = drawnWidth / MAX_GROUP_SIZE;
1428
1704
  drawnWidth = MAX_GROUP_SIZE;
1429
1705
  }
1706
+
1430
1707
  if (drawnHeight > MAX_GROUP_SIZE) {
1431
1708
  scaleY = drawnHeight / MAX_GROUP_SIZE;
1432
1709
  drawnHeight = MAX_GROUP_SIZE;
1433
1710
  }
1434
- var cacheId = 'groupAt' + this.groupLevel;
1711
+
1712
+ var cacheId = "groupAt" + this.groupLevel;
1713
+
1435
1714
  if (group.smask) {
1436
- cacheId += '_smask_' + this.smaskCounter++ % 2;
1715
+ cacheId += "_smask_" + this.smaskCounter++ % 2;
1437
1716
  }
1717
+
1438
1718
  var scratchCanvas = this.cachedCanvases.getCanvas(cacheId, drawnWidth, drawnHeight, true);
1439
1719
  var groupCtx = scratchCanvas.context;
1440
1720
  groupCtx.scale(1 / scaleX, 1 / scaleY);
1441
1721
  groupCtx.translate(-offsetX, -offsetY);
1442
1722
  groupCtx.transform.apply(groupCtx, currentTransform);
1723
+
1443
1724
  if (group.smask) {
1444
1725
  this.smaskStack.push({
1445
1726
  canvas: scratchCanvas.canvas,
1446
1727
  context: groupCtx,
1447
- offsetX: offsetX,
1448
- offsetY: offsetY,
1449
- scaleX: scaleX,
1450
- scaleY: scaleY,
1728
+ offsetX,
1729
+ offsetY,
1730
+ scaleX,
1731
+ scaleY,
1451
1732
  subtype: group.smask.subtype,
1452
1733
  backdrop: group.smask.backdrop,
1453
1734
  transferMap: group.smask.transferMap || null,
@@ -1458,9 +1739,10 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
1458
1739
  currentCtx.translate(offsetX, offsetY);
1459
1740
  currentCtx.scale(scaleX, scaleY);
1460
1741
  }
1742
+
1461
1743
  copyCtxState(currentCtx, groupCtx);
1462
1744
  this.ctx = groupCtx;
1463
- this.setGState([['BM', 'source-over'], ['ca', 1], ['CA', 1]]);
1745
+ this.setGState([["BM", "source-over"], ["ca", 1], ["CA", 1]]);
1464
1746
  this.groupStack.push(currentCtx);
1465
1747
  this.groupLevel++;
1466
1748
  this.current.activeSMask = null;
@@ -1469,20 +1751,24 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
1469
1751
  this.groupLevel--;
1470
1752
  var groupCtx = this.ctx;
1471
1753
  this.ctx = this.groupStack.pop();
1754
+
1472
1755
  if (this.ctx.imageSmoothingEnabled !== undefined) {
1473
1756
  this.ctx.imageSmoothingEnabled = false;
1474
1757
  } else {
1475
1758
  this.ctx.mozImageSmoothingEnabled = false;
1476
1759
  }
1760
+
1477
1761
  if (group.smask) {
1478
1762
  this.tempSMask = this.smaskStack.pop();
1479
1763
  } else {
1480
1764
  this.ctx.drawImage(groupCtx.canvas, 0, 0);
1481
1765
  }
1766
+
1482
1767
  this.restore();
1483
1768
  },
1484
1769
  beginAnnotations: function CanvasGraphics_beginAnnotations() {
1485
1770
  this.save();
1771
+
1486
1772
  if (this.baseTransform) {
1487
1773
  this.ctx.setTransform.apply(this.ctx, this.baseTransform);
1488
1774
  }
@@ -1494,6 +1780,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
1494
1780
  this.save();
1495
1781
  resetCtxToDefault(this.ctx);
1496
1782
  this.current = new CanvasExtraState();
1783
+
1497
1784
  if (Array.isArray(rect) && rect.length === 4) {
1498
1785
  var width = rect[2] - rect[0];
1499
1786
  var height = rect[3] - rect[1];
@@ -1501,6 +1788,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
1501
1788
  this.clip();
1502
1789
  this.endPath();
1503
1790
  }
1791
+
1504
1792
  this.transform.apply(this, transform);
1505
1793
  this.transform.apply(this, matrix);
1506
1794
  },
@@ -1508,26 +1796,30 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
1508
1796
  this.restore();
1509
1797
  },
1510
1798
  paintJpegXObject: function CanvasGraphics_paintJpegXObject(objId, w, h) {
1511
- var domImage = this.objs.get(objId);
1799
+ const domImage = this.processingType3 ? this.commonObjs.get(objId) : this.objs.get(objId);
1800
+
1512
1801
  if (!domImage) {
1513
- (0, _util.warn)('Dependent image isn\'t ready yet');
1802
+ (0, _util.warn)("Dependent image isn't ready yet");
1514
1803
  return;
1515
1804
  }
1805
+
1516
1806
  this.save();
1517
1807
  var ctx = this.ctx;
1518
1808
  ctx.scale(1 / w, -1 / h);
1519
1809
  ctx.drawImage(domImage, 0, 0, domImage.width, domImage.height, 0, -h, w, h);
1810
+
1520
1811
  if (this.imageLayer) {
1521
1812
  var currentTransform = ctx.mozCurrentTransformInverse;
1522
1813
  var position = this.getCanvasPosition(0, 0);
1523
1814
  this.imageLayer.appendImage({
1524
- objId: objId,
1815
+ objId,
1525
1816
  left: position[0],
1526
1817
  top: position[1],
1527
1818
  width: w / currentTransform[0],
1528
1819
  height: h / currentTransform[3]
1529
1820
  });
1530
1821
  }
1822
+
1531
1823
  this.restore();
1532
1824
  },
1533
1825
  paintImageMaskXObject: function CanvasGraphics_paintImageMaskXObject(img) {
@@ -1537,26 +1829,29 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
1537
1829
  var fillColor = this.current.fillColor;
1538
1830
  var isPatternFill = this.current.patternFill;
1539
1831
  var glyph = this.processingType3;
1832
+
1540
1833
  if (COMPILE_TYPE3_GLYPHS && glyph && glyph.compiled === undefined) {
1541
1834
  if (width <= MAX_SIZE_TO_COMPILE && height <= MAX_SIZE_TO_COMPILE) {
1542
1835
  glyph.compiled = compileType3Glyph({
1543
1836
  data: img.data,
1544
- width: width,
1545
- height: height
1837
+ width,
1838
+ height
1546
1839
  });
1547
1840
  } else {
1548
1841
  glyph.compiled = null;
1549
1842
  }
1550
1843
  }
1844
+
1551
1845
  if (glyph && glyph.compiled) {
1552
1846
  glyph.compiled(ctx);
1553
1847
  return;
1554
1848
  }
1555
- var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height);
1849
+
1850
+ var maskCanvas = this.cachedCanvases.getCanvas("maskCanvas", width, height);
1556
1851
  var maskCtx = maskCanvas.context;
1557
1852
  maskCtx.save();
1558
1853
  putBinaryImageMask(maskCtx, img);
1559
- maskCtx.globalCompositeOperation = 'source-in';
1854
+ maskCtx.globalCompositeOperation = "source-in";
1560
1855
  maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
1561
1856
  maskCtx.fillRect(0, 0, width, height);
1562
1857
  maskCtx.restore();
@@ -1567,15 +1862,16 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
1567
1862
  var height = imgData.height;
1568
1863
  var fillColor = this.current.fillColor;
1569
1864
  var isPatternFill = this.current.patternFill;
1570
- var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height);
1865
+ var maskCanvas = this.cachedCanvases.getCanvas("maskCanvas", width, height);
1571
1866
  var maskCtx = maskCanvas.context;
1572
1867
  maskCtx.save();
1573
1868
  putBinaryImageMask(maskCtx, imgData);
1574
- maskCtx.globalCompositeOperation = 'source-in';
1869
+ maskCtx.globalCompositeOperation = "source-in";
1575
1870
  maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
1576
1871
  maskCtx.fillRect(0, 0, width, height);
1577
1872
  maskCtx.restore();
1578
1873
  var ctx = this.ctx;
1874
+
1579
1875
  for (var i = 0, ii = positions.length; i < ii; i += 2) {
1580
1876
  ctx.save();
1581
1877
  ctx.transform(scaleX, 0, 0, scaleY, positions[i], positions[i + 1]);
@@ -1588,15 +1884,16 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
1588
1884
  var ctx = this.ctx;
1589
1885
  var fillColor = this.current.fillColor;
1590
1886
  var isPatternFill = this.current.patternFill;
1887
+
1591
1888
  for (var i = 0, ii = images.length; i < ii; i++) {
1592
1889
  var image = images[i];
1593
1890
  var width = image.width,
1594
1891
  height = image.height;
1595
- var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height);
1892
+ var maskCanvas = this.cachedCanvases.getCanvas("maskCanvas", width, height);
1596
1893
  var maskCtx = maskCanvas.context;
1597
1894
  maskCtx.save();
1598
1895
  putBinaryImageMask(maskCtx, image);
1599
- maskCtx.globalCompositeOperation = 'source-in';
1896
+ maskCtx.globalCompositeOperation = "source-in";
1600
1897
  maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
1601
1898
  maskCtx.fillRect(0, 0, width, height);
1602
1899
  maskCtx.restore();
@@ -1608,22 +1905,27 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
1608
1905
  }
1609
1906
  },
1610
1907
  paintImageXObject: function CanvasGraphics_paintImageXObject(objId) {
1611
- var imgData = this.objs.get(objId);
1908
+ const imgData = this.processingType3 ? this.commonObjs.get(objId) : this.objs.get(objId);
1909
+
1612
1910
  if (!imgData) {
1613
- (0, _util.warn)('Dependent image isn\'t ready yet');
1911
+ (0, _util.warn)("Dependent image isn't ready yet");
1614
1912
  return;
1615
1913
  }
1914
+
1616
1915
  this.paintInlineImageXObject(imgData);
1617
1916
  },
1618
1917
  paintImageXObjectRepeat: function CanvasGraphics_paintImageXObjectRepeat(objId, scaleX, scaleY, positions) {
1619
- var imgData = this.objs.get(objId);
1918
+ const imgData = this.processingType3 ? this.commonObjs.get(objId) : this.objs.get(objId);
1919
+
1620
1920
  if (!imgData) {
1621
- (0, _util.warn)('Dependent image isn\'t ready yet');
1921
+ (0, _util.warn)("Dependent image isn't ready yet");
1622
1922
  return;
1623
1923
  }
1924
+
1624
1925
  var width = imgData.width;
1625
1926
  var height = imgData.height;
1626
1927
  var map = [];
1928
+
1627
1929
  for (var i = 0, ii = positions.length; i < ii; i += 2) {
1628
1930
  map.push({
1629
1931
  transform: [scaleX, 0, 0, scaleY, positions[i], positions[i + 1]],
@@ -1633,6 +1935,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
1633
1935
  h: height
1634
1936
  });
1635
1937
  }
1938
+
1636
1939
  this.paintInlineImageXObjectGroup(imgData, map);
1637
1940
  },
1638
1941
  paintInlineImageXObject: function CanvasGraphics_paintInlineImageXObject(imgData) {
@@ -1649,28 +1952,34 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
1649
1952
  d = currentTransform[3];
1650
1953
  var heightScale = Math.max(Math.sqrt(c * c + d * d), 1);
1651
1954
  var imgToPaint, tmpCanvas;
1652
- if (typeof HTMLElement === 'function' && imgData instanceof HTMLElement || !imgData.data) {
1955
+
1956
+ if (typeof HTMLElement === "function" && imgData instanceof HTMLElement || !imgData.data) {
1653
1957
  imgToPaint = imgData;
1654
1958
  } else {
1655
- tmpCanvas = this.cachedCanvases.getCanvas('inlineImage', width, height);
1959
+ tmpCanvas = this.cachedCanvases.getCanvas("inlineImage", width, height);
1656
1960
  var tmpCtx = tmpCanvas.context;
1657
1961
  putBinaryImageData(tmpCtx, imgData);
1658
1962
  imgToPaint = tmpCanvas.canvas;
1659
1963
  }
1964
+
1660
1965
  var paintWidth = width,
1661
1966
  paintHeight = height;
1662
- var tmpCanvasId = 'prescale1';
1967
+ var tmpCanvasId = "prescale1";
1968
+
1663
1969
  while (widthScale > 2 && paintWidth > 1 || heightScale > 2 && paintHeight > 1) {
1664
1970
  var newWidth = paintWidth,
1665
1971
  newHeight = paintHeight;
1972
+
1666
1973
  if (widthScale > 2 && paintWidth > 1) {
1667
1974
  newWidth = Math.ceil(paintWidth / 2);
1668
1975
  widthScale /= paintWidth / newWidth;
1669
1976
  }
1977
+
1670
1978
  if (heightScale > 2 && paintHeight > 1) {
1671
1979
  newHeight = Math.ceil(paintHeight / 2);
1672
1980
  heightScale /= paintHeight / newHeight;
1673
1981
  }
1982
+
1674
1983
  tmpCanvas = this.cachedCanvases.getCanvas(tmpCanvasId, newWidth, newHeight);
1675
1984
  tmpCtx = tmpCanvas.context;
1676
1985
  tmpCtx.clearRect(0, 0, newWidth, newHeight);
@@ -1678,44 +1987,50 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
1678
1987
  imgToPaint = tmpCanvas.canvas;
1679
1988
  paintWidth = newWidth;
1680
1989
  paintHeight = newHeight;
1681
- tmpCanvasId = tmpCanvasId === 'prescale1' ? 'prescale2' : 'prescale1';
1990
+ tmpCanvasId = tmpCanvasId === "prescale1" ? "prescale2" : "prescale1";
1682
1991
  }
1992
+
1683
1993
  ctx.drawImage(imgToPaint, 0, 0, paintWidth, paintHeight, 0, -height, width, height);
1994
+
1684
1995
  if (this.imageLayer) {
1685
1996
  var position = this.getCanvasPosition(0, -height);
1686
1997
  this.imageLayer.appendImage({
1687
- imgData: imgData,
1998
+ imgData,
1688
1999
  left: position[0],
1689
2000
  top: position[1],
1690
2001
  width: width / currentTransform[0],
1691
2002
  height: height / currentTransform[3]
1692
2003
  });
1693
2004
  }
2005
+
1694
2006
  this.restore();
1695
2007
  },
1696
2008
  paintInlineImageXObjectGroup: function CanvasGraphics_paintInlineImageXObjectGroup(imgData, map) {
1697
2009
  var ctx = this.ctx;
1698
2010
  var w = imgData.width;
1699
2011
  var h = imgData.height;
1700
- var tmpCanvas = this.cachedCanvases.getCanvas('inlineImage', w, h);
2012
+ var tmpCanvas = this.cachedCanvases.getCanvas("inlineImage", w, h);
1701
2013
  var tmpCtx = tmpCanvas.context;
1702
2014
  putBinaryImageData(tmpCtx, imgData);
2015
+
1703
2016
  for (var i = 0, ii = map.length; i < ii; i++) {
1704
2017
  var entry = map[i];
1705
2018
  ctx.save();
1706
2019
  ctx.transform.apply(ctx, entry.transform);
1707
2020
  ctx.scale(1, -1);
1708
2021
  ctx.drawImage(tmpCanvas.canvas, entry.x, entry.y, entry.w, entry.h, 0, -1, 1, 1);
2022
+
1709
2023
  if (this.imageLayer) {
1710
2024
  var position = this.getCanvasPosition(entry.x, entry.y);
1711
2025
  this.imageLayer.appendImage({
1712
- imgData: imgData,
2026
+ imgData,
1713
2027
  left: position[0],
1714
2028
  top: position[1],
1715
2029
  width: w,
1716
2030
  height: h
1717
2031
  });
1718
2032
  }
2033
+
1719
2034
  ctx.restore();
1720
2035
  }
1721
2036
  },
@@ -1723,7 +2038,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
1723
2038
  this.ctx.fillRect(0, 0, 1, 1);
1724
2039
  },
1725
2040
  paintXObject: function CanvasGraphics_paintXObject() {
1726
- (0, _util.warn)('Unsupported \'paintXObject\' command.');
2041
+ (0, _util.warn)("Unsupported 'paintXObject' command.");
1727
2042
  },
1728
2043
  markPoint: function CanvasGraphics_markPoint(tag) {},
1729
2044
  markPointProps: function CanvasGraphics_markPointProps(tag, properties) {},
@@ -1734,21 +2049,26 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
1734
2049
  endCompat: function CanvasGraphics_endCompat() {},
1735
2050
  consumePath: function CanvasGraphics_consumePath() {
1736
2051
  var ctx = this.ctx;
2052
+
1737
2053
  if (this.pendingClip) {
1738
2054
  if (this.pendingClip === EO_CLIP) {
1739
- ctx.clip('evenodd');
2055
+ ctx.clip("evenodd");
1740
2056
  } else {
1741
2057
  ctx.clip();
1742
2058
  }
2059
+
1743
2060
  this.pendingClip = null;
1744
2061
  }
2062
+
1745
2063
  ctx.beginPath();
1746
2064
  },
1747
- getSinglePixelWidth: function getSinglePixelWidth(scale) {
2065
+
2066
+ getSinglePixelWidth(scale) {
1748
2067
  if (this._cachedGetSinglePixelWidth === null) {
1749
- var inverse = this.ctx.mozCurrentTransformInverse;
2068
+ const inverse = this.ctx.mozCurrentTransformInverse;
1750
2069
  this._cachedGetSinglePixelWidth = Math.sqrt(Math.max(inverse[0] * inverse[0] + inverse[1] * inverse[1], inverse[2] * inverse[2] + inverse[3] * inverse[3]));
1751
2070
  }
2071
+
1752
2072
  return this._cachedGetSinglePixelWidth;
1753
2073
  },
1754
2074
 
@@ -1757,9 +2077,12 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
1757
2077
  return [transform[0] * x + transform[2] * y + transform[4], transform[1] * x + transform[3] * y + transform[5]];
1758
2078
  }
1759
2079
  };
2080
+
1760
2081
  for (var op in _util.OPS) {
1761
2082
  CanvasGraphics.prototype[_util.OPS[op]] = CanvasGraphics.prototype[op];
1762
2083
  }
2084
+
1763
2085
  return CanvasGraphics;
1764
2086
  }();
2087
+
1765
2088
  exports.CanvasGraphics = CanvasGraphics;