[Pkg-javascript-commits] [pdf.js] 72/246: Load file:-URLs in the main thread.

David Prévot taffit at moszumanska.debian.org
Sun Sep 7 15:36:26 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository pdf.js.

commit bd25f6be9493cd918b27b78c2c50304d8a4dfafc
Author: Rob Wu <rob at robwu.nl>
Date:   Wed Jul 30 01:28:41 2014 +0200

    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.
---
 web/viewer.js | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/web/viewer.js b/web/viewer.js
index 1be81e0..adb0869 100644
--- a/web/viewer.js
+++ b/web/viewer.js
@@ -1952,6 +1952,28 @@ function webViewerInitialized() {
 //return;
 //#endif
 
+//#if GENERIC
+  if (file && file.lastIndexOf('file:', 0) === 0) {
+    // file:-scheme. Load the contents in the main thread because QtWebKit
+    // cannot load file:-URLs in a Web Worker. file:-URLs are usually loaded
+    // very quickly, so there is no need to set up progress event listeners.
+    PDFView.setTitleUsingUrl(file);
+    var xhr = new XMLHttpRequest();
+    xhr.onload = function() {
+      PDFView.open(new Uint8Array(xhr.response), 0);
+    };
+    try {
+      xhr.open('GET', file);
+      xhr.responseType = 'arraybuffer';
+      xhr.send();
+    } catch (e) {
+      PDFView.error(mozL10n.get('loading_error', null,
+            'An error occurred while loading the PDF.'), e);
+    }
+    return;
+  }
+//#endif
+
 //#if !B2G && !CHROME
   if (file) {
     PDFView.open(file, 0);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/pdf.js.git



More information about the Pkg-javascript-commits mailing list