mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 824174 - Update pdf.js to version 0.7.28. r=bdahl
This commit is contained in:
parent
cefced7722
commit
a058f5dd89
@ -1,4 +1,4 @@
|
||||
This is the pdf.js project output, https://github.com/mozilla/pdf.js
|
||||
|
||||
Current extension version is: 0.6.172
|
||||
Current extension version is: 0.7.28
|
||||
|
||||
|
@ -30,31 +30,19 @@ const PDF_CONTENT_TYPE = 'application/pdf';
|
||||
const PREF_PREFIX = 'pdfjs';
|
||||
const PDF_VIEWER_WEB_PAGE = 'resource://pdf.js/web/viewer.html';
|
||||
const MAX_DATABASE_LENGTH = 4096;
|
||||
const FIREFOX_ID = '{ec8030f7-c20a-464f-9b0e-13a3a9e97384}';
|
||||
|
||||
Cu.import('resource://gre/modules/XPCOMUtils.jsm');
|
||||
Cu.import('resource://gre/modules/Services.jsm');
|
||||
Cu.import('resource://gre/modules/NetUtil.jsm');
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, 'PrivateBrowsingUtils',
|
||||
'resource://gre/modules/PrivateBrowsingUtils.jsm');
|
||||
|
||||
let appInfo = Cc['@mozilla.org/xre/app-info;1']
|
||||
.getService(Ci.nsIXULAppInfo);
|
||||
let Svc = {};
|
||||
XPCOMUtils.defineLazyServiceGetter(Svc, 'mime',
|
||||
'@mozilla.org/mime;1',
|
||||
'nsIMIMEService');
|
||||
|
||||
let isInPrivateBrowsing;
|
||||
if (appInfo.ID === FIREFOX_ID) {
|
||||
let privateBrowsing = Cc['@mozilla.org/privatebrowsing;1']
|
||||
.getService(Ci.nsIPrivateBrowsingService);
|
||||
isInPrivateBrowsing = function getInPrivateBrowsing() {
|
||||
return privateBrowsing.privateBrowsingEnabled;
|
||||
};
|
||||
} else {
|
||||
isInPrivateBrowsing = function() { return false; };
|
||||
}
|
||||
|
||||
function getChromeWindow(domWindow) {
|
||||
var containingBrowser = domWindow.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIWebNavigation)
|
||||
@ -71,6 +59,14 @@ function getBoolPref(pref, def) {
|
||||
}
|
||||
}
|
||||
|
||||
function getIntPref(pref, def) {
|
||||
try {
|
||||
return Services.prefs.getIntPref(pref);
|
||||
} catch (ex) {
|
||||
return def;
|
||||
}
|
||||
}
|
||||
|
||||
function setStringPref(pref, value) {
|
||||
let str = Cc['@mozilla.org/supports-string;1']
|
||||
.createInstance(Ci.nsISupportsString);
|
||||
@ -211,6 +207,30 @@ function ChromeActions(domWindow, dataListener) {
|
||||
}
|
||||
|
||||
ChromeActions.prototype = {
|
||||
isInPrivateBrowsing: function() {
|
||||
let docIsPrivate;
|
||||
try {
|
||||
docIsPrivate = PrivateBrowsingUtils.isWindowPrivate(this.domWindow);
|
||||
} catch (x) {
|
||||
// unable to use PrivateBrowsingUtils, e.g. FF15
|
||||
}
|
||||
if (typeof docIsPrivate === 'undefined') {
|
||||
// per-window Private Browsing is not supported, trying global service
|
||||
try {
|
||||
let privateBrowsing = Cc['@mozilla.org/privatebrowsing;1']
|
||||
.getService(Ci.nsIPrivateBrowsingService);
|
||||
docIsPrivate = privateBrowsing.privateBrowsingEnabled;
|
||||
} catch (x) {
|
||||
// unable to get nsIPrivateBrowsingService (e.g. not Firefox)
|
||||
docIsPrivate = false;
|
||||
}
|
||||
}
|
||||
// caching the result
|
||||
this.isInPrivateBrowsing = function isInPrivateBrowsingCached() {
|
||||
return docIsPrivate;
|
||||
};
|
||||
return docIsPrivate;
|
||||
},
|
||||
download: function(data, sendResponse) {
|
||||
var originalUrl = data.originalUrl;
|
||||
// The data may not be downloaded so we need just retry getting the pdf with
|
||||
@ -223,16 +243,7 @@ ChromeActions.prototype = {
|
||||
var frontWindow = Cc['@mozilla.org/embedcomp/window-watcher;1'].
|
||||
getService(Ci.nsIWindowWatcher).activeWindow;
|
||||
|
||||
let docIsPrivate = false;
|
||||
try {
|
||||
docIsPrivate = this.domWindow
|
||||
.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIWebNavigation)
|
||||
.QueryInterface(Ci.nsILoadContext)
|
||||
.usePrivateBrowsing;
|
||||
} catch (x) {
|
||||
}
|
||||
|
||||
let docIsPrivate = this.isInPrivateBrowsing();
|
||||
let netChannel = NetUtil.newChannel(blobUri);
|
||||
if ('nsIPrivateBrowsingChannel' in Ci &&
|
||||
netChannel instanceof Ci.nsIPrivateBrowsingChannel) {
|
||||
@ -281,7 +292,7 @@ ChromeActions.prototype = {
|
||||
});
|
||||
},
|
||||
setDatabase: function(data) {
|
||||
if (isInPrivateBrowsing())
|
||||
if (this.isInPrivateBrowsing())
|
||||
return;
|
||||
// Protect against something sending tons of data to setDatabase.
|
||||
if (data.length > MAX_DATABASE_LENGTH)
|
||||
@ -289,7 +300,7 @@ ChromeActions.prototype = {
|
||||
setStringPref(PREF_PREFIX + '.database', data);
|
||||
},
|
||||
getDatabase: function() {
|
||||
if (isInPrivateBrowsing())
|
||||
if (this.isInPrivateBrowsing())
|
||||
return '{}';
|
||||
return getStringPref(PREF_PREFIX + '.database', '{}');
|
||||
},
|
||||
@ -351,6 +362,10 @@ ChromeActions.prototype = {
|
||||
getChromeWindow(this.domWindow).gFindBar &&
|
||||
'updateControlState' in getChromeWindow(this.domWindow).gFindBar;
|
||||
},
|
||||
supportsDocumentFonts: function() {
|
||||
var pref = getIntPref('browser.display.use_document_fonts', 1);
|
||||
return !!pref;
|
||||
},
|
||||
fallback: function(url, sendResponse) {
|
||||
var self = this;
|
||||
var domWindow = this.domWindow;
|
||||
|
@ -156,6 +156,13 @@ let PdfJs = {
|
||||
types.push(PDF_CONTENT_TYPE);
|
||||
}
|
||||
prefs.setCharPref(PREF_DISABLED_PLUGIN_TYPES, types.join(','));
|
||||
|
||||
// Update the category manager in case the plugins are already loaded.
|
||||
let categoryManager = Cc["@mozilla.org/categorymanager;1"];
|
||||
categoryManager.getService(Ci.nsICategoryManager).
|
||||
deleteCategoryEntry("Gecko-Content-Viewers",
|
||||
PDF_CONTENT_TYPE,
|
||||
false);
|
||||
},
|
||||
|
||||
// nsIObserver
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -521,7 +521,7 @@ html[dir='rtl'] .splitToolbarButtonSeparator {
|
||||
.splitToolbarButton:hover > .splitToolbarButtonSeparator,
|
||||
.splitToolbarButton.toggled > .splitToolbarButtonSeparator {
|
||||
padding: 12px 0;
|
||||
margin: 0;
|
||||
margin: 1px 0;
|
||||
box-shadow: 0 0 0 1px hsla(0,0%,100%,.03);
|
||||
-webkit-transition-property: padding;
|
||||
-webkit-transition-duration: 10ms;
|
||||
|
@ -936,6 +936,21 @@ var PDFView = {
|
||||
return support;
|
||||
},
|
||||
|
||||
get supportsDocumentFonts() {
|
||||
var support = true;
|
||||
support = FirefoxCom.requestSync('supportsDocumentFonts');
|
||||
Object.defineProperty(this, 'supportsDocumentFonts', { value: support,
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: false });
|
||||
return support;
|
||||
},
|
||||
|
||||
get isHorizontalScrollbarEnabled() {
|
||||
var div = document.getElementById('viewerContainer');
|
||||
return div.scrollWidth > div.clientWidth;
|
||||
},
|
||||
|
||||
initPassiveLoading: function pdfViewInitPassiveLoading() {
|
||||
if (!PDFView.loadingBar) {
|
||||
PDFView.loadingBar = new ProgressBar('#loadingBar', {});
|
||||
@ -2037,6 +2052,8 @@ var PageView = function pageView(container, pdfPage, id, scale,
|
||||
if (outputScale.scaled) {
|
||||
ctx.scale(outputScale.sx, outputScale.sy);
|
||||
}
|
||||
// Checking if document fonts are used only once
|
||||
var checkIfDocumentFontsUsed = !PDFView.pdfDocument.embeddedFontsUsed;
|
||||
|
||||
// Rendering area
|
||||
|
||||
@ -2049,6 +2066,12 @@ var PageView = function pageView(container, pdfPage, id, scale,
|
||||
delete self.loadingIconDiv;
|
||||
}
|
||||
|
||||
if (checkIfDocumentFontsUsed && PDFView.pdfDocument.embeddedFontsUsed &&
|
||||
!PDFView.supportsDocumentFonts) {
|
||||
console.error(mozL10n.get('web_fonts_disabled', null,
|
||||
'Web fonts are disabled: unable to use embedded PDF fonts.'));
|
||||
PDFView.fallback();
|
||||
}
|
||||
if (error) {
|
||||
PDFView.error(mozL10n.get('rendering_error', null,
|
||||
'An error occurred while rendering the page.'), error);
|
||||
@ -3095,6 +3118,7 @@ window.addEventListener('keydown', function keydown(evt) {
|
||||
case 61: // FF/Mac '='
|
||||
case 107: // FF '+' and '='
|
||||
case 187: // Chrome '+'
|
||||
case 171: // FF with German keyboard
|
||||
PDFView.zoomIn();
|
||||
handled = true;
|
||||
break;
|
||||
@ -3105,6 +3129,7 @@ window.addEventListener('keydown', function keydown(evt) {
|
||||
handled = true;
|
||||
break;
|
||||
case 48: // '0'
|
||||
case 96: // '0' on Numpad of Swedish keyboard
|
||||
PDFView.parseScale(DEFAULT_SCALE, true);
|
||||
handled = true;
|
||||
break;
|
||||
@ -3152,6 +3177,10 @@ window.addEventListener('keydown', function keydown(evt) {
|
||||
}
|
||||
// in fullscreen mode falls throw here
|
||||
case 37: // left arrow
|
||||
// horizontal scrolling using arrow keys
|
||||
if (PDFView.isHorizontalScrollbarEnabled) {
|
||||
break;
|
||||
}
|
||||
case 75: // 'k'
|
||||
case 80: // 'p'
|
||||
PDFView.page--;
|
||||
@ -3165,6 +3194,10 @@ window.addEventListener('keydown', function keydown(evt) {
|
||||
}
|
||||
// in fullscreen mode falls throw here
|
||||
case 39: // right arrow
|
||||
// horizontal scrolling using arrow keys
|
||||
if (PDFView.isHorizontalScrollbarEnabled) {
|
||||
break;
|
||||
}
|
||||
case 74: // 'j'
|
||||
case 78: // 'n'
|
||||
PDFView.page++;
|
||||
|
@ -120,3 +120,4 @@ 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.
|
||||
web_fonts_disabled=Web fonts are disabled: unable to use embedded PDF fonts.
|
||||
|
Loading…
Reference in New Issue
Block a user