Bug 999616 - Update pdf.js to version 1.0.68. r=Mossop, r=yury

This commit is contained in:
Ryan VanderMeulen 2014-04-22 13:25:20 -07:00
parent 8519043783
commit 41bf99a1c4
11 changed files with 811 additions and 587 deletions

View File

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

View File

@ -227,7 +227,8 @@ ChromeActions.prototype = {
// the original url.
var originalUri = NetUtil.newURI(data.originalUrl);
var filename = data.filename;
if (typeof filename !== 'string' || !/\.pdf$/i.test(filename)) {
if (typeof filename !== 'string' ||
(!/\.pdf$/i.test(filename) && !data.isAttachment)) {
filename = 'document.pdf';
}
var blobUri = data.blobUrl ? NetUtil.newURI(data.blobUrl) : originalUri;
@ -273,7 +274,8 @@ ChromeActions.prototype = {
var listener = {
extListener: null,
onStartRequest: function(aRequest, aContext) {
this.extListener = extHelperAppSvc.doContent('application/pdf',
this.extListener = extHelperAppSvc.doContent((data.isAttachment ? '' :
'application/pdf'),
aRequest, frontWindow, false);
this.extListener.onStartRequest(aRequest, aContext);
},

View File

@ -21,8 +21,8 @@ if (typeof PDFJS === 'undefined') {
(typeof window !== 'undefined' ? window : this).PDFJS = {};
}
PDFJS.version = '1.0.21';
PDFJS.build = 'f954cde';
PDFJS.version = '1.0.68';
PDFJS.build = 'ead4cbf';
(function pdfjsWrapper() {
// Use strict in our context only - users might not want it
@ -453,6 +453,28 @@ function string32(value) {
(value >> 8) & 0xff, value & 0xff);
}
function log2(x) {
var n = 1, i = 0;
while (x > n) {
n <<= 1;
i++;
}
return i;
}
function readInt8(data, start) {
return (data[start] << 24) >> 24;
}
function readUint16(data, offset) {
return (data[offset] << 8) | data[offset + 1];
}
function readUint32(data, offset) {
return ((data[offset] << 24) | (data[offset + 1] << 16) |
(data[offset + 2] << 8) | data[offset + 3]) >>> 0;
}
// Lazy test the endianness of the platform
// NOTE: This will be 'true' for simulated TypedArrays
function isLittleEndian() {
@ -1745,31 +1767,31 @@ var DeviceCmykCS = (function DeviceCmykCSClosure() {
var k = src[srcOffset + 3] * srcScale;
var r =
c * (-4.387332384609988 * c + 54.48615194189176 * m +
18.82290502165302 * y + 212.25662451639585 * k +
-285.2331026137004) +
m * (1.7149763477362134 * m - 5.6096736904047315 * y +
-17.873870861415444 * k - 5.497006427196366) +
y * (-2.5217340131683033 * y - 21.248923337353073 * k +
17.5119270841813) +
k * (-21.86122147463605 * k - 189.48180835922747) + 255;
(c * (-4.387332384609988 * c + 54.48615194189176 * m +
18.82290502165302 * y + 212.25662451639585 * k +
-285.2331026137004) +
m * (1.7149763477362134 * m - 5.6096736904047315 * y +
-17.873870861415444 * k - 5.497006427196366) +
y * (-2.5217340131683033 * y - 21.248923337353073 * k +
17.5119270841813) +
k * (-21.86122147463605 * k - 189.48180835922747) + 255) | 0;
var g =
c * (8.841041422036149 * c + 60.118027045597366 * m +
6.871425592049007 * y + 31.159100130055922 * k +
-79.2970844816548) +
m * (-15.310361306967817 * m + 17.575251261109482 * y +
131.35250912493976 * k - 190.9453302588951) +
y * (4.444339102852739 * y + 9.8632861493405 * k - 24.86741582555878) +
k * (-20.737325471181034 * k - 187.80453709719578) + 255;
(c * (8.841041422036149 * c + 60.118027045597366 * m +
6.871425592049007 * y + 31.159100130055922 * k +
-79.2970844816548) +
m * (-15.310361306967817 * m + 17.575251261109482 * y +
131.35250912493976 * k - 190.9453302588951) +
y * (4.444339102852739 * y + 9.8632861493405 * k - 24.86741582555878) +
k * (-20.737325471181034 * k - 187.80453709719578) + 255) | 0;
var b =
c * (0.8842522430003296 * c + 8.078677503112928 * m +
30.89978309703729 * y - 0.23883238689178934 * k +
-14.183576799673286) +
m * (10.49593273432072 * m + 63.02378494754052 * y +
50.606957656360734 * k - 112.23884253719248) +
y * (0.03296041114873217 * y + 115.60384449646641 * k +
-193.58209356861505) +
k * (-22.33816807309886 * k - 180.12613974708367) + 255;
(c * (0.8842522430003296 * c + 8.078677503112928 * m +
30.89978309703729 * y - 0.23883238689178934 * k +
-14.183576799673286) +
m * (10.49593273432072 * m + 63.02378494754052 * y +
50.606957656360734 * k - 112.23884253719248) +
y * (0.03296041114873217 * y + 115.60384449646641 * k +
-193.58209356861505) +
k * (-22.33816807309886 * k - 180.12613974708367) + 255) | 0;
dest[destOffset] = r > 255 ? 255 : r < 0 ? 0 : r;
dest[destOffset + 1] = g > 255 ? 255 : g < 0 ? 0 : g;
@ -2142,7 +2164,6 @@ var PDFFunction = (function PDFFunctionClosure() {
constructSampled: function PDFFunction_constructSampled(str, dict) {
function toMultiArray(arr) {
var inputLength = arr.length;
var outputLength = arr.length / 2;
var out = [];
var index = 0;
for (var i = 0; i < inputLength; i += 2) {
@ -2213,7 +2234,7 @@ var PDFFunction = (function PDFFunctionClosure() {
var samples = IR[5];
var size = IR[6];
var n = IR[7];
var mask = IR[8];
//var mask = IR[8];
var range = IR[9];
if (m != args.length) {
@ -2884,6 +2905,7 @@ var Annotation = (function AnnotationClosure() {
this.appearance = getDefaultAppearance(dict);
data.hasAppearance = !!this.appearance;
data.id = params.ref.num;
}
Annotation.prototype = {
@ -2992,8 +3014,6 @@ var Annotation = (function AnnotationClosure() {
var matrix = appearanceDict.get('Matrix') || [1, 0, 0, 1, 0 ,0];
var transform = getTransformMatrix(data.rect, bbox, matrix);
var border = data.border;
resourcesPromise.then(function(resources) {
var opList = new OperatorList();
opList.addOp(OPS.beginAnnotation, [data.rect, transform, matrix]);
@ -3219,7 +3239,6 @@ var TextWidgetAnnotation = (function TextWidgetAnnotationClosure() {
}
var parent = WidgetAnnotation.prototype;
Util.inherit(TextWidgetAnnotation, WidgetAnnotation, {
hasHtml: function TextWidgetAnnotation_hasHtml() {
return !this.data.hasAppearance && !!this.data.fieldValue;
@ -3242,7 +3261,7 @@ var TextWidgetAnnotation = (function TextWidgetAnnotationClosure() {
var fontObj = item.fontRefName ?
commonObjs.getData(item.fontRefName) : null;
var cssRules = setTextStyles(content, item, fontObj);
setTextStyles(content, item, fontObj);
element.appendChild(content);
@ -3274,7 +3293,6 @@ var TextWidgetAnnotation = (function TextWidgetAnnotationClosure() {
var appearanceFnArray = opList.fnArray;
var appearanceArgsArray = opList.argsArray;
var fnArray = [];
var argsArray = [];
// TODO(mack): Add support for stroke color
data.rgb = [0, 0, 0];
@ -3490,7 +3508,6 @@ var TextAnnotation = (function TextAnnotationClosure() {
}
};
var self = this;
image.addEventListener('click', function image_clickHandler() {
toggleAnnotation();
}, false);
@ -3595,7 +3612,6 @@ var LinkAnnotation = (function LinkAnnotationClosure() {
container.className = 'annotLink';
var item = this.data;
var rect = item.rect;
container.style.borderColor = item.colorCssRgb;
container.style.borderStyle = 'solid';
@ -3850,6 +3866,13 @@ var PDFDocumentProxy = (function PDFDocumentProxyClosure() {
getDestinations: function PDFDocumentProxy_getDestinations() {
return this.transport.getDestinations();
},
/**
* @return {Promise} A promise that is resolved with a lookup table for
* mapping named attachments to their content.
*/
getAttachments: function PDFDocumentProxy_getAttachments() {
return this.transport.getAttachments();
},
/**
* @return {Promise} A promise that is resolved with an array of all the
* JavaScript strings in the name tree.
@ -4627,6 +4650,16 @@ var WorkerTransport = (function WorkerTransportClosure() {
return promise;
},
getAttachments: function WorkerTransport_getAttachments() {
var promise = new PDFJS.LegacyPromise();
this.messageHandler.send('GetAttachments', null,
function transportAttachments(attachments) {
promise.resolve(attachments);
}
);
return promise;
},
startCleanup: function WorkerTransport_startCleanup() {
this.messageHandler.send('Cleanup', null,
function endCleanup() {
@ -5421,7 +5454,6 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
// imgData.kind tells us which one this is.
if (imgData.kind === ImageKind.GRAYSCALE_1BPP) {
// Grayscale, 1 bit per pixel (i.e. black-and-white).
var destDataLength = dest.length;
var srcLength = src.byteLength;
var dest32 = PDFJS.hasCanvasTypedArrays ? new Uint32Array(dest.buffer) :
new Uint32ArrayView(dest);
@ -5692,7 +5724,6 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
return i;
}
var executionEndIdx;
var endTime = Date.now() + EXECUTION_TIME;
var commonObjs = this.commonObjs;
@ -6268,7 +6299,6 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
var vertical = font.vertical;
var defaultVMetrics = font.defaultVMetrics;
var i, glyph, width;
var VERTICAL_TEXT_ROTATION = Math.PI / 2;
if (fontSize === 0) {
return;
@ -6396,7 +6426,6 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
}
},
showSpacedText: function CanvasGraphics_showSpacedText(arr) {
var ctx = this.ctx;
var current = this.current;
var font = current.font;
var fontSize = current.fontSize;
@ -6472,8 +6501,6 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
var base = cs.base;
var color;
if (base) {
var baseComps = base.numComps;
color = base.getRgb(args, 0);
}
pattern = new TilingPattern(IR, color, this.ctx, this.objs,
@ -7732,13 +7759,13 @@ var createMeshCanvas = (function createMeshCanvasClosure() {
ShadingIRs.Mesh = {
fromIR: function Mesh_fromIR(raw) {
var type = raw[1];
//var type = raw[1];
var coords = raw[2];
var colors = raw[3];
var figures = raw[4];
var bounds = raw[5];
var matrix = raw[6];
var bbox = raw[7];
//var bbox = raw[7];
var background = raw[8];
return {
type: 'Pattern',
@ -7835,7 +7862,6 @@ var TilingPattern = (function TilingPatternClosure() {
var color = this.color;
var objs = this.objs;
var commonObjs = this.commonObjs;
var ctx = this.ctx;
info('TilingType: ' + tilingType);

File diff suppressed because it is too large Load Diff

View File

@ -20,7 +20,6 @@
var FontInspector = (function FontInspectorClosure() {
var fonts;
var panelWidth = 300;
var active = false;
var fontAttribute = 'data-font-name';
function removeSelection() {
@ -327,6 +326,8 @@ var Stepper = (function StepperClosure() {
}
},
updateOperatorList: function updateOperatorList(operatorList) {
var self = this;
function cboxOnClick() {
var x = +this.dataset.idx;
if (this.checked) {
@ -342,7 +343,6 @@ var Stepper = (function StepperClosure() {
return;
}
var self = this;
var chunk = document.createDocumentFragment();
var operatorsToDisplay = Math.min(MAX_OPERATORS_COUNT,
operatorList.fnArray.length);

Binary file not shown.

After

Width:  |  Height:  |  Size: 384 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 871 B

View File

@ -533,6 +533,9 @@ html[dir='rtl'] .splitToolbarButton > .toolbarButton {
0 0 1px hsla(0,0%,0%,.05);
z-index: 199;
}
.splitToolbarButton > .toolbarButton {
position: relative;
}
html[dir='ltr'] .splitToolbarButton > .toolbarButton:first-child,
html[dir='rtl'] .splitToolbarButton > .toolbarButton:last-child {
position: relative;
@ -861,6 +864,10 @@ html[dir="rtl"] #viewOutline.toolbarButton::before {
content: url(images/toolbarButton-viewOutline-rtl.png);
}
#viewAttachments.toolbarButton::before {
content: url(images/toolbarButton-viewAttachments.png);
}
#viewFind.toolbarButton::before {
content: url(images/toolbarButton-search.png);
}
@ -1070,7 +1077,8 @@ a:focus > .thumbnail > .thumbnailSelectionRing,
color: hsla(0,0%,100%,1);
}
#outlineView {
#outlineView,
#attachmentsView {
position: absolute;
width: 192px;
top: 0;
@ -1088,7 +1096,8 @@ html[dir='rtl'] .outlineItem > .outlineItems {
margin-right: 20px;
}
.outlineItem > a {
.outlineItem > a,
.attachmentsItem > a {
text-decoration: none;
display: inline-block;
min-width: 95%;
@ -1102,15 +1111,18 @@ html[dir='rtl'] .outlineItem > .outlineItems {
white-space: normal;
}
html[dir='ltr'] .outlineItem > a {
html[dir='ltr'] .outlineItem > a,
html[dir='ltr'] .attachmentsItem > a {
padding: 2px 0 5px 10px;
}
html[dir='rtl'] .outlineItem > a {
html[dir='rtl'] .outlineItem > a,
html[dir='rtl'] .attachmentsItem > a {
padding: 2px 10px 5px 0;
}
.outlineItem > a:hover {
.outlineItem > a:hover,
.attachmentsItem > a:hover {
background-color: hsla(0,0%,100%,.02);
background-image: linear-gradient(hsla(0,0%,100%,.05), hsla(0,0%,100%,0));
background-clip: padding-box;
@ -1641,6 +1653,10 @@ html[dir='rtl'] #documentPropertiesContainer .row > * {
content: url(images/toolbarButton-viewOutline-rtl@2x.png);
}
#viewAttachments.toolbarButton::before {
content: url(images/toolbarButton-viewAttachments@2x.png);
}
#viewFind.toolbarButton::before {
content: url(images/toolbarButton-search@2x.png);
}

View File

@ -23,7 +23,7 @@ http://sourceforge.net/adobe/cmap/wiki/License/
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>PDF.js viewer</title>
<!-- This snippet is used in firefox extension, see Makefile -->
<!-- This snippet is used in the Firefox extension (included from viewer.html) -->
<base href="resource://pdf.js/web/" />
<script type="text/javascript" src="l10n.js"></script>
<script type="text/javascript" src="../build/pdf.js"></script>
@ -53,6 +53,9 @@ http://sourceforge.net/adobe/cmap/wiki/License/
<button id="viewOutline" class="toolbarButton group" title="Show Document Outline" tabindex="3" data-l10n-id="outline">
<span data-l10n-id="outline_label">Document Outline</span>
</button>
<button id="viewAttachments" class="toolbarButton group" title="Show Attachments" tabindex="4" data-l10n-id="attachments">
<span data-l10n-id="attachments_label">Attachments</span>
</button>
</div>
</div>
<div id="sidebarContent">
@ -60,6 +63,8 @@ http://sourceforge.net/adobe/cmap/wiki/License/
</div>
<div id="outlineView" class="hidden">
</div>
<div id="attachmentsView" class="hidden">
</div>
</div>
</div> <!-- sidebarContainer -->
@ -85,53 +90,53 @@ http://sourceforge.net/adobe/cmap/wiki/License/
<div id="secondaryToolbar" class="secondaryToolbar hidden doorHangerRight">
<div id="secondaryToolbarButtonContainer">
<button id="secondaryPresentationMode" class="secondaryToolbarButton presentationMode visibleLargeView" title="Switch to Presentation Mode" tabindex="18" data-l10n-id="presentation_mode">
<button id="secondaryPresentationMode" class="secondaryToolbarButton presentationMode visibleLargeView" title="Switch to Presentation Mode" tabindex="19" data-l10n-id="presentation_mode">
<span data-l10n-id="presentation_mode_label">Presentation Mode</span>
</button>
<button id="secondaryOpenFile" class="secondaryToolbarButton openFile visibleLargeView" title="Open File" tabindex="19" data-l10n-id="open_file">
<button id="secondaryOpenFile" class="secondaryToolbarButton openFile visibleLargeView" title="Open File" tabindex="20" data-l10n-id="open_file">
<span data-l10n-id="open_file_label">Open</span>
</button>
<button id="secondaryPrint" class="secondaryToolbarButton print visibleMediumView" title="Print" tabindex="20" data-l10n-id="print">
<button id="secondaryPrint" class="secondaryToolbarButton print visibleMediumView" title="Print" tabindex="21" data-l10n-id="print">
<span data-l10n-id="print_label">Print</span>
</button>
<button id="secondaryDownload" class="secondaryToolbarButton download visibleMediumView" title="Download" tabindex="21" data-l10n-id="download">
<button id="secondaryDownload" class="secondaryToolbarButton download visibleMediumView" title="Download" tabindex="22" data-l10n-id="download">
<span data-l10n-id="download_label">Download</span>
</button>
<a href="#" id="secondaryViewBookmark" class="secondaryToolbarButton bookmark visibleSmallView" title="Current view (copy or open in new window)" tabindex="22" data-l10n-id="bookmark">
<a href="#" id="secondaryViewBookmark" class="secondaryToolbarButton bookmark visibleSmallView" title="Current view (copy or open in new window)" tabindex="23" data-l10n-id="bookmark">
<span data-l10n-id="bookmark_label">Current View</span>
</a>
<div class="horizontalToolbarSeparator visibleLargeView"></div>
<button id="firstPage" class="secondaryToolbarButton firstPage" title="Go to First Page" tabindex="23" data-l10n-id="first_page">
<button id="firstPage" class="secondaryToolbarButton firstPage" title="Go to First Page" tabindex="24" data-l10n-id="first_page">
<span data-l10n-id="first_page_label">Go to First Page</span>
</button>
<button id="lastPage" class="secondaryToolbarButton lastPage" title="Go to Last Page" tabindex="24" data-l10n-id="last_page">
<button id="lastPage" class="secondaryToolbarButton lastPage" title="Go to Last Page" tabindex="25" data-l10n-id="last_page">
<span data-l10n-id="last_page_label">Go to Last Page</span>
</button>
<div class="horizontalToolbarSeparator"></div>
<button id="pageRotateCw" class="secondaryToolbarButton rotateCw" title="Rotate Clockwise" tabindex="25" data-l10n-id="page_rotate_cw">
<button id="pageRotateCw" class="secondaryToolbarButton rotateCw" title="Rotate Clockwise" tabindex="26" data-l10n-id="page_rotate_cw">
<span data-l10n-id="page_rotate_cw_label">Rotate Clockwise</span>
</button>
<button id="pageRotateCcw" class="secondaryToolbarButton rotateCcw" title="Rotate Counterclockwise" tabindex="26" data-l10n-id="page_rotate_ccw">
<button id="pageRotateCcw" class="secondaryToolbarButton rotateCcw" title="Rotate Counterclockwise" tabindex="27" data-l10n-id="page_rotate_ccw">
<span data-l10n-id="page_rotate_ccw_label">Rotate Counterclockwise</span>
</button>
<div class="horizontalToolbarSeparator"></div>
<button id="toggleHandTool" class="secondaryToolbarButton handTool" title="Enable hand tool" tabindex="27" data-l10n-id="hand_tool_enable">
<button id="toggleHandTool" class="secondaryToolbarButton handTool" title="Enable hand tool" tabindex="28" data-l10n-id="hand_tool_enable">
<span data-l10n-id="hand_tool_enable_label">Enable hand tool</span>
</button>
<div class="horizontalToolbarSeparator"></div>
<button id="documentProperties" class="secondaryToolbarButton documentProperties" title="Document Properties…" tabindex="28" data-l10n-id="document_properties">
<button id="documentProperties" class="secondaryToolbarButton documentProperties" title="Document Properties…" tabindex="29" data-l10n-id="document_properties">
<span data-l10n-id="document_properties_label">Document Properties…</span>
</button>
</div>
@ -141,77 +146,77 @@ http://sourceforge.net/adobe/cmap/wiki/License/
<div id="toolbarContainer">
<div id="toolbarViewer">
<div id="toolbarViewerLeft">
<button id="sidebarToggle" class="toolbarButton" title="Toggle Sidebar" tabindex="4" data-l10n-id="toggle_sidebar">
<button id="sidebarToggle" class="toolbarButton" title="Toggle Sidebar" tabindex="5" 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 hiddenSmallView" title="Find in Document" tabindex="5" data-l10n-id="findbar">
<button id="viewFind" class="toolbarButton group hiddenSmallView" title="Find in Document" tabindex="6" data-l10n-id="findbar">
<span data-l10n-id="findbar_label">Find</span>
</button>
<div class="splitToolbarButton">
<button class="toolbarButton pageUp" title="Previous Page" id="previous" tabindex="6" data-l10n-id="previous">
<button class="toolbarButton pageUp" title="Previous Page" id="previous" tabindex="7" data-l10n-id="previous">
<span data-l10n-id="previous_label">Previous</span>
</button>
<div class="splitToolbarButtonSeparator"></div>
<button class="toolbarButton pageDown" title="Next Page" id="next" tabindex="7" data-l10n-id="next">
<button class="toolbarButton pageDown" title="Next Page" id="next" tabindex="8" data-l10n-id="next">
<span data-l10n-id="next_label">Next</span>
</button>
</div>
<label id="pageNumberLabel" class="toolbarLabel" for="pageNumber" data-l10n-id="page_label">Page: </label>
<input type="number" id="pageNumber" class="toolbarField pageNumber" value="1" size="4" min="1" tabindex="8">
<input type="number" id="pageNumber" class="toolbarField pageNumber" value="1" size="4" min="1" tabindex="9">
<span id="numPages" class="toolbarLabel"></span>
</div>
<div id="toolbarViewerRight">
<button id="presentationMode" class="toolbarButton presentationMode hiddenLargeView" title="Switch to Presentation Mode" tabindex="12" data-l10n-id="presentation_mode">
<button id="presentationMode" class="toolbarButton presentationMode hiddenLargeView" title="Switch to Presentation Mode" tabindex="13" data-l10n-id="presentation_mode">
<span data-l10n-id="presentation_mode_label">Presentation Mode</span>
</button>
<button id="openFile" class="toolbarButton openFile hiddenLargeView" title="Open File" tabindex="13" data-l10n-id="open_file">
<button id="openFile" class="toolbarButton openFile hiddenLargeView" title="Open File" tabindex="14" data-l10n-id="open_file">
<span data-l10n-id="open_file_label">Open</span>
</button>
<button id="print" class="toolbarButton print hiddenMediumView" title="Print" tabindex="14" data-l10n-id="print">
<button id="print" class="toolbarButton print hiddenMediumView" title="Print" tabindex="15" data-l10n-id="print">
<span data-l10n-id="print_label">Print</span>
</button>
<button id="download" class="toolbarButton download hiddenMediumView" title="Download" tabindex="15" data-l10n-id="download">
<button id="download" class="toolbarButton download hiddenMediumView" title="Download" tabindex="16" data-l10n-id="download">
<span data-l10n-id="download_label">Download</span>
</button>
<!-- <div class="toolbarButtonSpacer"></div> -->
<a href="#" id="viewBookmark" class="toolbarButton bookmark hiddenSmallView" title="Current view (copy or open in new window)" tabindex="16" data-l10n-id="bookmark">
<a href="#" id="viewBookmark" class="toolbarButton bookmark hiddenSmallView" title="Current view (copy or open in new window)" tabindex="17" data-l10n-id="bookmark">
<span data-l10n-id="bookmark_label">Current View</span>
</a>
<div class="verticalToolbarSeparator hiddenSmallView"></div>
<button id="secondaryToolbarToggle" class="toolbarButton" title="Tools" tabindex="17" data-l10n-id="tools">
<button id="secondaryToolbarToggle" class="toolbarButton" title="Tools" tabindex="18" data-l10n-id="tools">
<span data-l10n-id="tools_label">Tools</span>
</button>
</div>
<div class="outerCenter">
<div class="innerCenter" id="toolbarViewerMiddle">
<div class="splitToolbarButton">
<button id="zoomOut" class="toolbarButton zoomOut" title="Zoom Out" tabindex="9" data-l10n-id="zoom_out">
<button id="zoomOut" class="toolbarButton zoomOut" title="Zoom Out" tabindex="10" data-l10n-id="zoom_out">
<span data-l10n-id="zoom_out_label">Zoom Out</span>
</button>
<div class="splitToolbarButtonSeparator"></div>
<button id="zoomIn" class="toolbarButton zoomIn" title="Zoom In" tabindex="10" data-l10n-id="zoom_in">
<button id="zoomIn" class="toolbarButton zoomIn" title="Zoom In" tabindex="11" data-l10n-id="zoom_in">
<span data-l10n-id="zoom_in_label">Zoom In</span>
</button>
</div>
<span id="scaleSelectContainer" class="dropdownToolbarButton">
<select id="scaleSelect" title="Zoom" tabindex="11" data-l10n-id="zoom">
<option id="pageAutoOption" value="auto" selected="selected" data-l10n-id="page_scale_auto">Automatic Zoom</option>
<option id="pageActualOption" value="page-actual" data-l10n-id="page_scale_actual">Actual Size</option>
<option id="pageFitOption" value="page-fit" data-l10n-id="page_scale_fit">Fit Page</option>
<option id="pageWidthOption" value="page-width" data-l10n-id="page_scale_width">Full Width</option>
<option id="customScaleOption" value="custom"></option>
<option value="0.5">50%</option>
<option value="0.75">75%</option>
<option value="1">100%</option>
<option value="1.25">125%</option>
<option value="1.5">150%</option>
<option value="2">200%</option>
<select id="scaleSelect" title="Zoom" tabindex="12" data-l10n-id="zoom">
<option id="pageAutoOption" title="" value="auto" selected="selected" data-l10n-id="page_scale_auto">Automatic Zoom</option>
<option id="pageActualOption" title="" value="page-actual" data-l10n-id="page_scale_actual">Actual Size</option>
<option id="pageFitOption" title="" value="page-fit" data-l10n-id="page_scale_fit">Fit Page</option>
<option id="pageWidthOption" title="" value="page-width" data-l10n-id="page_scale_width">Full Width</option>
<option id="customScaleOption" title="" value="custom"></option>
<option title="" value="0.5">50%</option>
<option title="" value="0.75">75%</option>
<option title="" value="1">100%</option>
<option title="" value="1.25">125%</option>
<option title="" value="1.5">150%</option>
<option title="" value="2">200%</option>
</select>
</span>
</div>

View File

@ -520,6 +520,18 @@ var DownloadManager = (function DownloadManagerClosure() {
});
},
downloadData: function DownloadManager_downloadData(data, filename,
contentType) {
var blobUrl = PDFJS.createObjectURL(data, contentType);
FirefoxCom.request('download', {
blobUrl: blobUrl,
originalUrl: blobUrl,
filename: filename,
isAttachment: true
});
},
download: function DownloadManager_download(blob, url, filename) {
var blobUrl = window.URL.createObjectURL(blob);
@ -2829,6 +2841,9 @@ var PDFView = {
},
close: function pdfViewClose() {
var errorWrapper = document.getElementById('errorWrapper');
errorWrapper.setAttribute('hidden', 'true');
if (!this.pdfDocument) {
return;
}
@ -2836,9 +2851,6 @@ var PDFView = {
this.pdfDocument.destroy();
this.pdfDocument = null;
var errorWrapper = document.getElementById('errorWrapper');
errorWrapper.setAttribute('hidden', 'true');
var thumbsView = document.getElementById('thumbnailView');
while (thumbsView.hasChildNodes()) {
thumbsView.removeChild(thumbsView.lastChild);
@ -2862,11 +2874,10 @@ var PDFView = {
open: function pdfViewOpen(url, scale, password,
pdfDataRangeTransport, args) {
if (this.pdfDocument) {
this.close();
// Reload the preferences if a document was previously opened.
Preferences.reload();
}
this.close();
var parameters = {password: password};
if (typeof url === 'string') { // URL
@ -3307,6 +3318,10 @@ var PDFView = {
});
}
});
pdfDocument.getAttachments().then(function(attachments) {
self.attachments = new DocumentAttachmentsView(attachments);
document.getElementById('viewAttachments').disabled = !attachments;
});
});
pdfDocument.getMetadata().then(function(data) {
@ -3548,12 +3563,14 @@ var PDFView = {
}
if ('pagemode' in params) {
var toggle = document.getElementById('sidebarToggle');
if (params.pagemode === 'thumbs' || params.pagemode === 'bookmarks') {
if (params.pagemode === 'thumbs' || params.pagemode === 'bookmarks' ||
params.pagemode === 'attachments') {
if (!this.sidebarOpen) {
toggle.click();
}
this.switchSidebarView(params.pagemode === 'thumbs' ?
'thumbs' : 'outline');
this.switchSidebarView(params.pagemode === 'bookmarks' ?
'outline' :
params.pagemode);
} else if (params.pagemode === 'none' && this.sidebarOpen) {
toggle.click();
}
@ -3569,24 +3586,28 @@ var PDFView = {
switchSidebarView: function pdfViewSwitchSidebarView(view) {
var thumbsView = document.getElementById('thumbnailView');
var outlineView = document.getElementById('outlineView');
var attachmentsView = document.getElementById('attachmentsView');
var thumbsButton = document.getElementById('viewThumbnail');
var outlineButton = document.getElementById('viewOutline');
var attachmentsButton = document.getElementById('viewAttachments');
switch (view) {
case 'thumbs':
var wasOutlineViewVisible = thumbsView.classList.contains('hidden');
var wasAnotherViewVisible = thumbsView.classList.contains('hidden');
thumbsButton.classList.add('toggled');
outlineButton.classList.remove('toggled');
attachmentsButton.classList.remove('toggled');
thumbsView.classList.remove('hidden');
outlineView.classList.add('hidden');
attachmentsView.classList.add('hidden');
PDFView.renderHighestPriority();
if (wasOutlineViewVisible) {
if (wasAnotherViewVisible) {
// Ensure that the thumbnail of the current page is visible
// when switching from the outline view.
// when switching from another view.
scrollIntoView(document.getElementById('thumbnailContainer' +
this.page));
}
@ -3595,13 +3616,28 @@ var PDFView = {
case 'outline':
thumbsButton.classList.remove('toggled');
outlineButton.classList.add('toggled');
attachmentsButton.classList.remove('toggled');
thumbsView.classList.add('hidden');
outlineView.classList.remove('hidden');
attachmentsView.classList.add('hidden');
if (outlineButton.getAttribute('disabled')) {
return;
}
break;
case 'attachments':
thumbsButton.classList.remove('toggled');
outlineButton.classList.remove('toggled');
attachmentsButton.classList.add('toggled');
thumbsView.classList.add('hidden');
outlineView.classList.add('hidden');
attachmentsView.classList.remove('hidden');
if (attachmentsButton.getAttribute('disabled')) {
return;
}
break;
}
},
@ -3673,7 +3709,7 @@ var PDFView = {
parseQueryString: function pdfViewParseQueryString(query) {
var parts = query.split('&');
var params = {};
for (var i = 0, ii = parts.length; i < parts.length; ++i) {
for (var i = 0, ii = parts.length; i < ii; ++i) {
var param = parts[i].split('=');
var key = param[0];
var value = param.length > 1 ? param[1] : null;
@ -3864,7 +3900,7 @@ var PageView = function pageView(container, id, scale,
}
};
this.reset = function pageViewReset() {
this.reset = function pageViewReset(keepAnnotations) {
if (this.renderTask) {
this.renderTask.cancel();
}
@ -3877,14 +3913,23 @@ var PageView = function pageView(container, id, scale,
var childNodes = div.childNodes;
for (var i = div.childNodes.length - 1; i >= 0; i--) {
var node = childNodes[i];
if (this.zoomLayer && this.zoomLayer === node) {
if ((this.zoomLayer && this.zoomLayer === node) ||
(keepAnnotations && this.annotationLayer === node)) {
continue;
}
div.removeChild(node);
}
div.removeAttribute('data-loaded');
this.annotationLayer = null;
if (keepAnnotations) {
if (this.annotationLayer) {
// Hide annotationLayer until all elements are resized
// so they are not displayed on the already-resized page
this.annotationLayer.setAttribute('hidden', 'true');
}
} else {
this.annotationLayer = null;
}
delete this.canvas;
@ -3916,7 +3961,7 @@ var PageView = function pageView(container, id, scale,
if (this.zoomLayer) {
this.cssTransform(this.zoomLayer.firstChild);
}
this.reset();
this.reset(true);
};
this.cssTransform = function pageCssTransform(canvas) {
@ -4065,60 +4110,73 @@ var PageView = function pageView(container, id, scale,
}
pdfPage.getAnnotations().then(function(annotationsData) {
if (self.annotationLayer) {
// If an annotationLayer already exists, delete it to avoid creating
// duplicate annotations when rapidly re-zooming the document.
pageDiv.removeChild(self.annotationLayer);
self.annotationLayer = null;
}
viewport = viewport.clone({ dontFlip: true });
for (var i = 0; i < annotationsData.length; i++) {
var data = annotationsData[i];
var annotation = PDFJS.Annotation.fromData(data);
if (!annotation || !annotation.hasHtml()) {
continue;
}
var transform = viewport.transform;
var transformStr = 'matrix(' + transform.join(',') + ')';
var data, element, i, ii;
var element = annotation.getHtmlElement(pdfPage.commonObjs);
mozL10n.translate(element);
data = annotation.getData();
var rect = data.rect;
var view = pdfPage.view;
rect = PDFJS.Util.normalizeRect([
rect[0],
view[3] - rect[1] + view[1],
rect[2],
view[3] - rect[3] + view[1]
]);
element.style.left = rect[0] + 'px';
element.style.top = rect[1] + 'px';
element.style.position = 'absolute';
var transform = viewport.transform;
var transformStr = 'matrix(' + transform.join(',') + ')';
CustomStyle.setProp('transform', element, transformStr);
var transformOriginStr = -rect[0] + 'px ' + -rect[1] + 'px';
CustomStyle.setProp('transformOrigin', element, transformOriginStr);
if (data.subtype === 'Link' && !data.url) {
var link = element.getElementsByTagName('a')[0];
if (link) {
if (data.action) {
bindNamedAction(link, data.action);
} else {
bindLink(link, ('dest' in data) ? data.dest : null);
}
if (self.annotationLayer) {
// If an annotationLayer already exists, refresh its children's
// transformation matrices
for (i = 0, ii = annotationsData.length; i < ii; i++) {
data = annotationsData[i];
element = self.annotationLayer.querySelector(
'[data-annotation-id="' + data.id + '"]');
if (element) {
CustomStyle.setProp('transform', element, transformStr);
}
}
// See this.reset()
self.annotationLayer.removeAttribute('hidden');
} else {
for (i = 0, ii = annotationsData.length; i < ii; i++) {
data = annotationsData[i];
var annotation = PDFJS.Annotation.fromData(data);
if (!annotation || !annotation.hasHtml()) {
continue;
}
if (!self.annotationLayer) {
var annotationLayerDiv = document.createElement('div');
annotationLayerDiv.className = 'annotationLayer';
pageDiv.appendChild(annotationLayerDiv);
self.annotationLayer = annotationLayerDiv;
element = annotation.getHtmlElement(pdfPage.commonObjs);
element.setAttribute('data-annotation-id', data.id);
mozL10n.translate(element);
data = annotation.getData();
var rect = data.rect;
var view = pdfPage.view;
rect = PDFJS.Util.normalizeRect([
rect[0],
view[3] - rect[1] + view[1],
rect[2],
view[3] - rect[3] + view[1]
]);
element.style.left = rect[0] + 'px';
element.style.top = rect[1] + 'px';
element.style.position = 'absolute';
CustomStyle.setProp('transform', element, transformStr);
var transformOriginStr = -rect[0] + 'px ' + -rect[1] + 'px';
CustomStyle.setProp('transformOrigin', element, transformOriginStr);
if (data.subtype === 'Link' && !data.url) {
var link = element.getElementsByTagName('a')[0];
if (link) {
if (data.action) {
bindNamedAction(link, data.action);
} else {
bindLink(link, ('dest' in data) ? data.dest : null);
}
}
}
if (!self.annotationLayer) {
var annotationLayerDiv = document.createElement('div');
annotationLayerDiv.className = 'annotationLayer';
pageDiv.appendChild(annotationLayerDiv);
self.annotationLayer = annotationLayerDiv;
}
self.annotationLayer.appendChild(element);
}
self.annotationLayer.appendChild(element);
}
});
}
@ -4254,10 +4312,14 @@ var PageView = function pageView(container, id, scale,
var canvas = document.createElement('canvas');
canvas.id = 'page' + this.id;
canvasWrapper.appendChild(canvas);
div.appendChild(canvasWrapper);
if (this.annotationLayer) {
// annotationLayer needs to stay on top
div.insertBefore(canvasWrapper, this.annotationLayer);
} else {
div.appendChild(canvasWrapper);
}
this.canvas = canvas;
var scale = this.scale;
var ctx = canvas.getContext('2d');
var outputScale = getOutputScale(ctx);
@ -4283,7 +4345,12 @@ var PageView = function pageView(container, id, scale,
textLayerDiv.className = 'textLayer';
textLayerDiv.style.width = canvas.style.width;
textLayerDiv.style.height = canvas.style.height;
div.appendChild(textLayerDiv);
if (this.annotationLayer) {
// annotationLayer needs to stay on top
div.insertBefore(textLayerDiv, this.annotationLayer);
} else {
div.appendChild(textLayerDiv);
}
}
var textLayer = this.textLayer =
textLayerDiv ? new TextLayerBuilder({
@ -4425,7 +4492,6 @@ var PageView = function pageView(container, id, scale,
canvasWrapper.appendChild(canvas);
printContainer.appendChild(canvasWrapper);
var self = this;
canvas.mozPrintCallback = function(obj) {
var ctx = obj.context;
@ -4794,9 +4860,6 @@ var TextLayerBuilder = function textLayerBuilder(options) {
var queryLen = (PDFFindController === null ?
0 : PDFFindController.state.query.length);
var lastDivIdx = -1;
var pos;
var ret = [];
// Loop over all the matches.
@ -4987,7 +5050,6 @@ var TextLayerBuilder = function textLayerBuilder(options) {
var DocumentOutlineView = function documentOutlineView(outline) {
var outlineView = document.getElementById('outlineView');
var outlineButton = document.getElementById('viewOutline');
while (outlineView.firstChild) {
outlineView.removeChild(outlineView.firstChild);
}
@ -5033,6 +5095,44 @@ var DocumentOutlineView = function documentOutlineView(outline) {
}
};
var DocumentAttachmentsView = function documentAttachmentsView(attachments) {
var attachmentsView = document.getElementById('attachmentsView');
while (attachmentsView.firstChild) {
attachmentsView.removeChild(attachmentsView.firstChild);
}
if (!attachments) {
if (!attachmentsView.classList.contains('hidden')) {
PDFView.switchSidebarView('thumbs');
}
return;
}
function bindItemLink(domObj, item) {
domObj.href = '#';
domObj.onclick = function documentAttachmentsViewOnclick(e) {
var downloadManager = new DownloadManager();
downloadManager.downloadData(item.content, getFileName(item.filename),
'');
return false;
};
}
var names = Object.keys(attachments).sort(function(a,b) {
return a.toLowerCase().localeCompare(b.toLowerCase());
});
for (var i = 0, ii = names.length; i < ii; i++) {
var item = attachments[names[i]];
var div = document.createElement('div');
div.className = 'attachmentsItem';
var a = document.createElement('a');
bindItemLink(a, item);
a.textContent = getFileName(item.filename);
div.appendChild(a);
attachmentsView.appendChild(div);
}
};
function webViewerLoad(evt) {
PDFView.initialize().then(webViewerInitialized);
@ -5166,6 +5266,11 @@ function webViewerInitialized() {
PDFView.switchSidebarView('outline');
});
document.getElementById('viewAttachments').addEventListener('click',
function() {
PDFView.switchSidebarView('attachments');
});
document.getElementById('previous').addEventListener('click',
function() {
PDFView.page--;

View File

@ -89,6 +89,8 @@ toggle_sidebar.title=Toggle Sidebar
toggle_sidebar_label=Toggle Sidebar
outline.title=Show Document Outline
outline_label=Document Outline
attachments.title=Show Attachments
attachments_label=Attachments
thumbs.title=Show Thumbnails
thumbs_label=Thumbnails
findbar.title=Find in Document