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:
parent
7f73fc9ace
commit
2570717e77
@ -16,10 +16,9 @@
|
|||||||
|
|
||||||
import {
|
import {
|
||||||
assert, createPromiseCapability, getVerbosityLevel, info, InvalidPDFException,
|
assert, createPromiseCapability, getVerbosityLevel, info, InvalidPDFException,
|
||||||
isArrayBuffer, isSameOrigin, loadJpegStream, MessageHandler,
|
isArrayBuffer, isSameOrigin, MessageHandler, MissingPDFException,
|
||||||
MissingPDFException, NativeImageDecoding, PageViewport, PasswordException,
|
NativeImageDecoding, PageViewport, PasswordException, stringToBytes,
|
||||||
stringToBytes, UnexpectedResponseException, UnknownErrorException,
|
UnexpectedResponseException, UnknownErrorException, unreachable, Util, warn
|
||||||
unreachable, Util, warn
|
|
||||||
} from '../shared/util';
|
} from '../shared/util';
|
||||||
import {
|
import {
|
||||||
DOMCanvasFactory, DOMCMapReaderFactory, DummyStatTimer, getDefaultSetting,
|
DOMCanvasFactory, DOMCMapReaderFactory, DummyStatTimer, getDefaultSetting,
|
||||||
@ -1818,7 +1817,21 @@ var WorkerTransport = (function WorkerTransportClosure() {
|
|||||||
switch (type) {
|
switch (type) {
|
||||||
case 'JpegStream':
|
case 'JpegStream':
|
||||||
imageData = data[3];
|
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;
|
break;
|
||||||
case 'Image':
|
case 'Image':
|
||||||
imageData = data[3];
|
imageData = data[3];
|
||||||
|
@ -1569,18 +1569,6 @@ MessageHandler.prototype = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
function loadJpegStream(id, imageUrl, objs) {
|
|
||||||
var img = new Image();
|
|
||||||
img.onload = (function loadJpegStream_onloadClosure() {
|
|
||||||
objs.resolve(id, img);
|
|
||||||
});
|
|
||||||
img.onerror = (function loadJpegStream_onerrorClosure() {
|
|
||||||
objs.resolve(id, null);
|
|
||||||
warn('Error during JPEG image loading');
|
|
||||||
});
|
|
||||||
img.src = imageUrl;
|
|
||||||
}
|
|
||||||
|
|
||||||
export {
|
export {
|
||||||
FONT_IDENTITY_MATRIX,
|
FONT_IDENTITY_MATRIX,
|
||||||
IDENTITY_MATRIX,
|
IDENTITY_MATRIX,
|
||||||
@ -1632,7 +1620,6 @@ export {
|
|||||||
createValidAbsoluteUrl,
|
createValidAbsoluteUrl,
|
||||||
isLittleEndian,
|
isLittleEndian,
|
||||||
isEvalSupported,
|
isEvalSupported,
|
||||||
loadJpegStream,
|
|
||||||
log2,
|
log2,
|
||||||
readInt8,
|
readInt8,
|
||||||
readUint16,
|
readUint16,
|
||||||
|
Loading…
Reference in New Issue
Block a user