mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-20 07:08:08 +02:00
Merge pull request #7829 from Snuffleupagus/finishPaintTask-promise
Let `finishPaintTask` in pdf_page_view.js return a promise instead, to avoid having to throw in the `paintTask.promise` rejection handler, and don't reject the `PDFPageView_draw` promise when rendering is `cancelled`
This commit is contained in:
commit
22f0a04df0
1 changed files with 17 additions and 12 deletions
|
@ -423,7 +423,7 @@ var PDFPageView = (function PDFPageViewClosure() {
|
|||
|
||||
if (error === 'cancelled') {
|
||||
self.error = null;
|
||||
return;
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
|
||||
self.renderingState = RenderingStates.FINISHED;
|
||||
|
@ -459,6 +459,11 @@ var PDFPageView = (function PDFPageViewClosure() {
|
|||
pageNumber: self.id,
|
||||
cssTransform: false,
|
||||
});
|
||||
|
||||
if (error) {
|
||||
return Promise.reject(error);
|
||||
}
|
||||
return Promise.resolve(undefined);
|
||||
};
|
||||
|
||||
var paintTask = this.renderer === RendererType.SVG ?
|
||||
|
@ -468,18 +473,18 @@ var PDFPageView = (function PDFPageViewClosure() {
|
|||
this.paintTask = paintTask;
|
||||
|
||||
var resultPromise = paintTask.promise.then(function () {
|
||||
finishPaintTask(null);
|
||||
if (textLayer) {
|
||||
pdfPage.getTextContent({
|
||||
normalizeWhitespace: true,
|
||||
}).then(function textContentResolved(textContent) {
|
||||
textLayer.setTextContent(textContent);
|
||||
textLayer.render(TEXT_LAYER_RENDER_DELAY);
|
||||
});
|
||||
}
|
||||
return finishPaintTask(null).then(function () {
|
||||
if (textLayer) {
|
||||
pdfPage.getTextContent({
|
||||
normalizeWhitespace: true,
|
||||
}).then(function textContentResolved(textContent) {
|
||||
textLayer.setTextContent(textContent);
|
||||
textLayer.render(TEXT_LAYER_RENDER_DELAY);
|
||||
});
|
||||
}
|
||||
});
|
||||
}, function (reason) {
|
||||
finishPaintTask(reason);
|
||||
throw reason;
|
||||
return finishPaintTask(reason);
|
||||
});
|
||||
|
||||
if (this.annotationLayerFactory) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue