mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-20 15:18:08 +02:00
Introduces LegacyPromise; polyfills DOM Promise
This commit is contained in:
parent
122cd150d4
commit
5bf3e44e30
20 changed files with 263 additions and 156 deletions
|
@ -269,7 +269,10 @@ function nextPage(task, loadError) {
|
|||
clear(ctx);
|
||||
|
||||
var drawContext, textLayerBuilder;
|
||||
var initPromise = new Promise();
|
||||
var resolveInitPromise;
|
||||
var initPromise = new Promise(function (resolve) {
|
||||
resolveInitPromise = resolve;
|
||||
});
|
||||
if (task.type == 'text') {
|
||||
// using dummy canvas for pdf context drawing operations
|
||||
if (!dummyCanvas) {
|
||||
|
@ -281,12 +284,12 @@ function nextPage(task, loadError) {
|
|||
|
||||
page.getTextContent().then(function(textContent) {
|
||||
textLayerBuilder.setTextContent(textContent);
|
||||
initPromise.resolve();
|
||||
resolveInitPromise();
|
||||
});
|
||||
} else {
|
||||
drawContext = ctx;
|
||||
textLayerBuilder = new NullTextLayerBuilder();
|
||||
initPromise.resolve();
|
||||
resolveInitPromise();
|
||||
}
|
||||
var renderContext = {
|
||||
canvasContext: drawContext,
|
||||
|
@ -300,7 +303,7 @@ function nextPage(task, loadError) {
|
|||
snapshotCurrentPage(task, error);
|
||||
});
|
||||
initPromise.then(function () {
|
||||
page.render(renderContext).then(function() {
|
||||
page.render(renderContext).promise.then(function() {
|
||||
completeRender(false);
|
||||
},
|
||||
function(error) {
|
||||
|
|
|
@ -80,10 +80,13 @@ describe('api', function() {
|
|||
});
|
||||
});
|
||||
describe('Page', function() {
|
||||
var promise = new Promise();
|
||||
var resolvePromise;
|
||||
var promise = new Promise(function (resolve) {
|
||||
resolvePromise = resolve;
|
||||
});
|
||||
PDFJS.getDocument(basicApiUrl).then(function(doc) {
|
||||
doc.getPage(1).then(function(data) {
|
||||
promise.resolve(data);
|
||||
resolvePromise(data);
|
||||
});
|
||||
});
|
||||
var page;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue