Bug 861399 - Update pdf.js to version 0.8.47. r=bdahl

This commit is contained in:
Ryan VanderMeulen 2013-04-16 13:34:43 -04:00
parent ac1916de10
commit 93bff3fb3d
8 changed files with 782 additions and 1179 deletions

View File

@ -1,4 +1,4 @@
This is the pdf.js project output, https://github.com/mozilla/pdf.js This is the pdf.js project output, https://github.com/mozilla/pdf.js
Current extension version is: 0.7.423 Current extension version is: 0.8.47

View File

@ -101,23 +101,6 @@ function getDOMWindow(aChannel) {
return win; return win;
} }
function isEnabled() {
if (MOZ_CENTRAL) {
var disabled = getBoolPref(PREF_PREFIX + '.disabled', false);
if (disabled)
return false;
// To also be considered enabled the "Preview in Firefox" option must be
// selected in the Application preferences.
var handlerInfo = Svc.mime
.getFromTypeAndExtension('application/pdf', 'pdf');
return !handlerInfo.alwaysAskBeforeHandling &&
handlerInfo.preferredAction == Ci.nsIHandlerInfo.handleInternally;
}
// Always returns true for the extension since enabling/disabling is handled
// by the add-on manager.
return true;
}
function getLocalizedStrings(path) { function getLocalizedStrings(path) {
var stringBundle = Cc['@mozilla.org/intl/stringbundle;1']. var stringBundle = Cc['@mozilla.org/intl/stringbundle;1'].
getService(Ci.nsIStringBundleService). getService(Ci.nsIStringBundleService).
@ -268,10 +251,13 @@ ChromeActions.prototype = {
var channel = Cc['@mozilla.org/network/input-stream-channel;1']. var channel = Cc['@mozilla.org/network/input-stream-channel;1'].
createInstance(Ci.nsIInputStreamChannel); createInstance(Ci.nsIInputStreamChannel);
channel.QueryInterface(Ci.nsIChannel); channel.QueryInterface(Ci.nsIChannel);
try {
// contentDisposition/contentDispositionFilename is readonly before FF18
channel.contentDisposition = Ci.nsIChannel.DISPOSITION_ATTACHMENT; channel.contentDisposition = Ci.nsIChannel.DISPOSITION_ATTACHMENT;
if (self.contentDispositionFilename) { if (self.contentDispositionFilename) {
channel.contentDispositionFilename = self.contentDispositionFilename; channel.contentDispositionFilename = self.contentDispositionFilename;
} }
} catch (e) {}
channel.setURI(originalUri); channel.setURI(originalUri);
channel.contentStream = aInputStream; channel.contentStream = aInputStream;
if ('nsIPrivateBrowsingChannel' in Ci && if ('nsIPrivateBrowsingChannel' in Ci &&
@ -380,6 +366,9 @@ ChromeActions.prototype = {
var prefGfx = getBoolPref('gfx.downloadable_fonts.enabled', true); var prefGfx = getBoolPref('gfx.downloadable_fonts.enabled', true);
return (!!prefBrowser && prefGfx); return (!!prefBrowser && prefGfx);
}, },
supportsDocumentColors: function() {
return getBoolPref('browser.display.use_document_colors', true);
},
fallback: function(url, sendResponse) { fallback: function(url, sendResponse) {
var self = this; var self = this;
var domWindow = this.domWindow; var domWindow = this.domWindow;
@ -577,9 +566,6 @@ PdfStreamConverter.prototype = {
// nsIStreamConverter::asyncConvertData // nsIStreamConverter::asyncConvertData
asyncConvertData: function(aFromType, aToType, aListener, aCtxt) { asyncConvertData: function(aFromType, aToType, aListener, aCtxt) {
if (!isEnabled())
throw Cr.NS_ERROR_NOT_IMPLEMENTED;
// Store the listener passed to us // Store the listener passed to us
this.listener = aListener; this.listener = aListener;
}, },

View File

@ -28,6 +28,8 @@ const PREF_PREVIOUS_ACTION = PREF_PREFIX + '.previousHandler.preferredAction';
const PREF_PREVIOUS_ASK = PREF_PREFIX + '.previousHandler.alwaysAskBeforeHandling'; const PREF_PREVIOUS_ASK = PREF_PREFIX + '.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_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');
@ -112,7 +114,10 @@ let PdfJs = {
// Listen for when pdf.js is completely disabled or a different pdf handler // Listen for when pdf.js is completely disabled or a different pdf handler
// is chosen. // is chosen.
Services.prefs.addObserver(PREF_DISABLED, this, false); Services.prefs.addObserver(PREF_DISABLED, this, false);
Services.prefs.addObserver(PREF_DISABLED_PLUGIN_TYPES, this, false);
Services.obs.addObserver(this, TOPIC_PDFJS_HANDLER_CHANGED, false); Services.obs.addObserver(this, TOPIC_PDFJS_HANDLER_CHANGED, false);
Services.obs.addObserver(this, TOPIC_PLUGINS_LIST_UPDATED, false);
Services.obs.addObserver(this, TOPIC_PLUGIN_INFO_UPDATED, false);
}, },
_migrate: function migrate() { _migrate: function migrate() {
@ -186,14 +191,39 @@ let PdfJs = {
*/ */
get enabled() { get enabled() {
var disabled = getBoolPref(PREF_DISABLED, true); var disabled = getBoolPref(PREF_DISABLED, true);
if (disabled) if (disabled) {
return false; return false;
}
var handlerInfo = Svc.mime. // the 'application/pdf' handler is selected as internal?
getFromTypeAndExtension('application/pdf', 'pdf'); var handlerInfo = Svc.mime
return handlerInfo.alwaysAskBeforeHandling == false && .getFromTypeAndExtension(PDF_CONTENT_TYPE, 'pdf');
handlerInfo.plugin == null && if (handlerInfo.alwaysAskBeforeHandling ||
handlerInfo.preferredAction == Ci.nsIHandlerInfo.handleInternally; handlerInfo.preferredAction !== Ci.nsIHandlerInfo.handleInternally) {
return false;
}
// we also need to check if pdf plugin is not present or disabled...
let tags = Cc["@mozilla.org/plugin/host;1"].
getService(Ci.nsIPluginHost).
getPluginTags();
let enabledPluginFound = tags.some(function(tag) {
if (tag.disabled) {
return false;
}
let mimeTypes = tag.getMimeTypes();
return mimeTypes.some(function(mimeType) {
return mimeType.type === PDF_CONTENT_TYPE;
});
});
if (!enabledPluginFound) {
return true; // no plugins for this type, it's good
}
// ... and full page plugins list must have 'application/pdf' type,
// in case when enabled pdf plugin exists.
return Services.prefs.prefHasUserValue(PREF_DISABLED_PLUGIN_TYPES) ?
(Services.prefs.getCharPref(PREF_DISABLED_PLUGIN_TYPES).split(',').
indexOf(PDF_CONTENT_TYPE) >= 0) : false;
}, },
_ensureRegistered: function _ensureRegistered() { _ensureRegistered: function _ensureRegistered() {
@ -205,7 +235,7 @@ let PdfJs = {
this._pdfRedirectorFactory = new Factory(); this._pdfRedirectorFactory = new Factory();
this._pdfRedirectorFactory.register(PdfRedirector); this._pdfRedirectorFactory.register(PdfRedirector);
Svc.pluginHost.registerPlayPreviewMimeType('application/pdf', true, Svc.pluginHost.registerPlayPreviewMimeType(PDF_CONTENT_TYPE, true,
'data:application/x-moz-playpreview-pdfjs;,'); 'data:application/x-moz-playpreview-pdfjs;,');
this._registered = true; this._registered = true;
@ -220,7 +250,7 @@ let PdfJs = {
this._pdfRedirectorFactory.unregister; this._pdfRedirectorFactory.unregister;
delete this._pdfRedirectorFactory; delete this._pdfRedirectorFactory;
Svc.pluginHost.unregisterPlayPreviewMimeType('application/pdf'); Svc.pluginHost.unregisterPlayPreviewMimeType(PDF_CONTENT_TYPE);
this._registered = false; this._registered = false;
} }

File diff suppressed because it is too large Load Diff

View File

@ -46,7 +46,7 @@ var FontInspector = (function FontInspectorClosure() {
} }
} }
function textLayerClick(e) { function textLayerClick(e) {
if (!e.target.dataset.fontName || e.target.tagName != 'DIV') if (!e.target.dataset.fontName || e.target.tagName.toUpperCase() !== 'DIV')
return; return;
var fontName = e.target.dataset.fontName; var fontName = e.target.dataset.fontName;
var selects = document.getElementsByTagName('input'); var selects = document.getElementsByTagName('input');

View File

@ -88,6 +88,18 @@ select {
margin-bottom: 100%; margin-bottom: 100%;
} }
:-webkit-full-screen a:not(.internalLink) {
display: none;
}
:-moz-full-screen a:not(.internalLink) {
display: none;
}
:fullscreen a:not(.internalLink) {
display: none;
}
#viewerContainer.presentationControls { #viewerContainer.presentationControls {
cursor: default; cursor: default;
} }
@ -391,12 +403,14 @@ html[dir='ltr'] #toolbarViewerLeft > *,
html[dir='ltr'] #toolbarViewerMiddle > *, html[dir='ltr'] #toolbarViewerMiddle > *,
html[dir='ltr'] #toolbarViewerRight > *, html[dir='ltr'] #toolbarViewerRight > *,
html[dir='ltr'] .findbar > * { html[dir='ltr'] .findbar > * {
position: relative;
float: left; float: left;
} }
html[dir='rtl'] #toolbarViewerLeft > *, html[dir='rtl'] #toolbarViewerLeft > *,
html[dir='rtl'] #toolbarViewerMiddle > *, html[dir='rtl'] #toolbarViewerMiddle > *,
html[dir='rtl'] #toolbarViewerRight > *, html[dir='rtl'] #toolbarViewerRight > *,
html[dir='rtl'] .findbar > * { html[dir='rtl'] .findbar > * {
position: relative;
float: right; float: right;
} }
@ -747,6 +761,14 @@ html[dir='rtl'] #findPrevious {
html[dir='rtl'] #findNext { html[dir='rtl'] #findNext {
margin-left: 3px; margin-left: 3px;
} }
.toolbarButton::before {
/* All matching images have a size of 16x16
* (except for the print button: 18x16)
* All relevant containers have a size of 32x25 */
position: absolute;
top: 4px;
left: 7px;
}
html[dir='ltr'] .toolbarButton.findPrevious::before { html[dir='ltr'] .toolbarButton.findPrevious::before {
display: inline-block; display: inline-block;
@ -806,6 +828,7 @@ html[dir='rtl'] .toolbarButton.pageDown::before {
.toolbarButton.print::before { .toolbarButton.print::before {
display: inline-block; display: inline-block;
content: url(images/toolbarButton-print.png); content: url(images/toolbarButton-print.png);
left: 6px;
} }
.toolbarButton.openFile::before { .toolbarButton.openFile::before {
@ -1038,7 +1061,6 @@ html[dir='rtl'] .outlineItem > a {
color: hsla(0,0%,100%,1); color: hsla(0,0%,100%,1);
} }
.noOutline,
.noResults { .noResults {
font-size: 12px; font-size: 12px;
color: hsla(0,0%,100%,.8); color: hsla(0,0%,100%,.8);

View File

@ -922,7 +922,7 @@ var PDFView = {
doc.webkitRequestFullScreen; doc.webkitRequestFullScreen;
// Disable fullscreen button if we're in an iframe // Disable fullscreen button if we're in an iframe
if (!!window.frameElement) if (window.parent !== window)
support = false; support = false;
Object.defineProperty(this, 'supportsFullScreen', { value: support, Object.defineProperty(this, 'supportsFullScreen', { value: support,
@ -952,6 +952,16 @@ var PDFView = {
return support; return support;
}, },
get supportsDocumentColors() {
var support = true;
support = FirefoxCom.requestSync('supportsDocumentColors');
Object.defineProperty(this, 'supportsDocumentColors', { value: support,
enumerable: true,
configurable: true,
writable: false });
return support;
},
get isHorizontalScrollbarEnabled() { get isHorizontalScrollbarEnabled() {
var div = document.getElementById('viewerContainer'); var div = document.getElementById('viewerContainer');
return div.scrollWidth > div.clientWidth; return div.scrollWidth > div.clientWidth;
@ -1370,6 +1380,7 @@ var PDFView = {
PDFJS.Promise.all(promises).then(function() { PDFJS.Promise.all(promises).then(function() {
pdfDocument.getOutline().then(function(outline) { pdfDocument.getOutline().then(function(outline) {
self.outline = new DocumentOutlineView(outline); self.outline = new DocumentOutlineView(outline);
document.getElementById('viewOutline').disabled = !outline;
}); });
// Make all navigation keys work on document load, // Make all navigation keys work on document load,
@ -1979,6 +1990,7 @@ var PageView = function pageView(container, id, scale,
PDFView.navigateTo(dest); PDFView.navigateTo(dest);
return false; return false;
}; };
link.className = 'internalLink';
} }
function createElementWithStyle(tagName, item, rect) { function createElementWithStyle(tagName, item, rect) {
if (!rect) { if (!rect) {
@ -2233,6 +2245,13 @@ var PageView = function pageView(container, id, scale,
'Web fonts are disabled: unable to use embedded PDF fonts.')); 'Web fonts are disabled: unable to use embedded PDF fonts.'));
PDFView.fallback(); PDFView.fallback();
} }
if (self.textLayer && self.textLayer.textDivs &&
self.textLayer.textDivs.length > 0 &&
!PDFView.supportsDocumentColors) {
console.error(mozL10n.get('web_colors_disabled', null,
'Web colors are disabled.'));
PDFView.fallback();
}
if (error) { if (error) {
PDFView.error(mozL10n.get('rendering_error', null, PDFView.error(mozL10n.get('rendering_error', null,
'An error occurred while rendering the page.'), error); 'An error occurred while rendering the page.'), error);
@ -2536,9 +2555,17 @@ var ThumbnailView = function thumbnailView(container, id, defaultViewport) {
var DocumentOutlineView = function documentOutlineView(outline) { var DocumentOutlineView = function documentOutlineView(outline) {
var outlineView = document.getElementById('outlineView'); var outlineView = document.getElementById('outlineView');
var outlineButton = document.getElementById('viewOutline');
while (outlineView.firstChild) while (outlineView.firstChild)
outlineView.removeChild(outlineView.firstChild); outlineView.removeChild(outlineView.firstChild);
if (!outline) {
if (!outlineView.classList.contains('hidden'))
PDFView.switchSidebarView('thumbs');
return;
}
function bindItemLink(domObj, item) { function bindItemLink(domObj, item) {
domObj.href = PDFView.getDestinationHash(item.dest); domObj.href = PDFView.getDestinationHash(item.dest);
domObj.onclick = function documentOutlineViewOnclick(e) { domObj.onclick = function documentOutlineViewOnclick(e) {
@ -2547,14 +2574,6 @@ var DocumentOutlineView = function documentOutlineView(outline) {
}; };
} }
if (!outline) {
var noOutline = document.createElement('div');
noOutline.classList.add('noOutline');
noOutline.textContent = mozL10n.get('no_outline', null,
'No Outline Available');
outlineView.appendChild(noOutline);
return;
}
var queue = [{parent: outlineView, items: outline}]; var queue = [{parent: outlineView, items: outline}];
while (queue.length > 0) { while (queue.length > 0) {
@ -2643,7 +2662,6 @@ var TextLayerBuilder = function textLayerBuilder(textLayerDiv, pageIdx) {
this.beginLayout = function textLayerBuilderBeginLayout() { this.beginLayout = function textLayerBuilderBeginLayout() {
this.textDivs = []; this.textDivs = [];
this.textLayerQueue = [];
this.renderingDone = false; this.renderingDone = false;
}; };
@ -3418,9 +3436,9 @@ window.addEventListener('keydown', function keydown(evt) {
// Some shortcuts should not get handled if a control/input element // Some shortcuts should not get handled if a control/input element
// is selected. // is selected.
var curElement = document.activeElement; var curElement = document.activeElement || document.querySelector(':focus');
if (curElement && (curElement.tagName == 'INPUT' || if (curElement && (curElement.tagName.toUpperCase() === 'INPUT' ||
curElement.tagName == 'SELECT')) { curElement.tagName.toUpperCase() === 'SELECT')) {
return; return;
} }
var controlsElement = document.getElementById('toolbar'); var controlsElement = document.getElementById('toolbar');

View File

@ -53,9 +53,6 @@ thumbs_label=Thumbnails
findbar.title=Find in Document findbar.title=Find in Document
findbar_label=Find findbar_label=Find
# Document outline messages
no_outline=No Outline Available
# Thumbnails panel item (tooltip and alt text for images) # Thumbnails panel item (tooltip and alt text for images)
# LOCALIZATION NOTE (thumb_page_title): "{{page}}" will be replaced by the page # LOCALIZATION NOTE (thumb_page_title): "{{page}}" will be replaced by the page
# number. # number.
@ -123,3 +120,4 @@ request_password=PDF is protected by a password:
printing_not_supported=Warning: Printing is not fully supported by this browser. printing_not_supported=Warning: Printing is not fully supported by this browser.
printing_not_ready=Warning: The PDF is not fully loaded for printing. printing_not_ready=Warning: The PDF is not fully loaded for printing.
web_fonts_disabled=Web fonts are disabled: unable to use embedded PDF fonts. web_fonts_disabled=Web fonts are disabled: unable to use embedded PDF fonts.
web_colors_disabled=Web colors are disabled.