Only use data-font-name attributes when necessary.

The data-font-name attribute of textLayer divs are only used by the Font
Inspector. This change ensures they are only present when the pdfBug
tools are enabled.
Remove setGStateForKey() closure.

setGStateForKey() is a closure that serves no particularly useful
purpose. This change inlines it at the single call site. This avoids 1.7
MiB of allocations (because closures are objects) for the MTA map
mentioned in https://bugzilla.mozilla.org/show_bug.cgi?id=835380#c17.
Merge pull request #5205 from nnethercote/setGState-closure

Remove setGStateForKey() closure.
Merge pull request #5193 from nnethercote/data-font-name

Only use data-font-name attributes when necessary.
Debounces scroll events in web viewer.

As requested in #5178, this change debounces the scroll events.
The reason for doing so is that browsers can event-storm especially on
scroll, communicating hundreds of subpixel changes.

The main reason for this resulting in poor performance is that on each
scroll event `scrollTop` was queried, which forces layouting.

This change will use `requestAnimationFrame` to make sure the browser can
allocate enough time to other tasks. The delay is however quite small, thus
the reduction in executions is less noticeable. Modern browsers however utilize
`requestAnimationFrame` to smoothen out rendering.
Fixes Type3 negative font direction
Apply the GRAYSCALE_1BPP optimization when `needsDecode` is set.

The scanned, black-and-white document at
https://bugzilla.mozilla.org/show_bug.cgi?id=835380 doesn't benefit from
the critical GRAYSCALE_1BPP optimization because the optimization is
skipped if `needsDecode` is set.

This change addresses that, and reduces both rendering time and memory
usage for that document by almost 10x.
Merge pull request #5210 from yurydelendik/type3dir

Fixes Type3 negative font direction
Merge pull request #5208 from CodingFabian/debounce-scroll

Debounces scroll events in web viewer.
Fix ensureByte() function name (copy-and-paste error)
Merge pull request #5212 from fkaelberer/fixFunctionName

Fix ensureByte() function name (copy-and-paste error)
Merge pull request #5204 from nnethercote/needsDecode

Apply the GRAYSCALE_1BPP optimization when `needsDecode` is set.
Set transformOrigin for text layer in css.

transformOrigin is set to 0% 0% in all cases. This adds extra memory
impact into the dom tree. It also involves the CustomStyles workaround
to determine the correct css rule for the browser.
By setting all vendor and standard variants in css, the rule is applied
without the dom memory overhead and without the minor computation
overhead to set the value.
no need to set textlayer properties which are overwritten in individual styles.
Merge pull request #5209 from CodingFabian/text-layer-transform-origin

Set transformOrigin for text layer in css.
Avoid creating intermediate strings in sanitizeMetrics

This patch avoids creating many intermediate strings, when adding dummy width/lsb entries for glyphs where those are missing.
For the relevant PDF files in our test suite, the average number of intermediate strings are well over 1000.
Merge pull request #5219 from Snuffleupagus/sanitizeMetrics-avoid-intermediate-strings

Avoid creating intermediate strings in sanitizeMetrics
Chrome extension: Isolate pageAction logic

Remove pageAction logic from extension router, and put it in a
separate file. The pageAction URL parsing logic has been simplified,
and all pageAction-related files have been moved to a separate directory.
Merge pull request #5232 from Rob--W/crx-isolate-pageAction-logic

Chrome extension: Isolate pageAction logic
In src/display/api.js, add documentation for the |progressCallback| parameter in |PDFJS.getDocument|