Make QueueOptimizer easier to read.

QueueOptimizer is really hard to read. Enough so that it's blocking my
efforts to streamline the representation used for operator lists.

This patch improves its readability in the following ways.

- More descriptive variable names make the sequence checking much clearer,
  as do additional comments.

- The addState() functions now return the index of the first op past the
  sequence, instead of setting context.currentOperation to the last op of
  the sequence.

- The loop in optimize() is clearer.

- The array modification in the fourth addState() function is much clearer
  -- we're just removing trios of ops.

- All four |addState| functions are now more consistent with each other.

I used some debug printfs to find documents where these optimizations are
used and then checked that the number of optimized ops was the same before
and after my changes.
Minimize memory usage of font-related arrays.

This patch replaces some vanilla arrays with typed arrays, and avoids
some array copying.

It reduces the peak RSS when viewing
http://www.dynacw.co.jp/Portals/3/fontsamplepdf/sample_4942546800828.pdf
from ~940 MiB to ~750 MiB, and reduces its load time from 83 to 76 ms.
Optimize common cases in hexToStr().

This avoids the creation of over two million array objects when viewing
http://www.dynacw.co.jp/Portals/3/fontsamplepdf/sample_4942546800828.pdf,
and reduces load time from 76 to 73 ms.
Converting PDFFindBar and PDFFindController to classes
Represent cid chars using integers, not strings.

cid chars are 16-bit unsigned integers. Currently we convert them to
single-char strings when inserting them into the CMap, and then convert
them back to integers when extracting them from the CMap. This patch
changes CMap so that cid chars stay in integer format throughout, saving
both time and space.

When loading the PDF from issue #4580, this change reduces peak RSS from
~600 to ~370 MiB. It also improves overall speed on that PDF by ~26%,
going from 724 ms to 533 ms.
Load file:-URLs in the main thread.

QtWebKit does not support file:-URLs in Web Workers.
To solve this issue, I'm loading file:-URLs in the main thread
for generic builds. file:-URLs load relatively quick, so there
is no need for sophisticated load progress notifications.
Add reduced test-cases for issues 4875 and 4881
Re-factor heuristics to recognize unknown glyphs for |toUnicode|
Adjust the heuristics to recognize more cases of unknown glyphs for |toUnicode| (issue 5070)
Fix issue where pdfDocument is null

Happens when no file is loaded
Merge pull request #5127 from Hengjie/fix-pdfdocument-null

Fix issue where pdfDocument is null
Compiles some of the FunctionType 4
Optimizes functions to not create arrays
Merge pull request #5129 from Snuffleupagus/issues-4875-4881-tests

Add reduced test-cases for issues 4875 and 4881
Merge pull request #5111 from nnethercote/better-cidchars

Represent cid chars using integers, not strings.
Make IdentityCMaps more compact.

IdentityCMap uses an array to represent a 16-bit unsigned identity
function. This is very space-inefficient, and some files cause multiple
IdentityCMaps to be instantiated (e.g. the one from #4580 has 74).

This patch make the representation implicit.

When loading the PDF from issue #4580, this change reduces peak RSS from
~370 to ~280 MiB. It also improves overall speed on that PDF by ~30%,
going from 522 ms to 366 ms.
Faster JBIG2 bitmap decoding
Properly set this.eof in CCITTFaxStream
Merge pull request #5136 from timvandermeij/ccitt-lines

Properly set this.eof in CCITTFaxStream
Merge pull request #5134 from yurydelendik/fun4

Improves speed of the functions