[Basilisk] Update pdf.js to 1.7.348 from Firefox 54.0.1

This commit is contained in:
Basilisk-Dev 2023-09-11 22:43:12 -04:00 • committed by roytam1
commit c5d109556c
14 changed files with 63753 additions and 63745 deletions

View file

@ -1,3 +1,3 @@
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: 1.6.467 Current extension version is: 1.7.348

View file

@ -15,9 +15,9 @@
/* globals Components, Services, XPCOMUtils, PdfjsChromeUtils, /* globals Components, Services, XPCOMUtils, PdfjsChromeUtils,
PdfjsContentUtils, PdfStreamConverter */ PdfjsContentUtils, PdfStreamConverter */
'use strict'; "use strict";
var EXPORTED_SYMBOLS = ['PdfJs']; var EXPORTED_SYMBOLS = ["PdfJs"];
const Cc = Components.classes; const Cc = Components.classes;
const Ci = Components.interfaces; const Ci = Components.interfaces;
@ -25,32 +25,32 @@ const Cr = Components.results;
const Cm = Components.manager; const Cm = Components.manager;
const Cu = Components.utils; const Cu = Components.utils;
const PREF_PREFIX = 'pdfjs'; const PREF_PREFIX = "pdfjs";
const PREF_DISABLED = PREF_PREFIX + '.disabled'; const PREF_DISABLED = PREF_PREFIX + ".disabled";
const PREF_MIGRATION_VERSION = PREF_PREFIX + '.migrationVersion'; const PREF_MIGRATION_VERSION = PREF_PREFIX + ".migrationVersion";
const PREF_PREVIOUS_ACTION = PREF_PREFIX + '.previousHandler.preferredAction'; const PREF_PREVIOUS_ACTION = PREF_PREFIX + ".previousHandler.preferredAction";
const PREF_PREVIOUS_ASK = PREF_PREFIX + const PREF_PREVIOUS_ASK = PREF_PREFIX +
'.previousHandler.alwaysAskBeforeHandling'; ".previousHandler.alwaysAskBeforeHandling";
const PREF_DISABLED_PLUGIN_TYPES = 'plugin.disable_full_page_plugin_for_types'; const PREF_DISABLED_PLUGIN_TYPES = "plugin.disable_full_page_plugin_for_types";
const TOPIC_PDFJS_HANDLER_CHANGED = 'pdfjs:handlerChanged'; const TOPIC_PDFJS_HANDLER_CHANGED = "pdfjs:handlerChanged";
const TOPIC_PLUGINS_LIST_UPDATED = 'plugins-list-updated'; const TOPIC_PLUGINS_LIST_UPDATED = "plugins-list-updated";
const TOPIC_PLUGIN_INFO_UPDATED = 'plugin-info-updated'; const TOPIC_PLUGIN_INFO_UPDATED = "plugin-info-updated";
const PDF_CONTENT_TYPE = 'application/pdf'; const PDF_CONTENT_TYPE = "application/pdf";
Cu.import('resource://gre/modules/XPCOMUtils.jsm'); Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import('resource://gre/modules/Services.jsm'); Cu.import("resource://gre/modules/Services.jsm");
var Svc = {}; var Svc = {};
XPCOMUtils.defineLazyServiceGetter(Svc, 'mime', XPCOMUtils.defineLazyServiceGetter(Svc, "mime",
'@mozilla.org/mime;1', "@mozilla.org/mime;1",
'nsIMIMEService'); "nsIMIMEService");
XPCOMUtils.defineLazyServiceGetter(Svc, 'pluginHost', XPCOMUtils.defineLazyServiceGetter(Svc, "pluginHost",
'@mozilla.org/plugin/host;1', "@mozilla.org/plugin/host;1",
'nsIPluginHost'); "nsIPluginHost");
XPCOMUtils.defineLazyModuleGetter(this, 'PdfjsChromeUtils', XPCOMUtils.defineLazyModuleGetter(this, "PdfjsChromeUtils",
'resource://pdf.js/PdfjsChromeUtils.jsm'); "resource://pdf.js/PdfjsChromeUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, 'PdfjsContentUtils', XPCOMUtils.defineLazyModuleGetter(this, "PdfjsContentUtils",
'resource://pdf.js/PdfjsContentUtils.jsm'); "resource://pdf.js/PdfjsContentUtils.jsm");
function getBoolPref(aPref, aDefaultValue) { function getBoolPref(aPref, aDefaultValue) {
try { try {
@ -94,22 +94,23 @@ function initializeDefaultPreferences() {
"enhanceTextSelection": false, "enhanceTextSelection": false,
"renderer": "canvas", "renderer": "canvas",
"renderInteractiveForms": false, "renderInteractiveForms": false,
"enablePrintAutoRotate": false,
"disablePageLabels": false "disablePageLabels": false
} }
var defaultBranch = Services.prefs.getDefaultBranch(PREF_PREFIX + '.'); var defaultBranch = Services.prefs.getDefaultBranch(PREF_PREFIX + ".");
var defaultValue; var defaultValue;
for (var key in DEFAULT_PREFERENCES) { for (var key in DEFAULT_PREFERENCES) {
defaultValue = DEFAULT_PREFERENCES[key]; defaultValue = DEFAULT_PREFERENCES[key];
switch (typeof defaultValue) { switch (typeof defaultValue) {
case 'boolean': case "boolean":
defaultBranch.setBoolPref(key, defaultValue); defaultBranch.setBoolPref(key, defaultValue);
break; break;
case 'number': case "number":
defaultBranch.setIntPref(key, defaultValue); defaultBranch.setIntPref(key, defaultValue);
break; break;
case 'string': case "string":
defaultBranch.setCharPref(key, defaultValue); defaultBranch.setCharPref(key, defaultValue);
break; break;
} }
@ -155,8 +156,8 @@ var PdfJs = {
init: function init(remote) { init: function init(remote) {
if (Services.appinfo.processType !== if (Services.appinfo.processType !==
Services.appinfo.PROCESS_TYPE_DEFAULT) { Services.appinfo.PROCESS_TYPE_DEFAULT) {
throw new Error('PdfJs.init should only get called ' + throw new Error("PdfJs.init should only get called " +
'in the parent process.'); "in the parent process.");
} }
PdfjsChromeUtils.init(); PdfjsChromeUtils.init();
if (!remote) { if (!remote) {
@ -219,13 +220,13 @@ var PdfJs = {
} }
if (currentVersion < 2) { if (currentVersion < 2) {
// cleaning up of unused database preference (see #3994) // cleaning up of unused database preference (see #3994)
Services.prefs.clearUserPref(PREF_PREFIX + '.database'); Services.prefs.clearUserPref(PREF_PREFIX + ".database");
} }
Services.prefs.setIntPref(PREF_MIGRATION_VERSION, VERSION); Services.prefs.setIntPref(PREF_MIGRATION_VERSION, VERSION);
}, },
_becomeHandler: function _becomeHandler() { _becomeHandler: function _becomeHandler() {
let handlerInfo = Svc.mime.getFromTypeAndExtension(PDF_CONTENT_TYPE, 'pdf'); let handlerInfo = Svc.mime.getFromTypeAndExtension(PDF_CONTENT_TYPE, "pdf");
let prefs = Services.prefs; let prefs = Services.prefs;
if (handlerInfo.preferredAction !== Ci.nsIHandlerInfo.handleInternally && if (handlerInfo.preferredAction !== Ci.nsIHandlerInfo.handleInternally &&
handlerInfo.preferredAction !== false) { handlerInfo.preferredAction !== false) {
@ -236,7 +237,7 @@ var PdfJs = {
prefs.setBoolPref(PREF_PREVIOUS_ASK, handlerInfo.alwaysAskBeforeHandling); prefs.setBoolPref(PREF_PREVIOUS_ASK, handlerInfo.alwaysAskBeforeHandling);
} }
let handlerService = Cc['@mozilla.org/uriloader/handler-service;1']. let handlerService = Cc["@mozilla.org/uriloader/handler-service;1"].
getService(Ci.nsIHandlerService); getService(Ci.nsIHandlerService);
// Change and save mime handler settings. // Change and save mime handler settings.
@ -245,24 +246,24 @@ var PdfJs = {
handlerService.store(handlerInfo); handlerService.store(handlerInfo);
// Also disable any plugins for pdfs. // Also disable any plugins for pdfs.
var stringTypes = ''; var stringTypes = "";
var types = []; var types = [];
if (prefs.prefHasUserValue(PREF_DISABLED_PLUGIN_TYPES)) { if (prefs.prefHasUserValue(PREF_DISABLED_PLUGIN_TYPES)) {
stringTypes = prefs.getCharPref(PREF_DISABLED_PLUGIN_TYPES); stringTypes = prefs.getCharPref(PREF_DISABLED_PLUGIN_TYPES);
} }
if (stringTypes !== '') { if (stringTypes !== "") {
types = stringTypes.split(','); types = stringTypes.split(",");
} }
if (types.indexOf(PDF_CONTENT_TYPE) === -1) { if (types.indexOf(PDF_CONTENT_TYPE) === -1) {
types.push(PDF_CONTENT_TYPE); types.push(PDF_CONTENT_TYPE);
} }
prefs.setCharPref(PREF_DISABLED_PLUGIN_TYPES, types.join(',')); prefs.setCharPref(PREF_DISABLED_PLUGIN_TYPES, types.join(","));
// Update the category manager in case the plugins are already loaded. // Update the category manager in case the plugins are already loaded.
let categoryManager = Cc['@mozilla.org/categorymanager;1']; let categoryManager = Cc["@mozilla.org/categorymanager;1"];
categoryManager.getService(Ci.nsICategoryManager). categoryManager.getService(Ci.nsICategoryManager).
deleteCategoryEntry('Gecko-Content-Viewers', deleteCategoryEntry("Gecko-Content-Viewers",
PDF_CONTENT_TYPE, PDF_CONTENT_TYPE,
false); false);
}, },
@ -272,7 +273,7 @@ var PdfJs = {
this.updateRegistration(); this.updateRegistration();
if (Services.appinfo.processType === if (Services.appinfo.processType ===
Services.appinfo.PROCESS_TYPE_DEFAULT) { Services.appinfo.PROCESS_TYPE_DEFAULT) {
let jsm = 'resource://pdf.js/PdfjsChromeUtils.jsm'; let jsm = "resource://pdf.js/PdfjsChromeUtils.jsm";
let PdfjsChromeUtils = Components.utils.import(jsm, {}).PdfjsChromeUtils; let PdfjsChromeUtils = Components.utils.import(jsm, {}).PdfjsChromeUtils;
PdfjsChromeUtils.notifyChildOfSettingsChange(); PdfjsChromeUtils.notifyChildOfSettingsChange();
} }
@ -297,7 +298,7 @@ var PdfJs = {
// Check if we have disabled plugin handling of 'application/pdf' in prefs // Check if we have disabled plugin handling of 'application/pdf' in prefs
if (Services.prefs.prefHasUserValue(PREF_DISABLED_PLUGIN_TYPES)) { if (Services.prefs.prefHasUserValue(PREF_DISABLED_PLUGIN_TYPES)) {
let disabledPluginTypes = let disabledPluginTypes =
Services.prefs.getCharPref(PREF_DISABLED_PLUGIN_TYPES).split(','); Services.prefs.getCharPref(PREF_DISABLED_PLUGIN_TYPES).split(",");
if (disabledPluginTypes.indexOf(PDF_CONTENT_TYPE) >= 0) { if (disabledPluginTypes.indexOf(PDF_CONTENT_TYPE) >= 0) {
return true; return true;
} }
@ -306,7 +307,7 @@ var PdfJs = {
// Check if there is an enabled pdf plugin. // Check if there is an enabled pdf plugin.
// Note: this check is performed last because getPluginTags() triggers // Note: this check is performed last because getPluginTags() triggers
// costly plugin list initialization (bug 881575) // costly plugin list initialization (bug 881575)
let tags = Cc['@mozilla.org/plugin/host;1']. let tags = Cc["@mozilla.org/plugin/host;1"].
getService(Ci.nsIPluginHost). getService(Ci.nsIPluginHost).
getPluginTags(); getPluginTags();
let enabledPluginFound = tags.some(function(tag) { let enabledPluginFound = tags.some(function(tag) {
@ -328,7 +329,7 @@ var PdfJs = {
return; return;
} }
this._pdfStreamConverterFactory = new Factory(); this._pdfStreamConverterFactory = new Factory();
Cu.import('resource://pdf.js/PdfStreamConverter.jsm'); Cu.import("resource://pdf.js/PdfStreamConverter.jsm");
this._pdfStreamConverterFactory.register(PdfStreamConverter); this._pdfStreamConverterFactory.register(PdfStreamConverter);
this._registered = true; this._registered = true;
@ -339,7 +340,7 @@ var PdfJs = {
return; return;
} }
this._pdfStreamConverterFactory.unregister(); this._pdfStreamConverterFactory.unregister();
Cu.unload('resource://pdf.js/PdfStreamConverter.jsm'); Cu.unload("resource://pdf.js/PdfStreamConverter.jsm");
delete this._pdfStreamConverterFactory; delete this._pdfStreamConverterFactory;
this._registered = false; this._registered = false;

View file

@ -14,41 +14,25 @@
*/ */
/* globals Components, Services */ /* globals Components, Services */
'use strict'; "use strict";
Components.utils.import('resource://gre/modules/Services.jsm'); Components.utils.import("resource://gre/modules/Services.jsm");
var EXPORTED_SYMBOLS = ['NetworkManager']; var EXPORTED_SYMBOLS = ["NetworkManager"];
function log(aMsg) { function log(aMsg) {
var msg = 'network.js: ' + (aMsg.join ? aMsg.join('') : aMsg); var msg = "PdfJsNetwork.jsm: " + (aMsg.join ? aMsg.join("") : aMsg);
Services.console.logStringMessage(msg); Services.console.logStringMessage(msg);
} }
var NetworkManager = (function NetworkManagerClosure() { var NetworkManager = (function NetworkManagerClosure() {
var OK_RESPONSE = 200; const OK_RESPONSE = 200;
var PARTIAL_CONTENT_RESPONSE = 206; const PARTIAL_CONTENT_RESPONSE = 206;
function NetworkManager(url, args) {
this.url = url;
args = args || {};
this.isHttp = /^https?:/i.test(url);
this.httpHeaders = (this.isHttp && args.httpHeaders) || {};
this.withCredentials = args.withCredentials || false;
this.getXhr = args.getXhr ||
function NetworkManager_getXhr() {
return new XMLHttpRequest();
};
this.currXhrId = 0;
this.pendingRequests = Object.create(null);
this.loadedRequests = Object.create(null);
}
function getArrayBuffer(xhr) { function getArrayBuffer(xhr) {
var data = xhr.response; var data = xhr.response;
if (typeof data !== 'string') { if (typeof data !== "string") {
return data; return data;
} }
var length = data.length; var length = data.length;
@ -59,41 +43,57 @@ var NetworkManager = (function NetworkManagerClosure() {
return array.buffer; return array.buffer;
} }
NetworkManager.prototype = { class NetworkManagerClass {
requestRange: function NetworkManager_requestRange(begin, end, listeners) { constructor(url, args) {
this.url = url;
args = args || {};
this.isHttp = /^https?:/i.test(url);
this.httpHeaders = (this.isHttp && args.httpHeaders) || {};
this.withCredentials = args.withCredentials || false;
this.getXhr = args.getXhr ||
function NetworkManager_getXhr() {
return new XMLHttpRequest();
};
this.currXhrId = 0;
this.pendingRequests = Object.create(null);
this.loadedRequests = Object.create(null);
}
requestRange(begin, end, listeners) {
var args = { var args = {
begin: begin, begin,
end: end end,
}; };
for (var prop in listeners) { for (var prop in listeners) {
args[prop] = listeners[prop]; args[prop] = listeners[prop];
} }
return this.request(args); return this.request(args);
}, }
requestFull: function NetworkManager_requestFull(listeners) { requestFull(listeners) {
return this.request(listeners); return this.request(listeners);
}, }
request: function NetworkManager_request(args) { request(args) {
var xhr = this.getXhr(); var xhr = this.getXhr();
var xhrId = this.currXhrId++; var xhrId = this.currXhrId++;
var pendingRequest = this.pendingRequests[xhrId] = { var pendingRequest = this.pendingRequests[xhrId] = {
xhr: xhr xhr,
}; };
xhr.open('GET', this.url); xhr.open("GET", this.url);
xhr.withCredentials = this.withCredentials; xhr.withCredentials = this.withCredentials;
for (var property in this.httpHeaders) { for (var property in this.httpHeaders) {
var value = this.httpHeaders[property]; var value = this.httpHeaders[property];
if (typeof value === 'undefined') { if (typeof value === "undefined") {
continue; continue;
} }
xhr.setRequestHeader(property, value); xhr.setRequestHeader(property, value);
} }
if (this.isHttp && 'begin' in args && 'end' in args) { if (this.isHttp && "begin" in args && "end" in args) {
var rangeStr = args.begin + '-' + (args.end - 1); var rangeStr = args.begin + "-" + (args.end - 1);
xhr.setRequestHeader('Range', 'bytes=' + rangeStr); xhr.setRequestHeader("Range", "bytes=" + rangeStr);
pendingRequest.expectedStatus = 206; pendingRequest.expectedStatus = 206;
} else { } else {
pendingRequest.expectedStatus = 200; pendingRequest.expectedStatus = 200;
@ -101,11 +101,11 @@ var NetworkManager = (function NetworkManagerClosure() {
var useMozChunkedLoading = !!args.onProgressiveData; var useMozChunkedLoading = !!args.onProgressiveData;
if (useMozChunkedLoading) { if (useMozChunkedLoading) {
xhr.responseType = 'moz-chunked-arraybuffer'; xhr.responseType = "moz-chunked-arraybuffer";
pendingRequest.onProgressiveData = args.onProgressiveData; pendingRequest.onProgressiveData = args.onProgressiveData;
pendingRequest.mozChunked = true; pendingRequest.mozChunked = true;
} else { } else {
xhr.responseType = 'arraybuffer'; xhr.responseType = "arraybuffer";
} }
if (args.onError) { if (args.onError) {
@ -124,9 +124,9 @@ var NetworkManager = (function NetworkManagerClosure() {
xhr.send(null); xhr.send(null);
return xhrId; return xhrId;
}, }
onProgress: function NetworkManager_onProgress(xhrId, evt) { onProgress(xhrId, evt) {
var pendingRequest = this.pendingRequests[xhrId]; var pendingRequest = this.pendingRequests[xhrId];
if (!pendingRequest) { if (!pendingRequest) {
// Maybe abortRequest was called... // Maybe abortRequest was called...
@ -142,9 +142,9 @@ var NetworkManager = (function NetworkManagerClosure() {
if (onProgress) { if (onProgress) {
onProgress(evt); onProgress(evt);
} }
}, }
onStateChange: function NetworkManager_onStateChange(xhrId, evt) { onStateChange(xhrId, evt) {
var pendingRequest = this.pendingRequests[xhrId]; var pendingRequest = this.pendingRequests[xhrId];
if (!pendingRequest) { if (!pendingRequest) {
// Maybe abortRequest was called... // Maybe abortRequest was called...
@ -197,61 +197,61 @@ var NetworkManager = (function NetworkManagerClosure() {
var chunk = getArrayBuffer(xhr); var chunk = getArrayBuffer(xhr);
if (xhrStatus === PARTIAL_CONTENT_RESPONSE) { if (xhrStatus === PARTIAL_CONTENT_RESPONSE) {
var rangeHeader = xhr.getResponseHeader('Content-Range'); var rangeHeader = xhr.getResponseHeader("Content-Range");
var matches = /bytes (\d+)-(\d+)\/(\d+)/.exec(rangeHeader); var matches = /bytes (\d+)-(\d+)\/(\d+)/.exec(rangeHeader);
var begin = parseInt(matches[1], 10); var begin = parseInt(matches[1], 10);
pendingRequest.onDone({ pendingRequest.onDone({
begin: begin, begin,
chunk: chunk chunk,
}); });
} else if (pendingRequest.onProgressiveData) { } else if (pendingRequest.onProgressiveData) {
pendingRequest.onDone(null); pendingRequest.onDone(null);
} else if (chunk) { } else if (chunk) {
pendingRequest.onDone({ pendingRequest.onDone({
begin: 0, begin: 0,
chunk: chunk chunk,
}); });
} else if (pendingRequest.onError) { } else if (pendingRequest.onError) {
pendingRequest.onError(xhr.status); pendingRequest.onError(xhr.status);
} }
}, }
hasPendingRequests: function NetworkManager_hasPendingRequests() { hasPendingRequests() {
for (var xhrId in this.pendingRequests) { for (var xhrId in this.pendingRequests) {
return true; return true;
} }
return false; return false;
}, }
getRequestXhr: function NetworkManager_getXhr(xhrId) { getRequestXhr(xhrId) {
return this.pendingRequests[xhrId].xhr; return this.pendingRequests[xhrId].xhr;
}, }
isStreamingRequest: function NetworkManager_isStreamingRequest(xhrId) { isStreamingRequest(xhrId) {
return !!(this.pendingRequests[xhrId].onProgressiveData); return !!(this.pendingRequests[xhrId].onProgressiveData);
}, }
isPendingRequest: function NetworkManager_isPendingRequest(xhrId) { isPendingRequest(xhrId) {
return xhrId in this.pendingRequests; return xhrId in this.pendingRequests;
}, }
isLoadedRequest: function NetworkManager_isLoadedRequest(xhrId) { isLoadedRequest(xhrId) {
return xhrId in this.loadedRequests; return xhrId in this.loadedRequests;
}, }
abortAllRequests: function NetworkManager_abortAllRequests() { abortAllRequests() {
for (var xhrId in this.pendingRequests) { for (var xhrId in this.pendingRequests) {
this.abortRequest(xhrId | 0); this.abortRequest(xhrId | 0);
} }
}, }
abortRequest: function NetworkManager_abortRequest(xhrId) { abortRequest(xhrId) {
var xhr = this.pendingRequests[xhrId].xhr; var xhr = this.pendingRequests[xhrId].xhr;
delete this.pendingRequests[xhrId]; delete this.pendingRequests[xhrId];
xhr.abort(); xhr.abort();
} }
}; }
return NetworkManager; return NetworkManagerClass;
})(); })();

View file

@ -14,25 +14,25 @@
*/ */
/* globals Components, Services, XPCOMUtils */ /* globals Components, Services, XPCOMUtils */
'use strict'; "use strict";
var EXPORTED_SYMBOLS = ['PdfjsChromeUtils']; var EXPORTED_SYMBOLS = ["PdfjsChromeUtils"];
const Cc = Components.classes; const Cc = Components.classes;
const Ci = Components.interfaces; const Ci = Components.interfaces;
const Cr = Components.results; const Cr = Components.results;
const Cu = Components.utils; const Cu = Components.utils;
const PREF_PREFIX = 'pdfjs'; const PREF_PREFIX = "pdfjs";
const PDF_CONTENT_TYPE = 'application/pdf'; const PDF_CONTENT_TYPE = "application/pdf";
Cu.import('resource://gre/modules/XPCOMUtils.jsm'); Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import('resource://gre/modules/Services.jsm'); Cu.import("resource://gre/modules/Services.jsm");
var Svc = {}; var Svc = {};
XPCOMUtils.defineLazyServiceGetter(Svc, 'mime', XPCOMUtils.defineLazyServiceGetter(Svc, "mime",
'@mozilla.org/mime;1', "@mozilla.org/mime;1",
'nsIMIMEService'); "nsIMIMEService");
var DEFAULT_PREFERENCES = var DEFAULT_PREFERENCES =
{ {
@ -52,6 +52,7 @@ var DEFAULT_PREFERENCES =
"enhanceTextSelection": false, "enhanceTextSelection": false,
"renderer": "canvas", "renderer": "canvas",
"renderInteractiveForms": false, "renderInteractiveForms": false,
"enablePrintAutoRotate": false,
"disablePageLabels": false "disablePageLabels": false
} }
@ -67,50 +68,50 @@ var PdfjsChromeUtils = {
* Public API * Public API
*/ */
init: function () { init() {
this._browsers = new WeakSet(); this._browsers = new WeakSet();
if (!this._ppmm) { if (!this._ppmm) {
// global parent process message manager (PPMM) // global parent process message manager (PPMM)
this._ppmm = Cc['@mozilla.org/parentprocessmessagemanager;1']. this._ppmm = Cc["@mozilla.org/parentprocessmessagemanager;1"].
getService(Ci.nsIMessageBroadcaster); getService(Ci.nsIMessageBroadcaster);
this._ppmm.addMessageListener('PDFJS:Parent:clearUserPref', this); this._ppmm.addMessageListener("PDFJS:Parent:clearUserPref", this);
this._ppmm.addMessageListener('PDFJS:Parent:setIntPref', this); this._ppmm.addMessageListener("PDFJS:Parent:setIntPref", this);
this._ppmm.addMessageListener('PDFJS:Parent:setBoolPref', this); this._ppmm.addMessageListener("PDFJS:Parent:setBoolPref", this);
this._ppmm.addMessageListener('PDFJS:Parent:setCharPref', this); this._ppmm.addMessageListener("PDFJS:Parent:setCharPref", this);
this._ppmm.addMessageListener('PDFJS:Parent:setStringPref', this); this._ppmm.addMessageListener("PDFJS:Parent:setStringPref", this);
this._ppmm.addMessageListener('PDFJS:Parent:isDefaultHandlerApp', this); this._ppmm.addMessageListener("PDFJS:Parent:isDefaultHandlerApp", this);
// global dom message manager (MMg) // global dom message manager (MMg)
this._mmg = Cc['@mozilla.org/globalmessagemanager;1']. this._mmg = Cc["@mozilla.org/globalmessagemanager;1"].
getService(Ci.nsIMessageListenerManager); getService(Ci.nsIMessageListenerManager);
this._mmg.addMessageListener('PDFJS:Parent:displayWarning', this); this._mmg.addMessageListener("PDFJS:Parent:displayWarning", this);
this._mmg.addMessageListener('PDFJS:Parent:addEventListener', this); this._mmg.addMessageListener("PDFJS:Parent:addEventListener", this);
this._mmg.addMessageListener('PDFJS:Parent:removeEventListener', this); this._mmg.addMessageListener("PDFJS:Parent:removeEventListener", this);
this._mmg.addMessageListener('PDFJS:Parent:updateControlState', this); this._mmg.addMessageListener("PDFJS:Parent:updateControlState", this);
// observer to handle shutdown // observer to handle shutdown
Services.obs.addObserver(this, 'quit-application', false); Services.obs.addObserver(this, "quit-application", false);
} }
}, },
uninit: function () { uninit() {
if (this._ppmm) { if (this._ppmm) {
this._ppmm.removeMessageListener('PDFJS:Parent:clearUserPref', this); this._ppmm.removeMessageListener("PDFJS:Parent:clearUserPref", this);
this._ppmm.removeMessageListener('PDFJS:Parent:setIntPref', this); this._ppmm.removeMessageListener("PDFJS:Parent:setIntPref", this);
this._ppmm.removeMessageListener('PDFJS:Parent:setBoolPref', this); this._ppmm.removeMessageListener("PDFJS:Parent:setBoolPref", this);
this._ppmm.removeMessageListener('PDFJS:Parent:setCharPref', this); this._ppmm.removeMessageListener("PDFJS:Parent:setCharPref", this);
this._ppmm.removeMessageListener('PDFJS:Parent:setStringPref', this); this._ppmm.removeMessageListener("PDFJS:Parent:setStringPref", this);
this._ppmm.removeMessageListener('PDFJS:Parent:isDefaultHandlerApp', this._ppmm.removeMessageListener("PDFJS:Parent:isDefaultHandlerApp",
this); this);
this._mmg.removeMessageListener('PDFJS:Parent:displayWarning', this); this._mmg.removeMessageListener("PDFJS:Parent:displayWarning", this);
this._mmg.removeMessageListener('PDFJS:Parent:addEventListener', this); this._mmg.removeMessageListener("PDFJS:Parent:addEventListener", this);
this._mmg.removeMessageListener('PDFJS:Parent:removeEventListener', this); this._mmg.removeMessageListener("PDFJS:Parent:removeEventListener", this);
this._mmg.removeMessageListener('PDFJS:Parent:updateControlState', this); this._mmg.removeMessageListener("PDFJS:Parent:updateControlState", this);
Services.obs.removeObserver(this, 'quit-application'); Services.obs.removeObserver(this, "quit-application");
this._mmg = null; this._mmg = null;
this._ppmm = null; this._ppmm = null;
@ -123,7 +124,7 @@ var PdfjsChromeUtils = {
* instruct the child to refresh its configuration and (possibly) * instruct the child to refresh its configuration and (possibly)
* the module's registration. * the module's registration.
*/ */
notifyChildOfSettingsChange: function () { notifyChildOfSettingsChange() {
if (Services.appinfo.processType === if (Services.appinfo.processType ===
Services.appinfo.PROCESS_TYPE_DEFAULT && this._ppmm) { Services.appinfo.PROCESS_TYPE_DEFAULT && this._ppmm) {
// XXX kinda bad, we want to get the parent process mm associated // XXX kinda bad, we want to get the parent process mm associated
@ -131,7 +132,7 @@ var PdfjsChromeUtils = {
// manager, which means this is going to fire to every child process // manager, which means this is going to fire to every child process
// we have open. Unfortunately I can't find a way to get at that // we have open. Unfortunately I can't find a way to get at that
// process specific mm from js. // process specific mm from js.
this._ppmm.broadcastAsyncMessage('PDFJS:Child:refreshSettings', {}); this._ppmm.broadcastAsyncMessage("PDFJS:Child:refreshSettings", {});
} }
}, },
@ -139,63 +140,63 @@ var PdfjsChromeUtils = {
* Events * Events
*/ */
observe: function(aSubject, aTopic, aData) { observe(aSubject, aTopic, aData) {
if (aTopic === 'quit-application') { if (aTopic === "quit-application") {
this.uninit(); this.uninit();
} }
}, },
receiveMessage: function (aMsg) { receiveMessage(aMsg) {
switch (aMsg.name) { switch (aMsg.name) {
case 'PDFJS:Parent:clearUserPref': case "PDFJS:Parent:clearUserPref":
this._clearUserPref(aMsg.data.name); this._clearUserPref(aMsg.data.name);
break; break;
case 'PDFJS:Parent:setIntPref': case "PDFJS:Parent:setIntPref":
this._setIntPref(aMsg.data.name, aMsg.data.value); this._setIntPref(aMsg.data.name, aMsg.data.value);
break; break;
case 'PDFJS:Parent:setBoolPref': case "PDFJS:Parent:setBoolPref":
this._setBoolPref(aMsg.data.name, aMsg.data.value); this._setBoolPref(aMsg.data.name, aMsg.data.value);
break; break;
case 'PDFJS:Parent:setCharPref': case "PDFJS:Parent:setCharPref":
this._setCharPref(aMsg.data.name, aMsg.data.value); this._setCharPref(aMsg.data.name, aMsg.data.value);
break; break;
case 'PDFJS:Parent:setStringPref': case "PDFJS:Parent:setStringPref":
this._setStringPref(aMsg.data.name, aMsg.data.value); this._setStringPref(aMsg.data.name, aMsg.data.value);
break; break;
case 'PDFJS:Parent:isDefaultHandlerApp': case "PDFJS:Parent:isDefaultHandlerApp":
return this.isDefaultHandlerApp(); return this.isDefaultHandlerApp();
case 'PDFJS:Parent:displayWarning': case "PDFJS:Parent:displayWarning":
this._displayWarning(aMsg); this._displayWarning(aMsg);
break; break;
case "PDFJS:Parent:updateControlState":
case 'PDFJS:Parent:updateControlState':
return this._updateControlState(aMsg); return this._updateControlState(aMsg);
case 'PDFJS:Parent:addEventListener': case "PDFJS:Parent:addEventListener":
return this._addEventListener(aMsg); return this._addEventListener(aMsg);
case 'PDFJS:Parent:removeEventListener': case "PDFJS:Parent:removeEventListener":
return this._removeEventListener(aMsg); return this._removeEventListener(aMsg);
} }
return undefined;
}, },
/* /*
* Internal * Internal
*/ */
_findbarFromMessage: function(aMsg) { _findbarFromMessage(aMsg) {
let browser = aMsg.target; let browser = aMsg.target;
let tabbrowser = browser.getTabBrowser(); let tabbrowser = browser.getTabBrowser();
let tab = tabbrowser.getTabForBrowser(browser); let tab = tabbrowser.getTabForBrowser(browser);
return tabbrowser.getFindBar(tab); return tabbrowser.getFindBar(tab);
}, },
_updateControlState: function (aMsg) { _updateControlState(aMsg) {
let data = aMsg.data; let data = aMsg.data;
this._findbarFromMessage(aMsg) this._findbarFromMessage(aMsg)
.updateControlState(data.result, data.findPrevious); .updateControlState(data.result, data.findPrevious);
}, },
handleEvent: function(aEvent) { handleEvent(aEvent) {
// To avoid forwarding the message as a CPOW, create a structured cloneable // To avoid forwarding the message as a CPOW, create a structured cloneable
// version of the event for both performance, and ease of usage, reasons. // version of the event for both performance, and ease of usage, reasons.
let type = aEvent.type; let type = aEvent.type;
@ -208,26 +209,25 @@ var PdfjsChromeUtils = {
let browser = aEvent.currentTarget.browser; let browser = aEvent.currentTarget.browser;
if (!this._browsers.has(browser)) { if (!this._browsers.has(browser)) {
throw new Error('FindEventManager was not bound ' + throw new Error("FindEventManager was not bound " +
'for the current browser.'); "for the current browser.");
} }
// Only forward the events if the current browser is a registered browser. // Only forward the events if the current browser is a registered browser.
let mm = browser.messageManager; let mm = browser.messageManager;
mm.sendAsyncMessage('PDFJS:Child:handleEvent', mm.sendAsyncMessage("PDFJS:Child:handleEvent", { type, detail, });
{ type: type, detail: detail });
aEvent.preventDefault(); aEvent.preventDefault();
}, },
_types: ['find', _types: ["find",
'findagain', "findagain",
'findhighlightallchange', "findhighlightallchange",
'findcasesensitivitychange'], "findcasesensitivitychange"],
_addEventListener: function (aMsg) { _addEventListener(aMsg) {
let browser = aMsg.target; let browser = aMsg.target;
if (this._browsers.has(browser)) { if (this._browsers.has(browser)) {
throw new Error('FindEventManager was bound 2nd time ' + throw new Error("FindEventManager was bound 2nd time " +
'without unbinding it first.'); "without unbinding it first.");
} }
// Since this jsm is global, we need to store all the browsers // Since this jsm is global, we need to store all the browsers
@ -242,10 +242,10 @@ var PdfjsChromeUtils = {
} }
}, },
_removeEventListener: function (aMsg) { _removeEventListener(aMsg) {
let browser = aMsg.target; let browser = aMsg.target;
if (!this._browsers.has(browser)) { if (!this._browsers.has(browser)) {
throw new Error('FindEventManager was unbound without binding it first.'); throw new Error("FindEventManager was unbound without binding it first.");
} }
this._browsers.delete(browser); this._browsers.delete(browser);
@ -258,39 +258,39 @@ var PdfjsChromeUtils = {
} }
}, },
_ensurePreferenceAllowed: function (aPrefName) { _ensurePreferenceAllowed(aPrefName) {
let unPrefixedName = aPrefName.split(PREF_PREFIX + '.'); let unPrefixedName = aPrefName.split(PREF_PREFIX + ".");
if (unPrefixedName[0] !== '' || if (unPrefixedName[0] !== "" ||
this._allowedPrefNames.indexOf(unPrefixedName[1]) === -1) { this._allowedPrefNames.indexOf(unPrefixedName[1]) === -1) {
let msg = '"' + aPrefName + '" ' + let msg = "\"" + aPrefName + "\" " +
'can\'t be accessed from content. See PdfjsChromeUtils.'; "can't be accessed from content. See PdfjsChromeUtils.";
throw new Error(msg); throw new Error(msg);
} }
}, },
_clearUserPref: function (aPrefName) { _clearUserPref(aPrefName) {
this._ensurePreferenceAllowed(aPrefName); this._ensurePreferenceAllowed(aPrefName);
Services.prefs.clearUserPref(aPrefName); Services.prefs.clearUserPref(aPrefName);
}, },
_setIntPref: function (aPrefName, aPrefValue) { _setIntPref(aPrefName, aPrefValue) {
this._ensurePreferenceAllowed(aPrefName); this._ensurePreferenceAllowed(aPrefName);
Services.prefs.setIntPref(aPrefName, aPrefValue); Services.prefs.setIntPref(aPrefName, aPrefValue);
}, },
_setBoolPref: function (aPrefName, aPrefValue) { _setBoolPref(aPrefName, aPrefValue) {
this._ensurePreferenceAllowed(aPrefName); this._ensurePreferenceAllowed(aPrefName);
Services.prefs.setBoolPref(aPrefName, aPrefValue); Services.prefs.setBoolPref(aPrefName, aPrefValue);
}, },
_setCharPref: function (aPrefName, aPrefValue) { _setCharPref(aPrefName, aPrefValue) {
this._ensurePreferenceAllowed(aPrefName); this._ensurePreferenceAllowed(aPrefName);
Services.prefs.setCharPref(aPrefName, aPrefValue); Services.prefs.setCharPref(aPrefName, aPrefValue);
}, },
_setStringPref: function (aPrefName, aPrefValue) { _setStringPref(aPrefName, aPrefValue) {
this._ensurePreferenceAllowed(aPrefName); this._ensurePreferenceAllowed(aPrefName);
let str = Cc['@mozilla.org/supports-string;1'] let str = Cc["@mozilla.org/supports-string;1"]
.createInstance(Ci.nsISupportsString); .createInstance(Ci.nsISupportsString);
str.data = aPrefValue; str.data = aPrefValue;
Services.prefs.setComplexValue(aPrefName, Ci.nsISupportsString, str); Services.prefs.setComplexValue(aPrefName, Ci.nsISupportsString, str);
@ -301,8 +301,8 @@ var PdfjsChromeUtils = {
* we bounce this pdfjs enabled configuration check over to the * we bounce this pdfjs enabled configuration check over to the
* parent. * parent.
*/ */
isDefaultHandlerApp: function () { isDefaultHandlerApp() {
var handlerInfo = Svc.mime.getFromTypeAndExtension(PDF_CONTENT_TYPE, 'pdf'); var handlerInfo = Svc.mime.getFromTypeAndExtension(PDF_CONTENT_TYPE, "pdf");
return (!handlerInfo.alwaysAskBeforeHandling && return (!handlerInfo.alwaysAskBeforeHandling &&
handlerInfo.preferredAction === Ci.nsIHandlerInfo.handleInternally); handlerInfo.preferredAction === Ci.nsIHandlerInfo.handleInternally);
}, },
@ -311,7 +311,7 @@ var PdfjsChromeUtils = {
* Display a notification warning when the renderer isn't sure * Display a notification warning when the renderer isn't sure
* a pdf displayed correctly. * a pdf displayed correctly.
*/ */
_displayWarning: function (aMsg) { _displayWarning(aMsg) {
let data = aMsg.data; let data = aMsg.data;
let browser = aMsg.target; let browser = aMsg.target;
@ -324,24 +324,23 @@ var PdfjsChromeUtils = {
let messageSent = false; let messageSent = false;
function sendMessage(download) { function sendMessage(download) {
let mm = browser.messageManager; let mm = browser.messageManager;
mm.sendAsyncMessage('PDFJS:Child:fallbackDownload', mm.sendAsyncMessage("PDFJS:Child:fallbackDownload", { download, });
{ download: download });
} }
let buttons = [{ let buttons = [{
label: data.label, label: data.label,
accessKey: data.accessKey, accessKey: data.accessKey,
callback: function() { callback() {
messageSent = true; messageSent = true;
sendMessage(true); sendMessage(true);
} }
}]; }];
notificationBox.appendNotification(data.message, 'pdfjs-fallback', null, notificationBox.appendNotification(data.message, "pdfjs-fallback", null,
notificationBox.PRIORITY_INFO_LOW, notificationBox.PRIORITY_INFO_LOW,
buttons, buttons,
function eventsCallback(eventType) { function eventsCallback(eventType) {
// Currently there is only one event "removed" but if there are any other // 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. // added in the future we still only care about removed at the moment.
if (eventType !== 'removed') { if (eventType !== "removed") {
return; return;
} }
// Don't send a response again if we already responded when the button was // Don't send a response again if we already responded when the button was

View file

@ -14,17 +14,17 @@
*/ */
/* globals Components, Services, XPCOMUtils */ /* globals Components, Services, XPCOMUtils */
'use strict'; "use strict";
var EXPORTED_SYMBOLS = ['PdfjsContentUtils']; var EXPORTED_SYMBOLS = ["PdfjsContentUtils"];
const Cc = Components.classes; const Cc = Components.classes;
const Ci = Components.interfaces; const Ci = Components.interfaces;
const Cr = Components.results; const Cr = Components.results;
const Cu = Components.utils; const Cu = Components.utils;
Cu.import('resource://gre/modules/XPCOMUtils.jsm'); Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import('resource://gre/modules/Services.jsm'); Cu.import("resource://gre/modules/Services.jsm");
var PdfjsContentUtils = { var PdfjsContentUtils = {
_mm: null, _mm: null,
@ -38,21 +38,21 @@ var PdfjsContentUtils = {
Services.appinfo.PROCESS_TYPE_CONTENT); Services.appinfo.PROCESS_TYPE_CONTENT);
}, },
init: function () { init() {
// child *process* mm, or when loaded into the parent for in-content // child *process* mm, or when loaded into the parent for in-content
// support the psuedo child process mm 'child PPMM'. // support the psuedo child process mm 'child PPMM'.
if (!this._mm) { if (!this._mm) {
this._mm = Cc['@mozilla.org/childprocessmessagemanager;1']. this._mm = Cc["@mozilla.org/childprocessmessagemanager;1"].
getService(Ci.nsISyncMessageSender); getService(Ci.nsISyncMessageSender);
this._mm.addMessageListener('PDFJS:Child:refreshSettings', this); this._mm.addMessageListener("PDFJS:Child:refreshSettings", this);
Services.obs.addObserver(this, 'quit-application', false); Services.obs.addObserver(this, "quit-application", false);
} }
}, },
uninit: function () { uninit() {
if (this._mm) { if (this._mm) {
this._mm.removeMessageListener('PDFJS:Child:refreshSettings', this); this._mm.removeMessageListener("PDFJS:Child:refreshSettings", this);
Services.obs.removeObserver(this, 'quit-application'); Services.obs.removeObserver(this, "quit-application");
} }
this._mm = null; this._mm = null;
}, },
@ -63,35 +63,35 @@ var PdfjsContentUtils = {
* approved pdfjs prefs in chrome utils. * approved pdfjs prefs in chrome utils.
*/ */
clearUserPref: function (aPrefName) { clearUserPref(aPrefName) {
this._mm.sendSyncMessage('PDFJS:Parent:clearUserPref', { this._mm.sendSyncMessage("PDFJS:Parent:clearUserPref", {
name: aPrefName name: aPrefName
}); });
}, },
setIntPref: function (aPrefName, aPrefValue) { setIntPref(aPrefName, aPrefValue) {
this._mm.sendSyncMessage('PDFJS:Parent:setIntPref', { this._mm.sendSyncMessage("PDFJS:Parent:setIntPref", {
name: aPrefName, name: aPrefName,
value: aPrefValue value: aPrefValue
}); });
}, },
setBoolPref: function (aPrefName, aPrefValue) { setBoolPref(aPrefName, aPrefValue) {
this._mm.sendSyncMessage('PDFJS:Parent:setBoolPref', { this._mm.sendSyncMessage("PDFJS:Parent:setBoolPref", {
name: aPrefName, name: aPrefName,
value: aPrefValue value: aPrefValue
}); });
}, },
setCharPref: function (aPrefName, aPrefValue) { setCharPref(aPrefName, aPrefValue) {
this._mm.sendSyncMessage('PDFJS:Parent:setCharPref', { this._mm.sendSyncMessage("PDFJS:Parent:setCharPref", {
name: aPrefName, name: aPrefName,
value: aPrefValue value: aPrefValue
}); });
}, },
setStringPref: function (aPrefName, aPrefValue) { setStringPref(aPrefName, aPrefValue) {
this._mm.sendSyncMessage('PDFJS:Parent:setStringPref', { this._mm.sendSyncMessage("PDFJS:Parent:setStringPref", {
name: aPrefName, name: aPrefName,
value: aPrefValue value: aPrefValue
}); });
@ -101,24 +101,24 @@ var PdfjsContentUtils = {
* Forwards default app query to the parent where we check various * Forwards default app query to the parent where we check various
* handler app settings only available in the parent process. * handler app settings only available in the parent process.
*/ */
isDefaultHandlerApp: function () { isDefaultHandlerApp() {
return this._mm.sendSyncMessage('PDFJS:Parent:isDefaultHandlerApp')[0]; return this._mm.sendSyncMessage("PDFJS:Parent:isDefaultHandlerApp")[0];
}, },
/* /*
* Request the display of a notification warning in the associated window * Request the display of a notification warning in the associated window
* when the renderer isn't sure a pdf displayed correctly. * when the renderer isn't sure a pdf displayed correctly.
*/ */
displayWarning: function (aWindow, aMessage, aLabel, accessKey) { displayWarning(aWindow, aMessage, aLabel, aAccessKey) {
// the child's dom frame mm associated with the window. // the child's dom frame mm associated with the window.
let winmm = aWindow.QueryInterface(Ci.nsIInterfaceRequestor) let winmm = aWindow.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDocShell) .getInterface(Ci.nsIDocShell)
.QueryInterface(Ci.nsIInterfaceRequestor) .QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIContentFrameMessageManager); .getInterface(Ci.nsIContentFrameMessageManager);
winmm.sendAsyncMessage('PDFJS:Parent:displayWarning', { winmm.sendAsyncMessage("PDFJS:Parent:displayWarning", {
message: aMessage, message: aMessage,
label: aLabel, label: aLabel,
accessKey: accessKey accessKey: aAccessKey,
}); });
}, },
@ -126,19 +126,19 @@ var PdfjsContentUtils = {
* Events * Events
*/ */
observe: function(aSubject, aTopic, aData) { observe(aSubject, aTopic, aData) {
if (aTopic === 'quit-application') { if (aTopic === "quit-application") {
this.uninit(); this.uninit();
} }
}, },
receiveMessage: function (aMsg) { receiveMessage(aMsg) {
switch (aMsg.name) { switch (aMsg.name) {
case 'PDFJS:Child:refreshSettings': case "PDFJS:Child:refreshSettings":
// Only react to this if we are remote. // Only react to this if we are remote.
if (Services.appinfo.processType === if (Services.appinfo.processType ===
Services.appinfo.PROCESS_TYPE_CONTENT) { Services.appinfo.PROCESS_TYPE_CONTENT) {
let jsm = 'resource://pdf.js/PdfJs.jsm'; let jsm = "resource://pdf.js/PdfJs.jsm";
let pdfjs = Components.utils.import(jsm, {}).PdfJs; let pdfjs = Components.utils.import(jsm, {}).PdfJs;
pdfjs.updateRegistration(); pdfjs.updateRegistration();
} }

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,617 +0,0 @@
/* Copyright 2012 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// NOTE: Be careful what goes in this file, as it is also used from the context
// of the addon. So using warn/error in here will break the addon.
'use strict';
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define('pdfjs/core/network', ['exports', 'pdfjs/shared/util',
'pdfjs/core/worker'], factory);
} else if (typeof exports !== 'undefined') {
factory(exports, require('../shared/util.js'), require('./worker.js'));
} else {
factory((root.pdfjsCoreNetwork = {}), root.pdfjsSharedUtil,
root.pdfjsCoreWorker);
}
}(this, function (exports, sharedUtil, coreWorker) {
if (typeof PDFJSDev !== 'undefined' && PDFJSDev.test('FIREFOX || MOZCENTRAL')) {
throw new Error('Module "pdfjs/core/network" shall not ' +
'be used with FIREFOX or MOZCENTRAL build.');
}
var OK_RESPONSE = 200;
var PARTIAL_CONTENT_RESPONSE = 206;
function NetworkManager(url, args) {
this.url = url;
args = args || {};
this.isHttp = /^https?:/i.test(url);
this.httpHeaders = (this.isHttp && args.httpHeaders) || {};
this.withCredentials = args.withCredentials || false;
this.getXhr = args.getXhr ||
function NetworkManager_getXhr() {
return new XMLHttpRequest();
};
this.currXhrId = 0;
this.pendingRequests = Object.create(null);
this.loadedRequests = Object.create(null);
}
function getArrayBuffer(xhr) {
var data = xhr.response;
if (typeof data !== 'string') {
return data;
}
var length = data.length;
var array = new Uint8Array(length);
for (var i = 0; i < length; i++) {
array[i] = data.charCodeAt(i) & 0xFF;
}
return array.buffer;
}
var supportsMozChunked =
typeof PDFJSDev !== 'undefined' && PDFJSDev.test('CHROME') ? false :
(function supportsMozChunkedClosure() {
try {
var x = new XMLHttpRequest();
// Firefox 37- required .open() to be called before setting responseType.
// https://bugzilla.mozilla.org/show_bug.cgi?id=707484
// Even though the URL is not visited, .open() could fail if the URL is
// blocked, e.g. via the connect-src CSP directive or the NoScript addon.
// When this error occurs, this feature detection method will mistakenly
// report that moz-chunked-arraybuffer is not supported in Firefox 37-.
x.open('GET', 'https://example.com');
x.responseType = 'moz-chunked-arraybuffer';
return x.responseType === 'moz-chunked-arraybuffer';
} catch (e) {
return false;
}
})();
NetworkManager.prototype = {
requestRange: function NetworkManager_requestRange(begin, end, listeners) {
var args = {
begin: begin,
end: end
};
for (var prop in listeners) {
args[prop] = listeners[prop];
}
return this.request(args);
},
requestFull: function NetworkManager_requestFull(listeners) {
return this.request(listeners);
},
request: function NetworkManager_request(args) {
var xhr = this.getXhr();
var xhrId = this.currXhrId++;
var pendingRequest = this.pendingRequests[xhrId] = {
xhr: xhr
};
xhr.open('GET', this.url);
xhr.withCredentials = this.withCredentials;
for (var property in this.httpHeaders) {
var value = this.httpHeaders[property];
if (typeof value === 'undefined') {
continue;
}
xhr.setRequestHeader(property, value);
}
if (this.isHttp && 'begin' in args && 'end' in args) {
var rangeStr = args.begin + '-' + (args.end - 1);
xhr.setRequestHeader('Range', 'bytes=' + rangeStr);
pendingRequest.expectedStatus = 206;
} else {
pendingRequest.expectedStatus = 200;
}
var useMozChunkedLoading = supportsMozChunked && !!args.onProgressiveData;
if (useMozChunkedLoading) {
xhr.responseType = 'moz-chunked-arraybuffer';
pendingRequest.onProgressiveData = args.onProgressiveData;
pendingRequest.mozChunked = true;
} else {
xhr.responseType = 'arraybuffer';
}
if (args.onError) {
xhr.onerror = function(evt) {
args.onError(xhr.status);
};
}
xhr.onreadystatechange = this.onStateChange.bind(this, xhrId);
xhr.onprogress = this.onProgress.bind(this, xhrId);
pendingRequest.onHeadersReceived = args.onHeadersReceived;
pendingRequest.onDone = args.onDone;
pendingRequest.onError = args.onError;
pendingRequest.onProgress = args.onProgress;
xhr.send(null);
return xhrId;
},
onProgress: function NetworkManager_onProgress(xhrId, evt) {
var pendingRequest = this.pendingRequests[xhrId];
if (!pendingRequest) {
// Maybe abortRequest was called...
return;
}
if (pendingRequest.mozChunked) {
var chunk = getArrayBuffer(pendingRequest.xhr);
pendingRequest.onProgressiveData(chunk);
}
var onProgress = pendingRequest.onProgress;
if (onProgress) {
onProgress(evt);
}
},
onStateChange: function NetworkManager_onStateChange(xhrId, evt) {
var pendingRequest = this.pendingRequests[xhrId];
if (!pendingRequest) {
// Maybe abortRequest was called...
return;
}
var xhr = pendingRequest.xhr;
if (xhr.readyState >= 2 && pendingRequest.onHeadersReceived) {
pendingRequest.onHeadersReceived();
delete pendingRequest.onHeadersReceived;
}
if (xhr.readyState !== 4) {
return;
}
if (!(xhrId in this.pendingRequests)) {
// The XHR request might have been aborted in onHeadersReceived()
// callback, in which case we should abort request
return;
}
delete this.pendingRequests[xhrId];
// success status == 0 can be on ftp, file and other protocols
if (xhr.status === 0 && this.isHttp) {
if (pendingRequest.onError) {
pendingRequest.onError(xhr.status);
}
return;
}
var xhrStatus = xhr.status || OK_RESPONSE;
// From http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.35.2:
// "A server MAY ignore the Range header". This means it's possible to
// get a 200 rather than a 206 response from a range request.
var ok_response_on_range_request =
xhrStatus === OK_RESPONSE &&
pendingRequest.expectedStatus === PARTIAL_CONTENT_RESPONSE;
if (!ok_response_on_range_request &&
xhrStatus !== pendingRequest.expectedStatus) {
if (pendingRequest.onError) {
pendingRequest.onError(xhr.status);
}
return;
}
this.loadedRequests[xhrId] = true;
var chunk = getArrayBuffer(xhr);
if (xhrStatus === PARTIAL_CONTENT_RESPONSE) {
var rangeHeader = xhr.getResponseHeader('Content-Range');
var matches = /bytes (\d+)-(\d+)\/(\d+)/.exec(rangeHeader);
var begin = parseInt(matches[1], 10);
pendingRequest.onDone({
begin: begin,
chunk: chunk
});
} else if (pendingRequest.onProgressiveData) {
pendingRequest.onDone(null);
} else if (chunk) {
pendingRequest.onDone({
begin: 0,
chunk: chunk
});
} else if (pendingRequest.onError) {
pendingRequest.onError(xhr.status);
}
},
hasPendingRequests: function NetworkManager_hasPendingRequests() {
for (var xhrId in this.pendingRequests) {
return true;
}
return false;
},
getRequestXhr: function NetworkManager_getXhr(xhrId) {
return this.pendingRequests[xhrId].xhr;
},
isStreamingRequest: function NetworkManager_isStreamingRequest(xhrId) {
return !!(this.pendingRequests[xhrId].onProgressiveData);
},
isPendingRequest: function NetworkManager_isPendingRequest(xhrId) {
return xhrId in this.pendingRequests;
},
isLoadedRequest: function NetworkManager_isLoadedRequest(xhrId) {
return xhrId in this.loadedRequests;
},
abortAllRequests: function NetworkManager_abortAllRequests() {
for (var xhrId in this.pendingRequests) {
this.abortRequest(xhrId | 0);
}
},
abortRequest: function NetworkManager_abortRequest(xhrId) {
var xhr = this.pendingRequests[xhrId].xhr;
delete this.pendingRequests[xhrId];
xhr.abort();
}
};
var assert = sharedUtil.assert;
var createPromiseCapability = sharedUtil.createPromiseCapability;
var isInt = sharedUtil.isInt;
var MissingPDFException = sharedUtil.MissingPDFException;
var UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
/** @implements {IPDFStream} */
function PDFNetworkStream(options) {
this._options = options;
var source = options.source;
this._manager = new NetworkManager(source.url, {
httpHeaders: source.httpHeaders,
withCredentials: source.withCredentials
});
this._rangeChunkSize = source.rangeChunkSize;
this._fullRequestReader = null;
this._rangeRequestReaders = [];
}
PDFNetworkStream.prototype = {
_onRangeRequestReaderClosed:
function PDFNetworkStream_onRangeRequestReaderClosed(reader) {
var i = this._rangeRequestReaders.indexOf(reader);
if (i >= 0) {
this._rangeRequestReaders.splice(i, 1);
}
},
getFullReader: function PDFNetworkStream_getFullReader() {
assert(!this._fullRequestReader);
this._fullRequestReader =
new PDFNetworkStreamFullRequestReader(this._manager, this._options);
return this._fullRequestReader;
},
getRangeReader: function PDFNetworkStream_getRangeReader(begin, end) {
var reader = new PDFNetworkStreamRangeRequestReader(this._manager,
begin, end);
reader.onClosed = this._onRangeRequestReaderClosed.bind(this);
this._rangeRequestReaders.push(reader);
return reader;
},
cancelAllRequests: function PDFNetworkStream_cancelAllRequests(reason) {
if (this._fullRequestReader) {
this._fullRequestReader.cancel(reason);
}
var readers = this._rangeRequestReaders.slice(0);
readers.forEach(function (reader) {
reader.cancel(reason);
});
}
};
/** @implements {IPDFStreamReader} */
function PDFNetworkStreamFullRequestReader(manager, options) {
this._manager = manager;
var source = options.source;
var args = {
onHeadersReceived: this._onHeadersReceived.bind(this),
onProgressiveData: source.disableStream ? null :
this._onProgressiveData.bind(this),
onDone: this._onDone.bind(this),
onError: this._onError.bind(this),
onProgress: this._onProgress.bind(this)
};
this._url = source.url;
this._fullRequestId = manager.requestFull(args);
this._headersReceivedCapability = createPromiseCapability();
this._disableRange = options.disableRange || false;
this._contentLength = source.length; // optional
this._rangeChunkSize = source.rangeChunkSize;
if (!this._rangeChunkSize && !this._disableRange) {
this._disableRange = true;
}
this._isStreamingSupported = false;
this._isRangeSupported = false;
this._cachedChunks = [];
this._requests = [];
this._done = false;
this._storedError = undefined;
this.onProgress = null;
}
PDFNetworkStreamFullRequestReader.prototype = {
_validateRangeRequestCapabilities: function
PDFNetworkStreamFullRequestReader_validateRangeRequestCapabilities() {
if (this._disableRange) {
return false;
}
var networkManager = this._manager;
if (!networkManager.isHttp) {
return false;
}
var fullRequestXhrId = this._fullRequestId;
var fullRequestXhr = networkManager.getRequestXhr(fullRequestXhrId);
if (fullRequestXhr.getResponseHeader('Accept-Ranges') !== 'bytes') {
return false;
}
var contentEncoding =
fullRequestXhr.getResponseHeader('Content-Encoding') || 'identity';
if (contentEncoding !== 'identity') {
return false;
}
var length = fullRequestXhr.getResponseHeader('Content-Length');
length = parseInt(length, 10);
if (!isInt(length)) {
return false;
}
this._contentLength = length; // setting right content length
if (length <= 2 * this._rangeChunkSize) {
// The file size is smaller than the size of two chunks, so it does
// not make any sense to abort the request and retry with a range
// request.
return false;
}
return true;
},
_onHeadersReceived:
function PDFNetworkStreamFullRequestReader_onHeadersReceived() {
if (this._validateRangeRequestCapabilities()) {
this._isRangeSupported = true;
}
var networkManager = this._manager;
var fullRequestXhrId = this._fullRequestId;
if (networkManager.isStreamingRequest(fullRequestXhrId)) {
// We can continue fetching when progressive loading is enabled,
// and we don't need the autoFetch feature.
this._isStreamingSupported = true;
} else if (this._isRangeSupported) {
// NOTE: by cancelling the full request, and then issuing range
// requests, there will be an issue for sites where you can only
// request the pdf once. However, if this is the case, then the
// server should not be returning that it can support range
// requests.
networkManager.abortRequest(fullRequestXhrId);
}
this._headersReceivedCapability.resolve();
},
_onProgressiveData:
function PDFNetworkStreamFullRequestReader_onProgressiveData(chunk) {
if (this._requests.length > 0) {
var requestCapability = this._requests.shift();
requestCapability.resolve({value: chunk, done: false});
} else {
this._cachedChunks.push(chunk);
}
},
_onDone: function PDFNetworkStreamFullRequestReader_onDone(args) {
if (args) {
this._onProgressiveData(args.chunk);
}
this._done = true;
if (this._cachedChunks.length > 0) {
return;
}
this._requests.forEach(function (requestCapability) {
requestCapability.resolve({value: undefined, done: true});
});
this._requests = [];
},
_onError: function PDFNetworkStreamFullRequestReader_onError(status) {
var url = this._url;
var exception;
if (status === 404 || status === 0 && /^file:/.test(url)) {
exception = new MissingPDFException('Missing PDF "' + url + '".');
} else {
exception = new UnexpectedResponseException(
'Unexpected server response (' + status +
') while retrieving PDF "' + url + '".', status);
}
this._storedError = exception;
this._headersReceivedCapability.reject(exception);
this._requests.forEach(function (requestCapability) {
requestCapability.reject(exception);
});
this._requests = [];
this._cachedChunks = [];
},
_onProgress: function PDFNetworkStreamFullRequestReader_onProgress(data) {
if (this.onProgress) {
this.onProgress({
loaded: data.loaded,
total: data.lengthComputable ? data.total : this._contentLength
});
}
},
get isRangeSupported() {
return this._isRangeSupported;
},
get isStreamingSupported() {
return this._isStreamingSupported;
},
get contentLength() {
return this._contentLength;
},
get headersReady() {
return this._headersReceivedCapability.promise;
},
read: function PDFNetworkStreamFullRequestReader_read() {
if (this._storedError) {
return Promise.reject(this._storedError);
}
if (this._cachedChunks.length > 0) {
var chunk = this._cachedChunks.shift();
return Promise.resolve(chunk);
}
if (this._done) {
return Promise.resolve({value: undefined, done: true});
}
var requestCapability = createPromiseCapability();
this._requests.push(requestCapability);
return requestCapability.promise;
},
cancel: function PDFNetworkStreamFullRequestReader_cancel(reason) {
this._done = true;
this._headersReceivedCapability.reject(reason);
this._requests.forEach(function (requestCapability) {
requestCapability.resolve({value: undefined, done: true});
});
this._requests = [];
if (this._manager.isPendingRequest(this._fullRequestId)) {
this._manager.abortRequest(this._fullRequestId);
}
this._fullRequestReader = null;
}
};
/** @implements {IPDFStreamRangeReader} */
function PDFNetworkStreamRangeRequestReader(manager, begin, end) {
this._manager = manager;
var args = {
onDone: this._onDone.bind(this),
onProgress: this._onProgress.bind(this)
};
this._requestId = manager.requestRange(begin, end, args);
this._requests = [];
this._queuedChunk = null;
this._done = false;
this.onProgress = null;
this.onClosed = null;
}
PDFNetworkStreamRangeRequestReader.prototype = {
_close: function PDFNetworkStreamRangeRequestReader_close() {
if (this.onClosed) {
this.onClosed(this);
}
},
_onDone: function PDFNetworkStreamRangeRequestReader_onDone(data) {
var chunk = data.chunk;
if (this._requests.length > 0) {
var requestCapability = this._requests.shift();
requestCapability.resolve({value: chunk, done: false});
} else {
this._queuedChunk = chunk;
}
this._done = true;
this._requests.forEach(function (requestCapability) {
requestCapability.resolve({value: undefined, done: true});
});
this._requests = [];
this._close();
},
_onProgress: function PDFNetworkStreamRangeRequestReader_onProgress(evt) {
if (!this.isStreamingSupported && this.onProgress) {
this.onProgress({
loaded: evt.loaded
});
}
},
get isStreamingSupported() {
return false; // TODO allow progressive range bytes loading
},
read: function PDFNetworkStreamRangeRequestReader_read() {
if (this._queuedChunk !== null) {
var chunk = this._queuedChunk;
this._queuedChunk = null;
return Promise.resolve({value: chunk, done: false});
}
if (this._done) {
return Promise.resolve({value: undefined, done: true});
}
var requestCapability = createPromiseCapability();
this._requests.push(requestCapability);
return requestCapability.promise;
},
cancel: function PDFNetworkStreamRangeRequestReader_cancel(reason) {
this._done = true;
this._requests.forEach(function (requestCapability) {
requestCapability.resolve({value: undefined, done: true});
});
this._requests = [];
if (this._manager.isPendingRequest(this._requestId)) {
this._manager.abortRequest(this._requestId);
}
this._close();
}
};
coreWorker.setPDFNetworkStreamClass(PDFNetworkStream);
exports.PDFNetworkStream = PDFNetworkStream;
exports.NetworkManager = NetworkManager;
}));

View file

@ -14,16 +14,16 @@
*/ */
/* globals Components, PdfjsContentUtils, PdfJs, Services */ /* globals Components, PdfjsContentUtils, PdfJs, Services */
'use strict'; "use strict";
/* /*
* pdfjschildbootstrap.js loads into the content process to take care of * pdfjschildbootstrap.js loads into the content process to take care of
* initializing our built-in version of pdfjs when running remote. * initializing our built-in version of pdfjs when running remote.
*/ */
Components.utils.import('resource://gre/modules/Services.jsm'); Components.utils.import("resource://gre/modules/Services.jsm");
Components.utils.import('resource://pdf.js/PdfJs.jsm'); Components.utils.import("resource://pdf.js/PdfJs.jsm");
Components.utils.import('resource://pdf.js/PdfjsContentUtils.jsm'); Components.utils.import("resource://pdf.js/PdfjsContentUtils.jsm");
// init content utils shim pdfjs will use to access privileged apis. // init content utils shim pdfjs will use to access privileged apis.
PdfjsContentUtils.init(); PdfjsContentUtils.init();
@ -32,4 +32,3 @@ if (Services.appinfo.processType === Services.appinfo.PROCESS_TYPE_CONTENT) {
// register various pdfjs factories that hook us into content loading. // register various pdfjs factories that hook us into content loading.
PdfJs.updateRegistration(); PdfJs.updateRegistration();
} }

View file

@ -387,7 +387,9 @@ var Stepper = (function StepperClosure() {
this.table.appendChild(chunk); this.table.appendChild(chunk);
}, },
getNextBreakPoint: function getNextBreakPoint() { getNextBreakPoint: function getNextBreakPoint() {
this.breakPoints.sort(function(a, b) { return a - b; }); this.breakPoints.sort(function(a, b) {
return a - b;
});
for (var i = 0; i < this.breakPoints.length; i++) { for (var i = 0; i < this.breakPoints.length; i++) {
if (this.breakPoints[i] > this.currentIdx) { if (this.breakPoints[i] > this.currentIdx) {
return this.breakPoints[i]; return this.breakPoints[i];
@ -484,7 +486,9 @@ var Stats = (function Stats() {
wrapper.appendChild(title); wrapper.appendChild(title);
wrapper.appendChild(statsDiv); wrapper.appendChild(statsDiv);
stats.push({ pageNumber: pageNumber, div: wrapper }); stats.push({ pageNumber: pageNumber, div: wrapper });
stats.sort(function(a, b) { return a.pageNumber - b.pageNumber; }); stats.sort(function(a, b) {
return a.pageNumber - b.pageNumber;
});
clear(this.panel); clear(this.panel);
for (var i = 0, ii = stats.length; i < ii; ++i) { for (var i = 0, ii = stats.length; i < ii; ++i) {
this.panel.appendChild(stats[i].div); this.panel.appendChild(stats[i].div);

View file

@ -1,17 +1,17 @@
'use strict'; "use strict";
// Small subset of the webL10n API by Fabien Cazenave for pdf.js extension. // Small subset of the webL10n API by Fabien Cazenave for pdf.js extension.
(function(window) { (function(window) {
var gLanguage = ''; var gLanguage = "";
var gExternalLocalizerServices = null; var gExternalLocalizerServices = null;
var gReadyState = 'loading'; var gReadyState = "loading";
// fetch an l10n objects // fetch an l10n objects
function getL10nData(key) { function getL10nData(key) {
var response = gExternalLocalizerServices.getStrings(key); var response = gExternalLocalizerServices.getStrings(key);
var data = JSON.parse(response); var data = JSON.parse(response);
if (!data) { if (!data) {
console.warn('[l10n] #' + key + ' missing for [' + gLanguage + ']'); console.warn("[l10n] #" + key + " missing for [" + gLanguage + "]");
} }
return data; return data;
} }
@ -22,25 +22,25 @@
return text; return text;
} }
return text.replace(/\{\{\s*(\w+)\s*\}\}/g, function(all, name) { return text.replace(/\{\{\s*(\w+)\s*\}\}/g, function(all, name) {
return (name in args ? args[name] : '{{' + name + '}}'); return (name in args ? args[name] : "{{" + name + "}}");
}); });
} }
// translate a string // translate a string
function translateString(key, args, fallback) { function translateString(key, args, fallback) {
var i = key.lastIndexOf('.'); var i = key.lastIndexOf(".");
var name, property; var name, property;
if (i >= 0) { if (i >= 0) {
name = key.substring(0, i); name = key.substring(0, i);
property = key.substring(i + 1); property = key.substring(i + 1);
} else { } else {
name = key; name = key;
property = 'textContent'; property = "textContent";
} }
var data = getL10nData(name); var data = getL10nData(name);
var value = (data && data[property]) || fallback; var value = (data && data[property]) || fallback;
if (!value) { if (!value) {
return '{{' + key + '}}'; return "{{" + key + "}}";
} }
return substArguments(value, args); return substArguments(value, args);
} }
@ -65,7 +65,7 @@
try { try {
args = JSON.parse(element.dataset.l10nArgs); args = JSON.parse(element.dataset.l10nArgs);
} catch (e) { } catch (e) {
console.warn('[l10n] could not parse arguments for #' + key + ''); console.warn("[l10n] could not parse arguments for #" + key + "");
} }
} }
@ -79,10 +79,10 @@
// translate an HTML subtree // translate an HTML subtree
function translateFragment(element) { function translateFragment(element) {
element = element || document.querySelector('html'); element = element || document.querySelector("html");
// check all translatable children (= w/ a `data-l10n-id' attribute) // check all translatable children (= w/ a `data-l10n-id' attribute)
var children = element.querySelectorAll('*[data-l10n-id]'); var children = element.querySelectorAll("*[data-l10n-id]");
var elementCount = children.length; var elementCount = children.length;
for (var i = 0; i < elementCount; i++) { for (var i = 0; i < elementCount; i++) {
translateElement(children[i]); translateElement(children[i]);
@ -99,16 +99,16 @@
translateFragment(); translateFragment();
gReadyState = 'complete'; gReadyState = "complete";
// fire a 'localized' DOM event // fire a 'localized' DOM event
var evtObject = document.createEvent('Event'); var evtObject = document.createEvent("Event");
evtObject.initEvent('localized', false, false); evtObject.initEvent("localized", false, false);
evtObject.language = gLanguage; evtObject.language = gLanguage;
window.dispatchEvent(evtObject); window.dispatchEvent(evtObject);
} }
window.addEventListener('DOMContentLoaded', function() { window.addEventListener("DOMContentLoaded", function() {
if (gExternalLocalizerServices) { if (gExternalLocalizerServices) {
translateDocument(); translateDocument();
} }
@ -121,30 +121,32 @@
get: translateString, get: translateString,
// get the document language // get the document language
getLanguage: function() { getLanguage() {
return gLanguage; return gLanguage;
}, },
// get the direction (ltr|rtl) of the current language // get the direction (ltr|rtl) of the current language
getDirection: function() { getDirection() {
// http://www.w3.org/International/questions/qa-scripts // http://www.w3.org/International/questions/qa-scripts
// Arabic, Hebrew, Farsi, Pashto, Urdu // Arabic, Hebrew, Farsi, Pashto, Urdu
var rtlList = ['ar', 'he', 'fa', 'ps', 'ur']; var rtlList = ["ar", "he", "fa", "ps", "ur"];
// use the short language code for "full" codes like 'ar-sa' (issue 5440) // use the short language code for "full" codes like 'ar-sa' (issue 5440)
var shortCode = gLanguage.split('-')[0]; var shortCode = gLanguage.split("-")[0];
return (rtlList.indexOf(shortCode) >= 0) ? 'rtl' : 'ltr'; return (rtlList.indexOf(shortCode) >= 0) ? "rtl" : "ltr";
}, },
getReadyState: function() { return gReadyState; }, getReadyState() {
return gReadyState;
},
setExternalLocalizerServices: function (externalLocalizerServices) { setExternalLocalizerServices(externalLocalizerServices) {
gExternalLocalizerServices = externalLocalizerServices; gExternalLocalizerServices = externalLocalizerServices;
// ... in case if we missed DOMContentLoaded above. // ... in case if we missed DOMContentLoaded above.
if (window.document.readyState === 'interactive' || if (window.document.readyState === "interactive" ||
window.document.readyState === 'complete') { window.document.readyState === "complete") {
translateDocument(); translateDocument();
} }
}, },

View file

@ -1084,6 +1084,24 @@ html[dir="rtl"] #viewOutline.toolbarButton::before {
content: url(images/toolbarButton-search.png); content: url(images/toolbarButton-search.png);
} }
.toolbarButton.pdfSidebarNotification::after {
position: absolute;
display: inline-block;
top: 1px;
/* Create a filled circle, with a diameter of 9 pixels, using only CSS: */
content: '';
background-color: #70DB55;
height: 9px;
width: 9px;
border-radius: 50%;
}
html[dir='ltr'] .toolbarButton.pdfSidebarNotification::after {
left: 17px;
}
html[dir='rtl'] .toolbarButton.pdfSidebarNotification::after {
right: 17px;
}
.secondaryToolbarButton { .secondaryToolbarButton {
position: relative; position: relative;
margin: 0 0 4px 0; margin: 0 0 4px 0;

File diff suppressed because it is too large Load diff