@vaadin-component-factory/vcf-pdf-viewer 0.9.0 → 1.0.0
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/README.md +1 -1
- package/package.json +42 -26
- package/{src/display → pdfjs/dist}/display_utils.js +344 -139
- package/{src/display → pdfjs/dist}/fetch_stream.js +115 -97
- package/pdfjs/dist/l10n_utils.js +140 -0
- package/{src/shared → pdfjs/dist}/message_handler.js +243 -259
- package/{src/display → pdfjs/dist}/network.js +149 -87
- package/{src/display/content_disposition.js → pdfjs/dist/network_utils.js} +167 -55
- package/{src/display → pdfjs/dist}/node_stream.js +133 -98
- package/pdfjs/dist/pdf.js +12778 -0
- package/pdfjs/dist/pdf_link_service.js +638 -0
- package/pdfjs/dist/pdf_rendering_queue.js +199 -0
- package/pdfjs/dist/pdf_thumbnail_viewer.js +819 -0
- package/pdfjs/dist/pdf_viewer.js +3598 -0
- package/pdfjs/dist/ui_utils.js +1033 -0
- package/{src/shared → pdfjs/dist}/util.js +301 -287
- package/pdfjs/dist/worker.js +62813 -0
- package/src/vcf-pdf-viewer.js +98 -46
- package/theme/lumo/vcf-pdf-viewer-styles.js +4 -4
- package/theme/material/vcf-pdf-viewer-styles.js +4 -4
- package/theme/material/vcf-pdf-viewer.js +2 -2
- package/src/core/.eslintrc +0 -13
- package/src/core/annotation.js +0 -2948
- package/src/core/arithmetic_decoder.js +0 -182
- package/src/core/ascii_85_stream.js +0 -98
- package/src/core/ascii_hex_stream.js +0 -79
- package/src/core/base_stream.js +0 -110
- package/src/core/bidi.js +0 -438
- package/src/core/calibri_factors.js +0 -308
- package/src/core/catalog.js +0 -1459
- package/src/core/ccitt.js +0 -1062
- package/src/core/ccitt_stream.js +0 -60
- package/src/core/cff_font.js +0 -116
- package/src/core/cff_parser.js +0 -1949
- package/src/core/charsets.js +0 -119
- package/src/core/chunked_stream.js +0 -557
- package/src/core/cmap.js +0 -1039
- package/src/core/colorspace.js +0 -1533
- package/src/core/core_utils.js +0 -464
- package/src/core/crypto.js +0 -1900
- package/src/core/decode_stream.js +0 -170
- package/src/core/decrypt_stream.js +0 -59
- package/src/core/default_appearance.js +0 -99
- package/src/core/document.js +0 -1456
- package/src/core/encodings.js +0 -301
- package/src/core/evaluator.js +0 -4601
- package/src/core/file_spec.js +0 -108
- package/src/core/flate_stream.js +0 -402
- package/src/core/font_renderer.js +0 -882
- package/src/core/fonts.js +0 -3260
- package/src/core/fonts_utils.js +0 -221
- package/src/core/function.js +0 -1257
- package/src/core/glyf.js +0 -706
- package/src/core/glyphlist.js +0 -4558
- package/src/core/helvetica_factors.js +0 -353
- package/src/core/image.js +0 -802
- package/src/core/image_utils.js +0 -291
- package/src/core/jbig2.js +0 -2572
- package/src/core/jbig2_stream.js +0 -73
- package/src/core/jpeg_stream.js +0 -105
- package/src/core/jpg.js +0 -1416
- package/src/core/jpx.js +0 -2343
- package/src/core/jpx_stream.js +0 -87
- package/src/core/liberationsans_widths.js +0 -221
- package/src/core/lzw_stream.js +0 -150
- package/src/core/metadata_parser.js +0 -146
- package/src/core/metrics.js +0 -2970
- package/src/core/murmurhash3.js +0 -139
- package/src/core/myriadpro_factors.js +0 -290
- package/src/core/name_number_tree.js +0 -153
- package/src/core/object_loader.js +0 -149
- package/src/core/opentype_file_builder.js +0 -154
- package/src/core/operator_list.js +0 -734
- package/src/core/parser.js +0 -1416
- package/src/core/pattern.js +0 -985
- package/src/core/pdf_manager.js +0 -217
- package/src/core/predictor_stream.js +0 -238
- package/src/core/primitives.js +0 -402
- package/src/core/ps_parser.js +0 -272
- package/src/core/run_length_stream.js +0 -61
- package/src/core/segoeui_factors.js +0 -308
- package/src/core/standard_fonts.js +0 -817
- package/src/core/stream.js +0 -103
- package/src/core/struct_tree.js +0 -335
- package/src/core/to_unicode_map.js +0 -103
- package/src/core/type1_font.js +0 -421
- package/src/core/type1_parser.js +0 -776
- package/src/core/unicode.js +0 -1649
- package/src/core/worker.js +0 -848
- package/src/core/worker_stream.js +0 -135
- package/src/core/writer.js +0 -278
- package/src/core/xfa/bind.js +0 -652
- package/src/core/xfa/builder.js +0 -207
- package/src/core/xfa/config.js +0 -1926
- package/src/core/xfa/connection_set.js +0 -202
- package/src/core/xfa/data.js +0 -82
- package/src/core/xfa/datasets.js +0 -76
- package/src/core/xfa/factory.js +0 -111
- package/src/core/xfa/fonts.js +0 -181
- package/src/core/xfa/formcalc_lexer.js +0 -385
- package/src/core/xfa/formcalc_parser.js +0 -1340
- package/src/core/xfa/html_utils.js +0 -639
- package/src/core/xfa/layout.js +0 -383
- package/src/core/xfa/locale_set.js +0 -345
- package/src/core/xfa/namespaces.js +0 -81
- package/src/core/xfa/parser.js +0 -184
- package/src/core/xfa/setup.js +0 -38
- package/src/core/xfa/signature.js +0 -40
- package/src/core/xfa/som.js +0 -338
- package/src/core/xfa/stylesheet.js +0 -40
- package/src/core/xfa/template.js +0 -6260
- package/src/core/xfa/text.js +0 -290
- package/src/core/xfa/unknown.js +0 -29
- package/src/core/xfa/utils.js +0 -217
- package/src/core/xfa/xdp.js +0 -59
- package/src/core/xfa/xfa_object.js +0 -1130
- package/src/core/xfa/xhtml.js +0 -543
- package/src/core/xfa_fonts.js +0 -208
- package/src/core/xml_parser.js +0 -507
- package/src/core/xref.js +0 -899
- package/src/display/annotation_layer.js +0 -2107
- package/src/display/annotation_storage.js +0 -113
- package/src/display/api.js +0 -3292
- package/src/display/base_factory.js +0 -180
- package/src/display/canvas.js +0 -2828
- package/src/display/font_loader.js +0 -484
- package/src/display/metadata.js +0 -41
- package/src/display/network_utils.js +0 -100
- package/src/display/node_utils.js +0 -83
- package/src/display/optional_content_config.js +0 -189
- package/src/display/pattern_helper.js +0 -659
- package/src/display/svg.js +0 -1709
- package/src/display/text_layer.js +0 -847
- package/src/display/transport_stream.js +0 -303
- package/src/display/worker_options.js +0 -40
- package/src/display/xfa_layer.js +0 -204
- package/src/doc_helper.js +0 -25
- package/src/images/logo.svg +0 -41
- package/src/interfaces.js +0 -169
- package/src/license_header.js +0 -14
- package/src/license_header_libre.js +0 -21
- package/src/pdf.image_decoders.js +0 -46
- package/src/pdf.js +0 -146
- package/src/pdf.sandbox.external.js +0 -181
- package/src/pdf.sandbox.js +0 -151
- package/src/pdf.scripting.js +0 -25
- package/src/pdf.worker.entry.js +0 -19
- package/src/pdf.worker.js +0 -23
- package/src/scripting_api/aform.js +0 -608
- package/src/scripting_api/app.js +0 -621
- package/src/scripting_api/color.js +0 -129
- package/src/scripting_api/common.js +0 -58
- package/src/scripting_api/console.js +0 -38
- package/src/scripting_api/constants.js +0 -208
- package/src/scripting_api/doc.js +0 -1195
- package/src/scripting_api/error.js +0 -23
- package/src/scripting_api/event.js +0 -232
- package/src/scripting_api/field.js +0 -620
- package/src/scripting_api/fullscreen.js +0 -145
- package/src/scripting_api/initialization.js +0 -223
- package/src/scripting_api/pdf_object.js +0 -24
- package/src/scripting_api/print_params.js +0 -146
- package/src/scripting_api/proxy.js +0 -139
- package/src/scripting_api/thermometer.js +0 -69
- package/src/scripting_api/util.js +0 -581
- package/src/shared/.eslintrc +0 -13
- package/src/shared/cffStandardStrings.js +0 -311
- package/src/shared/compatibility.js +0 -114
- package/src/shared/fonts_utils.js +0 -429
- package/src/shared/is_node.js +0 -27
- package/src/shared/scripting_utils.js +0 -85
- package/src/worker_loader.js +0 -32
package/src/core/xfa/layout.js
DELETED
|
@@ -1,383 +0,0 @@
|
|
|
1
|
-
/* Copyright 2021 Mozilla Foundation
|
|
2
|
-
*
|
|
3
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
* you may not use this file except in compliance with the License.
|
|
5
|
-
* You may obtain a copy of the License at
|
|
6
|
-
*
|
|
7
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
*
|
|
9
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
* See the License for the specific language governing permissions and
|
|
13
|
-
* limitations under the License.
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
import {
|
|
17
|
-
$extra,
|
|
18
|
-
$flushHTML,
|
|
19
|
-
$getSubformParent,
|
|
20
|
-
$getTemplateRoot,
|
|
21
|
-
$isSplittable,
|
|
22
|
-
$isThereMoreWidth,
|
|
23
|
-
} from "./xfa_object.js";
|
|
24
|
-
import { measureToString } from "./html_utils.js";
|
|
25
|
-
|
|
26
|
-
// Subform and ExclGroup have a layout so they share these functions.
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* How layout works ?
|
|
30
|
-
*
|
|
31
|
-
* A container has an initial space (with a width and a height) to fit in,
|
|
32
|
-
* which means that once all the children have been added then
|
|
33
|
-
* the total width/height must be lower than the given ones in
|
|
34
|
-
* the initial space.
|
|
35
|
-
* So if the container has known dimensions and these ones are ok with the
|
|
36
|
-
* space then continue else we return HTMLResult.FAILURE: it's up to the
|
|
37
|
-
* parent to deal with this failure (e.g. if parent layout is lr-tb and
|
|
38
|
-
* we fail to add a child at end of line (lr) then we try to add it on the
|
|
39
|
-
* next line).
|
|
40
|
-
* And then we run through the children, each child gets its initial space
|
|
41
|
-
* in calling its parent $getAvailableSpace method
|
|
42
|
-
* (see _filteredChildrenGenerator and $childrenToHTML in xfa_object.js)
|
|
43
|
-
* then we try to layout child in its space. If everything is ok then we add
|
|
44
|
-
* the result to its parent through $addHTML which will recompute the available
|
|
45
|
-
* space in parent according to its layout property else we return
|
|
46
|
-
* HTMLResult.Failure.
|
|
47
|
-
* Before a failure some children may have been layed out: they've been saved in
|
|
48
|
-
* [$extra].children and [$extra] has properties generator and failingNode
|
|
49
|
-
* in order to save the state where we were before a failure.
|
|
50
|
-
* This [$extra].children property is useful when a container has to be splited.
|
|
51
|
-
* So if a container is unbreakable, we must delete its [$extra] property before
|
|
52
|
-
* returning.
|
|
53
|
-
*/
|
|
54
|
-
|
|
55
|
-
function createLine(node, children) {
|
|
56
|
-
return {
|
|
57
|
-
name: "div",
|
|
58
|
-
attributes: {
|
|
59
|
-
class: [node.layout === "lr-tb" ? "xfaLr" : "xfaRl"],
|
|
60
|
-
},
|
|
61
|
-
children,
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
function flushHTML(node) {
|
|
66
|
-
if (!node[$extra]) {
|
|
67
|
-
return null;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
const attributes = node[$extra].attributes;
|
|
71
|
-
const html = {
|
|
72
|
-
name: "div",
|
|
73
|
-
attributes,
|
|
74
|
-
children: node[$extra].children,
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
if (node[$extra].failingNode) {
|
|
78
|
-
const htmlFromFailing = node[$extra].failingNode[$flushHTML]();
|
|
79
|
-
if (htmlFromFailing) {
|
|
80
|
-
if (node.layout.endsWith("-tb")) {
|
|
81
|
-
html.children.push(createLine(node, [htmlFromFailing]));
|
|
82
|
-
} else {
|
|
83
|
-
html.children.push(htmlFromFailing);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
if (html.children.length === 0) {
|
|
89
|
-
return null;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
return html;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
function addHTML(node, html, bbox) {
|
|
96
|
-
const extra = node[$extra];
|
|
97
|
-
const availableSpace = extra.availableSpace;
|
|
98
|
-
|
|
99
|
-
const [x, y, w, h] = bbox;
|
|
100
|
-
switch (node.layout) {
|
|
101
|
-
case "position": {
|
|
102
|
-
extra.width = Math.max(extra.width, x + w);
|
|
103
|
-
extra.height = Math.max(extra.height, y + h);
|
|
104
|
-
extra.children.push(html);
|
|
105
|
-
break;
|
|
106
|
-
}
|
|
107
|
-
case "lr-tb":
|
|
108
|
-
case "rl-tb":
|
|
109
|
-
if (!extra.line || extra.attempt === 1) {
|
|
110
|
-
extra.line = createLine(node, []);
|
|
111
|
-
extra.children.push(extra.line);
|
|
112
|
-
extra.numberInLine = 0;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
extra.numberInLine += 1;
|
|
116
|
-
extra.line.children.push(html);
|
|
117
|
-
|
|
118
|
-
if (extra.attempt === 0) {
|
|
119
|
-
// Add the element on the line
|
|
120
|
-
extra.currentWidth += w;
|
|
121
|
-
extra.height = Math.max(extra.height, extra.prevHeight + h);
|
|
122
|
-
} else {
|
|
123
|
-
extra.currentWidth = w;
|
|
124
|
-
extra.prevHeight = extra.height;
|
|
125
|
-
extra.height += h;
|
|
126
|
-
|
|
127
|
-
// The element has been added on a new line so switch to line mode now.
|
|
128
|
-
extra.attempt = 0;
|
|
129
|
-
}
|
|
130
|
-
extra.width = Math.max(extra.width, extra.currentWidth);
|
|
131
|
-
break;
|
|
132
|
-
case "rl-row":
|
|
133
|
-
case "row": {
|
|
134
|
-
extra.children.push(html);
|
|
135
|
-
extra.width += w;
|
|
136
|
-
extra.height = Math.max(extra.height, h);
|
|
137
|
-
const height = measureToString(extra.height);
|
|
138
|
-
for (const child of extra.children) {
|
|
139
|
-
child.attributes.style.height = height;
|
|
140
|
-
}
|
|
141
|
-
break;
|
|
142
|
-
}
|
|
143
|
-
case "table": {
|
|
144
|
-
extra.width = Math.min(availableSpace.width, Math.max(extra.width, w));
|
|
145
|
-
extra.height += h;
|
|
146
|
-
extra.children.push(html);
|
|
147
|
-
break;
|
|
148
|
-
}
|
|
149
|
-
case "tb": {
|
|
150
|
-
extra.width = availableSpace.width;
|
|
151
|
-
extra.height += h;
|
|
152
|
-
extra.children.push(html);
|
|
153
|
-
break;
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
function getAvailableSpace(node) {
|
|
159
|
-
const availableSpace = node[$extra].availableSpace;
|
|
160
|
-
const marginV = node.margin
|
|
161
|
-
? node.margin.topInset + node.margin.bottomInset
|
|
162
|
-
: 0;
|
|
163
|
-
const marginH = node.margin
|
|
164
|
-
? node.margin.leftInset + node.margin.rightInset
|
|
165
|
-
: 0;
|
|
166
|
-
|
|
167
|
-
switch (node.layout) {
|
|
168
|
-
case "lr-tb":
|
|
169
|
-
case "rl-tb":
|
|
170
|
-
if (node[$extra].attempt === 0) {
|
|
171
|
-
return {
|
|
172
|
-
width: availableSpace.width - marginH - node[$extra].currentWidth,
|
|
173
|
-
height: availableSpace.height - marginV - node[$extra].prevHeight,
|
|
174
|
-
};
|
|
175
|
-
}
|
|
176
|
-
return {
|
|
177
|
-
width: availableSpace.width - marginH,
|
|
178
|
-
height: availableSpace.height - marginV - node[$extra].height,
|
|
179
|
-
};
|
|
180
|
-
case "rl-row":
|
|
181
|
-
case "row":
|
|
182
|
-
const width = node[$extra].columnWidths
|
|
183
|
-
.slice(node[$extra].currentColumn)
|
|
184
|
-
.reduce((a, x) => a + x);
|
|
185
|
-
return { width, height: availableSpace.height - marginH };
|
|
186
|
-
case "table":
|
|
187
|
-
case "tb":
|
|
188
|
-
return {
|
|
189
|
-
width: availableSpace.width - marginH,
|
|
190
|
-
height: availableSpace.height - marginV - node[$extra].height,
|
|
191
|
-
};
|
|
192
|
-
case "position":
|
|
193
|
-
default:
|
|
194
|
-
return availableSpace;
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
function getTransformedBBox(node) {
|
|
199
|
-
// Take into account rotation and anchor to get the real bounding box.
|
|
200
|
-
let w = node.w === "" ? NaN : node.w;
|
|
201
|
-
let h = node.h === "" ? NaN : node.h;
|
|
202
|
-
let [centerX, centerY] = [0, 0];
|
|
203
|
-
switch (node.anchorType || "") {
|
|
204
|
-
case "bottomCenter":
|
|
205
|
-
[centerX, centerY] = [w / 2, h];
|
|
206
|
-
break;
|
|
207
|
-
case "bottomLeft":
|
|
208
|
-
[centerX, centerY] = [0, h];
|
|
209
|
-
break;
|
|
210
|
-
case "bottomRight":
|
|
211
|
-
[centerX, centerY] = [w, h];
|
|
212
|
-
break;
|
|
213
|
-
case "middleCenter":
|
|
214
|
-
[centerX, centerY] = [w / 2, h / 2];
|
|
215
|
-
break;
|
|
216
|
-
case "middleLeft":
|
|
217
|
-
[centerX, centerY] = [0, h / 2];
|
|
218
|
-
break;
|
|
219
|
-
case "middleRight":
|
|
220
|
-
[centerX, centerY] = [w, h / 2];
|
|
221
|
-
break;
|
|
222
|
-
case "topCenter":
|
|
223
|
-
[centerX, centerY] = [w / 2, 0];
|
|
224
|
-
break;
|
|
225
|
-
case "topRight":
|
|
226
|
-
[centerX, centerY] = [w, 0];
|
|
227
|
-
break;
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
let x, y;
|
|
231
|
-
switch (node.rotate || 0) {
|
|
232
|
-
case 0:
|
|
233
|
-
[x, y] = [-centerX, -centerY];
|
|
234
|
-
break;
|
|
235
|
-
case 90:
|
|
236
|
-
[x, y] = [-centerY, centerX];
|
|
237
|
-
[w, h] = [h, -w];
|
|
238
|
-
break;
|
|
239
|
-
case 180:
|
|
240
|
-
[x, y] = [centerX, centerY];
|
|
241
|
-
[w, h] = [-w, -h];
|
|
242
|
-
break;
|
|
243
|
-
case 270:
|
|
244
|
-
[x, y] = [centerY, -centerX];
|
|
245
|
-
[w, h] = [-h, w];
|
|
246
|
-
break;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
return [
|
|
250
|
-
node.x + x + Math.min(0, w),
|
|
251
|
-
node.y + y + Math.min(0, h),
|
|
252
|
-
Math.abs(w),
|
|
253
|
-
Math.abs(h),
|
|
254
|
-
];
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
/**
|
|
258
|
-
* Returning true means that the node will be layed out
|
|
259
|
-
* else the layout will go to its next step (changing of line
|
|
260
|
-
* in case of lr-tb or changing content area...).
|
|
261
|
-
*/
|
|
262
|
-
function checkDimensions(node, space) {
|
|
263
|
-
if (node[$getTemplateRoot]()[$extra].firstUnsplittable === null) {
|
|
264
|
-
return true;
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
if (node.w === 0 || node.h === 0) {
|
|
268
|
-
return true;
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
const ERROR = 2;
|
|
272
|
-
const parent = node[$getSubformParent]();
|
|
273
|
-
const attempt = (parent[$extra] && parent[$extra].attempt) || 0;
|
|
274
|
-
|
|
275
|
-
const [, y, w, h] = getTransformedBBox(node);
|
|
276
|
-
switch (parent.layout) {
|
|
277
|
-
case "lr-tb":
|
|
278
|
-
case "rl-tb":
|
|
279
|
-
if (attempt === 0) {
|
|
280
|
-
// Try to put an element in the line.
|
|
281
|
-
|
|
282
|
-
if (!node[$getTemplateRoot]()[$extra].noLayoutFailure) {
|
|
283
|
-
if (node.h !== "" && Math.round(h - space.height) > ERROR) {
|
|
284
|
-
// Not enough height.
|
|
285
|
-
return false;
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
if (node.w !== "") {
|
|
289
|
-
if (Math.round(w - space.width) <= ERROR) {
|
|
290
|
-
return true;
|
|
291
|
-
}
|
|
292
|
-
if (parent[$extra].numberInLine === 0) {
|
|
293
|
-
return space.height > 0;
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
return false;
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
return space.width > 0;
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
// No layout failure.
|
|
303
|
-
|
|
304
|
-
// Put the element on the line but we can fail
|
|
305
|
-
// and then in the second step (next line) we'll accept.
|
|
306
|
-
if (node.w !== "") {
|
|
307
|
-
return Math.round(w - space.width) <= ERROR;
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
return space.width > 0;
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
// Second attempt: try to put the element on the next line.
|
|
314
|
-
|
|
315
|
-
if (node[$getTemplateRoot]()[$extra].noLayoutFailure) {
|
|
316
|
-
// We cannot fail.
|
|
317
|
-
return true;
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
if (node.h !== "" && Math.round(h - space.height) > ERROR) {
|
|
321
|
-
return false;
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
if (node.w === "" || Math.round(w - space.width) <= ERROR) {
|
|
325
|
-
return space.height > 0;
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
if (parent[$isThereMoreWidth]()) {
|
|
329
|
-
return false;
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
return space.height > 0;
|
|
333
|
-
case "table":
|
|
334
|
-
case "tb":
|
|
335
|
-
if (node[$getTemplateRoot]()[$extra].noLayoutFailure) {
|
|
336
|
-
return true;
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
// If the node has a height then check if it's fine with available height.
|
|
340
|
-
// If the node is breakable then we can return true.
|
|
341
|
-
if (node.h !== "" && !node[$isSplittable]()) {
|
|
342
|
-
return Math.round(h - space.height) <= ERROR;
|
|
343
|
-
}
|
|
344
|
-
// Else wait and see: this node will be layed out itself
|
|
345
|
-
// in the provided space and maybe a children won't fit.
|
|
346
|
-
|
|
347
|
-
if (node.w === "" || Math.round(w - space.width) <= ERROR) {
|
|
348
|
-
return space.height > 0;
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
if (parent[$isThereMoreWidth]()) {
|
|
352
|
-
return false;
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
return space.height > 0;
|
|
356
|
-
case "position":
|
|
357
|
-
if (node[$getTemplateRoot]()[$extra].noLayoutFailure) {
|
|
358
|
-
return true;
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
if (node.h === "" || Math.round(h + y - space.height) <= ERROR) {
|
|
362
|
-
return true;
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
const area = node[$getTemplateRoot]()[$extra].currentContentArea;
|
|
366
|
-
return h + y > area.h;
|
|
367
|
-
case "rl-row":
|
|
368
|
-
case "row":
|
|
369
|
-
if (node[$getTemplateRoot]()[$extra].noLayoutFailure) {
|
|
370
|
-
return true;
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
if (node.h !== "") {
|
|
374
|
-
return Math.round(h - space.height) <= ERROR;
|
|
375
|
-
}
|
|
376
|
-
return true;
|
|
377
|
-
default:
|
|
378
|
-
// No layout, so accept everything.
|
|
379
|
-
return true;
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
export { addHTML, checkDimensions, flushHTML, getAvailableSpace };
|
|
@@ -1,345 +0,0 @@
|
|
|
1
|
-
/* Copyright 2021 Mozilla Foundation
|
|
2
|
-
*
|
|
3
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
* you may not use this file except in compliance with the License.
|
|
5
|
-
* You may obtain a copy of the License at
|
|
6
|
-
*
|
|
7
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
*
|
|
9
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
* See the License for the specific language governing permissions and
|
|
13
|
-
* limitations under the License.
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
import { $buildXFAObject, NamespaceIds } from "./namespaces.js";
|
|
17
|
-
import {
|
|
18
|
-
ContentObject,
|
|
19
|
-
StringObject,
|
|
20
|
-
XFAObject,
|
|
21
|
-
XFAObjectArray,
|
|
22
|
-
} from "./xfa_object.js";
|
|
23
|
-
import { getInteger, getStringOption } from "./utils.js";
|
|
24
|
-
|
|
25
|
-
const LOCALE_SET_NS_ID = NamespaceIds.localeSet.id;
|
|
26
|
-
|
|
27
|
-
class CalendarSymbols extends XFAObject {
|
|
28
|
-
constructor(attributes) {
|
|
29
|
-
super(LOCALE_SET_NS_ID, "calendarSymbols", /* hasChildren = */ true);
|
|
30
|
-
this.name = "gregorian";
|
|
31
|
-
this.dayNames = new XFAObjectArray(2);
|
|
32
|
-
this.eraNames = null;
|
|
33
|
-
this.meridiemNames = null;
|
|
34
|
-
this.monthNames = new XFAObjectArray(2);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
class CurrencySymbol extends StringObject {
|
|
39
|
-
constructor(attributes) {
|
|
40
|
-
super(LOCALE_SET_NS_ID, "currencySymbol");
|
|
41
|
-
this.name = getStringOption(attributes.name, [
|
|
42
|
-
"symbol",
|
|
43
|
-
"isoname",
|
|
44
|
-
"decimal",
|
|
45
|
-
]);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
class CurrencySymbols extends XFAObject {
|
|
50
|
-
constructor(attributes) {
|
|
51
|
-
super(LOCALE_SET_NS_ID, "currencySymbols", /* hasChildren = */ true);
|
|
52
|
-
this.currencySymbol = new XFAObjectArray(3);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
class DatePattern extends StringObject {
|
|
57
|
-
constructor(attributes) {
|
|
58
|
-
super(LOCALE_SET_NS_ID, "datePattern");
|
|
59
|
-
this.name = getStringOption(attributes.name, [
|
|
60
|
-
"full",
|
|
61
|
-
"long",
|
|
62
|
-
"med",
|
|
63
|
-
"short",
|
|
64
|
-
]);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
class DatePatterns extends XFAObject {
|
|
69
|
-
constructor(attributes) {
|
|
70
|
-
super(LOCALE_SET_NS_ID, "datePatterns", /* hasChildren = */ true);
|
|
71
|
-
this.datePattern = new XFAObjectArray(4);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
class DateTimeSymbols extends ContentObject {
|
|
76
|
-
// TODO: spec unclear about the format of the array.
|
|
77
|
-
|
|
78
|
-
constructor(attributes) {
|
|
79
|
-
super(LOCALE_SET_NS_ID, "dateTimeSymbols");
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
class Day extends StringObject {
|
|
84
|
-
constructor(attributes) {
|
|
85
|
-
super(LOCALE_SET_NS_ID, "day");
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
class DayNames extends XFAObject {
|
|
90
|
-
constructor(attributes) {
|
|
91
|
-
super(LOCALE_SET_NS_ID, "dayNames", /* hasChildren = */ true);
|
|
92
|
-
this.abbr = getInteger({
|
|
93
|
-
data: attributes.abbr,
|
|
94
|
-
defaultValue: 0,
|
|
95
|
-
validate: x => x === 1,
|
|
96
|
-
});
|
|
97
|
-
this.day = new XFAObjectArray(7);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
class Era extends StringObject {
|
|
102
|
-
constructor(attributes) {
|
|
103
|
-
super(LOCALE_SET_NS_ID, "era");
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
class EraNames extends XFAObject {
|
|
108
|
-
constructor(attributes) {
|
|
109
|
-
super(LOCALE_SET_NS_ID, "eraNames", /* hasChildren = */ true);
|
|
110
|
-
this.era = new XFAObjectArray(2);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
class Locale extends XFAObject {
|
|
115
|
-
constructor(attributes) {
|
|
116
|
-
super(LOCALE_SET_NS_ID, "locale", /* hasChildren = */ true);
|
|
117
|
-
this.desc = attributes.desc || "";
|
|
118
|
-
this.name = "isoname";
|
|
119
|
-
this.calendarSymbols = null;
|
|
120
|
-
this.currencySymbols = null;
|
|
121
|
-
this.datePatterns = null;
|
|
122
|
-
this.dateTimeSymbols = null;
|
|
123
|
-
this.numberPatterns = null;
|
|
124
|
-
this.numberSymbols = null;
|
|
125
|
-
this.timePatterns = null;
|
|
126
|
-
this.typeFaces = null;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
class LocaleSet extends XFAObject {
|
|
131
|
-
constructor(attributes) {
|
|
132
|
-
super(LOCALE_SET_NS_ID, "localeSet", /* hasChildren = */ true);
|
|
133
|
-
this.locale = new XFAObjectArray();
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
class Meridiem extends StringObject {
|
|
138
|
-
constructor(attributes) {
|
|
139
|
-
super(LOCALE_SET_NS_ID, "meridiem");
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
class MeridiemNames extends XFAObject {
|
|
144
|
-
constructor(attributes) {
|
|
145
|
-
super(LOCALE_SET_NS_ID, "meridiemNames", /* hasChildren = */ true);
|
|
146
|
-
this.meridiem = new XFAObjectArray(2);
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
class Month extends StringObject {
|
|
151
|
-
constructor(attributes) {
|
|
152
|
-
super(LOCALE_SET_NS_ID, "month");
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
class MonthNames extends XFAObject {
|
|
157
|
-
constructor(attributes) {
|
|
158
|
-
super(LOCALE_SET_NS_ID, "monthNames", /* hasChildren = */ true);
|
|
159
|
-
this.abbr = getInteger({
|
|
160
|
-
data: attributes.abbr,
|
|
161
|
-
defaultValue: 0,
|
|
162
|
-
validate: x => x === 1,
|
|
163
|
-
});
|
|
164
|
-
this.month = new XFAObjectArray(12);
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
class NumberPattern extends StringObject {
|
|
169
|
-
constructor(attributes) {
|
|
170
|
-
super(LOCALE_SET_NS_ID, "numberPattern");
|
|
171
|
-
this.name = getStringOption(attributes.name, [
|
|
172
|
-
"full",
|
|
173
|
-
"long",
|
|
174
|
-
"med",
|
|
175
|
-
"short",
|
|
176
|
-
]);
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
class NumberPatterns extends XFAObject {
|
|
181
|
-
constructor(attributes) {
|
|
182
|
-
super(LOCALE_SET_NS_ID, "numberPatterns", /* hasChildren = */ true);
|
|
183
|
-
this.numberPattern = new XFAObjectArray(4);
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
class NumberSymbol extends StringObject {
|
|
188
|
-
constructor(attributes) {
|
|
189
|
-
super(LOCALE_SET_NS_ID, "numberSymbol");
|
|
190
|
-
this.name = getStringOption(attributes.name, [
|
|
191
|
-
"decimal",
|
|
192
|
-
"grouping",
|
|
193
|
-
"percent",
|
|
194
|
-
"minus",
|
|
195
|
-
"zero",
|
|
196
|
-
]);
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
class NumberSymbols extends XFAObject {
|
|
201
|
-
constructor(attributes) {
|
|
202
|
-
super(LOCALE_SET_NS_ID, "numberSymbols", /* hasChildren = */ true);
|
|
203
|
-
this.numberSymbol = new XFAObjectArray(5);
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
class TimePattern extends StringObject {
|
|
208
|
-
constructor(attributes) {
|
|
209
|
-
super(LOCALE_SET_NS_ID, "timePattern");
|
|
210
|
-
this.name = getStringOption(attributes.name, [
|
|
211
|
-
"full",
|
|
212
|
-
"long",
|
|
213
|
-
"med",
|
|
214
|
-
"short",
|
|
215
|
-
]);
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
class TimePatterns extends XFAObject {
|
|
220
|
-
constructor(attributes) {
|
|
221
|
-
super(LOCALE_SET_NS_ID, "timePatterns", /* hasChildren = */ true);
|
|
222
|
-
this.timePattern = new XFAObjectArray(4);
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
class TypeFace extends XFAObject {
|
|
227
|
-
constructor(attributes) {
|
|
228
|
-
super(LOCALE_SET_NS_ID, "typeFace", /* hasChildren = */ true);
|
|
229
|
-
this.name = attributes.name | "";
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
class TypeFaces extends XFAObject {
|
|
234
|
-
constructor(attributes) {
|
|
235
|
-
super(LOCALE_SET_NS_ID, "typeFaces", /* hasChildren = */ true);
|
|
236
|
-
this.typeFace = new XFAObjectArray();
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
class LocaleSetNamespace {
|
|
241
|
-
static [$buildXFAObject](name, attributes) {
|
|
242
|
-
if (LocaleSetNamespace.hasOwnProperty(name)) {
|
|
243
|
-
return LocaleSetNamespace[name](attributes);
|
|
244
|
-
}
|
|
245
|
-
return undefined;
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
static calendarSymbols(attrs) {
|
|
249
|
-
return new CalendarSymbols(attrs);
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
static currencySymbol(attrs) {
|
|
253
|
-
return new CurrencySymbol(attrs);
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
static currencySymbols(attrs) {
|
|
257
|
-
return new CurrencySymbols(attrs);
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
static datePattern(attrs) {
|
|
261
|
-
return new DatePattern(attrs);
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
static datePatterns(attrs) {
|
|
265
|
-
return new DatePatterns(attrs);
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
static dateTimeSymbols(attrs) {
|
|
269
|
-
return new DateTimeSymbols(attrs);
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
static day(attrs) {
|
|
273
|
-
return new Day(attrs);
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
static dayNames(attrs) {
|
|
277
|
-
return new DayNames(attrs);
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
static era(attrs) {
|
|
281
|
-
return new Era(attrs);
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
static eraNames(attrs) {
|
|
285
|
-
return new EraNames(attrs);
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
static locale(attrs) {
|
|
289
|
-
return new Locale(attrs);
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
static localeSet(attrs) {
|
|
293
|
-
return new LocaleSet(attrs);
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
static meridiem(attrs) {
|
|
297
|
-
return new Meridiem(attrs);
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
static meridiemNames(attrs) {
|
|
301
|
-
return new MeridiemNames(attrs);
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
static month(attrs) {
|
|
305
|
-
return new Month(attrs);
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
static monthNames(attrs) {
|
|
309
|
-
return new MonthNames(attrs);
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
static numberPattern(attrs) {
|
|
313
|
-
return new NumberPattern(attrs);
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
static numberPatterns(attrs) {
|
|
317
|
-
return new NumberPatterns(attrs);
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
static numberSymbol(attrs) {
|
|
321
|
-
return new NumberSymbol(attrs);
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
static numberSymbols(attrs) {
|
|
325
|
-
return new NumberSymbols(attrs);
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
static timePattern(attrs) {
|
|
329
|
-
return new TimePattern(attrs);
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
static timePatterns(attrs) {
|
|
333
|
-
return new TimePatterns(attrs);
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
static typeFace(attrs) {
|
|
337
|
-
return new TypeFace(attrs);
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
static typeFaces(attrs) {
|
|
341
|
-
return new TypeFaces(attrs);
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
export { LocaleSetNamespace };
|