The hand-written ranges gave a wrong class to many characters (e.g. ₪, €,
punctuation, Hebrew presentation forms, U+FEFF), hence a wrong reordering in
the text layer and in find. The table is generated from DerivedBidiClass.txt,
and surrogate pairs are now kept together.
The Unicode tables are coded with the range coder of Hellbox: unicode.bin is 2,639 bytes instead of 14,262, the Wasm module 131,848 bytes instead of 132,729, and the JS fallback 60,131 bytes with Brotli instead of 59,029.
While the binary CMap format is fairly efficient already, by also compressing them maximally with Brotli we can reduce their size even further.
The decompression is done on load in the worker-thread, and thanks to the existing caching it only needs to happen *once* per file. By utilizing the `BrotliStream` class all builds/environments can use these smaller files, and in e.g. Firefox (which supports native decompression) even the largest binary CMap files are decompressed in *under* `1` millisecond.
*Note:* This reduces the size of the `gulp mozcentral` bundle by `320076` bytes, i.e. over 312 kilo-bytes.
The upstream decode.js calls `makeBrotliDecode()` at module evaluation,
which unpacks the 122KB dictionary and builds the lookup tables each
time the worker starts, even if the PDF doesn't contain any Brotli
stream.
So export the factory instead and only call it the first time the
fallback is actually used. The `release-brotli` task now applies this
change to the downloaded file.
Replace bundled font programs with glyph data. Generate replacement fonts
with PDF widths and substitutes for missing XFA fonts. Use a JavaScript
fallback when WASM is disabled or fails to load.
The fallbacks are now built with wasm2js instead of the deprecated WASM=0 and only contain the converted modules.
The compilation of the openjpeg decoder has been improved too.
Update the OpenJPEG decoder in order to support any number of components, to pad the missing ones to match the color space and to upsample the subsampled ones.
Use the last filter to detect JPX and JBIG2 images.
In compact density the toolbar shrinks to 32px but the select kept its 32px
min-height, so its border overflowed and was clipped. Use the small button
size there, like the 24px toolbar buttons.
Collect Webpack output in memory as Vinyl files and close the compiler
after each run. Log compilation diagnostics and fail the stream on errors.
Remove webpack-stream and its unused dependencies, including memory-fs
and Vinyl 2.
Bug 2066198 lets the PDF viewer load the moz-message-bar module from a
chrome: URL. Add the required CSP and localization entries, and preserve viewer
focus on dismissal.
The `LiberationSans-*.ttf` files are the unmodified upstream release of
Liberation Sans 1.07.4: their `name` table reports `Version 1.07.4` and
points at the Liberation Fonts license, and their glyph count, cmap
coverage and advance widths match the upstream 1.07.4 build exactly.
That version is licensed under the GPL v2 with the Liberation font
exception, but `LICENSE_LIBERATION` contains the SIL Open Font License
1.1, which only applies starting with Liberation 2.0.
So replace it with the `License.txt` and `COPYING` files shipped with the
1.07.4 release, and document in the README where the fonts come from and
what needs to be updated when they're replaced.
It fixes#21746.
The file `external/qcms/LICENSE_PDFJS_QCMS` contained a BSD-2-Clause text
(copied from the openjpeg one), whereas https://github.com/mozilla/pdf.js.qcms
is released under the MIT license.
It fixes#21745.
The rule rewrites `Math.max(C, Math.min(A, B))` to `MathClamp(A, C, B)`, always
taking the inner call's first operand as the value. `Math.min` is commutative,
so the value is just as often the second one, and then the fixer swaps it with
the upper bound: the result is `Math.min(C, v)`, which no longer applies the
lower bound at all. Both call sites the fixer rewrote hit that case, so the
max-outer patterns are now reported without a fix.
Reporting them still needs its own message. `Math.max(C, Math.min(A, B))` is
only `MathClamp(A, C, B)` when `C <= B`, and the rule can't know whether that
holds, so telling the reader to "use MathClamp" is wrong advice. The message
states the condition instead, and `useClamp` is left to the min-outer patterns,
which are exact.
In `PSStackBasedInterpreter.build` the outputs were therefore never clamped up
to the Range minimum. The interpreter runs whenever `PSStackToTree` can't turn
the program into a tree — a stack-shrinking `if`, or a `copy`/`index`/`roll`
whose operand isn't a constant — and it then let a Type 4 function return e.g.
-1.5 for a component declared as `/Range [0 1]`.
In `SplitView.#clampFirstSize` the first pane's size was never clamped up to
`#minSize`: dragging the resizer past it wrote a negative `flexGrow`.
The existing range-clamping test only checked the upper bound, which is the one
the wrong operand order preserves.
It flags the regexes whose search is quadratic in the input length, like
the autolinker and XFA-path ones fixed recently.
The three existing offenders: `\s*` matched the CSS indentation but also
the line terminators that make `^` match with the `m` flag (the
preprocessed CSS is unchanged), `(\d+)` made every digit of a number a
candidate start position, and `/T.*$/` could fail on the `$` and
backtrack since `.` doesn't match a line terminator.
In a couple of cases, where a boolean is returned, it's also possible to use an OR operator rather a ternary.
*Note:* This patch reduces the size of the `gulp mozcentral` bundle by `960` bytes.
Move the `fs.existsSync(indexPath)` check below the `--no-download`
early return: in that mode the check is unused (the read after
refreshIndex already validates existence), so it's wasted disk I/O.
Address two CodeQL findings on the per-test index downloader:
- "File data in outbound network request": validate the cached ETag
against the RFC 7232 grammar before sending it as If-None-Match, so
the cache file's contents can't be injected into the request header.
- "Network data written to file": cache the re-serialized JSON
(JSON.stringify(JSON.parse(...))) instead of the raw response body,
so only well-formed JSON produced by our own serializer is written.
`coverage_search` now fetches `per-test-index.json` from the pdf.js.refs
gh-pages branch, caches it locally, and only re-downloads it (via ETag)
when it changed, so querying which ref tests cover a line/function no
longer needs a local `--coverage-per-test` build. `--no-download` reuses
the cached index offline and `--index` points at a local one.
`browsertest` and `makeref` accept the same `--code` filter to run (or
regenerate refs for) only the covering tests, dropping any covered IDs
that aren't in this branch's manifest so the run isn't rejected.
- functions were already removed
- variables can be removed when their initializer does not have side effects
- classes can be removed when they have no static blocks
Fixes#21337
Enable the recommended preset and fix or per-line-disable the 78
findings it surfaces. Most are equivalent rewrites, intentional
patterns (control chars, the whatwg email regex, autolinker URL regex)
keep their behavior via targeted disables.