зеркало из https://github.com/mozilla/pjs.git
Bug 743264 - Update pdf.js to version 0.2.536. r=mossop
This commit is contained in:
Родитель
e9a3b24dc9
Коммит
d74c03d969
|
@ -12,6 +12,7 @@
|
||||||
Jakob Miland <saebekassebil@gmail.com>
|
Jakob Miland <saebekassebil@gmail.com>
|
||||||
Artur Adib <aadib@mozilla.com>
|
Artur Adib <aadib@mozilla.com>
|
||||||
Brendan Dahl <bdahl@mozilla.com>
|
Brendan Dahl <bdahl@mozilla.com>
|
||||||
|
David Quintana <gigaherz@gmail.com>
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a
|
Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
copy of this software and associated documentation files (the "Software"),
|
copy of this software and associated documentation files (the "Software"),
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
This is the pdf.js project output, https://github.com/mozilla/pdf.js
|
This is the pdf.js project output, https://github.com/mozilla/pdf.js
|
||||||
|
|
||||||
Current extension version is: 0.2.414
|
Current extension version is: 0.2.536
|
||||||
|
|
||||||
|
|
|
@ -30,23 +30,11 @@ function log(aMsg) {
|
||||||
Services.console.logStringMessage(msg);
|
Services.console.logStringMessage(msg);
|
||||||
dump(msg + '\n');
|
dump(msg + '\n');
|
||||||
}
|
}
|
||||||
function getWindow(top, id) {
|
|
||||||
return top.QueryInterface(Ci.nsIInterfaceRequestor)
|
function getDOMWindow(aChannel) {
|
||||||
.getInterface(Ci.nsIDOMWindowUtils)
|
var requestor = aChannel.notificationCallbacks;
|
||||||
.getOuterWindowWithId(id);
|
var win = requestor.getInterface(Components.interfaces.nsIDOMWindow);
|
||||||
}
|
return win;
|
||||||
function windowID(win) {
|
|
||||||
return win.QueryInterface(Ci.nsIInterfaceRequestor)
|
|
||||||
.getInterface(Ci.nsIDOMWindowUtils)
|
|
||||||
.outerWindowID;
|
|
||||||
}
|
|
||||||
function topWindow(win) {
|
|
||||||
return win.QueryInterface(Ci.nsIInterfaceRequestor)
|
|
||||||
.getInterface(Ci.nsIWebNavigation)
|
|
||||||
.QueryInterface(Ci.nsIDocShellTreeItem)
|
|
||||||
.rootTreeItem
|
|
||||||
.QueryInterface(Ci.nsIInterfaceRequestor)
|
|
||||||
.getInterface(Ci.nsIDOMWindow);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// All the priviledged actions.
|
// All the priviledged actions.
|
||||||
|
@ -75,6 +63,7 @@ ChromeActions.prototype = {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// Event listener to trigger chrome privedged code.
|
// Event listener to trigger chrome privedged code.
|
||||||
function RequestListener(actions) {
|
function RequestListener(actions) {
|
||||||
this.actions = actions;
|
this.actions = actions;
|
||||||
|
@ -163,38 +152,32 @@ PdfStreamConverter.prototype = {
|
||||||
var channel = ioService.newChannel(
|
var channel = ioService.newChannel(
|
||||||
'resource://pdf.js/web/viewer.html', null, null);
|
'resource://pdf.js/web/viewer.html', null, null);
|
||||||
|
|
||||||
|
var listener = this.listener;
|
||||||
|
// Proxy all the request observer calls, when it gets to onStopRequest
|
||||||
|
// we can get the dom window.
|
||||||
|
var proxy = {
|
||||||
|
onStartRequest: function() {
|
||||||
|
listener.onStartRequest.apply(listener, arguments);
|
||||||
|
},
|
||||||
|
onDataAvailable: function() {
|
||||||
|
listener.onDataAvailable.apply(listener, arguments);
|
||||||
|
},
|
||||||
|
onStopRequest: function() {
|
||||||
|
var domWindow = getDOMWindow(channel);
|
||||||
|
// Double check the url is still the correct one.
|
||||||
|
if (domWindow.document.documentURIObject.equals(aRequest.URI)) {
|
||||||
|
let requestListener = new RequestListener(new ChromeActions);
|
||||||
|
domWindow.addEventListener(PDFJS_EVENT_ID, function(event) {
|
||||||
|
requestListener.receive(event);
|
||||||
|
}, false, true);
|
||||||
|
}
|
||||||
|
listener.onStopRequest.apply(listener, arguments);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// Keep the URL the same so the browser sees it as the same.
|
// Keep the URL the same so the browser sees it as the same.
|
||||||
channel.originalURI = aRequest.URI;
|
channel.originalURI = aRequest.URI;
|
||||||
channel.asyncOpen(this.listener, aContext);
|
channel.asyncOpen(proxy, aContext);
|
||||||
|
|
||||||
// Setup a global listener waiting for the next DOM to be created and verfiy
|
|
||||||
// that its the one we want by its URL. When the correct DOM is found create
|
|
||||||
// an event listener on that window for the pdf.js events that require
|
|
||||||
// chrome priviledges. Code snippet from John Galt.
|
|
||||||
let window = aRequest.loadGroup.groupObserver
|
|
||||||
.QueryInterface(Ci.nsIWebProgress)
|
|
||||||
.DOMWindow;
|
|
||||||
let top = topWindow(window);
|
|
||||||
let id = windowID(window);
|
|
||||||
window = null;
|
|
||||||
|
|
||||||
top.addEventListener('DOMWindowCreated', function onDOMWinCreated(event) {
|
|
||||||
let doc = event.originalTarget;
|
|
||||||
let win = doc.defaultView;
|
|
||||||
|
|
||||||
if (id == windowID(win)) {
|
|
||||||
top.removeEventListener('DOMWindowCreated', onDOMWinCreated, true);
|
|
||||||
if (!doc.documentURIObject.equals(aRequest.URI))
|
|
||||||
return;
|
|
||||||
|
|
||||||
let requestListener = new RequestListener(new ChromeActions);
|
|
||||||
win.addEventListener(PDFJS_EVENT_ID, function(event) {
|
|
||||||
requestListener.receive(event);
|
|
||||||
}, false, true);
|
|
||||||
} else if (!getWindow(top, id)) {
|
|
||||||
top.removeEventListener('DOMWindowCreated', onDOMWinCreated, true);
|
|
||||||
}
|
|
||||||
}, true);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// nsIRequestObserver::onStopRequest
|
// nsIRequestObserver::onStopRequest
|
||||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -391,11 +391,43 @@ canvas {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#loading {
|
#loadingBox {
|
||||||
margin: 100px 0;
|
margin: 100px 0;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#loadingBar {
|
||||||
|
background-color: #333;
|
||||||
|
display: inline-block;
|
||||||
|
border: 1px solid black;
|
||||||
|
clear: both;
|
||||||
|
margin:0px;
|
||||||
|
line-height: 0;
|
||||||
|
border-radius: 4px;
|
||||||
|
width: 15em;
|
||||||
|
height: 1.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
#loadingBar .progress {
|
||||||
|
background-color: green;
|
||||||
|
display: inline-block;
|
||||||
|
float: left;
|
||||||
|
|
||||||
|
background: #b4e391;
|
||||||
|
background: -moz-linear-gradient(top, #b4e391 0%, #61c419 50%, #b4e391 100%);
|
||||||
|
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#b4e391), color-stop(50%,#61c419), color-stop(100%,#b4e391));
|
||||||
|
background: -webkit-linear-gradient(top, #b4e391 0%,#61c419 50%,#b4e391 100%);
|
||||||
|
background: -o-linear-gradient(top, #b4e391 0%,#61c419 50%,#b4e391 100%);
|
||||||
|
background: -ms-linear-gradient(top, #b4e391 0%,#61c419 50%,#b4e391 100%);
|
||||||
|
background: linear-gradient(top, #b4e391 0%,#61c419 50%,#b4e391 100%);
|
||||||
|
|
||||||
|
border-top-left-radius: 3px;
|
||||||
|
border-bottom-left-radius: 3px;
|
||||||
|
|
||||||
|
width: 0%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
#PDFBug {
|
#PDFBug {
|
||||||
font-size: 10px;
|
font-size: 10px;
|
||||||
position: fixed;
|
position: fixed;
|
||||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -15,6 +15,15 @@ var kMaxScale = 4.0;
|
||||||
var kImageDirectory = './images/';
|
var kImageDirectory = './images/';
|
||||||
var kSettingsMemory = 20;
|
var kSettingsMemory = 20;
|
||||||
|
|
||||||
|
function getFileName(url) {
|
||||||
|
var anchor = url.indexOf('#');
|
||||||
|
var query = url.indexOf('?');
|
||||||
|
var end = Math.min(
|
||||||
|
anchor > 0 ? anchor : url.length,
|
||||||
|
query > 0 ? query : url.length);
|
||||||
|
return url.substring(url.lastIndexOf('/', end) + 1, end);
|
||||||
|
}
|
||||||
|
|
||||||
var Cache = function cacheCache(size) {
|
var Cache = function cacheCache(size) {
|
||||||
var data = [];
|
var data = [];
|
||||||
this.push = function cachePush(view) {
|
this.push = function cachePush(view) {
|
||||||
|
@ -27,6 +36,48 @@ var Cache = function cacheCache(size) {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var ProgressBar = (function ProgressBarClosure() {
|
||||||
|
|
||||||
|
function clamp(v, min, max) {
|
||||||
|
return Math.min(Math.max(v, min), max);
|
||||||
|
}
|
||||||
|
|
||||||
|
function ProgressBar(id, opts) {
|
||||||
|
|
||||||
|
// Fetch the sub-elements for later
|
||||||
|
this.div = document.querySelector(id + ' .progress');
|
||||||
|
|
||||||
|
// Get options, with sensible defaults
|
||||||
|
this.height = opts.height || 100;
|
||||||
|
this.width = opts.width || 100;
|
||||||
|
this.units = opts.units || '%';
|
||||||
|
this.percent = opts.percent || 0;
|
||||||
|
|
||||||
|
// Initialize heights
|
||||||
|
this.div.style.height = this.height + this.units;
|
||||||
|
}
|
||||||
|
|
||||||
|
ProgressBar.prototype = {
|
||||||
|
|
||||||
|
updateBar: function ProgressBar_updateBar() {
|
||||||
|
var progressSize = this.width * this._percent / 100;
|
||||||
|
|
||||||
|
this.div.style.width = progressSize + this.units;
|
||||||
|
},
|
||||||
|
|
||||||
|
get percent() {
|
||||||
|
return this._percent;
|
||||||
|
},
|
||||||
|
|
||||||
|
set percent(val) {
|
||||||
|
this._percent = clamp(val, 0, 100);
|
||||||
|
this.updateBar();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return ProgressBar;
|
||||||
|
})();
|
||||||
|
|
||||||
var RenderingQueue = (function RenderingQueueClosure() {
|
var RenderingQueue = (function RenderingQueueClosure() {
|
||||||
function RenderingQueue() {
|
function RenderingQueue() {
|
||||||
this.items = [];
|
this.items = [];
|
||||||
|
@ -258,7 +309,13 @@ var PDFView = {
|
||||||
},
|
},
|
||||||
|
|
||||||
open: function pdfViewOpen(url, scale) {
|
open: function pdfViewOpen(url, scale) {
|
||||||
document.title = this.url = url;
|
this.url = url;
|
||||||
|
|
||||||
|
document.title = decodeURIComponent(getFileName(url)) || url;
|
||||||
|
|
||||||
|
if (!PDFView.loadingBar) {
|
||||||
|
PDFView.loadingBar = new ProgressBar('#loadingBar', {});
|
||||||
|
}
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
PDFJS.getPdf(
|
PDFJS.getPdf(
|
||||||
|
@ -400,6 +457,8 @@ var PDFView = {
|
||||||
var percent = Math.round(level * 100);
|
var percent = Math.round(level * 100);
|
||||||
var loadingIndicator = document.getElementById('loading');
|
var loadingIndicator = document.getElementById('loading');
|
||||||
loadingIndicator.textContent = 'Loading... ' + percent + '%';
|
loadingIndicator.textContent = 'Loading... ' + percent + '%';
|
||||||
|
|
||||||
|
PDFView.loadingBar.percent = percent;
|
||||||
},
|
},
|
||||||
|
|
||||||
load: function pdfViewLoad(data, scale) {
|
load: function pdfViewLoad(data, scale) {
|
||||||
|
@ -414,8 +473,8 @@ var PDFView = {
|
||||||
var errorWrapper = document.getElementById('errorWrapper');
|
var errorWrapper = document.getElementById('errorWrapper');
|
||||||
errorWrapper.setAttribute('hidden', 'true');
|
errorWrapper.setAttribute('hidden', 'true');
|
||||||
|
|
||||||
var loadingIndicator = document.getElementById('loading');
|
var loadingBox = document.getElementById('loadingBox');
|
||||||
loadingIndicator.setAttribute('hidden', 'true');
|
loadingBox.setAttribute('hidden', 'true');
|
||||||
|
|
||||||
var sidebar = document.getElementById('sidebarView');
|
var sidebar = document.getElementById('sidebarView');
|
||||||
sidebar.parentNode.scrollTop = 0;
|
sidebar.parentNode.scrollTop = 0;
|
||||||
|
@ -499,6 +558,24 @@ var PDFView = {
|
||||||
// Setting the default one.
|
// Setting the default one.
|
||||||
this.parseScale(kDefaultScale, true);
|
this.parseScale(kDefaultScale, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.metadata = null;
|
||||||
|
var metadata = pdf.catalog.metadata;
|
||||||
|
var info = this.documentInfo = pdf.info;
|
||||||
|
var pdfTitle;
|
||||||
|
|
||||||
|
if (metadata) {
|
||||||
|
this.metadata = metadata = new PDFJS.Metadata(metadata);
|
||||||
|
|
||||||
|
if (metadata.has('dc:title'))
|
||||||
|
pdfTitle = metadata.get('dc:title');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!pdfTitle && info && info['Title'])
|
||||||
|
pdfTitle = info['Title'];
|
||||||
|
|
||||||
|
if (pdfTitle)
|
||||||
|
document.title = pdfTitle;
|
||||||
},
|
},
|
||||||
|
|
||||||
setHash: function pdfViewSetHash(hash) {
|
setHash: function pdfViewSetHash(hash) {
|
||||||
|
@ -1195,10 +1272,6 @@ window.addEventListener('load', function webViewerLoad(evt) {
|
||||||
sidebarScrollView.addEventListener('scroll', updateThumbViewArea, true);
|
sidebarScrollView.addEventListener('scroll', updateThumbViewArea, true);
|
||||||
}, true);
|
}, true);
|
||||||
|
|
||||||
window.addEventListener('unload', function webViewerUnload(evt) {
|
|
||||||
window.scrollTo(0, 0);
|
|
||||||
}, true);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Render the next not yet visible page already such that it is
|
* Render the next not yet visible page already such that it is
|
||||||
* hopefully ready once the user scrolls to it.
|
* hopefully ready once the user scrolls to it.
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
<Description about="urn:mozilla:install-manifest">
|
<Description about="urn:mozilla:install-manifest">
|
||||||
<em:id>uriloader@pdf.js</em:id>
|
<em:id>uriloader@pdf.js</em:id>
|
||||||
<em:name>PDF Viewer</em:name>
|
<em:name>PDF Viewer</em:name>
|
||||||
<em:version>0.2.414</em:version>
|
<em:version>0.2.536</em:version>
|
||||||
<em:targetApplication>
|
<em:targetApplication>
|
||||||
<Description>
|
<Description>
|
||||||
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
|
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
|
||||||
|
@ -20,7 +20,7 @@
|
||||||
<em:bootstrap>true</em:bootstrap>
|
<em:bootstrap>true</em:bootstrap>
|
||||||
<em:creator>Mozilla</em:creator>
|
<em:creator>Mozilla</em:creator>
|
||||||
<em:description>Uses HTML5 to display PDF files directly in Firefox.</em:description>
|
<em:description>Uses HTML5 to display PDF files directly in Firefox.</em:description>
|
||||||
<em:homepageURL>http://support.mozilla.org/kb/using-mozilla-pdf-viewer</em:homepageURL>
|
<em:homepageURL>https://support.mozilla.org/kb/Opening%20PDF%20files%20within%20Firefox</em:homepageURL>
|
||||||
<em:type>2</em:type>
|
<em:type>2</em:type>
|
||||||
</Description>
|
</Description>
|
||||||
</RDF>
|
</RDF>
|
||||||
|
|
Загрузка…
Ссылка в новой задаче