mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 773422 - Update pdf.js to version 0.3.452. r=Mossop
This commit is contained in:
parent
46385c5488
commit
ad79e37647
@ -1,4 +1,4 @@
|
||||
This is the pdf.js project output, https://github.com/mozilla/pdf.js
|
||||
|
||||
Current extension version is: 0.3.345
|
||||
Current extension version is: 0.3.452
|
||||
|
||||
|
111
browser/extensions/pdfjs/bootstrap.js
vendored
111
browser/extensions/pdfjs/bootstrap.js
vendored
@ -1,111 +0,0 @@
|
||||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
||||
|
||||
'use strict';
|
||||
|
||||
const RESOURCE_NAME = 'pdf.js';
|
||||
const EXT_PREFIX = 'extensions.uriloader@pdf.js';
|
||||
|
||||
let Cc = Components.classes;
|
||||
let Ci = Components.interfaces;
|
||||
let Cm = Components.manager;
|
||||
let Cu = Components.utils;
|
||||
|
||||
Cu.import('resource://gre/modules/Services.jsm');
|
||||
|
||||
function getBoolPref(pref, def) {
|
||||
try {
|
||||
return Services.prefs.getBoolPref(pref);
|
||||
} catch (ex) {
|
||||
return def;
|
||||
}
|
||||
}
|
||||
|
||||
function setStringPref(pref, value) {
|
||||
let str = Cc['@mozilla.org/supports-string;1']
|
||||
.createInstance(Ci.nsISupportsString);
|
||||
str.data = value;
|
||||
Services.prefs.setComplexValue(pref, Ci.nsISupportsString, str);
|
||||
}
|
||||
|
||||
function log(str) {
|
||||
if (!getBoolPref(EXT_PREFIX + '.pdfBugEnabled', false))
|
||||
return;
|
||||
dump(str + '\n');
|
||||
}
|
||||
|
||||
// Register/unregister a class as a component.
|
||||
let Factory = {
|
||||
registrar: null,
|
||||
aClass: null,
|
||||
register: function(aClass) {
|
||||
if (this.aClass) {
|
||||
log('Cannot register more than one class');
|
||||
return;
|
||||
}
|
||||
this.registrar = Cm.QueryInterface(Ci.nsIComponentRegistrar);
|
||||
this.aClass = aClass;
|
||||
var proto = aClass.prototype;
|
||||
this.registrar.registerFactory(proto.classID, proto.classDescription,
|
||||
proto.contractID, this);
|
||||
},
|
||||
unregister: function() {
|
||||
if (!this.aClass) {
|
||||
log('Class was never registered.');
|
||||
return;
|
||||
}
|
||||
var proto = this.aClass.prototype;
|
||||
this.registrar.unregisterFactory(proto.classID, this);
|
||||
this.aClass = null;
|
||||
},
|
||||
// nsIFactory::createInstance
|
||||
createInstance: function(outer, iid) {
|
||||
if (outer !== null)
|
||||
throw Cr.NS_ERROR_NO_AGGREGATION;
|
||||
return (new (this.aClass)).QueryInterface(iid);
|
||||
}
|
||||
};
|
||||
|
||||
let pdfStreamConverterUrl = null;
|
||||
|
||||
// As of Firefox 13 bootstrapped add-ons don't support automatic registering and
|
||||
// unregistering of resource urls and components/contracts. Until then we do
|
||||
// it programatically. See ManifestDirective ManifestParser.cpp for support.
|
||||
|
||||
function startup(aData, aReason) {
|
||||
// Setup the resource url.
|
||||
var ioService = Services.io;
|
||||
var resProt = ioService.getProtocolHandler('resource')
|
||||
.QueryInterface(Ci.nsIResProtocolHandler);
|
||||
var aliasURI = ioService.newURI('content/', 'UTF-8', aData.resourceURI);
|
||||
resProt.setSubstitution(RESOURCE_NAME, aliasURI);
|
||||
|
||||
// Load the component and register it.
|
||||
pdfStreamConverterUrl = aData.resourceURI.spec +
|
||||
'components/PdfStreamConverter.js';
|
||||
Cu.import(pdfStreamConverterUrl);
|
||||
Factory.register(PdfStreamConverter);
|
||||
}
|
||||
|
||||
function shutdown(aData, aReason) {
|
||||
if (aReason == APP_SHUTDOWN)
|
||||
return;
|
||||
var ioService = Services.io;
|
||||
var resProt = ioService.getProtocolHandler('resource')
|
||||
.QueryInterface(Ci.nsIResProtocolHandler);
|
||||
// Remove the resource url.
|
||||
resProt.setSubstitution(RESOURCE_NAME, null);
|
||||
// Remove the contract/component.
|
||||
Factory.unregister();
|
||||
// Unload the converter
|
||||
Cu.unload(pdfStreamConverterUrl);
|
||||
pdfStreamConverterUrl = null;
|
||||
}
|
||||
|
||||
function install(aData, aReason) {
|
||||
}
|
||||
|
||||
function uninstall(aData, aReason) {
|
||||
setStringPref(EXT_PREFIX + '.database', '{}');
|
||||
}
|
||||
|
@ -128,37 +128,55 @@ function ChromeActions(domWindow) {
|
||||
}
|
||||
|
||||
ChromeActions.prototype = {
|
||||
download: function(data) {
|
||||
var handlerInfo = Svc.mime
|
||||
.getFromTypeAndExtension('application/pdf', 'pdf');
|
||||
var uri = NetUtil.newURI(data);
|
||||
|
||||
download: function(data, sendResponse) {
|
||||
var originalUrl = data.originalUrl;
|
||||
// The data may not be downloaded so we need just retry getting the pdf with
|
||||
// the original url.
|
||||
var originalUri = NetUtil.newURI(data.originalUrl);
|
||||
var blobUri = data.blobUrl ? NetUtil.newURI(data.blobUrl) : originalUri;
|
||||
var extHelperAppSvc =
|
||||
Cc['@mozilla.org/uriloader/external-helper-app-service;1'].
|
||||
getService(Ci.nsIExternalHelperAppService);
|
||||
getService(Ci.nsIExternalHelperAppService);
|
||||
var frontWindow = Cc['@mozilla.org/embedcomp/window-watcher;1'].
|
||||
getService(Ci.nsIWindowWatcher).activeWindow;
|
||||
var ioService = Services.io;
|
||||
var channel = ioService.newChannel(data, null, null);
|
||||
var listener = {
|
||||
extListener: null,
|
||||
onStartRequest: function(aRequest, aContext) {
|
||||
this.extListener = extHelperAppSvc.doContent('application/pdf',
|
||||
aRequest, frontWindow, false);
|
||||
this.extListener.onStartRequest(aRequest, aContext);
|
||||
},
|
||||
onStopRequest: function(aRequest, aContext, aStatusCode) {
|
||||
if (this.extListener)
|
||||
this.extListener.onStopRequest(aRequest, aContext, aStatusCode);
|
||||
},
|
||||
onDataAvailable: function(aRequest, aContext, aInputStream, aOffset,
|
||||
aCount) {
|
||||
this.extListener.onDataAvailable(aRequest, aContext, aInputStream,
|
||||
aOffset, aCount);
|
||||
}
|
||||
};
|
||||
getService(Ci.nsIWindowWatcher).activeWindow;
|
||||
|
||||
channel.asyncOpen(listener, null);
|
||||
NetUtil.asyncFetch(blobUri, function(aInputStream, aResult) {
|
||||
if (!Components.isSuccessCode(aResult)) {
|
||||
if (sendResponse)
|
||||
sendResponse(true);
|
||||
return;
|
||||
}
|
||||
// Create a nsIInputStreamChannel so we can set the url on the channel
|
||||
// so the filename will be correct.
|
||||
let channel = Cc['@mozilla.org/network/input-stream-channel;1'].
|
||||
createInstance(Ci.nsIInputStreamChannel);
|
||||
channel.setURI(originalUri);
|
||||
channel.contentStream = aInputStream;
|
||||
channel.QueryInterface(Ci.nsIChannel);
|
||||
|
||||
var listener = {
|
||||
extListener: null,
|
||||
onStartRequest: function(aRequest, aContext) {
|
||||
this.extListener = extHelperAppSvc.doContent('application/pdf',
|
||||
aRequest, frontWindow, false);
|
||||
this.extListener.onStartRequest(aRequest, aContext);
|
||||
},
|
||||
onStopRequest: function(aRequest, aContext, aStatusCode) {
|
||||
if (this.extListener)
|
||||
this.extListener.onStopRequest(aRequest, aContext, aStatusCode);
|
||||
// Notify the content code we're done downloading.
|
||||
if (sendResponse)
|
||||
sendResponse(false);
|
||||
},
|
||||
onDataAvailable: function(aRequest, aContext, aInputStream, aOffset,
|
||||
aCount) {
|
||||
this.extListener.onDataAvailable(aRequest, aContext, aInputStream,
|
||||
aOffset, aCount);
|
||||
}
|
||||
};
|
||||
|
||||
channel.asyncOpen(listener, null);
|
||||
});
|
||||
},
|
||||
setDatabase: function(data) {
|
||||
if (inPrivateBrowsing)
|
||||
@ -195,7 +213,7 @@ ChromeActions.prototype = {
|
||||
searchEnabled: function() {
|
||||
return getBoolPref(PREF_PREFIX + '.searchEnabled', false);
|
||||
},
|
||||
fallback: function(url) {
|
||||
fallback: function(url, sendResponse) {
|
||||
var self = this;
|
||||
var domWindow = this.domWindow;
|
||||
var strings = getLocalizedStrings('chrome.properties');
|
||||
@ -204,17 +222,32 @@ ChromeActions.prototype = {
|
||||
var win = Services.wm.getMostRecentWindow('navigator:browser');
|
||||
var browser = win.gBrowser.getBrowserForDocument(domWindow.top.document);
|
||||
var notificationBox = win.gBrowser.getNotificationBox(browser);
|
||||
// Flag so we don't call the response callback twice, since if the user
|
||||
// clicks open with different viewer both the button callback and
|
||||
// eventCallback will be called.
|
||||
var sentResponse = false;
|
||||
var buttons = [{
|
||||
label: getLocalizedString(strings, 'open_with_different_viewer'),
|
||||
accessKey: getLocalizedString(strings, 'open_with_different_viewer',
|
||||
'accessKey'),
|
||||
callback: function() {
|
||||
self.download(url);
|
||||
sentResponse = true;
|
||||
sendResponse(true);
|
||||
}
|
||||
}];
|
||||
notificationBox.appendNotification(message, 'pdfjs-fallback', null,
|
||||
notificationBox.PRIORITY_WARNING_LOW,
|
||||
buttons);
|
||||
buttons,
|
||||
function eventsCallback(eventType) {
|
||||
// Currently there is only one event "removed" but if there are any other
|
||||
// added in the future we still only care about removed at the moment.
|
||||
if (eventType !== 'removed')
|
||||
return;
|
||||
// Don't send a response again if we already responded when the button was
|
||||
// clicked.
|
||||
if (!sentResponse)
|
||||
sendResponse(false);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@ -222,20 +255,38 @@ ChromeActions.prototype = {
|
||||
function RequestListener(actions) {
|
||||
this.actions = actions;
|
||||
}
|
||||
// Receive an event and synchronously responds.
|
||||
// Receive an event and synchronously or asynchronously responds.
|
||||
RequestListener.prototype.receive = function(event) {
|
||||
var message = event.target;
|
||||
var doc = message.ownerDocument;
|
||||
var action = message.getUserData('action');
|
||||
var data = message.getUserData('data');
|
||||
var sync = message.getUserData('sync');
|
||||
var actions = this.actions;
|
||||
if (!(action in actions)) {
|
||||
log('Unknown action: ' + action);
|
||||
return;
|
||||
}
|
||||
var response = actions[action].call(this.actions, data);
|
||||
message.setUserData('response', response, null);
|
||||
};
|
||||
if (sync) {
|
||||
var response = actions[action].call(this.actions, data);
|
||||
message.setUserData('response', response, null);
|
||||
} else {
|
||||
var response;
|
||||
if (!message.getUserData('callback')) {
|
||||
doc.documentElement.removeChild(message);
|
||||
response = null;
|
||||
} else {
|
||||
response = function sendResponse(response) {
|
||||
message.setUserData('response', response, null);
|
||||
|
||||
var listener = doc.createEvent('HTMLEvents');
|
||||
listener.initEvent('pdf.js.response', true, false);
|
||||
return message.dispatchEvent(listener);
|
||||
}
|
||||
}
|
||||
actions[action].call(this.actions, data, response);
|
||||
}
|
||||
};
|
||||
|
||||
function PdfStreamConverter() {
|
||||
}
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 708 B After Width: | Height: | Size: 417 B |
@ -9,7 +9,7 @@
|
||||
|
||||
// fetch an l10n objects
|
||||
function getL10nData(key) {
|
||||
var response = FirefoxCom.request('getStrings', key);
|
||||
var response = FirefoxCom.requestSync('getStrings', key);
|
||||
var data = JSON.parse(response);
|
||||
if (!data)
|
||||
console.warn('[l10n] #' + key + ' missing for [' + gLanguage + ']');
|
||||
@ -78,7 +78,7 @@
|
||||
}
|
||||
|
||||
window.addEventListener('DOMContentLoaded', function() {
|
||||
gLanguage = FirefoxCom.request('getLocale', null);
|
||||
gLanguage = FirefoxCom.requestSync('getLocale', null);
|
||||
|
||||
translateFragment();
|
||||
|
||||
|
@ -11,7 +11,13 @@ body {
|
||||
height: 100%;
|
||||
background-color: #404040;
|
||||
background-image: url(images/texture.png);
|
||||
font-family: Segoe UI, Verdana, sans-serif;
|
||||
}
|
||||
|
||||
body,
|
||||
input,
|
||||
button,
|
||||
select {
|
||||
font: message-box;
|
||||
}
|
||||
|
||||
.hidden {
|
||||
@ -54,19 +60,31 @@ html[dir='rtl'] .innerCenter {
|
||||
bottom: 0;
|
||||
width: 200px;
|
||||
visibility: hidden;
|
||||
-moz-transition-duration: 200ms;
|
||||
-moz-transition-timing-function: ease;
|
||||
-webkit-transition-duration: 200ms;
|
||||
-webkit-transition-timing-function: ease;
|
||||
-moz-transition-duration: 200ms;
|
||||
-moz-transition-timing-function: ease;
|
||||
-ms-transition-duration: 200ms;
|
||||
-ms-transition-timing-function: ease;
|
||||
-o-transition-duration: 200ms;
|
||||
-o-transition-timing-function: ease;
|
||||
transition-duration: 200ms;
|
||||
transition-timing-function: ease;
|
||||
|
||||
}
|
||||
html[dir='ltr'] #sidebarContainer {
|
||||
-moz-transition-property: left;
|
||||
-webkit-transition-property: left;
|
||||
-moz-transition-property: left;
|
||||
-ms-transition-property: left;
|
||||
-o-transition-property: left;
|
||||
transition-property: left;
|
||||
left: -200px;
|
||||
}
|
||||
html[dir='rtl'] #sidebarContainer {
|
||||
-moz-transition-property: right;
|
||||
-webkit-transition-property: right;
|
||||
-ms-transition-property: right;
|
||||
-o-transition-property: right;
|
||||
transition-property: right;
|
||||
right: -200px;
|
||||
}
|
||||
|
||||
@ -87,19 +105,31 @@ html[dir='rtl'] #outerContainer.sidebarOpen > #sidebarContainer {
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
-moz-transition-duration: 200ms;
|
||||
-moz-transition-timing-function: ease;
|
||||
-webkit-transition-duration: 200ms;
|
||||
-webkit-transition-timing-function: ease;
|
||||
-moz-transition-duration: 200ms;
|
||||
-moz-transition-timing-function: ease;
|
||||
-ms-transition-duration: 200ms;
|
||||
-ms-transition-timing-function: ease;
|
||||
-o-transition-duration: 200ms;
|
||||
-o-transition-timing-function: ease;
|
||||
transition-duration: 200ms;
|
||||
transition-timing-function: ease;
|
||||
}
|
||||
html[dir='ltr'] #outerContainer.sidebarOpen > #mainContainer {
|
||||
-moz-transition-property: left;
|
||||
-webkit-transition-property: left;
|
||||
-moz-transition-property: left;
|
||||
-ms-transition-property: left;
|
||||
-o-transition-property: left;
|
||||
transition-property: left;
|
||||
left: 200px;
|
||||
}
|
||||
html[dir='rtl'] #outerContainer.sidebarOpen > #mainContainer {
|
||||
-moz-transition-property: right;
|
||||
-webkit-transition-property: right;
|
||||
-moz-transition-property: right;
|
||||
-ms-transition-property: right;
|
||||
-o-transition-property: right;
|
||||
transition-property: right;
|
||||
right: 200px;
|
||||
}
|
||||
|
||||
@ -146,11 +176,17 @@ html[dir='rtl'] #sidebarContent {
|
||||
|
||||
#toolbarSidebar {
|
||||
width: 200px;
|
||||
height: 32px;
|
||||
height: 29px;
|
||||
background-image: url(images/texture.png),
|
||||
-webkit-linear-gradient(hsla(0,0%,30%,.99), hsla(0,0%,25%,.95));
|
||||
background-image: url(images/texture.png),
|
||||
-moz-linear-gradient(hsla(0,0%,30%,.99), hsla(0,0%,25%,.95));
|
||||
background-image: url(images/texture.png),
|
||||
-webkit-linear-gradient(hsla(0,0%,30%,.99), hsla(0,0%,25%,.95));
|
||||
-ms-linear-gradient(hsla(0,0%,30%,.99), hsla(0,0%,25%,.95));
|
||||
background-image: url(images/texture.png),
|
||||
-o-linear-gradient(hsla(0,0%,30%,.99), hsla(0,0%,25%,.95));
|
||||
background-image: url(images/texture.png),
|
||||
linear-gradient(hsla(0,0%,30%,.99), hsla(0,0%,25%,.95));
|
||||
box-shadow: inset -2px 0 0 hsla(0,0%,100%,.08),
|
||||
inset 0 1px 1px hsla(0,0%,0%,.15),
|
||||
inset 0 -1px 0 hsla(0,0%,100%,.05),
|
||||
@ -161,10 +197,16 @@ html[dir='rtl'] #sidebarContent {
|
||||
#toolbarViewer {
|
||||
position: relative;
|
||||
height: 32px;
|
||||
background-image: url(images/texture.png),
|
||||
-webkit-linear-gradient(hsla(0,0%,32%,.99), hsla(0,0%,27%,.95));
|
||||
background-image: url(images/texture.png),
|
||||
-moz-linear-gradient(hsla(0,0%,32%,.99), hsla(0,0%,27%,.95));
|
||||
background-image: url(images/texture.png),
|
||||
-webkit-linear-gradient(hsla(0,0%,32%,.99), hsla(0,0%,27%,.95));
|
||||
-ms-linear-gradient(hsla(0,0%,32%,.99), hsla(0,0%,27%,.95));
|
||||
background-image: url(images/texture.png),
|
||||
-o-linear-gradient(hsla(0,0%,32%,.99), hsla(0,0%,27%,.95));
|
||||
background-image: url(images/texture.png),
|
||||
linear-gradient(hsla(0,0%,32%,.99), hsla(0,0%,27%,.95));
|
||||
border-left: 1px solid hsla(0,0%,0%,.5);
|
||||
box-shadow: inset 1px 0 0 hsla(0,0%,100%,.08),
|
||||
inset 0 1px 1px hsla(0,0%,0%,.15),
|
||||
@ -242,28 +284,48 @@ html[dir='rtl'] .splitToolbarButton > .toolbarButton {
|
||||
margin-right:0;
|
||||
}
|
||||
|
||||
.splitToolbarButton.toggled .toolbarButton {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.splitToolbarButton:hover > .toolbarButton,
|
||||
.splitToolbarButton:focus > .toolbarButton,
|
||||
.splitToolbarButton.toggled > .toolbarButton {
|
||||
.splitToolbarButton.toggled > .toolbarButton,
|
||||
.toolbarButton.textButton {
|
||||
background-color: hsla(0,0%,0%,.12);
|
||||
background-image: -moz-linear-gradient(hsla(0,0%,100%,.05), hsla(0,0%,100%,0));
|
||||
background-image: -webkit-linear-gradient(hsla(0,0%,100%,.05), hsla(0,0%,100%,0));
|
||||
background-image: -moz-linear-gradient(hsla(0,0%,100%,.05), hsla(0,0%,100%,0));
|
||||
background-image: -ms-linear-gradient(hsla(0,0%,100%,.05), hsla(0,0%,100%,0));
|
||||
background-image: -o-linear-gradient(hsla(0,0%,100%,.05), hsla(0,0%,100%,0));
|
||||
background-image: linear-gradient(hsla(0,0%,100%,.05), hsla(0,0%,100%,0));
|
||||
background-clip: padding-box;
|
||||
border: 1px solid hsla(0,0%,0%,.35);
|
||||
border-color: hsla(0,0%,0%,.32) hsla(0,0%,0%,.38) hsla(0,0%,0%,.42);
|
||||
box-shadow: 0 1px 0 hsla(0,0%,100%,.05) inset,
|
||||
0 0 1px hsla(0,0%,100%,.15) inset,
|
||||
0 1px 0 hsla(0,0%,100%,.05);
|
||||
-moz-transition-property: background-color, border-color, box-shadow;
|
||||
-moz-transition-duration: 150ms;
|
||||
-moz-transition-timing-function: ease;
|
||||
-webkit-transition-property: background-color, border-color, box-shadow;
|
||||
-webkit-transition-duration: 150ms;
|
||||
-webkit-transition-timing-function: ease;
|
||||
-moz-transition-property: background-color, border-color, box-shadow;
|
||||
-moz-transition-duration: 150ms;
|
||||
-moz-transition-timing-function: ease;
|
||||
-ms-transition-property: background-color, border-color, box-shadow;
|
||||
-ms-transition-duration: 150ms;
|
||||
-ms-transition-timing-function: ease;
|
||||
-o-transition-property: background-color, border-color, box-shadow;
|
||||
-o-transition-duration: 150ms;
|
||||
-o-transition-timing-function: ease;
|
||||
transition-property: background-color, border-color, box-shadow;
|
||||
transition-duration: 150ms;
|
||||
transition-timing-function: ease;
|
||||
|
||||
}
|
||||
.splitToolbarButton > .toolbarButton:hover,
|
||||
.splitToolbarButton > .toolbarButton:focus,
|
||||
.dropdownToolbarButton:hover {
|
||||
.dropdownToolbarButton:hover,
|
||||
.toolbarButton.textButton:hover,
|
||||
.toolbarButton.textButton:focus {
|
||||
background-color: hsla(0,0%,0%,.2);
|
||||
box-shadow: 0 1px 0 hsla(0,0%,100%,.05) inset,
|
||||
0 0 1px hsla(0,0%,100%,.15) inset,
|
||||
@ -308,12 +370,21 @@ html[dir='rtl'] .splitToolbarButtonSeparator {
|
||||
padding: 12px 0;
|
||||
margin: 0;
|
||||
box-shadow: 0 0 0 1px hsla(0,0%,100%,.03);
|
||||
-moz-transition-property: padding;
|
||||
-moz-transition-duration: 10ms;
|
||||
-moz-transition-timing-function: ease;
|
||||
-webkit-transition-property: padding;
|
||||
-webkit-transition-duration: 10ms;
|
||||
-webkit-transition-timing-function: ease;
|
||||
-moz-transition-property: padding;
|
||||
-moz-transition-duration: 10ms;
|
||||
-moz-transition-timing-function: ease;
|
||||
-ms-transition-property: padding;
|
||||
-ms-transition-duration: 10ms;
|
||||
-ms-transition-timing-function: ease;
|
||||
-o-transition-property: padding;
|
||||
-o-transition-duration: 10ms;
|
||||
-o-transition-timing-function: ease;
|
||||
transition-property: padding;
|
||||
transition-duration: 10ms;
|
||||
transition-timing-function: ease;
|
||||
}
|
||||
|
||||
.toolbarButton,
|
||||
@ -325,15 +396,26 @@ html[dir='rtl'] .splitToolbarButtonSeparator {
|
||||
color: hsl(0,0%,95%);
|
||||
font-size: 12px;
|
||||
line-height: 14px;
|
||||
-moz-user-select:none;
|
||||
-webkit-user-select:none;
|
||||
-moz-user-select:none;
|
||||
-ms-user-select:none;
|
||||
/* Opera does not support user-select, use <... unselectable="on"> instead */
|
||||
cursor: default;
|
||||
-moz-transition-property: background-color, border-color, box-shadow;
|
||||
-moz-transition-duration: 150ms;
|
||||
-moz-transition-timing-function: ease;
|
||||
-webkit-transition-property: background-color, border-color, box-shadow;
|
||||
-webkit-transition-duration: 150ms;
|
||||
-webkit-transition-timing-function: ease;
|
||||
-moz-transition-property: background-color, border-color, box-shadow;
|
||||
-moz-transition-duration: 150ms;
|
||||
-moz-transition-timing-function: ease;
|
||||
-ms-transition-property: background-color, border-color, box-shadow;
|
||||
-ms-transition-duration: 150ms;
|
||||
-ms-transition-timing-function: ease;
|
||||
-o-transition-property: background-color, border-color, box-shadow;
|
||||
-o-transition-duration: 150ms;
|
||||
-o-transition-timing-function: ease;
|
||||
transition-property: background-color, border-color, box-shadow;
|
||||
transition-duration: 150ms;
|
||||
transition-timing-function: ease;
|
||||
}
|
||||
|
||||
html[dir='ltr'] .toolbarButton,
|
||||
@ -349,8 +431,11 @@ html[dir='rtl'] .dropdownToolbarButton {
|
||||
.toolbarButton:focus,
|
||||
.dropdownToolbarButton {
|
||||
background-color: hsla(0,0%,0%,.12);
|
||||
background-image: -moz-linear-gradient(hsla(0,0%,100%,.05), hsla(0,0%,100%,0));
|
||||
background-image: -webkit-linear-gradient(hsla(0,0%,100%,.05), hsla(0,0%,100%,0));
|
||||
background-image: -moz-linear-gradient(hsla(0,0%,100%,.05), hsla(0,0%,100%,0));
|
||||
background-image: -ms-linear-gradient(hsla(0,0%,100%,.05), hsla(0,0%,100%,0));
|
||||
background-image: -o-linear-gradient(hsla(0,0%,100%,.05), hsla(0,0%,100%,0));
|
||||
background-image: linear-gradient(hsla(0,0%,100%,.05), hsla(0,0%,100%,0));
|
||||
background-clip: padding-box;
|
||||
border: 1px solid hsla(0,0%,0%,.35);
|
||||
border-color: hsla(0,0%,0%,.32) hsla(0,0%,0%,.38) hsla(0,0%,0%,.42);
|
||||
@ -362,35 +447,59 @@ html[dir='rtl'] .dropdownToolbarButton {
|
||||
.toolbarButton:hover:active,
|
||||
.dropdownToolbarButton:hover:active {
|
||||
background-color: hsla(0,0%,0%,.2);
|
||||
background-image: -moz-linear-gradient(hsla(0,0%,100%,.05), hsla(0,0%,100%,0));
|
||||
background-image: -webkit-linear-gradient(hsla(0,0%,100%,.05), hsla(0,0%,100%,0));
|
||||
background-image: -moz-linear-gradient(hsla(0,0%,100%,.05), hsla(0,0%,100%,0));
|
||||
background-image: -ms-linear-gradient(hsla(0,0%,100%,.05), hsla(0,0%,100%,0));
|
||||
background-image: -o-linear-gradient(hsla(0,0%,100%,.05), hsla(0,0%,100%,0));
|
||||
background-image: linear-gradient(hsla(0,0%,100%,.05), hsla(0,0%,100%,0));
|
||||
border-color: hsla(0,0%,0%,.35) hsla(0,0%,0%,.4) hsla(0,0%,0%,.45);
|
||||
box-shadow: 0 1px 1px hsla(0,0%,0%,.1) inset,
|
||||
0 0 1px hsla(0,0%,0%,.2) inset,
|
||||
0 1px 0 hsla(0,0%,100%,.05);
|
||||
-moz-transition-property: background-color, border-color, box-shadow;
|
||||
-moz-transition-duration: 10ms;
|
||||
-moz-transition-timing-function: linear;
|
||||
-webkit-transition-property: background-color, border-color, box-shadow;
|
||||
-webkit-transition-duration: 10ms;
|
||||
-webkit-transition-timing-function: linear;
|
||||
-moz-transition-property: background-color, border-color, box-shadow;
|
||||
-moz-transition-duration: 10ms;
|
||||
-moz-transition-timing-function: linear;
|
||||
-ms-transition-property: background-color, border-color, box-shadow;
|
||||
-ms-transition-duration: 10ms;
|
||||
-ms-transition-timing-function: linear;
|
||||
-o-transition-property: background-color, border-color, box-shadow;
|
||||
-o-transition-duration: 10ms;
|
||||
-o-transition-timing-function: linear;
|
||||
transition-property: background-color, border-color, box-shadow;
|
||||
transition-duration: 10ms;
|
||||
transition-timing-function: linear;
|
||||
}
|
||||
|
||||
.toolbarButton.toggled,
|
||||
.splitToolbarButton.toggled > .toolbarButton.toggled {
|
||||
background-color: hsla(0,0%,0%,.3);
|
||||
background-image: -moz-linear-gradient(hsla(0,0%,100%,.05), hsla(0,0%,100%,0));
|
||||
background-image: -webkit-linear-gradient(hsla(0,0%,100%,.05), hsla(0,0%,100%,0));
|
||||
background-image: -moz-linear-gradient(hsla(0,0%,100%,.05), hsla(0,0%,100%,0));
|
||||
background-image: -ms-linear-gradient(hsla(0,0%,100%,.05), hsla(0,0%,100%,0));
|
||||
background-image: -o-linear-gradient(hsla(0,0%,100%,.05), hsla(0,0%,100%,0));
|
||||
background-image: linear-gradient(hsla(0,0%,100%,.05), hsla(0,0%,100%,0));
|
||||
border-color: hsla(0,0%,0%,.4) hsla(0,0%,0%,.45) hsla(0,0%,0%,.5);
|
||||
box-shadow: 0 1px 1px hsla(0,0%,0%,.1) inset,
|
||||
0 0 1px hsla(0,0%,0%,.2) inset,
|
||||
0 1px 0 hsla(0,0%,100%,.05);
|
||||
-moz-transition-property: background-color, border-color, box-shadow;
|
||||
-moz-transition-duration: 10ms;
|
||||
-moz-transition-timing-function: linear;
|
||||
-webkit-transition-property: background-color, border-color, box-shadow;
|
||||
-webkit-transition-duration: 10ms;
|
||||
-webkit-transition-timing-function: linear;
|
||||
-moz-transition-property: background-color, border-color, box-shadow;
|
||||
-moz-transition-duration: 10ms;
|
||||
-moz-transition-timing-function: linear;
|
||||
-ms-transition-property: background-color, border-color, box-shadow;
|
||||
-ms-transition-duration: 10ms;
|
||||
-ms-transition-timing-function: linear;
|
||||
-o-transition-property: background-color, border-color, box-shadow;
|
||||
-o-transition-duration: 10ms;
|
||||
-o-transition-timing-function: linear;
|
||||
transition-property: background-color, border-color, box-shadow;
|
||||
transition-duration: 10ms;
|
||||
transition-timing-function: linear;
|
||||
}
|
||||
|
||||
.toolbarButton.toggled:hover:active,
|
||||
@ -417,8 +526,8 @@ html[dir='rtl'] .dropdownToolbarButton {
|
||||
}
|
||||
|
||||
.dropdownToolbarButton > select {
|
||||
-moz-appearance: none; /* in the future this might matter, see bugzilla bug #649849 */
|
||||
-webkit-appearance: none;
|
||||
-moz-appearance: none; /* in the future this might matter, see bugzilla bug #649849 */
|
||||
min-width: 140px;
|
||||
font-size: 12px;
|
||||
color: hsl(0,0%,95%);
|
||||
@ -460,8 +569,8 @@ html[dir='rtl'] .toolbarButton:first-child {
|
||||
}
|
||||
|
||||
.toolbarButtonFlexibleSpacer {
|
||||
-moz-box-flex: 1;
|
||||
-webkit-box-flex: 1;
|
||||
-moz-box-flex: 1;
|
||||
min-width: 30px;
|
||||
}
|
||||
|
||||
@ -516,8 +625,8 @@ html[dir='rtl'] .toolbarButton.pageDown::before {
|
||||
}
|
||||
|
||||
.toolbarButton.bookmark {
|
||||
-moz-box-sizing: border-box;
|
||||
-webkit-box-sizing: border-box;
|
||||
-moz-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
margin-top: 3px;
|
||||
padding-top: 4px;
|
||||
@ -544,8 +653,6 @@ html[dir='rtl'] .toolbarButton.pageDown::before {
|
||||
|
||||
|
||||
.toolbarField {
|
||||
min-width: 16px;
|
||||
width: 32px;
|
||||
padding: 3px 6px;
|
||||
margin: 4px 0 4px 0;
|
||||
border: 1px solid transparent;
|
||||
@ -560,7 +667,6 @@ html[dir='rtl'] .toolbarButton.pageDown::before {
|
||||
color: hsl(0,0%,95%);
|
||||
font-size: 12px;
|
||||
line-height: 14px;
|
||||
text-align: right;
|
||||
outline-style: none;
|
||||
-moz-transition-property: background-color, border-color, box-shadow;
|
||||
-moz-transition-duration: 150ms;
|
||||
@ -568,6 +674,8 @@ html[dir='rtl'] .toolbarButton.pageDown::before {
|
||||
}
|
||||
|
||||
.toolbarField.pageNumber {
|
||||
min-width: 16px;
|
||||
text-align: right;
|
||||
width: 40px;
|
||||
}
|
||||
|
||||
@ -597,8 +705,8 @@ html[dir='rtl'] .toolbarButton.pageDown::before {
|
||||
font-size: 12px;
|
||||
line-height: 14px;
|
||||
text-align: left;
|
||||
-moz-user-select:none;
|
||||
-webkit-user-select:none;
|
||||
-moz-user-select:none;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
@ -674,17 +782,19 @@ a:focus > .thumbnail > .thumbnailSelectionRing,
|
||||
bottom: 0;
|
||||
padding: 4px 4px 0;
|
||||
overflow: auto;
|
||||
-moz-user-select:none;
|
||||
-webkit-user-select:none;
|
||||
-moz-user-select:none;
|
||||
}
|
||||
|
||||
.outlineItem > .outlineItems {
|
||||
margin-left: 20px;
|
||||
}
|
||||
|
||||
.outlineItem > a {
|
||||
.outlineItem > a,
|
||||
#searchResults > a {
|
||||
text-decoration: none;
|
||||
display: block;
|
||||
display: inline-block;
|
||||
min-width: 95%;
|
||||
height: 20px;
|
||||
padding: 2px 0 0 10px;
|
||||
margin-bottom: 1px;
|
||||
@ -697,7 +807,8 @@ a:focus > .thumbnail > .thumbnailSelectionRing,
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.outlineItem > a:hover {
|
||||
.outlineItem > a:hover,
|
||||
#searchResults > a:hover {
|
||||
background-color: hsla(0,0%,100%,.02);
|
||||
background-image: -moz-linear-gradient(hsla(0,0%,100%,.05), hsla(0,0%,100%,0));
|
||||
background-clip: padding-box;
|
||||
@ -707,6 +818,23 @@ a:focus > .thumbnail > .thumbnailSelectionRing,
|
||||
color: hsla(0,0%,100%,.9);
|
||||
}
|
||||
|
||||
.outlineItem.selected {
|
||||
background-color: hsla(0,0%,100%,.08);
|
||||
background-image: -moz-linear-gradient(hsla(0,0%,100%,.05), hsla(0,0%,100%,0));
|
||||
background-clip: padding-box;
|
||||
box-shadow: 0 1px 0 hsla(0,0%,100%,.05) inset,
|
||||
0 0 1px hsla(0,0%,100%,.1) inset,
|
||||
0 0 1px hsla(0,0%,0%,.2);
|
||||
color: hsla(0,0%,100%,1);
|
||||
}
|
||||
|
||||
.noOutline,
|
||||
.noResults {
|
||||
font-size: 12px;
|
||||
color: hsla(0,0%,100%,.8);
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
#searchScrollView {
|
||||
position: absolute;
|
||||
top: 10px;
|
||||
@ -723,27 +851,26 @@ a:focus > .thumbnail > .thumbnailSelectionRing,
|
||||
}
|
||||
|
||||
#searchToolbar > input {
|
||||
margin-left: 8px;
|
||||
width: 130px;
|
||||
margin-left: 4px;
|
||||
width: 124px;
|
||||
}
|
||||
|
||||
#searchToolbar button {
|
||||
width: auto;
|
||||
margin: 0;
|
||||
padding: 0 6px;
|
||||
height: 22px;
|
||||
}
|
||||
|
||||
#searchResults {
|
||||
overflow: auto;
|
||||
background-color: #fff;
|
||||
position: absolute;
|
||||
top: 30px;
|
||||
bottom: 0px;
|
||||
left: 0px;
|
||||
right: 0;
|
||||
padding: 4px 4px 0;
|
||||
font-size: smaller;
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
#searchResults a {
|
||||
display: block;
|
||||
white-space: pre;
|
||||
text-decoration: none;
|
||||
color: black;
|
||||
}
|
||||
|
||||
#sidebarControls {
|
||||
@ -754,24 +881,6 @@ a:focus > .thumbnail > .thumbnailSelectionRing,
|
||||
bottom: 35px;
|
||||
}
|
||||
|
||||
.outlineItem.selected {
|
||||
background-color: hsla(0,0%,100%,.08);
|
||||
background-image: -moz-linear-gradient(hsla(0,0%,100%,.05), hsla(0,0%,100%,0));
|
||||
background-clip: padding-box;
|
||||
box-shadow: 0 1px 0 hsla(0,0%,100%,.05) inset,
|
||||
0 0 1px hsla(0,0%,100%,.1) inset,
|
||||
0 0 1px hsla(0,0%,0%,.2);
|
||||
color: hsla(0,0%,100%,1);
|
||||
}
|
||||
|
||||
.noOutline {
|
||||
font-size: 12px;
|
||||
color: hsla(0,0%,100%,.8);
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
|
||||
|
||||
canvas {
|
||||
margin: auto;
|
||||
display: block;
|
||||
@ -784,9 +893,9 @@ canvas {
|
||||
margin: 10px auto;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
box-shadow: 0px 4px 10px #000;
|
||||
-moz-box-shadow: 0px 4px 10px #000;
|
||||
-webkit-box-shadow: 0px 4px 10px #000;
|
||||
-moz-box-shadow: 0px 4px 10px #000;
|
||||
box-shadow: 0px 4px 10px #000;
|
||||
background-color: white;
|
||||
}
|
||||
|
||||
@ -798,9 +907,9 @@ canvas {
|
||||
.page > a:hover {
|
||||
opacity: 0.2;
|
||||
background: #ff0;
|
||||
box-shadow: 0px 2px 10px #ff0;
|
||||
-moz-box-shadow: 0px 2px 10px #ff0;
|
||||
-webkit-box-shadow: 0px 2px 10px #ff0;
|
||||
-moz-box-shadow: 0px 2px 10px #ff0;
|
||||
box-shadow: 0px 2px 10px #ff0;
|
||||
}
|
||||
|
||||
.loadingIcon {
|
||||
@ -814,23 +923,33 @@ canvas {
|
||||
}
|
||||
|
||||
#loadingBox {
|
||||
margin: 100px 0;
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
margin-top: -25px;
|
||||
left: 0;
|
||||
right: 0;
|
||||
text-align: center;
|
||||
color: #ddd;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
#loadingBar {
|
||||
background-color: #333;
|
||||
display: inline-block;
|
||||
border: 1px solid black;
|
||||
clear: both;
|
||||
margin: 0px;
|
||||
margin-top: 5px;
|
||||
line-height: 0;
|
||||
border-radius: 4px;
|
||||
border-radius: 2px;
|
||||
width: 200px;
|
||||
height: 25px;
|
||||
|
||||
background-color: hsla(0,0%,0%,.3);
|
||||
background-image: -moz-linear-gradient(hsla(0,0%,100%,.05), hsla(0,0%,100%,0));
|
||||
background-image: -webkit-linear-gradient(hsla(0,0%,100%,.05), hsla(0,0%,100%,0));
|
||||
border: 1px solid #000;
|
||||
box-shadow: 0 1px 1px hsla(0,0%,0%,.1) inset,
|
||||
0 0 1px hsla(0,0%,0%,.2) inset,
|
||||
0 0 1px 1px rgba(255, 255, 255, 0.1);
|
||||
}
|
||||
|
||||
#loadingBar .progress {
|
||||
@ -838,23 +957,23 @@ canvas {
|
||||
float: left;
|
||||
|
||||
background: #666;
|
||||
background: -moz-linear-gradient(top, #999 0%, #666 50%, #999 100%);
|
||||
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#999), color-stop(50%,#666), color-stop(100%,#999));
|
||||
background: -webkit-linear-gradient(top, #999 0%,#666 50%,#999 100%);
|
||||
background: -o-linear-gradient(top, #999 0%,#666 50%,#999 100%);
|
||||
background: -ms-linear-gradient(top, #999 0%,#666 50%,#999 100%);
|
||||
background: linear-gradient(top, #999 0%,#666 50%,#999 100%);
|
||||
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#b2b2b2), color-stop(100%,#898989));
|
||||
background: -webkit-linear-gradient(top, #b2b2b2 0%,#898989 100%);
|
||||
background: -moz-linear-gradient(top, #b2b2b2 0%,#898989 100%);
|
||||
background: -ms-linear-gradient(top, #b2b2b2 0%,#898989 100%);
|
||||
background: -o-linear-gradient(top, #b2b2b2 0%,#898989 100%);
|
||||
background: linear-gradient(top, #b2b2b2 0%,#898989 100%);
|
||||
|
||||
border-top-left-radius: 3px;
|
||||
border-bottom-left-radius: 3px;
|
||||
border-top-left-radius: 2px;
|
||||
border-bottom-left-radius: 2px;
|
||||
|
||||
width: 0%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
#loadingBar .progress.full {
|
||||
border-top-right-radius: 3px;
|
||||
border-bottom-right-radius: 3px;
|
||||
border-top-right-radius: 2px;
|
||||
border-bottom-right-radius: 2px;
|
||||
}
|
||||
|
||||
.textLayer {
|
||||
@ -896,9 +1015,9 @@ canvas {
|
||||
padding: 0.2em;
|
||||
max-width: 20em;
|
||||
background-color: #F1E47B;
|
||||
box-shadow: 0px 2px 10px #333;
|
||||
-moz-box-shadow: 0px 2px 10px #333;
|
||||
-webkit-box-shadow: 0px 2px 10px #333;
|
||||
-moz-box-shadow: 0px 2px 10px #333;
|
||||
box-shadow: 0px 2px 10px #333;
|
||||
}
|
||||
|
||||
.annotComment > div > h1 {
|
||||
@ -994,7 +1113,16 @@ canvas {
|
||||
font-size: 10px;
|
||||
}
|
||||
|
||||
@page {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
#printContainer {
|
||||
display: none;
|
||||
}
|
||||
|
||||
@media print {
|
||||
/* Rules for browsers that don't support mozPrintCallback. */
|
||||
#sidebarContainer, .toolbar, #loadingBox, #errorWrapper, .textLayer {
|
||||
display: none;
|
||||
}
|
||||
@ -1008,14 +1136,27 @@ canvas {
|
||||
.page {
|
||||
float: left;
|
||||
display: none;
|
||||
box-shadow: none;
|
||||
-moz-box-shadow: none;
|
||||
-webkit-box-shadow: none;
|
||||
-moz-box-shadow: none;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.page[data-loaded] {
|
||||
display: block;
|
||||
}
|
||||
|
||||
/* Rules for browsers that support mozPrintCallback */
|
||||
body[data-mozPrintCallback] #outerContainer {
|
||||
display: none;
|
||||
}
|
||||
body[data-mozPrintCallback] #printContainer {
|
||||
display: block;
|
||||
}
|
||||
#printContainer canvas {
|
||||
position: relative;
|
||||
top: 0;
|
||||
left: 0;
|
||||
}
|
||||
}
|
||||
|
||||
@media all and (max-width: 950px) {
|
||||
@ -1066,3 +1207,10 @@ canvas {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
@media all and (max-width: 500px) {
|
||||
#scaleSelectContainer, #pageNumberLabel {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -14,6 +14,13 @@ var kMinScale = 0.25;
|
||||
var kMaxScale = 4.0;
|
||||
var kImageDirectory = './images/';
|
||||
var kSettingsMemory = 20;
|
||||
var RenderingStates = {
|
||||
INITIAL: 0,
|
||||
RUNNING: 1,
|
||||
PAUSED: 2,
|
||||
FINISHED: 3
|
||||
};
|
||||
|
||||
|
||||
var mozL10n = document.mozL10n || document.webL10n;
|
||||
|
||||
@ -83,49 +90,22 @@ var ProgressBar = (function ProgressBarClosure() {
|
||||
return ProgressBar;
|
||||
})();
|
||||
|
||||
var RenderingQueue = (function RenderingQueueClosure() {
|
||||
function RenderingQueue() {
|
||||
this.items = [];
|
||||
}
|
||||
|
||||
RenderingQueue.prototype = {
|
||||
enqueueDraw: function RenderingQueueEnqueueDraw(item) {
|
||||
if (!item.drawingRequired())
|
||||
return; // as no redraw required, no need for queueing.
|
||||
|
||||
this.items.push(item);
|
||||
if (this.items.length > 1)
|
||||
return; // not first item
|
||||
|
||||
item.draw(this.continueExecution.bind(this));
|
||||
},
|
||||
continueExecution: function RenderingQueueContinueExecution() {
|
||||
var item = this.items.shift();
|
||||
|
||||
if (this.items.length == 0)
|
||||
return; // queue is empty
|
||||
|
||||
item = this.items[0];
|
||||
item.draw(this.continueExecution.bind(this));
|
||||
}
|
||||
};
|
||||
|
||||
return RenderingQueue;
|
||||
})();
|
||||
|
||||
var FirefoxCom = (function FirefoxComClosure() {
|
||||
return {
|
||||
/**
|
||||
* Creates an event that hopefully the extension is listening for and will
|
||||
* Creates an event that the extension is listening for and will
|
||||
* synchronously respond to.
|
||||
* NOTE: It is reccomended to use request() instead since one day we may not
|
||||
* be able to synchronously reply.
|
||||
* @param {String} action The action to trigger.
|
||||
* @param {String} data Optional data to send.
|
||||
* @return {*} The response.
|
||||
*/
|
||||
request: function(action, data) {
|
||||
requestSync: function(action, data) {
|
||||
var request = document.createTextNode('');
|
||||
request.setUserData('action', action, null);
|
||||
request.setUserData('data', data, null);
|
||||
request.setUserData('sync', true, null);
|
||||
document.documentElement.appendChild(request);
|
||||
|
||||
var sender = document.createEvent('Events');
|
||||
@ -134,6 +114,39 @@ var FirefoxCom = (function FirefoxComClosure() {
|
||||
var response = request.getUserData('response');
|
||||
document.documentElement.removeChild(request);
|
||||
return response;
|
||||
},
|
||||
/**
|
||||
* Creates an event that the extension is listening for and will
|
||||
* asynchronously respond by calling the callback.
|
||||
* @param {String} action The action to trigger.
|
||||
* @param {String} data Optional data to send.
|
||||
* @param {Function} callback Optional response callback that will be called
|
||||
* with one data argument.
|
||||
*/
|
||||
request: function(action, data, callback) {
|
||||
var request = document.createTextNode('');
|
||||
request.setUserData('action', action, null);
|
||||
request.setUserData('data', data, null);
|
||||
request.setUserData('sync', false, null);
|
||||
if (callback) {
|
||||
request.setUserData('callback', callback, null);
|
||||
|
||||
document.addEventListener('pdf.js.response', function listener(event) {
|
||||
var node = event.target,
|
||||
callback = node.getUserData('callback'),
|
||||
response = node.getUserData('response');
|
||||
|
||||
document.documentElement.removeChild(node);
|
||||
|
||||
document.removeEventListener('pdf.js.response', listener, false);
|
||||
return callback(response);
|
||||
}, false);
|
||||
}
|
||||
document.documentElement.appendChild(request);
|
||||
|
||||
var sender = document.createEvent('HTMLEvents');
|
||||
sender.initEvent('pdf.js.message', true, false);
|
||||
return request.dispatchEvent(sender);
|
||||
}
|
||||
};
|
||||
})();
|
||||
@ -160,7 +173,7 @@ var Settings = (function SettingsClosure() {
|
||||
var database = null;
|
||||
var index;
|
||||
if (isFirefoxExtension)
|
||||
database = FirefoxCom.request('getDatabase', null) || '{}';
|
||||
database = FirefoxCom.requestSync('getDatabase', null) || '{}';
|
||||
else if (isLocalStorageEnabled)
|
||||
database = localStorage.getItem('database') || '{}';
|
||||
else
|
||||
@ -193,7 +206,7 @@ var Settings = (function SettingsClosure() {
|
||||
file[name] = val;
|
||||
var database = JSON.stringify(this.database);
|
||||
if (isFirefoxExtension)
|
||||
FirefoxCom.request('setDatabase', database);
|
||||
FirefoxCom.requestSync('setDatabase', database);
|
||||
else if (isLocalStorageEnabled)
|
||||
localStorage.setItem('database', database);
|
||||
},
|
||||
@ -210,7 +223,6 @@ var Settings = (function SettingsClosure() {
|
||||
})();
|
||||
|
||||
var cache = new Cache(kCacheSize);
|
||||
var renderingQueue = new RenderingQueue();
|
||||
var currentPageNumber = 1;
|
||||
|
||||
var PDFView = {
|
||||
@ -222,15 +234,48 @@ var PDFView = {
|
||||
startedTextExtraction: false,
|
||||
pageText: [],
|
||||
container: null,
|
||||
thumbnailContainer: null,
|
||||
initialized: false,
|
||||
fellback: false,
|
||||
pdfDocument: null,
|
||||
sidebarOpen: false,
|
||||
pageViewScroll: null,
|
||||
thumbnailViewScroll: null,
|
||||
|
||||
// called once when the document is loaded
|
||||
initialize: function pdfViewInitialize() {
|
||||
this.container = document.getElementById('viewerContainer');
|
||||
var container = this.container = document.getElementById('viewerContainer');
|
||||
this.pageViewScroll = {};
|
||||
this.watchScroll(container, this.pageViewScroll, updateViewarea);
|
||||
|
||||
var thumbnailContainer = this.thumbnailContainer =
|
||||
document.getElementById('thumbnailView');
|
||||
this.thumbnailViewScroll = {};
|
||||
this.watchScroll(thumbnailContainer, this.thumbnailViewScroll,
|
||||
this.renderHighestPriority.bind(this));
|
||||
|
||||
this.initialized = true;
|
||||
},
|
||||
|
||||
setScale: function pdfViewSetScale(val, resetAutoSettings) {
|
||||
// Helper function to keep track whether a div was scrolled up or down and
|
||||
// then call a callback.
|
||||
watchScroll: function pdfViewWatchScroll(viewAreaElement, state, callback) {
|
||||
state.down = true;
|
||||
state.lastY = viewAreaElement.scrollTop;
|
||||
viewAreaElement.addEventListener('scroll', function webViewerScroll(evt) {
|
||||
var currentY = viewAreaElement.scrollTop;
|
||||
var lastY = state.lastY;
|
||||
if (currentY > lastY)
|
||||
state.down = true;
|
||||
else if (currentY < lastY)
|
||||
state.down = false;
|
||||
// else do nothing and use previous value
|
||||
state.lastY = currentY;
|
||||
callback();
|
||||
}, true);
|
||||
},
|
||||
|
||||
setScale: function pdfViewSetScale(val, resetAutoSettings, noScroll) {
|
||||
if (val == this.currentScale)
|
||||
return;
|
||||
|
||||
@ -238,7 +283,7 @@ var PDFView = {
|
||||
for (var i = 0; i < pages.length; i++)
|
||||
pages[i].update(val * kCssUnits);
|
||||
|
||||
if (this.currentScale != val)
|
||||
if (!noScroll && this.currentScale != val)
|
||||
this.pages[this.page - 1].scrollIntoView();
|
||||
this.currentScale = val;
|
||||
|
||||
@ -249,14 +294,14 @@ var PDFView = {
|
||||
window.dispatchEvent(event);
|
||||
},
|
||||
|
||||
parseScale: function pdfViewParseScale(value, resetAutoSettings) {
|
||||
parseScale: function pdfViewParseScale(value, resetAutoSettings, noScroll) {
|
||||
if ('custom' == value)
|
||||
return;
|
||||
|
||||
var scale = parseFloat(value);
|
||||
this.currentScaleValue = value;
|
||||
if (scale) {
|
||||
this.setScale(scale, true);
|
||||
this.setScale(scale, true, noScroll);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -268,22 +313,22 @@ var PDFView = {
|
||||
currentPage.height * currentPage.scale / kCssUnits;
|
||||
switch (value) {
|
||||
case 'page-actual':
|
||||
this.setScale(1, resetAutoSettings);
|
||||
scale = 1;
|
||||
break;
|
||||
case 'page-width':
|
||||
this.setScale(pageWidthScale, resetAutoSettings);
|
||||
scale = pageWidthScale;
|
||||
break;
|
||||
case 'page-height':
|
||||
this.setScale(pageHeightScale, resetAutoSettings);
|
||||
scale = pageHeightScale;
|
||||
break;
|
||||
case 'page-fit':
|
||||
this.setScale(
|
||||
Math.min(pageWidthScale, pageHeightScale), resetAutoSettings);
|
||||
scale = Math.min(pageWidthScale, pageHeightScale);
|
||||
break;
|
||||
case 'auto':
|
||||
this.setScale(Math.min(1.0, pageWidthScale), resetAutoSettings);
|
||||
scale = Math.min(1.0, pageWidthScale);
|
||||
break;
|
||||
}
|
||||
this.setScale(scale, resetAutoSettings, noScroll);
|
||||
|
||||
selectScaleOption(value);
|
||||
},
|
||||
@ -334,6 +379,17 @@ var PDFView = {
|
||||
return currentPageNumber;
|
||||
},
|
||||
|
||||
get supportsPrinting() {
|
||||
var canvas = document.createElement('canvas');
|
||||
var value = 'mozPrintCallback' in canvas;
|
||||
// shadow
|
||||
Object.defineProperty(this, 'supportsPrinting', { value: value,
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: false });
|
||||
return value;
|
||||
},
|
||||
|
||||
open: function pdfViewOpen(url, scale, password) {
|
||||
var parameters = {password: password};
|
||||
if (typeof url === 'string') { // URL
|
||||
@ -348,6 +404,7 @@ var PDFView = {
|
||||
PDFView.loadingBar = new ProgressBar('#loadingBar', {});
|
||||
}
|
||||
|
||||
this.pdfDocument = null;
|
||||
var self = this;
|
||||
self.loading = true;
|
||||
PDFJS.getDocument(parameters).then(
|
||||
@ -356,7 +413,7 @@ var PDFView = {
|
||||
self.loading = false;
|
||||
},
|
||||
function getDocumentError(message, exception) {
|
||||
if (exception.name === 'PasswordException') {
|
||||
if (exception && exception.name === 'PasswordException') {
|
||||
if (exception.code === 'needpassword') {
|
||||
var promptString = mozL10n.get('request_password', null,
|
||||
'PDF is protected by a password:');
|
||||
@ -384,9 +441,37 @@ var PDFView = {
|
||||
},
|
||||
|
||||
download: function pdfViewDownload() {
|
||||
function noData() {
|
||||
FirefoxCom.request('download', { originalUrl: url });
|
||||
}
|
||||
|
||||
var url = this.url.split('#')[0];
|
||||
if (PDFJS.isFirefoxExtension) {
|
||||
FirefoxCom.request('download', url);
|
||||
// Document isn't ready just try to download with the url.
|
||||
if (!this.pdfDocument) {
|
||||
noData();
|
||||
return;
|
||||
}
|
||||
this.pdfDocument.getData().then(
|
||||
function getDataSuccess(data) {
|
||||
var bb = new MozBlobBuilder();
|
||||
bb.append(data.buffer);
|
||||
var blobUrl = window.URL.createObjectURL(
|
||||
bb.getBlob('application/pdf'));
|
||||
|
||||
FirefoxCom.request('download', { blobUrl: blobUrl, originalUrl: url },
|
||||
function response(err) {
|
||||
if (err) {
|
||||
// This error won't really be helpful because it's likely the
|
||||
// fallback won't work either (or is already open).
|
||||
PDFView.error('PDF failed to download.');
|
||||
}
|
||||
window.URL.revokeObjectURL(blobUrl);
|
||||
}
|
||||
);
|
||||
},
|
||||
noData // Error ocurred try downloading with just the url.
|
||||
);
|
||||
} else {
|
||||
url += '#pdfjs.action=download', '_parent';
|
||||
window.open(url, '_parent');
|
||||
@ -402,7 +487,11 @@ var PDFView = {
|
||||
return;
|
||||
this.fellback = true;
|
||||
var url = this.url.split('#')[0];
|
||||
FirefoxCom.request('fallback', url);
|
||||
FirefoxCom.request('fallback', url, function response(download) {
|
||||
if (!download)
|
||||
return;
|
||||
PDFView.download();
|
||||
});
|
||||
},
|
||||
|
||||
navigateTo: function pdfViewNavigateTo(dest) {
|
||||
@ -528,10 +617,6 @@ var PDFView = {
|
||||
|
||||
progress: function pdfViewProgress(level) {
|
||||
var percent = Math.round(level * 100);
|
||||
var loadingIndicator = document.getElementById('loading');
|
||||
loadingIndicator.textContent = mozL10n.get('loading', {percent: percent},
|
||||
'Loading... {{percent}}%');
|
||||
|
||||
PDFView.loadingBar.percent = percent;
|
||||
},
|
||||
|
||||
@ -540,15 +625,18 @@ var PDFView = {
|
||||
// when page is painted, using the image as thumbnail base
|
||||
pageView.onAfterDraw = function pdfViewLoadOnAfterDraw() {
|
||||
thumbnailView.setImage(pageView.canvas);
|
||||
preDraw();
|
||||
};
|
||||
}
|
||||
|
||||
this.pdfDocument = pdfDocument;
|
||||
|
||||
var errorWrapper = document.getElementById('errorWrapper');
|
||||
errorWrapper.setAttribute('hidden', 'true');
|
||||
|
||||
var loadingBox = document.getElementById('loadingBox');
|
||||
loadingBox.setAttribute('hidden', 'true');
|
||||
var loadingIndicator = document.getElementById('loading');
|
||||
loadingIndicator.textContent = '';
|
||||
|
||||
var thumbsView = document.getElementById('thumbnailView');
|
||||
thumbsView.parentNode.scrollTop = 0;
|
||||
@ -663,6 +751,88 @@ var PDFView = {
|
||||
}
|
||||
},
|
||||
|
||||
renderHighestPriority: function pdfViewRenderHighestPriority() {
|
||||
// Pages have a higher priority than thumbnails, so check them first.
|
||||
var visiblePages = this.getVisiblePages();
|
||||
var pageView = this.getHighestPriority(visiblePages, this.pages,
|
||||
this.pageViewScroll.down);
|
||||
if (pageView) {
|
||||
this.renderView(pageView, 'page');
|
||||
return;
|
||||
}
|
||||
// No pages needed rendering so check thumbnails.
|
||||
if (this.sidebarOpen) {
|
||||
var visibleThumbs = this.getVisibleThumbs();
|
||||
var thumbView = this.getHighestPriority(visibleThumbs,
|
||||
this.thumbnails,
|
||||
this.thumbnailViewScroll.down);
|
||||
if (thumbView)
|
||||
this.renderView(thumbView, 'thumbnail');
|
||||
}
|
||||
},
|
||||
|
||||
getHighestPriority: function pdfViewGetHighestPriority(visibleViews, views,
|
||||
scrolledDown) {
|
||||
// The state has changed figure out which page has the highest priority to
|
||||
// render next (if any).
|
||||
// Priority:
|
||||
// 1 visible pages
|
||||
// 2 if last scrolled down page after the visible pages
|
||||
// 2 if last scrolled up page before the visible pages
|
||||
var numVisible = visibleViews.length;
|
||||
if (numVisible === 0) {
|
||||
info('No visible views.');
|
||||
return false;
|
||||
}
|
||||
for (var i = 0; i < numVisible; ++i) {
|
||||
var view = visibleViews[i].view;
|
||||
if (!this.isViewFinshed(view))
|
||||
return view;
|
||||
}
|
||||
|
||||
// All the visible views have rendered, try to render next/previous pages.
|
||||
if (scrolledDown) {
|
||||
var lastVisible = visibleViews[visibleViews.length - 1];
|
||||
var nextPageIndex = lastVisible.id;
|
||||
// ID's start at 1 so no need to add 1.
|
||||
if (views[nextPageIndex] && !this.isViewFinshed(views[nextPageIndex]))
|
||||
return views[nextPageIndex];
|
||||
} else {
|
||||
var previousPageIndex = visibleViews[0].id - 2;
|
||||
if (views[previousPageIndex] &&
|
||||
!this.isViewFinshed(views[previousPageIndex]))
|
||||
return views[previousPageIndex];
|
||||
}
|
||||
// Everything that needs to be rendered has been.
|
||||
return false;
|
||||
},
|
||||
|
||||
isViewFinshed: function pdfViewNeedsRendering(view) {
|
||||
return view.renderingState === RenderingStates.FINISHED;
|
||||
},
|
||||
|
||||
// Render a page or thumbnail view. This calls the appropriate function based
|
||||
// on the views state. If the view is already rendered it will return false.
|
||||
renderView: function pdfViewRender(view, type) {
|
||||
var state = view.renderingState;
|
||||
switch (state) {
|
||||
case RenderingStates.FINISHED:
|
||||
return false;
|
||||
case RenderingStates.PAUSED:
|
||||
PDFView.highestPriorityPage = type + view.id;
|
||||
view.resume();
|
||||
break;
|
||||
case RenderingStates.RUNNING:
|
||||
PDFView.highestPriorityPage = type + view.id;
|
||||
break;
|
||||
case RenderingStates.INITIAL:
|
||||
PDFView.highestPriorityPage = type + view.id;
|
||||
view.draw(this.renderHighestPriority.bind(this));
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
|
||||
search: function pdfViewStartSearch() {
|
||||
// Limit this function to run every <SEARCH_TIMEOUT>ms.
|
||||
var SEARCH_TIMEOUT = 250;
|
||||
@ -720,7 +890,12 @@ var PDFView = {
|
||||
pageFound = true;
|
||||
}
|
||||
if (!pageFound) {
|
||||
searchResults.textContent = '(Not found)';
|
||||
searchResults.textContent = '';
|
||||
var noResults = document.createElement('div');
|
||||
noResults.classList.add('noResults');
|
||||
noResults.textContent = mozL10n.get('search_terms_not_found', null,
|
||||
'(Not found)');
|
||||
searchResults.appendChild(noResults);
|
||||
}
|
||||
},
|
||||
|
||||
@ -781,7 +956,7 @@ var PDFView = {
|
||||
outlineView.classList.add('hidden');
|
||||
searchView.classList.add('hidden');
|
||||
|
||||
updateThumbViewArea();
|
||||
PDFView.renderHighestPriority();
|
||||
break;
|
||||
|
||||
case 'outline':
|
||||
@ -831,63 +1006,39 @@ var PDFView = {
|
||||
},
|
||||
|
||||
getVisiblePages: function pdfViewGetVisiblePages() {
|
||||
var pages = this.pages;
|
||||
var kBottomMargin = 10;
|
||||
var kTopPadding = 30;
|
||||
var visiblePages = [];
|
||||
|
||||
var currentHeight = kTopPadding + kBottomMargin;
|
||||
var container = this.container;
|
||||
// Add 1px to the scrolltop to give a little wiggle room if the math is off,
|
||||
// this won't be needed if we calc current page number based off the middle
|
||||
// of the screen instead of the top.
|
||||
var containerTop = container.scrollTop + 1;
|
||||
for (var i = 1; i <= pages.length; ++i) {
|
||||
var page = pages[i - 1];
|
||||
var pageHeight = page.height + kBottomMargin;
|
||||
if (currentHeight + pageHeight > containerTop)
|
||||
break;
|
||||
|
||||
currentHeight += pageHeight;
|
||||
}
|
||||
|
||||
var containerBottom = containerTop + container.clientHeight;
|
||||
for (; i <= pages.length && currentHeight < containerBottom; ++i) {
|
||||
var singlePage = pages[i - 1];
|
||||
visiblePages.push({ id: singlePage.id, y: currentHeight,
|
||||
view: singlePage });
|
||||
currentHeight += page.height + kBottomMargin;
|
||||
}
|
||||
return visiblePages;
|
||||
return this.getVisibleElements(this.container,
|
||||
this.pages);
|
||||
},
|
||||
|
||||
getVisibleThumbs: function pdfViewGetVisibleThumbs() {
|
||||
var thumbs = this.thumbnails;
|
||||
var kBottomMargin = 15;
|
||||
var visibleThumbs = [];
|
||||
return this.getVisibleElements(this.thumbnailContainer,
|
||||
this.thumbnails);
|
||||
},
|
||||
|
||||
var view = document.getElementById('thumbnailView');
|
||||
var currentHeight = kBottomMargin;
|
||||
// Generic helper to find out what elements are visible within a scroll pane.
|
||||
getVisibleElements: function pdfViewGetVisibleElements(scrollEl, views) {
|
||||
var currentHeight = 0, view;
|
||||
var top = scrollEl.scrollTop;
|
||||
|
||||
var top = view.scrollTop;
|
||||
for (var i = 1; i <= thumbs.length; ++i) {
|
||||
var thumb = thumbs[i - 1];
|
||||
var thumbHeight = thumb.height * thumb.scaleY + kBottomMargin;
|
||||
if (currentHeight + thumbHeight > top)
|
||||
for (var i = 1; i <= views.length; ++i) {
|
||||
view = views[i - 1];
|
||||
currentHeight = view.el.offsetTop;
|
||||
if (currentHeight + view.el.clientHeight > top)
|
||||
break;
|
||||
|
||||
currentHeight += thumbHeight;
|
||||
currentHeight += view.el.clientHeight;
|
||||
}
|
||||
|
||||
var bottom = top + view.clientHeight;
|
||||
for (; i <= thumbs.length && currentHeight < bottom; ++i) {
|
||||
var singleThumb = thumbs[i - 1];
|
||||
visibleThumbs.push({ id: singleThumb.id, y: currentHeight,
|
||||
view: singleThumb });
|
||||
currentHeight += singleThumb.height * singleThumb.scaleY + kBottomMargin;
|
||||
var visible = [];
|
||||
var bottom = top + scrollEl.clientHeight;
|
||||
for (; i <= views.length && currentHeight < bottom; ++i) {
|
||||
view = views[i - 1];
|
||||
currentHeight = view.el.offsetTop;
|
||||
visible.push({ id: view.id, y: currentHeight,
|
||||
view: view });
|
||||
currentHeight += view.el.clientHeight;
|
||||
}
|
||||
|
||||
return visibleThumbs;
|
||||
return visible;
|
||||
},
|
||||
|
||||
// Helper function to parse query string (e.g. ?param1=value&parm2=...).
|
||||
@ -901,6 +1052,26 @@ var PDFView = {
|
||||
params[unescape(key)] = unescape(value);
|
||||
}
|
||||
return params;
|
||||
},
|
||||
|
||||
beforePrint: function pdfViewSetupBeforePrint() {
|
||||
if (!this.supportsPrinting) {
|
||||
var printMessage = mozL10n.get('printing_not_supported', null,
|
||||
'Warning: Printing is not fully supported by this browser.');
|
||||
this.error(printMessage);
|
||||
return;
|
||||
}
|
||||
var body = document.querySelector('body');
|
||||
body.setAttribute('data-mozPrintCallback', true);
|
||||
for (var i = 0, ii = this.pages.length; i < ii; ++i) {
|
||||
this.pages[i].beforePrint();
|
||||
}
|
||||
},
|
||||
|
||||
afterPrint: function pdfViewSetupAfterPrint() {
|
||||
var div = document.getElementById('printContainer');
|
||||
while (div.hasChildNodes())
|
||||
div.removeChild(div.lastChild);
|
||||
}
|
||||
};
|
||||
|
||||
@ -912,10 +1083,13 @@ var PageView = function pageView(container, pdfPage, id, scale,
|
||||
this.scale = scale || 1.0;
|
||||
this.viewport = this.pdfPage.getViewport(this.scale);
|
||||
|
||||
this.renderingState = RenderingStates.INITIAL;
|
||||
this.resume = null;
|
||||
|
||||
var anchor = document.createElement('a');
|
||||
anchor.name = '' + this.id;
|
||||
|
||||
var div = document.createElement('div');
|
||||
var div = this.el = document.createElement('div');
|
||||
div.id = 'pageContainer' + this.id;
|
||||
div.className = 'page';
|
||||
|
||||
@ -928,6 +1102,9 @@ var PageView = function pageView(container, pdfPage, id, scale,
|
||||
};
|
||||
|
||||
this.update = function pageViewUpdate(scale) {
|
||||
this.renderingState = RenderingStates.INITIAL;
|
||||
this.resume = null;
|
||||
|
||||
this.scale = scale || this.scale;
|
||||
var viewport = this.pdfPage.getViewport(this.scale);
|
||||
|
||||
@ -1101,9 +1278,9 @@ var PageView = function pageView(container, pdfPage, id, scale,
|
||||
}
|
||||
|
||||
if (scale && scale !== PDFView.currentScale)
|
||||
PDFView.parseScale(scale, true);
|
||||
PDFView.parseScale(scale, true, true);
|
||||
else if (PDFView.currentScale === kUnknownScale)
|
||||
PDFView.parseScale(kDefaultScale, true);
|
||||
PDFView.parseScale(kDefaultScale, true, true);
|
||||
|
||||
var boundingRect = [
|
||||
this.viewport.convertToViewportPoint(x, y),
|
||||
@ -1130,16 +1307,11 @@ var PageView = function pageView(container, pdfPage, id, scale,
|
||||
}, 0);
|
||||
};
|
||||
|
||||
this.drawingRequired = function() {
|
||||
return !div.querySelector('canvas');
|
||||
};
|
||||
|
||||
this.draw = function pageviewDraw(callback) {
|
||||
if (!this.drawingRequired()) {
|
||||
this.updateStats();
|
||||
callback();
|
||||
return;
|
||||
}
|
||||
if (this.renderingState !== RenderingStates.INITIAL)
|
||||
error('Must be in new state before drawing');
|
||||
|
||||
this.renderingState = RenderingStates.RUNNING;
|
||||
|
||||
var canvas = document.createElement('canvas');
|
||||
canvas.id = 'page' + this.id;
|
||||
@ -1169,6 +1341,8 @@ var PageView = function pageView(container, pdfPage, id, scale,
|
||||
|
||||
var self = this;
|
||||
function pageViewDrawCallback(error) {
|
||||
self.renderingState = RenderingStates.FINISHED;
|
||||
|
||||
if (self.loadingIconDiv) {
|
||||
div.removeChild(self.loadingIconDiv);
|
||||
delete self.loadingIconDiv;
|
||||
@ -1191,7 +1365,18 @@ var PageView = function pageView(container, pdfPage, id, scale,
|
||||
var renderContext = {
|
||||
canvasContext: ctx,
|
||||
viewport: this.viewport,
|
||||
textLayer: textLayer
|
||||
textLayer: textLayer,
|
||||
continueCallback: function pdfViewcContinueCallback(cont) {
|
||||
if (PDFView.highestPriorityPage !== 'page' + self.id) {
|
||||
self.renderingState = RenderingStates.PAUSED;
|
||||
self.resume = function resumeCallback() {
|
||||
self.renderingState = RenderingStates.RUNNING;
|
||||
cont();
|
||||
};
|
||||
return;
|
||||
}
|
||||
cont();
|
||||
}
|
||||
};
|
||||
this.pdfPage.render(renderContext).then(
|
||||
function pdfPageRenderCallback() {
|
||||
@ -1206,6 +1391,44 @@ var PageView = function pageView(container, pdfPage, id, scale,
|
||||
div.setAttribute('data-loaded', true);
|
||||
};
|
||||
|
||||
this.beforePrint = function pageViewBeforePrint() {
|
||||
var pdfPage = this.pdfPage;
|
||||
var viewport = pdfPage.getViewport(1);
|
||||
|
||||
var canvas = this.canvas = document.createElement('canvas');
|
||||
canvas.width = viewport.width;
|
||||
canvas.height = viewport.height;
|
||||
canvas.style.width = viewport.width + 'pt';
|
||||
canvas.style.height = viewport.height + 'pt';
|
||||
|
||||
var printContainer = document.getElementById('printContainer');
|
||||
printContainer.appendChild(canvas);
|
||||
|
||||
var self = this;
|
||||
canvas.mozPrintCallback = function(obj) {
|
||||
var ctx = obj.context;
|
||||
var renderContext = {
|
||||
canvasContext: ctx,
|
||||
viewport: viewport
|
||||
};
|
||||
|
||||
pdfPage.render(renderContext).then(function() {
|
||||
// Tell the printEngine that rendering this canvas/page has finished.
|
||||
obj.done();
|
||||
self.pdfPage.destroy();
|
||||
}, function(error) {
|
||||
console.error(error);
|
||||
// Tell the printEngine that rendering this canvas/page has failed.
|
||||
// This will make the print proces stop.
|
||||
if ('abort' in object)
|
||||
obj.abort();
|
||||
else
|
||||
obj.done();
|
||||
self.pdfPage.destroy();
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
this.updateStats = function pageViewUpdateStats() {
|
||||
if (PDFJS.pdfBug && Stats.enabled) {
|
||||
var stats = this.stats;
|
||||
@ -1234,7 +1457,7 @@ var ThumbnailView = function thumbnailView(container, pdfPage, id) {
|
||||
var scaleX = this.scaleX = (canvasWidth / pageWidth);
|
||||
var scaleY = this.scaleY = (canvasHeight / pageHeight);
|
||||
|
||||
var div = document.createElement('div');
|
||||
var div = this.el = document.createElement('div');
|
||||
div.id = 'thumbnailContainer' + id;
|
||||
div.className = 'thumbnail';
|
||||
|
||||
@ -1242,6 +1465,7 @@ var ThumbnailView = function thumbnailView(container, pdfPage, id) {
|
||||
container.appendChild(anchor);
|
||||
|
||||
this.hasImage = false;
|
||||
this.renderingState = RenderingStates.INITIAL;
|
||||
|
||||
function getPageDrawContext() {
|
||||
var canvas = document.createElement('canvas');
|
||||
@ -1274,22 +1498,40 @@ var ThumbnailView = function thumbnailView(container, pdfPage, id) {
|
||||
};
|
||||
|
||||
this.draw = function thumbnailViewDraw(callback) {
|
||||
if (this.renderingState !== RenderingStates.INITIAL)
|
||||
error('Must be in new state before drawing');
|
||||
|
||||
this.renderingState = RenderingStates.RUNNING;
|
||||
if (this.hasImage) {
|
||||
callback();
|
||||
return;
|
||||
}
|
||||
|
||||
var self = this;
|
||||
var ctx = getPageDrawContext();
|
||||
var drawViewport = pdfPage.getViewport(scaleX);
|
||||
var renderContext = {
|
||||
canvasContext: ctx,
|
||||
viewport: drawViewport
|
||||
viewport: drawViewport,
|
||||
continueCallback: function(cont) {
|
||||
if (PDFView.highestPriorityPage !== 'thumbnail' + self.id) {
|
||||
self.renderingState = RenderingStates.PAUSED;
|
||||
self.resume = function() {
|
||||
self.renderingState = RenderingStates.RUNNING;
|
||||
cont();
|
||||
};
|
||||
return;
|
||||
}
|
||||
cont();
|
||||
}
|
||||
};
|
||||
pdfPage.render(renderContext).then(
|
||||
function pdfPageRenderCallback() {
|
||||
self.renderingState = RenderingStates.FINISHED;
|
||||
callback();
|
||||
},
|
||||
function pdfPageRenderError(error) {
|
||||
self.renderingState = RenderingStates.FINISHED;
|
||||
callback();
|
||||
}
|
||||
);
|
||||
@ -1299,7 +1541,7 @@ var ThumbnailView = function thumbnailView(container, pdfPage, id) {
|
||||
this.setImage = function thumbnailViewSetImage(img) {
|
||||
if (this.hasImage || !img)
|
||||
return;
|
||||
|
||||
this.renderingState = RenderingStates.FINISHED;
|
||||
var ctx = getPageDrawContext();
|
||||
ctx.drawImage(img, 0, 0, img.width, img.height,
|
||||
0, 0, ctx.canvas.width, ctx.canvas.height);
|
||||
@ -1520,7 +1762,7 @@ window.addEventListener('load', function webViewerLoad(evt) {
|
||||
PDFJS.disableTextLayer = (hashParams['disableTextLayer'] === 'true');
|
||||
|
||||
if ('pdfBug' in hashParams &&
|
||||
(!PDFJS.isFirefoxExtension || FirefoxCom.request('pdfBugEnabled'))) {
|
||||
(!PDFJS.isFirefoxExtension || FirefoxCom.requestSync('pdfBugEnabled'))) {
|
||||
PDFJS.pdfBug = true;
|
||||
var pdfBug = hashParams['pdfBug'];
|
||||
var enabled = pdfBug.split(',');
|
||||
@ -1529,10 +1771,14 @@ window.addEventListener('load', function webViewerLoad(evt) {
|
||||
}
|
||||
|
||||
if (!PDFJS.isFirefoxExtension ||
|
||||
(PDFJS.isFirefoxExtension && FirefoxCom.request('searchEnabled'))) {
|
||||
(PDFJS.isFirefoxExtension && FirefoxCom.requestSync('searchEnabled'))) {
|
||||
document.querySelector('#viewSearch').classList.remove('hidden');
|
||||
}
|
||||
|
||||
if (!PDFView.supportsPrinting) {
|
||||
document.getElementById('print').classList.add('hidden');
|
||||
}
|
||||
|
||||
// Listen for warnings to trigger the fallback UI. Errors should be caught
|
||||
// and call PDFView.error() so we don't need to listen for those.
|
||||
PDFJS.LogManager.addLogger({
|
||||
@ -1541,9 +1787,6 @@ window.addEventListener('load', function webViewerLoad(evt) {
|
||||
}
|
||||
});
|
||||
|
||||
var thumbsView = document.getElementById('thumbnailView');
|
||||
thumbsView.addEventListener('scroll', updateThumbViewArea, true);
|
||||
|
||||
var mainContainer = document.getElementById('mainContainer');
|
||||
var outerContainer = document.getElementById('outerContainer');
|
||||
mainContainer.addEventListener('transitionend', function(e) {
|
||||
@ -1560,56 +1803,19 @@ window.addEventListener('load', function webViewerLoad(evt) {
|
||||
this.classList.toggle('toggled');
|
||||
outerContainer.classList.add('sidebarMoving');
|
||||
outerContainer.classList.toggle('sidebarOpen');
|
||||
updateThumbViewArea();
|
||||
PDFView.sidebarOpen = outerContainer.classList.contains('sidebarOpen');
|
||||
PDFView.renderHighestPriority();
|
||||
});
|
||||
|
||||
PDFView.open(file, 0);
|
||||
}, true);
|
||||
|
||||
/**
|
||||
* Render the next not yet visible page already such that it is
|
||||
* hopefully ready once the user scrolls to it.
|
||||
*/
|
||||
function preDraw() {
|
||||
var pages = PDFView.pages;
|
||||
var visible = PDFView.getVisiblePages();
|
||||
var last = visible[visible.length - 1];
|
||||
// PageView.id is the actual page number, which is + 1 compared
|
||||
// to the index in `pages`. That means, pages[last.id] is the next
|
||||
// PageView instance.
|
||||
if (pages[last.id] && pages[last.id].drawingRequired()) {
|
||||
renderingQueue.enqueueDraw(pages[last.id]);
|
||||
return;
|
||||
}
|
||||
// If there is nothing to draw on the next page, maybe the user
|
||||
// is scrolling up, so, let's try to render the next page *before*
|
||||
// the first visible page
|
||||
if (pages[visible[0].id - 2]) {
|
||||
renderingQueue.enqueueDraw(pages[visible[0].id - 2]);
|
||||
}
|
||||
}
|
||||
|
||||
function updateViewarea() {
|
||||
if (!PDFView.initialized)
|
||||
return;
|
||||
var visiblePages = PDFView.getVisiblePages();
|
||||
var pageToDraw;
|
||||
for (var i = 0; i < visiblePages.length; i++) {
|
||||
var page = visiblePages[i];
|
||||
var pageObj = PDFView.pages[page.id - 1];
|
||||
|
||||
pageToDraw |= pageObj.drawingRequired();
|
||||
renderingQueue.enqueueDraw(pageObj);
|
||||
}
|
||||
|
||||
if (!visiblePages.length)
|
||||
return;
|
||||
|
||||
// If there is no need to draw a page that is currenlty visible, preDraw the
|
||||
// next page the user might scroll to.
|
||||
if (!pageToDraw) {
|
||||
preDraw();
|
||||
}
|
||||
PDFView.renderHighestPriority();
|
||||
|
||||
updateViewarea.inProgress = true; // used in "set page"
|
||||
var currentId = PDFView.page;
|
||||
@ -1640,29 +1846,6 @@ function updateViewarea() {
|
||||
document.getElementById('viewBookmark').href = href;
|
||||
}
|
||||
|
||||
window.addEventListener('scroll', function webViewerScroll(evt) {
|
||||
updateViewarea();
|
||||
}, true);
|
||||
|
||||
var thumbnailTimer;
|
||||
|
||||
function updateThumbViewArea() {
|
||||
// Only render thumbs after pausing scrolling for this amount of time
|
||||
// (makes UI more responsive)
|
||||
var delay = 50; // in ms
|
||||
|
||||
if (thumbnailTimer)
|
||||
clearTimeout(thumbnailTimer);
|
||||
|
||||
thumbnailTimer = setTimeout(function() {
|
||||
var visibleThumbs = PDFView.getVisibleThumbs();
|
||||
for (var i = 0; i < visibleThumbs.length; i++) {
|
||||
var thumb = visibleThumbs[i];
|
||||
renderingQueue.enqueueDraw(PDFView.thumbnails[thumb.id - 1]);
|
||||
}
|
||||
}, delay);
|
||||
}
|
||||
|
||||
window.addEventListener('resize', function webViewerResize(evt) {
|
||||
if (PDFView.initialized &&
|
||||
(document.getElementById('pageWidthOption').selected ||
|
||||
@ -1771,6 +1954,18 @@ window.addEventListener('pagechange', function pagechange(evt) {
|
||||
document.getElementById('next').disabled = (page >= PDFView.pages.length);
|
||||
}, true);
|
||||
|
||||
// Firefox specific event, so that we can prevent browser from zooming
|
||||
window.addEventListener('DOMMouseScroll', function(evt) {
|
||||
if (evt.ctrlKey) {
|
||||
evt.preventDefault();
|
||||
|
||||
var ticks = evt.detail;
|
||||
var direction = (ticks > 0) ? 'zoomOut' : 'zoomIn';
|
||||
for (var i = 0, length = Math.abs(ticks); i < length; i++)
|
||||
PDFView[direction]();
|
||||
}
|
||||
}, false);
|
||||
|
||||
window.addEventListener('keydown', function keydown(evt) {
|
||||
var handled = false;
|
||||
var cmd = (evt.ctrlKey ? 1 : 0) |
|
||||
@ -1838,3 +2033,11 @@ window.addEventListener('keydown', function keydown(evt) {
|
||||
evt.preventDefault();
|
||||
}
|
||||
});
|
||||
|
||||
window.addEventListener('beforeprint', function beforePrint(evt) {
|
||||
PDFView.beforePrint();
|
||||
});
|
||||
|
||||
window.addEventListener('afterprint', function afterPrint(evt) {
|
||||
PDFView.afterPrint();
|
||||
});
|
||||
|
@ -1,27 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
#filter substitution
|
||||
|
||||
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
|
||||
|
||||
<Description about="urn:mozilla:install-manifest">
|
||||
<em:id>uriloader@pdf.js</em:id>
|
||||
<!-- PDFJS_LOCALIZED_METADATA -->
|
||||
<em:name>PDF Viewer</em:name>
|
||||
<em:version>0.3.266</em:version>
|
||||
<em:targetApplication>
|
||||
<Description>
|
||||
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
|
||||
<em:minVersion>@FIREFOX_VERSION@</em:minVersion>
|
||||
<em:maxVersion>@FIREFOX_VERSION@</em:maxVersion>
|
||||
</Description>
|
||||
</em:targetApplication>
|
||||
<em:strictCompatibility>true</em:strictCompatibility>
|
||||
<em:bootstrap>true</em:bootstrap>
|
||||
<em:creator>Mozilla</em:creator>
|
||||
<em:description>Uses HTML5 to display PDF files directly in Firefox.</em:description>
|
||||
<em:homepageURL>https://support.mozilla.org/kb/Opening%20PDF%20files%20within%20Firefox</em:homepageURL>
|
||||
<em:type>2</em:type>
|
||||
</Description>
|
||||
</RDF>
|
@ -1,3 +1,4 @@
|
||||
# Chrome notification bar messages and buttons
|
||||
unsupported_feature=This PDF document might not be displayed correctly.
|
||||
open_with_different_viewer=Open With Different Viewer
|
||||
open_with_different_viewer.accessKey=o
|
||||
|
@ -78,14 +78,14 @@ page_scale_auto=Automatic Zoom
|
||||
page_scale_actual=Actual Size
|
||||
|
||||
# Loading indicator messages
|
||||
# LOCALIZATION NOTE (error_line): "{{[percent}}" will be replaced with a percentage
|
||||
loading=Loading… {{percent}}%
|
||||
loading_error_indicator=Error
|
||||
loading_error=An error occurred while loading the PDF.
|
||||
|
||||
# LOCALIZATION NOTE (text_annotation_type): This is used as a tooltip.
|
||||
# "{{[type}}" will be replaced with an annotation type from a list defined in
|
||||
# "{{type}}" will be replaced with an annotation type from a list defined in
|
||||
# the PDF spec (32000-1:2008 Table 169 – Annotation types).
|
||||
# Some common types are e.g.: "Check", "Text", "Comment", "Note"
|
||||
text_annotation_type=[{{type}} Annotation]
|
||||
request_password=PDF is protected by a password:
|
||||
|
||||
printing_not_supported=Warning: Printing is not fully supported by this browser.
|
||||
|
Loading…
Reference in New Issue
Block a user