mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 835954 - Update pdf.js to version 0.7.180. r=yury
This commit is contained in:
parent
b7ce5d6ac0
commit
b55326c986
@ -1,4 +1,4 @@
|
||||
This is the pdf.js project output, https://github.com/mozilla/pdf.js
|
||||
|
||||
Current extension version is: 0.7.82
|
||||
Current extension version is: 0.7.180
|
||||
|
||||
|
@ -201,9 +201,10 @@ PdfDataListener.prototype = {
|
||||
};
|
||||
|
||||
// All the priviledged actions.
|
||||
function ChromeActions(domWindow, dataListener) {
|
||||
function ChromeActions(domWindow, dataListener, contentDispositionFilename) {
|
||||
this.domWindow = domWindow;
|
||||
this.dataListener = dataListener;
|
||||
this.contentDispositionFilename = contentDispositionFilename;
|
||||
}
|
||||
|
||||
ChromeActions.prototype = {
|
||||
@ -232,6 +233,7 @@ ChromeActions.prototype = {
|
||||
return docIsPrivate;
|
||||
},
|
||||
download: function(data, sendResponse) {
|
||||
var self = this;
|
||||
var originalUrl = data.originalUrl;
|
||||
// The data may not be downloaded so we need just retry getting the pdf with
|
||||
// the original url.
|
||||
@ -259,9 +261,13 @@ ChromeActions.prototype = {
|
||||
// so the filename will be correct.
|
||||
let channel = Cc['@mozilla.org/network/input-stream-channel;1'].
|
||||
createInstance(Ci.nsIInputStreamChannel);
|
||||
channel.QueryInterface(Ci.nsIChannel);
|
||||
channel.contentDisposition = Ci.nsIChannel.DISPOSITION_ATTACHMENT;
|
||||
if (self.contentDispositionFilename) {
|
||||
channel.contentDispositionFilename = self.contentDispositionFilename;
|
||||
}
|
||||
channel.setURI(originalUri);
|
||||
channel.contentStream = aInputStream;
|
||||
channel.QueryInterface(Ci.nsIChannel);
|
||||
if ('nsIPrivateBrowsingChannel' in Ci &&
|
||||
channel instanceof Ci.nsIPrivateBrowsingChannel) {
|
||||
channel.setPrivate(docIsPrivate);
|
||||
@ -583,6 +589,10 @@ PdfStreamConverter.prototype = {
|
||||
// Creating storage for PDF data
|
||||
var contentLength = aRequest.contentLength;
|
||||
var dataListener = new PdfDataListener(contentLength);
|
||||
var contentDispositionFilename;
|
||||
try {
|
||||
contentDispositionFilename = aRequest.contentDispositionFilename;
|
||||
} catch (e) {}
|
||||
this.dataListener = dataListener;
|
||||
this.binaryStream = Cc['@mozilla.org/binaryinputstream;1']
|
||||
.createInstance(Ci.nsIBinaryInputStream);
|
||||
@ -613,7 +623,8 @@ PdfStreamConverter.prototype = {
|
||||
var domWindow = getDOMWindow(channel);
|
||||
// Double check the url is still the correct one.
|
||||
if (domWindow.document.documentURIObject.equals(aRequest.URI)) {
|
||||
let actions = new ChromeActions(domWindow, dataListener);
|
||||
let actions = new ChromeActions(domWindow, dataListener,
|
||||
contentDispositionFilename);
|
||||
let requestListener = new RequestListener(actions);
|
||||
domWindow.addEventListener(PDFJS_EVENT_ID, function(event) {
|
||||
requestListener.receive(event);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -94,21 +94,16 @@
|
||||
// get a localized string
|
||||
get: translateString,
|
||||
|
||||
// get|set the document language and direction
|
||||
get language() {
|
||||
return {
|
||||
// get|set the document language (ISO-639-1)
|
||||
get code() { return gLanguage; },
|
||||
// get the document language
|
||||
getLanguage: function() { return gLanguage; },
|
||||
|
||||
// get the direction (ltr|rtl) of the current language
|
||||
get direction() {
|
||||
getDirection: function() {
|
||||
// http://www.w3.org/International/questions/qa-scripts
|
||||
// Arabic, Hebrew, Farsi, Pashto, Urdu
|
||||
var rtlList = ['ar', 'he', 'fa', 'ps', 'ur'];
|
||||
return (rtlList.indexOf(gLanguage) >= 0) ? 'rtl' : 'ltr';
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
})(this);
|
||||
|
||||
|
@ -665,7 +665,6 @@ html[dir='rtl'] .dropdownToolbarButton {
|
||||
}
|
||||
|
||||
.dropdownToolbarButton {
|
||||
min-width: 120px;
|
||||
max-width: 120px;
|
||||
padding: 3px 2px 2px;
|
||||
overflow: hidden;
|
||||
|
@ -14,7 +14,7 @@ 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.
|
||||
-->
|
||||
<html dir="ltr">
|
||||
<html dir="ltr" mozdisallowselectionprint>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
||||
@ -81,8 +81,8 @@ limitations under the License.
|
||||
<div id="toolbarContainer">
|
||||
<div id="toolbarViewer">
|
||||
<div id="toolbarViewerLeft">
|
||||
<button id="sidebarToggle" class="toolbarButton" title="Toggle Sidebar" tabindex="3" data-l10n-id="toggle_slider">
|
||||
<span data-l10n-id="toggle_slider_label">Toggle Sidebar</span>
|
||||
<button id="sidebarToggle" class="toolbarButton" title="Toggle Sidebar" tabindex="3" data-l10n-id="toggle_sidebar">
|
||||
<span data-l10n-id="toggle_sidebar_label">Toggle Sidebar</span>
|
||||
</button>
|
||||
<div class="toolbarButtonSpacer"></div>
|
||||
<button id="viewFind" class="toolbarButton group" title="Find in Document" tabindex="4" data-l10n-id="findbar">
|
||||
|
@ -57,7 +57,13 @@ function getFileName(url) {
|
||||
}
|
||||
|
||||
function scrollIntoView(element, spot) {
|
||||
// Assuming offsetParent is available (it's not available when viewer is in
|
||||
// hidden iframe or object). We have to scroll: if the offsetParent is not set
|
||||
// producing the error. See also animationStartedClosure.
|
||||
var parent = element.offsetParent, offsetY = element.offsetTop;
|
||||
if (!parent) {
|
||||
error('offsetParent is not set -- cannot scroll');
|
||||
}
|
||||
while (parent.clientHeight == parent.scrollHeight) {
|
||||
offsetY += parent.offsetTop;
|
||||
parent = parent.offsetParent;
|
||||
@ -1038,6 +1044,13 @@ var PDFView = {
|
||||
'Invalid or corrupted PDF file.');
|
||||
}
|
||||
|
||||
if (exception && exception.name === 'MissingPDFException') {
|
||||
// special message for missing PDF's
|
||||
var loadingErrorMessage = mozL10n.get('missing_file_error', null,
|
||||
'Missing PDF file.');
|
||||
|
||||
}
|
||||
|
||||
var loadingIndicator = document.getElementById('loading');
|
||||
loadingIndicator.textContent = mozL10n.get('loading_error_indicator',
|
||||
null, 'Error');
|
||||
@ -1285,7 +1298,8 @@ var PDFView = {
|
||||
});
|
||||
|
||||
// outline and initial view depends on destinations and pagesRefMap
|
||||
var promises = [pagesPromise, destinationsPromise, storePromise];
|
||||
var promises = [pagesPromise, destinationsPromise, storePromise,
|
||||
PDFView.animationStartedPromise];
|
||||
PDFJS.Promise.all(promises).then(function() {
|
||||
pdfDocument.getOutline().then(function(outline) {
|
||||
self.outline = new DocumentOutlineView(outline);
|
||||
@ -1326,6 +1340,11 @@ var PDFView = {
|
||||
|
||||
if (pdfTitle)
|
||||
self.setTitle(pdfTitle + ' - ' + document.title);
|
||||
|
||||
if (info.IsAcroFormPresent) {
|
||||
// AcroForm/XFA was found
|
||||
PDFView.fallback();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
@ -1936,10 +1955,6 @@ var PageView = function pageView(container, pdfPage, id, scale,
|
||||
if (textAnnotation)
|
||||
div.appendChild(textAnnotation);
|
||||
break;
|
||||
case 'Widget':
|
||||
// TODO: support forms
|
||||
PDFView.fallback();
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -2059,6 +2074,9 @@ var PageView = function pageView(container, pdfPage, id, scale,
|
||||
}
|
||||
|
||||
var ctx = canvas.getContext('2d');
|
||||
// TODO(mack): use data attributes to store these
|
||||
ctx._scaleX = outputScale.sx;
|
||||
ctx._scaleY = outputScale.sy;
|
||||
ctx.save();
|
||||
ctx.fillStyle = 'rgb(255, 255, 255)';
|
||||
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||
@ -2072,7 +2090,12 @@ var PageView = function pageView(container, pdfPage, id, scale,
|
||||
// Rendering area
|
||||
|
||||
var self = this;
|
||||
var renderingWasReset = false;
|
||||
function pageViewDrawCallback(error) {
|
||||
if (renderingWasReset) {
|
||||
return;
|
||||
}
|
||||
|
||||
self.renderingState = RenderingStates.FINISHED;
|
||||
|
||||
if (self.loadingIconDiv) {
|
||||
@ -2105,6 +2128,12 @@ var PageView = function pageView(container, pdfPage, id, scale,
|
||||
viewport: this.viewport,
|
||||
textLayer: textLayer,
|
||||
continueCallback: function pdfViewcContinueCallback(cont) {
|
||||
if (self.renderingState === RenderingStates.INITIAL) {
|
||||
// The page update() was called, we just need to abort any rendering.
|
||||
renderingWasReset = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (PDFView.highestPriorityPage !== 'page' + self.id) {
|
||||
self.renderingState = RenderingStates.PAUSED;
|
||||
self.resume = function resumeCallback() {
|
||||
@ -2885,9 +2914,19 @@ document.addEventListener('DOMContentLoaded', function webViewerLoad(evt) {
|
||||
PDFView.download();
|
||||
});
|
||||
|
||||
document.getElementById('pageNumber').addEventListener('click',
|
||||
function() {
|
||||
this.select();
|
||||
});
|
||||
|
||||
document.getElementById('pageNumber').addEventListener('change',
|
||||
function() {
|
||||
PDFView.page = this.value;
|
||||
// Handle the user inputting a floating point number.
|
||||
PDFView.page = (this.value | 0);
|
||||
|
||||
if (this.value !== (this.value | 0).toString()) {
|
||||
this.value = PDFView.page;
|
||||
}
|
||||
});
|
||||
|
||||
document.getElementById('scaleSelect').addEventListener('change',
|
||||
@ -3039,6 +3078,16 @@ function selectScaleOption(value) {
|
||||
|
||||
window.addEventListener('localized', function localized(evt) {
|
||||
document.getElementsByTagName('html')[0].dir = mozL10n.getDirection();
|
||||
|
||||
// Adjust the width of the zoom box to fit the content.
|
||||
var container = document.getElementById('scaleSelectContainer');
|
||||
var select = document.getElementById('scaleSelect');
|
||||
|
||||
select.setAttribute('style', 'min-width: inherit;');
|
||||
var width = select.clientWidth + 8;
|
||||
container.setAttribute('style', 'min-width: ' + width + 'px; ' +
|
||||
'max-width: ' + width + 'px;');
|
||||
select.setAttribute('style', 'min-width: ' + (width + 20) + 'px;');
|
||||
}, true);
|
||||
|
||||
window.addEventListener('scalechange', function scalechange(evt) {
|
||||
@ -3280,4 +3329,19 @@ window.addEventListener('afterprint', function afterPrint(evt) {
|
||||
window.addEventListener('webkitfullscreenchange', fullscreenChange, false);
|
||||
})();
|
||||
|
||||
(function animationStartedClosure() {
|
||||
// The offsetParent is not set until the pdf.js iframe or object is visible.
|
||||
// Waiting for first animation.
|
||||
var requestAnimationFrame = window.requestAnimationFrame ||
|
||||
window.mozRequestAnimationFrame ||
|
||||
window.webkitRequestAnimationFrame ||
|
||||
window.oRequestAnimationFrame ||
|
||||
window.msRequestAnimationFrame ||
|
||||
function startAtOnce(callback) { callback(); };
|
||||
PDFView.animationStartedPromise = new PDFJS.Promise();
|
||||
requestAnimationFrame(function onAnimationFrame() {
|
||||
PDFView.animationStartedPromise.resolve();
|
||||
});
|
||||
})();
|
||||
|
||||
|
||||
|
@ -44,8 +44,8 @@ bookmark_label=Current View
|
||||
# Tooltips and alt text for side panel toolbar buttons
|
||||
# (the _label strings are alt text for the buttons, the .title strings are
|
||||
# tooltips)
|
||||
toggle_slider.title=Toggle Slider
|
||||
toggle_slider_label=Toggle Slider
|
||||
toggle_sidebar.title=Toggle Sidebar
|
||||
toggle_sidebar_label=Toggle Sidebar
|
||||
outline.title=Show Document Outline
|
||||
outline_label=Document Outline
|
||||
thumbs.title=Show Thumbnails
|
||||
@ -111,6 +111,7 @@ page_scale_actual=Actual Size
|
||||
loading_error_indicator=Error
|
||||
loading_error=An error occurred while loading the PDF.
|
||||
invalid_file_error=Invalid or corrupted PDF file.
|
||||
missing_file_error=Missing PDF file.
|
||||
|
||||
# LOCALIZATION NOTE (text_annotation_type): This is used as a tooltip.
|
||||
# "{{type}}" will be replaced with an annotation type from a list defined in
|
||||
|
Loading…
Reference in New Issue
Block a user