Inline the code in loadJpegStream at the only call-site in src/display/api.js.js`

Since `loadJpegStream` is only used at a *single* spot in the code-base, and given that it's very heavily tailored to the calling code (since it relies on the data structure of `PDFObjects`), this patch simply inlines the code in `src/display/api.js` instead.
This commit is contained in:
Jonas Jenwald 2018-02-01 15:38:17 +01:00
parent 7f73fc9ace
commit 2570717e77
2 changed files with 18 additions and 18 deletions

View file

@ -16,10 +16,9 @@
import {
assert, createPromiseCapability, getVerbosityLevel, info, InvalidPDFException,
isArrayBuffer, isSameOrigin, loadJpegStream, MessageHandler,
MissingPDFException, NativeImageDecoding, PageViewport, PasswordException,
stringToBytes, UnexpectedResponseException, UnknownErrorException,
unreachable, Util, warn
isArrayBuffer, isSameOrigin, MessageHandler, MissingPDFException,
NativeImageDecoding, PageViewport, PasswordException, stringToBytes,
UnexpectedResponseException, UnknownErrorException, unreachable, Util, warn
} from '../shared/util';
import {
DOMCanvasFactory, DOMCMapReaderFactory, DummyStatTimer, getDefaultSetting,
@ -1818,7 +1817,21 @@ var WorkerTransport = (function WorkerTransportClosure() {
switch (type) {
case 'JpegStream':
imageData = data[3];
loadJpegStream(id, imageData, pageProxy.objs);
new Promise((resolve, reject) => {
const img = new Image();
img.onload = function() {
resolve(img);
};
img.onerror = function() {
reject(new Error('Error during JPEG image loading'));
};
img.src = imageData;
}).then((img) => {
pageProxy.objs.resolve(id, img);
}, (reason) => {
warn(reason);
pageProxy.objs.resolve(id, null);
});
break;
case 'Image':
imageData = data[3];