mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-13 05:15:45 +00:00
Bug 1188344 - Update pdf.js to version 1.1.366. r=bdahl
This commit is contained in:
parent
4e4a1d7346
commit
c09e5e4fd0
@ -1,3 +1,3 @@
|
||||
This is the pdf.js project output, https://github.com/mozilla/pdf.js
|
||||
|
||||
Current extension version is: 1.1.270
|
||||
Current extension version is: 1.1.366
|
||||
|
@ -22,33 +22,14 @@ if (typeof PDFJS === 'undefined') {
|
||||
(typeof window !== 'undefined' ? window : this).PDFJS = {};
|
||||
}
|
||||
|
||||
PDFJS.version = '1.1.270';
|
||||
PDFJS.build = 'ccfafea';
|
||||
PDFJS.version = '1.1.366';
|
||||
PDFJS.build = '9e9df56';
|
||||
|
||||
(function pdfjsWrapper() {
|
||||
// Use strict in our context only - users might not want it
|
||||
'use strict';
|
||||
|
||||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
||||
/* 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.
|
||||
*/
|
||||
/* globals Cmd, ColorSpace, Dict, MozBlobBuilder, Name, PDFJS, Ref, URL,
|
||||
Promise */
|
||||
|
||||
'use strict';
|
||||
|
||||
var globalScope = (typeof window === 'undefined') ? this : window;
|
||||
|
||||
@ -1969,13 +1950,10 @@ var PDFPageProxy = (function PDFPageProxyClosure() {
|
||||
* annotation objects.
|
||||
*/
|
||||
getAnnotations: function PDFPageProxy_getAnnotations() {
|
||||
if (this.annotationsPromise) {
|
||||
return this.annotationsPromise;
|
||||
if (!this.annotationsPromise) {
|
||||
this.annotationsPromise = this.transport.getAnnotations(this.pageIndex);
|
||||
}
|
||||
|
||||
var promise = this.transport.getAnnotations(this.pageIndex);
|
||||
this.annotationsPromise = promise;
|
||||
return promise;
|
||||
return this.annotationsPromise;
|
||||
},
|
||||
/**
|
||||
* Begins the process of rendering a page to the desired context.
|
||||
@ -6085,7 +6063,7 @@ var AnnotationUtils = (function AnnotationUtilsClosure() {
|
||||
style.fontFamily = fontFamily + fallbackName;
|
||||
}
|
||||
|
||||
function initContainer(item, drawBorder) {
|
||||
function initContainer(item) {
|
||||
var container = document.createElement('section');
|
||||
var cstyle = container.style;
|
||||
var width = item.rect[2] - item.rect[0];
|
||||
@ -6140,12 +6118,12 @@ var AnnotationUtils = (function AnnotationUtilsClosure() {
|
||||
// Border color
|
||||
if (item.color) {
|
||||
container.style.borderColor =
|
||||
Util.makeCssRgb(Math.round(item.color[0] * 255),
|
||||
Math.round(item.color[1] * 255),
|
||||
Math.round(item.color[2] * 255));
|
||||
Util.makeCssRgb(item.color[0] | 0,
|
||||
item.color[1] | 0,
|
||||
item.color[2] | 0);
|
||||
} else {
|
||||
// Default color is black, but that's not obvious from the spec.
|
||||
container.style.borderColor = 'rgb(0,0,0)';
|
||||
// Transparent (invisible) border, so do not draw it at all.
|
||||
container.style.borderWidth = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -6189,7 +6167,7 @@ var AnnotationUtils = (function AnnotationUtilsClosure() {
|
||||
rect[2] = rect[0] + (rect[3] - rect[1]); // make it square
|
||||
}
|
||||
|
||||
var container = initContainer(item, false);
|
||||
var container = initContainer(item);
|
||||
container.className = 'annotText';
|
||||
|
||||
var image = document.createElement('img');
|
||||
@ -6212,17 +6190,15 @@ var AnnotationUtils = (function AnnotationUtilsClosure() {
|
||||
content.setAttribute('hidden', true);
|
||||
|
||||
var i, ii;
|
||||
if (item.hasBgColor) {
|
||||
if (item.hasBgColor && item.color) {
|
||||
var color = item.color;
|
||||
|
||||
// Enlighten the color (70%)
|
||||
var BACKGROUND_ENLIGHT = 0.7;
|
||||
var r = BACKGROUND_ENLIGHT * (1.0 - color[0]) + color[0];
|
||||
var g = BACKGROUND_ENLIGHT * (1.0 - color[1]) + color[1];
|
||||
var b = BACKGROUND_ENLIGHT * (1.0 - color[2]) + color[2];
|
||||
content.style.backgroundColor = Util.makeCssRgb((r * 255) | 0,
|
||||
(g * 255) | 0,
|
||||
(b * 255) | 0);
|
||||
var r = BACKGROUND_ENLIGHT * (255 - color[0]) + color[0];
|
||||
var g = BACKGROUND_ENLIGHT * (255 - color[1]) + color[1];
|
||||
var b = BACKGROUND_ENLIGHT * (255 - color[2]) + color[2];
|
||||
content.style.backgroundColor = Util.makeCssRgb(r | 0, g | 0, b | 0);
|
||||
}
|
||||
|
||||
var title = document.createElement('h1');
|
||||
@ -6298,7 +6274,7 @@ var AnnotationUtils = (function AnnotationUtilsClosure() {
|
||||
}
|
||||
|
||||
function getHtmlElementForLinkAnnotation(item) {
|
||||
var container = initContainer(item, true);
|
||||
var container = initContainer(item);
|
||||
container.className = 'annotLink';
|
||||
|
||||
var link = document.createElement('a');
|
||||
|
558
browser/extensions/pdfjs/content/build/pdf.worker.js
vendored
558
browser/extensions/pdfjs/content/build/pdf.worker.js
vendored
@ -22,33 +22,14 @@ if (typeof PDFJS === 'undefined') {
|
||||
(typeof window !== 'undefined' ? window : this).PDFJS = {};
|
||||
}
|
||||
|
||||
PDFJS.version = '1.1.270';
|
||||
PDFJS.build = 'ccfafea';
|
||||
PDFJS.version = '1.1.366';
|
||||
PDFJS.build = '9e9df56';
|
||||
|
||||
(function pdfjsWrapper() {
|
||||
// Use strict in our context only - users might not want it
|
||||
'use strict';
|
||||
|
||||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
||||
/* 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.
|
||||
*/
|
||||
/* globals Cmd, ColorSpace, Dict, MozBlobBuilder, Name, PDFJS, Ref, URL,
|
||||
Promise */
|
||||
|
||||
'use strict';
|
||||
|
||||
var globalScope = (typeof window === 'undefined') ? this : window;
|
||||
|
||||
@ -1416,14 +1397,9 @@ var ChunkedStream = (function ChunkedStreamClosure() {
|
||||
},
|
||||
|
||||
nextEmptyChunk: function ChunkedStream_nextEmptyChunk(beginChunk) {
|
||||
var chunk, n;
|
||||
for (chunk = beginChunk, n = this.numChunks; chunk < n; ++chunk) {
|
||||
if (!this.loadedChunks[chunk]) {
|
||||
return chunk;
|
||||
}
|
||||
}
|
||||
// Wrap around to beginning
|
||||
for (chunk = 0; chunk < beginChunk; ++chunk) {
|
||||
var chunk, numChunks = this.numChunks;
|
||||
for (var i = 0; i < numChunks; ++i) {
|
||||
chunk = (beginChunk + i) % numChunks; // Wrap around to beginning
|
||||
if (!this.loadedChunks[chunk]) {
|
||||
return chunk;
|
||||
}
|
||||
@ -1700,7 +1676,7 @@ var ChunkedStreamManager = (function ChunkedStreamManagerClosure() {
|
||||
this.requestChunks(chunksToRequest, callback);
|
||||
},
|
||||
|
||||
// Groups a sorted array of chunks into as few continguous larger
|
||||
// Groups a sorted array of chunks into as few contiguous larger
|
||||
// chunks as possible
|
||||
groupChunks: function ChunkedStreamManager_groupChunks(chunks) {
|
||||
var groupedChunks = [];
|
||||
@ -1825,15 +1801,6 @@ var ChunkedStreamManager = (function ChunkedStreamManagerClosure() {
|
||||
},
|
||||
|
||||
getEndChunk: function ChunkedStreamManager_getEndChunk(end) {
|
||||
if (end % this.chunkSize === 0) {
|
||||
return end / this.chunkSize;
|
||||
}
|
||||
|
||||
// 0 -> 0
|
||||
// 1 -> 1
|
||||
// 99 -> 1
|
||||
// 100 -> 1
|
||||
// 101 -> 2
|
||||
var chunk = Math.floor((end - 1) / this.chunkSize) + 1;
|
||||
return chunk;
|
||||
}
|
||||
@ -2137,11 +2104,6 @@ var Page = (function PageClosure() {
|
||||
return shadow(this, 'view', cropBox);
|
||||
},
|
||||
|
||||
get annotationRefs() {
|
||||
return shadow(this, 'annotationRefs',
|
||||
this.getInheritedPageProp('Annots'));
|
||||
},
|
||||
|
||||
get rotate() {
|
||||
var rotate = this.getInheritedPageProp('Rotate') || 0;
|
||||
// Normalize rotation so it's a multiple of 90 and between 0 and 270
|
||||
@ -2287,18 +2249,20 @@ var Page = (function PageClosure() {
|
||||
var annotations = this.annotations;
|
||||
var annotationsData = [];
|
||||
for (var i = 0, n = annotations.length; i < n; ++i) {
|
||||
annotationsData.push(annotations[i].getData());
|
||||
annotationsData.push(annotations[i].data);
|
||||
}
|
||||
return annotationsData;
|
||||
},
|
||||
|
||||
get annotations() {
|
||||
var annotations = [];
|
||||
var annotationRefs = (this.annotationRefs || []);
|
||||
var annotationRefs = this.getInheritedPageProp('Annots') || [];
|
||||
var annotationFactory = new AnnotationFactory();
|
||||
for (var i = 0, n = annotationRefs.length; i < n; ++i) {
|
||||
var annotationRef = annotationRefs[i];
|
||||
var annotation = Annotation.fromRef(this.xref, annotationRef);
|
||||
if (annotation) {
|
||||
var annotation = annotationFactory.create(this.xref, annotationRef);
|
||||
if (annotation &&
|
||||
(annotation.isViewable() || annotation.isPrintable())) {
|
||||
annotations.push(annotation);
|
||||
}
|
||||
}
|
||||
@ -3037,7 +3001,7 @@ var Catalog = (function CatalogClosure() {
|
||||
}
|
||||
|
||||
var xref = this.xref;
|
||||
var dest, nameTreeRef, nameDictionaryRef;
|
||||
var dest = null, nameTreeRef, nameDictionaryRef;
|
||||
var obj = this.catDict.get('Names');
|
||||
if (obj && obj.has('Dests')) {
|
||||
nameTreeRef = obj.getRaw('Dests');
|
||||
@ -3045,17 +3009,11 @@ var Catalog = (function CatalogClosure() {
|
||||
nameDictionaryRef = this.catDict.get('Dests');
|
||||
}
|
||||
|
||||
if (nameDictionaryRef) {
|
||||
// reading simple destination dictionary
|
||||
obj = nameDictionaryRef;
|
||||
obj.forEach(function catalogForEach(key, value) {
|
||||
if (!value) {
|
||||
return;
|
||||
}
|
||||
if (key === destinationId) {
|
||||
dest = fetchDestination(value);
|
||||
}
|
||||
});
|
||||
if (nameDictionaryRef) { // Simple destination dictionary.
|
||||
var value = nameDictionaryRef.get(destinationId);
|
||||
if (value) {
|
||||
dest = fetchDestination(value);
|
||||
}
|
||||
}
|
||||
if (nameTreeRef) {
|
||||
var nameTree = new NameTree(nameTreeRef, xref);
|
||||
@ -3092,6 +3050,19 @@ var Catalog = (function CatalogClosure() {
|
||||
var obj = this.catDict.get('Names');
|
||||
|
||||
var javaScript = [];
|
||||
function appendIfJavaScriptDict(jsDict) {
|
||||
var type = jsDict.get('S');
|
||||
if (!isName(type) || type.name !== 'JavaScript') {
|
||||
return;
|
||||
}
|
||||
var js = jsDict.get('JS');
|
||||
if (isStream(js)) {
|
||||
js = bytesToString(js.getBytes());
|
||||
} else if (!isString(js)) {
|
||||
return;
|
||||
}
|
||||
javaScript.push(stringToPDFString(js));
|
||||
}
|
||||
if (obj && obj.has('JavaScript')) {
|
||||
var nameTree = new NameTree(obj.getRaw('JavaScript'), xref);
|
||||
var names = nameTree.getAll();
|
||||
@ -3102,36 +3073,25 @@ var Catalog = (function CatalogClosure() {
|
||||
// We don't really use the JavaScript right now. This code is
|
||||
// defensive so we don't cause errors on document load.
|
||||
var jsDict = names[name];
|
||||
if (!isDict(jsDict)) {
|
||||
continue;
|
||||
if (isDict(jsDict)) {
|
||||
appendIfJavaScriptDict(jsDict);
|
||||
}
|
||||
var type = jsDict.get('S');
|
||||
if (!isName(type) || type.name !== 'JavaScript') {
|
||||
continue;
|
||||
}
|
||||
var js = jsDict.get('JS');
|
||||
if (!isString(js) && !isStream(js)) {
|
||||
continue;
|
||||
}
|
||||
if (isStream(js)) {
|
||||
js = bytesToString(js.getBytes());
|
||||
}
|
||||
javaScript.push(stringToPDFString(js));
|
||||
}
|
||||
}
|
||||
|
||||
// Append OpenAction actions to javaScript array
|
||||
var openactionDict = this.catDict.get('OpenAction');
|
||||
if (isDict(openactionDict)) {
|
||||
var objType = openactionDict.get('Type');
|
||||
if (isDict(openactionDict, 'Action')) {
|
||||
var actionType = openactionDict.get('S');
|
||||
var action = openactionDict.get('N');
|
||||
var isPrintAction = (isName(objType) && objType.name === 'Action' &&
|
||||
isName(actionType) && actionType.name === 'Named' &&
|
||||
isName(action) && action.name === 'Print');
|
||||
|
||||
if (isPrintAction) {
|
||||
javaScript.push('print(true);');
|
||||
if (isName(actionType) && actionType.name === 'Named') {
|
||||
// The named Print action is not a part of the PDF 1.7 specification,
|
||||
// but is supported by many PDF readers/writers (including Adobe's).
|
||||
var action = openactionDict.get('N');
|
||||
if (isName(action) && action.name === 'Print') {
|
||||
javaScript.push('print({});');
|
||||
}
|
||||
} else {
|
||||
appendIfJavaScriptDict(openactionDict);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3633,7 +3593,7 @@ var XRef = (function XRefClosure() {
|
||||
} else if ((m = /^(\d+)\s+(\d+)\s+obj\b/.exec(token))) {
|
||||
if (typeof this.entries[m[1]] === 'undefined') {
|
||||
this.entries[m[1]] = {
|
||||
offset: position,
|
||||
offset: position - stream.start,
|
||||
gen: m[2] | 0,
|
||||
uncompressed: true
|
||||
};
|
||||
@ -3646,8 +3606,8 @@ var XRef = (function XRefClosure() {
|
||||
var xrefTagOffset = skipUntil(content, 0, xrefBytes);
|
||||
if (xrefTagOffset < contentLength &&
|
||||
content[xrefTagOffset + 5] < 64) {
|
||||
xrefStms.push(position);
|
||||
this.xrefstms[position] = 1; // don't read it recursively
|
||||
xrefStms.push(position - stream.start);
|
||||
this.xrefstms[position - stream.start] = 1; // Avoid recursion
|
||||
}
|
||||
|
||||
position += contentLength;
|
||||
@ -3966,7 +3926,7 @@ var NameTree = (function NameTreeClosure() {
|
||||
var names = obj.get('Names');
|
||||
if (names) {
|
||||
for (i = 0, n = names.length; i < n; i += 2) {
|
||||
dict[names[i]] = xref.fetchIfRef(names[i + 1]);
|
||||
dict[xref.fetchIfRef(names[i])] = xref.fetchIfRef(names[i + 1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -4005,9 +3965,9 @@ var NameTree = (function NameTreeClosure() {
|
||||
var kid = xref.fetchIfRef(kids[m]);
|
||||
var limits = kid.get('Limits');
|
||||
|
||||
if (destinationId < limits[0]) {
|
||||
if (destinationId < xref.fetchIfRef(limits[0])) {
|
||||
r = m - 1;
|
||||
} else if (destinationId > limits[1]) {
|
||||
} else if (destinationId > xref.fetchIfRef(limits[1])) {
|
||||
l = m + 1;
|
||||
} else {
|
||||
kidsOrNames = xref.fetchIfRef(kids[m]);
|
||||
@ -4031,9 +3991,9 @@ var NameTree = (function NameTreeClosure() {
|
||||
// Check only even indices (0, 2, 4, ...) because the
|
||||
// odd indices contain the actual D array.
|
||||
m = (l + r) & ~1;
|
||||
if (destinationId < names[m]) {
|
||||
if (destinationId < xref.fetchIfRef(names[m])) {
|
||||
r = m - 2;
|
||||
} else if (destinationId > names[m]) {
|
||||
} else if (destinationId > xref.fetchIfRef(names[m])) {
|
||||
l = m + 2;
|
||||
} else {
|
||||
return xref.fetchIfRef(names[m + 1]);
|
||||
@ -4381,7 +4341,54 @@ var ExpertSubsetCharset = [
|
||||
|
||||
|
||||
var DEFAULT_ICON_SIZE = 22; // px
|
||||
var SUPPORTED_TYPES = ['Link', 'Text', 'Widget'];
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function AnnotationFactory() {}
|
||||
AnnotationFactory.prototype = {
|
||||
/**
|
||||
* @param {XRef} xref
|
||||
* @param {Object} ref
|
||||
* @returns {Annotation}
|
||||
*/
|
||||
create: function AnnotationFactory_create(xref, ref) {
|
||||
var dict = xref.fetchIfRef(ref);
|
||||
if (!isDict(dict)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Determine the annotation's subtype.
|
||||
var subtype = dict.get('Subtype');
|
||||
subtype = isName(subtype) ? subtype.name : '';
|
||||
|
||||
// Return the right annotation object based on the subtype and field type.
|
||||
var parameters = {
|
||||
dict: dict,
|
||||
ref: ref
|
||||
};
|
||||
|
||||
switch (subtype) {
|
||||
case 'Link':
|
||||
return new LinkAnnotation(parameters);
|
||||
|
||||
case 'Text':
|
||||
return new TextAnnotation(parameters);
|
||||
|
||||
case 'Widget':
|
||||
var fieldType = Util.getInheritableProperty(dict, 'FT');
|
||||
if (isName(fieldType) && fieldType.name === 'Tx') {
|
||||
return new TextWidgetAnnotation(parameters);
|
||||
}
|
||||
return new WidgetAnnotation(parameters);
|
||||
|
||||
default:
|
||||
warn('Unimplemented annotation type "' + subtype + '", ' +
|
||||
'falling back to base annotation');
|
||||
return new Annotation(parameters);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var Annotation = (function AnnotationClosure() {
|
||||
// 12.5.5: Algorithm: Appearance streams
|
||||
@ -4434,32 +4441,13 @@ var Annotation = (function AnnotationClosure() {
|
||||
var data = this.data = {};
|
||||
|
||||
data.subtype = dict.get('Subtype').name;
|
||||
var rect = dict.get('Rect') || [0, 0, 0, 0];
|
||||
data.rect = Util.normalizeRect(rect);
|
||||
data.annotationFlags = dict.get('F');
|
||||
|
||||
var color = dict.get('C');
|
||||
if (!color) {
|
||||
// The PDF spec does not mention how a missing color array is interpreted.
|
||||
// Adobe Reader seems to default to black in this case.
|
||||
data.color = [0, 0, 0];
|
||||
} else if (isArray(color)) {
|
||||
switch (color.length) {
|
||||
case 0:
|
||||
// Empty array denotes transparent border.
|
||||
data.color = null;
|
||||
break;
|
||||
case 1:
|
||||
// TODO: implement DeviceGray
|
||||
break;
|
||||
case 3:
|
||||
data.color = color;
|
||||
break;
|
||||
case 4:
|
||||
// TODO: implement DeviceCMYK
|
||||
break;
|
||||
}
|
||||
}
|
||||
this.setRectangle(dict.get('Rect'));
|
||||
data.rect = this.rectangle;
|
||||
|
||||
this.setColor(dict.get('C'));
|
||||
data.color = this.color;
|
||||
|
||||
this.borderStyle = data.borderStyle = new AnnotationBorderStyle();
|
||||
this.setBorderStyle(dict);
|
||||
@ -4470,6 +4458,63 @@ var Annotation = (function AnnotationClosure() {
|
||||
}
|
||||
|
||||
Annotation.prototype = {
|
||||
/**
|
||||
* Set the rectangle.
|
||||
*
|
||||
* @public
|
||||
* @memberof Annotation
|
||||
* @param {Array} rectangle - The rectangle array with exactly four entries
|
||||
*/
|
||||
setRectangle: function Annotation_setRectangle(rectangle) {
|
||||
if (isArray(rectangle) && rectangle.length === 4) {
|
||||
this.rectangle = Util.normalizeRect(rectangle);
|
||||
} else {
|
||||
this.rectangle = [0, 0, 0, 0];
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Set the color and take care of color space conversion.
|
||||
*
|
||||
* @public
|
||||
* @memberof Annotation
|
||||
* @param {Array} color - The color array containing either 0
|
||||
* (transparent), 1 (grayscale), 3 (RGB) or
|
||||
* 4 (CMYK) elements
|
||||
*/
|
||||
setColor: function Annotation_setColor(color) {
|
||||
var rgbColor = new Uint8Array(3); // Black in RGB color space (default)
|
||||
if (!isArray(color)) {
|
||||
this.color = rgbColor;
|
||||
return;
|
||||
}
|
||||
|
||||
switch (color.length) {
|
||||
case 0: // Transparent, which we indicate with a null value
|
||||
this.color = null;
|
||||
break;
|
||||
|
||||
case 1: // Convert grayscale to RGB
|
||||
ColorSpace.singletons.gray.getRgbItem(color, 0, rgbColor, 0);
|
||||
this.color = rgbColor;
|
||||
break;
|
||||
|
||||
case 3: // Convert RGB percentages to RGB
|
||||
ColorSpace.singletons.rgb.getRgbItem(color, 0, rgbColor, 0);
|
||||
this.color = rgbColor;
|
||||
break;
|
||||
|
||||
case 4: // Convert CMYK to RGB
|
||||
ColorSpace.singletons.cmyk.getRgbItem(color, 0, rgbColor, 0);
|
||||
this.color = rgbColor;
|
||||
break;
|
||||
|
||||
default:
|
||||
this.color = rgbColor;
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Set the border style (as AnnotationBorderStyle object).
|
||||
*
|
||||
@ -4497,7 +4542,6 @@ var Annotation = (function AnnotationClosure() {
|
||||
this.borderStyle.setHorizontalCornerRadius(array[0]);
|
||||
this.borderStyle.setVerticalCornerRadius(array[1]);
|
||||
this.borderStyle.setWidth(array[2]);
|
||||
this.borderStyle.setStyle('S');
|
||||
|
||||
if (array.length === 4) { // Dash array available
|
||||
this.borderStyle.setDashArray(array[3]);
|
||||
@ -4513,19 +4557,11 @@ var Annotation = (function AnnotationClosure() {
|
||||
}
|
||||
},
|
||||
|
||||
getData: function Annotation_getData() {
|
||||
return this.data;
|
||||
},
|
||||
|
||||
isInvisible: function Annotation_isInvisible() {
|
||||
var data = this.data;
|
||||
if (data && SUPPORTED_TYPES.indexOf(data.subtype) !== -1) {
|
||||
return false;
|
||||
} else {
|
||||
return !!(data &&
|
||||
data.annotationFlags && // Default: not invisible
|
||||
data.annotationFlags & 0x1); // Invisible
|
||||
}
|
||||
return !!(data &&
|
||||
data.annotationFlags && // Default: not invisible
|
||||
data.annotationFlags & 0x1); // Invisible
|
||||
},
|
||||
|
||||
isViewable: function Annotation_isViewable() {
|
||||
@ -4601,70 +4637,6 @@ var Annotation = (function AnnotationClosure() {
|
||||
}
|
||||
};
|
||||
|
||||
Annotation.getConstructor =
|
||||
function Annotation_getConstructor(subtype, fieldType) {
|
||||
|
||||
if (!subtype) {
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO(mack): Implement FreeText annotations
|
||||
if (subtype === 'Link') {
|
||||
return LinkAnnotation;
|
||||
} else if (subtype === 'Text') {
|
||||
return TextAnnotation;
|
||||
} else if (subtype === 'Widget') {
|
||||
if (!fieldType) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (fieldType === 'Tx') {
|
||||
return TextWidgetAnnotation;
|
||||
} else {
|
||||
return WidgetAnnotation;
|
||||
}
|
||||
} else {
|
||||
return Annotation;
|
||||
}
|
||||
};
|
||||
|
||||
Annotation.fromRef = function Annotation_fromRef(xref, ref) {
|
||||
|
||||
var dict = xref.fetchIfRef(ref);
|
||||
if (!isDict(dict)) {
|
||||
return;
|
||||
}
|
||||
|
||||
var subtype = dict.get('Subtype');
|
||||
subtype = isName(subtype) ? subtype.name : '';
|
||||
if (!subtype) {
|
||||
return;
|
||||
}
|
||||
|
||||
var fieldType = Util.getInheritableProperty(dict, 'FT');
|
||||
fieldType = isName(fieldType) ? fieldType.name : '';
|
||||
|
||||
var Constructor = Annotation.getConstructor(subtype, fieldType);
|
||||
if (!Constructor) {
|
||||
return;
|
||||
}
|
||||
|
||||
var params = {
|
||||
dict: dict,
|
||||
ref: ref,
|
||||
};
|
||||
|
||||
var annotation = new Constructor(params);
|
||||
|
||||
if (annotation.isViewable() || annotation.isPrintable()) {
|
||||
return annotation;
|
||||
} else {
|
||||
if (SUPPORTED_TYPES.indexOf(subtype) === -1) {
|
||||
warn('unimplemented annotation type: ' + subtype);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Annotation.appendToOperatorList = function Annotation_appendToOperatorList(
|
||||
annotations, opList, pdfManager, partialEvaluator, intent) {
|
||||
|
||||
@ -6493,7 +6465,7 @@ var ColorSpace = (function ColorSpaceClosure() {
|
||||
* @param {Number} n Number of components the color space has.
|
||||
*/
|
||||
ColorSpace.isDefaultDecode = function ColorSpace_isDefaultDecode(decode, n) {
|
||||
if (!decode) {
|
||||
if (!isArray(decode)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -9431,7 +9403,7 @@ var CipherTransformFactory = (function CipherTransformFactoryClosure() {
|
||||
})();
|
||||
|
||||
|
||||
var PatternType = {
|
||||
var ShadingType = {
|
||||
FUNCTION_BASED: 1,
|
||||
AXIAL: 2,
|
||||
RADIAL: 3,
|
||||
@ -9463,17 +9435,17 @@ var Pattern = (function PatternClosure() {
|
||||
|
||||
try {
|
||||
switch (type) {
|
||||
case PatternType.AXIAL:
|
||||
case PatternType.RADIAL:
|
||||
case ShadingType.AXIAL:
|
||||
case ShadingType.RADIAL:
|
||||
// Both radial and axial shadings are handled by RadialAxial shading.
|
||||
return new Shadings.RadialAxial(dict, matrix, xref, res);
|
||||
case PatternType.FREE_FORM_MESH:
|
||||
case PatternType.LATTICE_FORM_MESH:
|
||||
case PatternType.COONS_PATCH_MESH:
|
||||
case PatternType.TENSOR_PATCH_MESH:
|
||||
case ShadingType.FREE_FORM_MESH:
|
||||
case ShadingType.LATTICE_FORM_MESH:
|
||||
case ShadingType.COONS_PATCH_MESH:
|
||||
case ShadingType.TENSOR_PATCH_MESH:
|
||||
return new Shadings.Mesh(shading, matrix, xref, res);
|
||||
default:
|
||||
throw new Error('Unknown PatternType: ' + type);
|
||||
throw new Error('Unsupported ShadingType: ' + type);
|
||||
}
|
||||
} catch (ex) {
|
||||
if (ex instanceof MissingDataException) {
|
||||
@ -9521,7 +9493,7 @@ Shadings.RadialAxial = (function RadialAxialClosure() {
|
||||
extendEnd = extendArr[1];
|
||||
}
|
||||
|
||||
if (this.shadingType === PatternType.RADIAL &&
|
||||
if (this.shadingType === ShadingType.RADIAL &&
|
||||
(!extendStart || !extendEnd)) {
|
||||
// Radial gradient only currently works if either circle is fully within
|
||||
// the other circle.
|
||||
@ -9596,13 +9568,13 @@ Shadings.RadialAxial = (function RadialAxialClosure() {
|
||||
var coordsArr = this.coordsArr;
|
||||
var shadingType = this.shadingType;
|
||||
var type, p0, p1, r0, r1;
|
||||
if (shadingType === PatternType.AXIAL) {
|
||||
if (shadingType === ShadingType.AXIAL) {
|
||||
p0 = [coordsArr[0], coordsArr[1]];
|
||||
p1 = [coordsArr[2], coordsArr[3]];
|
||||
r0 = null;
|
||||
r1 = null;
|
||||
type = 'axial';
|
||||
} else if (shadingType === PatternType.RADIAL) {
|
||||
} else if (shadingType === ShadingType.RADIAL) {
|
||||
p0 = [coordsArr[0], coordsArr[1]];
|
||||
p1 = [coordsArr[3], coordsArr[4]];
|
||||
r0 = coordsArr[2];
|
||||
@ -9636,7 +9608,7 @@ Shadings.Mesh = (function MeshClosure() {
|
||||
|
||||
var numComps = context.numComps;
|
||||
this.tmpCompsBuf = new Float32Array(numComps);
|
||||
var csNumComps = context.colorSpace;
|
||||
var csNumComps = context.colorSpace.numComps;
|
||||
this.tmpCsCompsBuf = context.colorFn ? new Float32Array(csNumComps) :
|
||||
this.tmpCompsBuf;
|
||||
}
|
||||
@ -9756,13 +9728,10 @@ Shadings.Mesh = (function MeshClosure() {
|
||||
|
||||
reader.align();
|
||||
}
|
||||
|
||||
var psPacked = new Int32Array(ps);
|
||||
|
||||
mesh.figures.push({
|
||||
type: 'triangles',
|
||||
coords: psPacked,
|
||||
colors: psPacked
|
||||
coords: new Int32Array(ps),
|
||||
colors: new Int32Array(ps),
|
||||
});
|
||||
}
|
||||
|
||||
@ -9777,13 +9746,10 @@ Shadings.Mesh = (function MeshClosure() {
|
||||
coords.push(coord);
|
||||
colors.push(color);
|
||||
}
|
||||
|
||||
var psPacked = new Int32Array(ps);
|
||||
|
||||
mesh.figures.push({
|
||||
type: 'lattice',
|
||||
coords: psPacked,
|
||||
colors: psPacked,
|
||||
coords: new Int32Array(ps),
|
||||
colors: new Int32Array(ps),
|
||||
verticesPerRow: verticesPerRow
|
||||
});
|
||||
}
|
||||
@ -9925,29 +9891,32 @@ Shadings.Mesh = (function MeshClosure() {
|
||||
break;
|
||||
case 1:
|
||||
tmp1 = ps[12]; tmp2 = ps[13]; tmp3 = ps[14]; tmp4 = ps[15];
|
||||
ps[12] = pi + 5; ps[13] = pi + 4; ps[14] = pi + 3; ps[15] = pi + 2;
|
||||
ps[ 8] = pi + 6; /* values for 5, 6, 9, 10 are */ ps[11] = pi + 1;
|
||||
ps[ 4] = pi + 7; /* calculated below */ ps[ 7] = pi;
|
||||
ps[ 0] = tmp1; ps[ 1] = tmp2; ps[ 2] = tmp3; ps[ 3] = tmp4;
|
||||
ps[12] = tmp4; ps[13] = pi + 0; ps[14] = pi + 1; ps[15] = pi + 2;
|
||||
ps[ 8] = tmp3; /* values for 5, 6, 9, 10 are */ ps[11] = pi + 3;
|
||||
ps[ 4] = tmp2; /* calculated below */ ps[ 7] = pi + 4;
|
||||
ps[ 0] = tmp1; ps[ 1] = pi + 7; ps[ 2] = pi + 6; ps[ 3] = pi + 5;
|
||||
tmp1 = cs[2]; tmp2 = cs[3];
|
||||
cs[2] = ci + 1; cs[3] = ci;
|
||||
cs[0] = tmp1; cs[1] = tmp2;
|
||||
cs[2] = tmp2; cs[3] = ci;
|
||||
cs[0] = tmp1; cs[1] = ci + 1;
|
||||
break;
|
||||
case 2:
|
||||
ps[12] = ps[15]; ps[13] = pi + 7; ps[14] = pi + 6; ps[15] = pi + 5;
|
||||
ps[ 8] = ps[11]; /* values for 5, 6, 9, 10 are */ ps[11] = pi + 4;
|
||||
ps[ 4] = ps[7]; /* calculated below */ ps[ 7] = pi + 3;
|
||||
ps[ 0] = ps[3]; ps[ 1] = pi; ps[ 2] = pi + 1; ps[ 3] = pi + 2;
|
||||
cs[2] = cs[3]; cs[3] = ci + 1;
|
||||
cs[0] = cs[1]; cs[1] = ci;
|
||||
tmp1 = ps[15];
|
||||
tmp2 = ps[11];
|
||||
ps[12] = ps[3]; ps[13] = pi + 0; ps[14] = pi + 1; ps[15] = pi + 2;
|
||||
ps[ 8] = ps[7]; /* values for 5, 6, 9, 10 are */ ps[11] = pi + 3;
|
||||
ps[ 4] = tmp2; /* calculated below */ ps[ 7] = pi + 4;
|
||||
ps[ 0] = tmp1; ps[ 1] = pi + 7; ps[ 2] = pi + 6; ps[ 3] = pi + 5;
|
||||
tmp1 = cs[3];
|
||||
cs[2] = cs[1]; cs[3] = ci;
|
||||
cs[0] = tmp1; cs[1] = ci + 1;
|
||||
break;
|
||||
case 3:
|
||||
ps[12] = ps[0]; ps[13] = ps[1]; ps[14] = ps[2]; ps[15] = ps[3];
|
||||
ps[ 8] = pi; /* values for 5, 6, 9, 10 are */ ps[11] = pi + 7;
|
||||
ps[ 4] = pi + 1; /* calculated below */ ps[ 7] = pi + 6;
|
||||
ps[ 0] = pi + 2; ps[ 1] = pi + 3; ps[ 2] = pi + 4; ps[ 3] = pi + 5;
|
||||
cs[2] = cs[0]; cs[3] = cs[1];
|
||||
cs[0] = ci; cs[1] = ci + 1;
|
||||
ps[12] = ps[0]; ps[13] = pi + 0; ps[14] = pi + 1; ps[15] = pi + 2;
|
||||
ps[ 8] = ps[1]; /* values for 5, 6, 9, 10 are */ ps[11] = pi + 3;
|
||||
ps[ 4] = ps[2]; /* calculated below */ ps[ 7] = pi + 4;
|
||||
ps[ 0] = ps[3]; ps[ 1] = pi + 7; ps[ 2] = pi + 6; ps[ 3] = pi + 5;
|
||||
cs[2] = cs[0]; cs[3] = ci;
|
||||
cs[0] = cs[1]; cs[1] = ci + 1;
|
||||
break;
|
||||
}
|
||||
// set p11, p12, p21, p22
|
||||
@ -10032,29 +10001,32 @@ Shadings.Mesh = (function MeshClosure() {
|
||||
break;
|
||||
case 1:
|
||||
tmp1 = ps[12]; tmp2 = ps[13]; tmp3 = ps[14]; tmp4 = ps[15];
|
||||
ps[12] = pi + 5; ps[13] = pi + 4; ps[14] = pi + 3; ps[15] = pi + 2;
|
||||
ps[ 8] = pi + 6; ps[ 9] = pi + 11; ps[10] = pi + 10; ps[11] = pi + 1;
|
||||
ps[ 4] = pi + 7; ps[ 5] = pi + 8; ps[ 6] = pi + 9; ps[ 7] = pi;
|
||||
ps[ 0] = tmp1; ps[ 1] = tmp2; ps[ 2] = tmp3; ps[ 3] = tmp4;
|
||||
ps[12] = tmp4; ps[13] = pi + 0; ps[14] = pi + 1; ps[15] = pi + 2;
|
||||
ps[ 8] = tmp3; ps[ 9] = pi + 9; ps[10] = pi + 10; ps[11] = pi + 3;
|
||||
ps[ 4] = tmp2; ps[ 5] = pi + 8; ps[ 6] = pi + 11; ps[ 7] = pi + 4;
|
||||
ps[ 0] = tmp1; ps[ 1] = pi + 7; ps[ 2] = pi + 6; ps[ 3] = pi + 5;
|
||||
tmp1 = cs[2]; tmp2 = cs[3];
|
||||
cs[2] = ci + 1; cs[3] = ci;
|
||||
cs[0] = tmp1; cs[1] = tmp2;
|
||||
cs[2] = tmp2; cs[3] = ci;
|
||||
cs[0] = tmp1; cs[1] = ci + 1;
|
||||
break;
|
||||
case 2:
|
||||
ps[12] = ps[15]; ps[13] = pi + 7; ps[14] = pi + 6; ps[15] = pi + 5;
|
||||
ps[ 8] = ps[11]; ps[ 9] = pi + 8; ps[10] = pi + 11; ps[11] = pi + 4;
|
||||
ps[ 4] = ps[7]; ps[ 5] = pi + 9; ps[ 6] = pi + 10; ps[ 7] = pi + 3;
|
||||
ps[ 0] = ps[3]; ps[ 1] = pi; ps[ 2] = pi + 1; ps[ 3] = pi + 2;
|
||||
cs[2] = cs[3]; cs[3] = ci + 1;
|
||||
cs[0] = cs[1]; cs[1] = ci;
|
||||
tmp1 = ps[15];
|
||||
tmp2 = ps[11];
|
||||
ps[12] = ps[3]; ps[13] = pi + 0; ps[14] = pi + 1; ps[15] = pi + 2;
|
||||
ps[ 8] = ps[7]; ps[ 9] = pi + 9; ps[10] = pi + 10; ps[11] = pi + 3;
|
||||
ps[ 4] = tmp2; ps[ 5] = pi + 8; ps[ 6] = pi + 11; ps[ 7] = pi + 4;
|
||||
ps[ 0] = tmp1; ps[ 1] = pi + 7; ps[ 2] = pi + 6; ps[ 3] = pi + 5;
|
||||
tmp1 = cs[3];
|
||||
cs[2] = cs[1]; cs[3] = ci;
|
||||
cs[0] = tmp1; cs[1] = ci + 1;
|
||||
break;
|
||||
case 3:
|
||||
ps[12] = ps[0]; ps[13] = ps[1]; ps[14] = ps[2]; ps[15] = ps[3];
|
||||
ps[ 8] = pi; ps[ 9] = pi + 9; ps[10] = pi + 8; ps[11] = pi + 7;
|
||||
ps[ 4] = pi + 1; ps[ 5] = pi + 10; ps[ 6] = pi + 11; ps[ 7] = pi + 6;
|
||||
ps[ 0] = pi + 2; ps[ 1] = pi + 3; ps[ 2] = pi + 4; ps[ 3] = pi + 5;
|
||||
cs[2] = cs[0]; cs[3] = cs[1];
|
||||
cs[0] = ci; cs[1] = ci + 1;
|
||||
ps[12] = ps[0]; ps[13] = pi + 0; ps[14] = pi + 1; ps[15] = pi + 2;
|
||||
ps[ 8] = ps[1]; ps[ 9] = pi + 9; ps[10] = pi + 10; ps[11] = pi + 3;
|
||||
ps[ 4] = ps[2]; ps[ 5] = pi + 8; ps[ 6] = pi + 11; ps[ 7] = pi + 4;
|
||||
ps[ 0] = ps[3]; ps[ 1] = pi + 7; ps[ 2] = pi + 6; ps[ 3] = pi + 5;
|
||||
cs[2] = cs[0]; cs[3] = ci;
|
||||
cs[0] = cs[1]; cs[1] = ci + 1;
|
||||
break;
|
||||
}
|
||||
mesh.figures.push({
|
||||
@ -10143,19 +10115,19 @@ Shadings.Mesh = (function MeshClosure() {
|
||||
|
||||
var patchMesh = false;
|
||||
switch (this.shadingType) {
|
||||
case PatternType.FREE_FORM_MESH:
|
||||
case ShadingType.FREE_FORM_MESH:
|
||||
decodeType4Shading(this, reader);
|
||||
break;
|
||||
case PatternType.LATTICE_FORM_MESH:
|
||||
case ShadingType.LATTICE_FORM_MESH:
|
||||
var verticesPerRow = dict.get('VerticesPerRow') | 0;
|
||||
assert(verticesPerRow >= 2, 'Invalid VerticesPerRow');
|
||||
decodeType5Shading(this, reader, verticesPerRow);
|
||||
break;
|
||||
case PatternType.COONS_PATCH_MESH:
|
||||
case ShadingType.COONS_PATCH_MESH:
|
||||
decodeType6Shading(this, reader);
|
||||
patchMesh = true;
|
||||
break;
|
||||
case PatternType.TENSOR_PATCH_MESH:
|
||||
case ShadingType.TENSOR_PATCH_MESH:
|
||||
decodeType7Shading(this, reader);
|
||||
patchMesh = true;
|
||||
break;
|
||||
@ -14339,6 +14311,13 @@ var GlyphMapForStandardFonts = {
|
||||
'3316': 578, '3379': 42785, '3393': 1159, '3416': 8377
|
||||
};
|
||||
|
||||
// The glyph map for ArialBlack differs slightly from the glyph map used for
|
||||
// other well-known standard fonts. Hence we use this (incomplete) CID to GID
|
||||
// mapping to adjust the glyph map for non-embedded ArialBlack fonts.
|
||||
var SupplementalGlyphMapForArialBlack = {
|
||||
'227': 322, '264': 261, '291': 346,
|
||||
};
|
||||
|
||||
// Some characters, e.g. copyrightserif, are mapped to the private use area and
|
||||
// might not be displayed using standard fonts. Mapping/hacking well-known chars
|
||||
// to the similar equivalents in the normal characters range.
|
||||
@ -16347,8 +16326,13 @@ var Font = (function FontClosure() {
|
||||
// Standard fonts might be embedded as CID font without glyph mapping.
|
||||
// Building one based on GlyphMapForStandardFonts.
|
||||
var map = [];
|
||||
for (var code in GlyphMapForStandardFonts) {
|
||||
map[+code] = GlyphMapForStandardFonts[code];
|
||||
for (charCode in GlyphMapForStandardFonts) {
|
||||
map[+charCode] = GlyphMapForStandardFonts[charCode];
|
||||
}
|
||||
if (/ArialBlack/i.test(name)) {
|
||||
for (charCode in SupplementalGlyphMapForArialBlack) {
|
||||
map[+charCode] = SupplementalGlyphMapForArialBlack[charCode];
|
||||
}
|
||||
}
|
||||
var isIdentityUnicode = this.toUnicode instanceof IdentityToUnicodeMap;
|
||||
if (!isIdentityUnicode) {
|
||||
@ -17872,7 +17856,7 @@ var Font = (function FontClosure() {
|
||||
var isTrueType = !tables['CFF '];
|
||||
if (!isTrueType) {
|
||||
// OpenType font
|
||||
if (header.version === 'OTTO' ||
|
||||
if ((header.version === 'OTTO' && properties.type !== 'CIDFontType2') ||
|
||||
!tables.head || !tables.hhea || !tables.maxp || !tables.post) {
|
||||
// no major tables: throwing everything at CFFFont
|
||||
cffFile = new Stream(tables['CFF '].data);
|
||||
@ -29889,6 +29873,16 @@ var Parser = (function ParserClosure() {
|
||||
this.buf2 = this.lexer.getObj();
|
||||
}
|
||||
},
|
||||
tryShift: function Parser_tryShift() {
|
||||
try {
|
||||
this.shift();
|
||||
return true;
|
||||
} catch (e) {
|
||||
// Upon failure, the caller should reset this.lexer.pos to a known good
|
||||
// state and call this.shift() twice to reset the buffers.
|
||||
return false;
|
||||
}
|
||||
},
|
||||
getObj: function Parser_getObj(cipherTransform) {
|
||||
var buf1 = this.buf1;
|
||||
this.shift();
|
||||
@ -30262,9 +30256,10 @@ var Parser = (function ParserClosure() {
|
||||
stream.pos = pos + length;
|
||||
lexer.nextChar();
|
||||
|
||||
this.shift(); // '>>'
|
||||
this.shift(); // 'stream'
|
||||
if (!isCmd(this.buf1, 'endstream')) {
|
||||
// Shift '>>' and check whether the new object marks the end of the stream
|
||||
if (this.tryShift() && isCmd(this.buf2, 'endstream')) {
|
||||
this.shift(); // 'stream'
|
||||
} else {
|
||||
// bad stream length, scanning for endstream
|
||||
stream.pos = pos;
|
||||
var SCAN_BLOCK_SIZE = 2048;
|
||||
@ -30496,6 +30491,11 @@ var Lexer = (function LexerClosure() {
|
||||
if (ch === 0x2D) { // '-'
|
||||
sign = -1;
|
||||
ch = this.nextChar();
|
||||
|
||||
if (ch === 0x2D) { // '-'
|
||||
// Ignore double negative (this is consistent with Adobe Reader).
|
||||
ch = this.nextChar();
|
||||
}
|
||||
} else if (ch === 0x2B) { // '+'
|
||||
ch = this.nextChar();
|
||||
}
|
||||
@ -30674,9 +30674,8 @@ var Lexer = (function LexerClosure() {
|
||||
strBuf.push(String.fromCharCode(ch));
|
||||
}
|
||||
}
|
||||
if (strBuf.length > 128) {
|
||||
error('Warning: name token is longer than allowed by the spec: ' +
|
||||
strBuf.length);
|
||||
if (strBuf.length > 127) {
|
||||
warn('name token is longer than allowed by the spec: ' + strBuf.length);
|
||||
}
|
||||
return Name.get(strBuf.join(''));
|
||||
},
|
||||
@ -32011,7 +32010,8 @@ var JpegStream = (function JpegStreamClosure() {
|
||||
JpegStream.prototype.isNativelySupported =
|
||||
function JpegStream_isNativelySupported(xref, res) {
|
||||
var cs = ColorSpace.parse(this.dict.get('ColorSpace', 'CS'), xref, res);
|
||||
return cs.name === 'DeviceGray' || cs.name === 'DeviceRGB';
|
||||
return (cs.name === 'DeviceGray' || cs.name === 'DeviceRGB') &&
|
||||
cs.isDefaultDecode(this.dict.get('Decode', 'D'));
|
||||
};
|
||||
/**
|
||||
* Checks if the image can be decoded by the browser.
|
||||
@ -32019,8 +32019,8 @@ var JpegStream = (function JpegStreamClosure() {
|
||||
JpegStream.prototype.isNativelyDecodable =
|
||||
function JpegStream_isNativelyDecodable(xref, res) {
|
||||
var cs = ColorSpace.parse(this.dict.get('ColorSpace', 'CS'), xref, res);
|
||||
var numComps = cs.numComps;
|
||||
return numComps === 1 || numComps === 3;
|
||||
return (cs.numComps === 1 || cs.numComps === 3) &&
|
||||
cs.isDefaultDecode(this.dict.get('Decode', 'D'));
|
||||
};
|
||||
|
||||
return JpegStream;
|
||||
@ -38859,30 +38859,6 @@ var bidi = PDFJS.bidi = (function bidiClosure() {
|
||||
return bidi;
|
||||
})();
|
||||
|
||||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
||||
|
||||
/* Copyright 2014 Opera Software ASA
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*
|
||||
* Based on https://code.google.com/p/smhasher/wiki/MurmurHash3.
|
||||
* Hashes roughly 100 KB per millisecond on i7 3.4 GHz.
|
||||
*/
|
||||
/* globals Uint32ArrayView */
|
||||
|
||||
'use strict';
|
||||
|
||||
var MurmurHash3_64 = (function MurmurHash3_64Closure (seed) {
|
||||
// Workaround for missing math precison in JS.
|
||||
|
@ -59,6 +59,53 @@
|
||||
.textLayer ::selection { background: rgb(0,0,255); }
|
||||
.textLayer ::-moz-selection { background: rgb(0,0,255); }
|
||||
|
||||
|
||||
.annotationLayer .annotLink > a:hover {
|
||||
opacity: 0.2;
|
||||
background: #ff0;
|
||||
box-shadow: 0px 2px 10px #ff0;
|
||||
}
|
||||
|
||||
.annotationLayer .annotText > img {
|
||||
position: absolute;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.annotationLayer .annotTextContentWrapper {
|
||||
position: absolute;
|
||||
width: 20em;
|
||||
}
|
||||
|
||||
.annotationLayer .annotTextContent {
|
||||
z-index: 200;
|
||||
float: left;
|
||||
max-width: 20em;
|
||||
background-color: #FFFF99;
|
||||
box-shadow: 0px 2px 5px #333;
|
||||
border-radius: 2px;
|
||||
padding: 0.6em;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.annotationLayer .annotTextContent > h1 {
|
||||
font-size: 1em;
|
||||
border-bottom: 1px solid #000000;
|
||||
padding-bottom: 0.2em;
|
||||
}
|
||||
|
||||
.annotationLayer .annotTextContent > p {
|
||||
padding-top: 0.2em;
|
||||
}
|
||||
|
||||
.annotationLayer .annotLink > a {
|
||||
position: absolute;
|
||||
font-size: 1em;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.pdfViewer .canvasWrapper {
|
||||
overflow: hidden;
|
||||
}
|
||||
@ -96,12 +143,6 @@
|
||||
background: url('images/loading-icon.gif') center no-repeat;
|
||||
}
|
||||
|
||||
.pdfViewer .page .annotLink > a:hover {
|
||||
opacity: 0.2;
|
||||
background: #ff0;
|
||||
box-shadow: 0px 2px 10px #ff0;
|
||||
}
|
||||
|
||||
.pdfPresentationMode:-moz-full-screen .pdfViewer .page {
|
||||
margin-bottom: 100%;
|
||||
border: 0;
|
||||
@ -112,46 +153,6 @@
|
||||
border: 0;
|
||||
}
|
||||
|
||||
.pdfViewer .page .annotText > img {
|
||||
position: absolute;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.pdfViewer .page .annotTextContentWrapper {
|
||||
position: absolute;
|
||||
width: 20em;
|
||||
}
|
||||
|
||||
.pdfViewer .page .annotTextContent {
|
||||
z-index: 200;
|
||||
float: left;
|
||||
max-width: 20em;
|
||||
background-color: #FFFF99;
|
||||
box-shadow: 0px 2px 5px #333;
|
||||
border-radius: 2px;
|
||||
padding: 0.6em;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.pdfViewer .page .annotTextContent > h1 {
|
||||
font-size: 1em;
|
||||
border-bottom: 1px solid #000000;
|
||||
padding-bottom: 0.2em;
|
||||
}
|
||||
|
||||
.pdfViewer .page .annotTextContent > p {
|
||||
padding-top: 0.2em;
|
||||
}
|
||||
|
||||
.pdfViewer .page .annotLink > a {
|
||||
position: absolute;
|
||||
font-size: 1em;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
* {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
@ -661,6 +662,7 @@ html[dir='rtl'] .splitToolbarButton > .toolbarButton {
|
||||
.splitToolbarButton > .toolbarButton:focus,
|
||||
.dropdownToolbarButton:hover,
|
||||
.overlayButton:hover,
|
||||
.overlayButton:focus,
|
||||
.toolbarButton.textButton:hover,
|
||||
.toolbarButton.textButton:focus {
|
||||
background-color: hsla(0,0%,0%,.2);
|
||||
|
@ -84,10 +84,10 @@ See https://github.com/adobe-type-tools/cmap-resources
|
||||
<span data-l10n-id="find_next_label">Next</span>
|
||||
</button>
|
||||
</div>
|
||||
<input type="checkbox" id="findHighlightAll" class="toolbarField">
|
||||
<label for="findHighlightAll" class="toolbarLabel" tabindex="94" data-l10n-id="find_highlight">Highlight all</label>
|
||||
<input type="checkbox" id="findMatchCase" class="toolbarField">
|
||||
<label for="findMatchCase" class="toolbarLabel" tabindex="95" data-l10n-id="find_match_case_label">Match case</label>
|
||||
<input type="checkbox" id="findHighlightAll" class="toolbarField" tabindex="94">
|
||||
<label for="findHighlightAll" class="toolbarLabel" data-l10n-id="find_highlight">Highlight all</label>
|
||||
<input type="checkbox" id="findMatchCase" class="toolbarField" tabindex="95">
|
||||
<label for="findMatchCase" class="toolbarLabel" data-l10n-id="find_match_case_label">Match case</label>
|
||||
<span id="findMsg" class="toolbarLabel"></span>
|
||||
</div> <!-- findbar -->
|
||||
|
||||
|
@ -20,10 +20,10 @@
|
||||
PDFThumbnailViewer, URL, noContextMenuHandler, SecondaryToolbar,
|
||||
PasswordPrompt, PDFPresentationMode, PDFDocumentProperties, HandTool,
|
||||
Promise, PDFLinkService, PDFOutlineView, PDFAttachmentView,
|
||||
OverlayManager, PDFFindController, PDFFindBar, getVisibleElements,
|
||||
watchScroll, PDFViewer, PDFRenderingQueue, PresentationModeState,
|
||||
parseQueryString, RenderingStates, UNKNOWN_SCALE,
|
||||
DEFAULT_SCALE_VALUE, IGNORE_CURRENT_POSITION_ON_ZOOM: true */
|
||||
OverlayManager, PDFFindController, PDFFindBar, PDFViewer,
|
||||
PDFRenderingQueue, PresentationModeState, parseQueryString,
|
||||
RenderingStates, UNKNOWN_SCALE, DEFAULT_SCALE_VALUE,
|
||||
IGNORE_CURRENT_POSITION_ON_ZOOM: true */
|
||||
|
||||
'use strict';
|
||||
|
||||
@ -4074,7 +4074,7 @@ var TextLayerBuilder = (function TextLayerBuilderClosure() {
|
||||
// We don't bother scaling single-char text divs, because it has very
|
||||
// little effect on text highlighting. This makes scrolling on docs with
|
||||
// lots of such divs a lot faster.
|
||||
if (textDiv.textContent.length > 1) {
|
||||
if (geom.str.length > 1) {
|
||||
if (style.vertical) {
|
||||
textDiv.dataset.canvasWidth = geom.height * this.viewport.scale;
|
||||
} else {
|
||||
@ -4449,7 +4449,8 @@ DefaultAnnotationsLayerFactory.prototype = {
|
||||
createAnnotationsLayerBuilder: function (pageDiv, pdfPage) {
|
||||
return new AnnotationsLayerBuilder({
|
||||
pageDiv: pageDiv,
|
||||
pdfPage: pdfPage
|
||||
pdfPage: pdfPage,
|
||||
linkService: new SimpleLinkService(),
|
||||
});
|
||||
}
|
||||
};
|
||||
@ -4511,7 +4512,7 @@ var PDFViewer = (function pdfViewer() {
|
||||
function PDFViewer(options) {
|
||||
this.container = options.container;
|
||||
this.viewer = options.viewer || options.container.firstElementChild;
|
||||
this.linkService = options.linkService || new SimpleLinkService(this);
|
||||
this.linkService = options.linkService || new SimpleLinkService();
|
||||
this.removePageBorders = options.removePageBorders || false;
|
||||
|
||||
this.defaultRenderingQueue = !options.renderingQueue;
|
||||
@ -4636,6 +4637,10 @@ var PDFViewer = (function pdfViewer() {
|
||||
}
|
||||
|
||||
this._setScale(this._currentScaleValue, true);
|
||||
|
||||
if (this.defaultRenderingQueue) {
|
||||
this.update();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
@ -4773,7 +4778,7 @@ var PDFViewer = (function pdfViewer() {
|
||||
}
|
||||
},
|
||||
|
||||
_scrollUpdate: function () {
|
||||
_scrollUpdate: function PDFViewer_scrollUpdate() {
|
||||
if (this.pagesCount === 0) {
|
||||
return;
|
||||
}
|
||||
@ -4822,12 +4827,13 @@ var PDFViewer = (function pdfViewer() {
|
||||
}
|
||||
|
||||
this._setScaleDispatchEvent(newScale, newValue, preset);
|
||||
|
||||
if (this.defaultRenderingQueue) {
|
||||
this.update();
|
||||
}
|
||||
},
|
||||
|
||||
_setScale: function pdfViewer_setScale(value, noScroll) {
|
||||
if (value === 'custom') {
|
||||
return;
|
||||
}
|
||||
var scale = parseFloat(value);
|
||||
|
||||
if (scale > 0) {
|
||||
@ -4886,14 +4892,14 @@ var PDFViewer = (function pdfViewer() {
|
||||
var pageView = this._pages[pageNumber - 1];
|
||||
|
||||
if (this.isInPresentationMode) {
|
||||
if (this.linkService.page !== pageView.id) {
|
||||
if (this._currentPageNumber !== pageView.id) {
|
||||
// Avoid breaking getVisiblePages in presentation mode.
|
||||
this.linkService.page = pageView.id;
|
||||
this.currentPageNumber = pageView.id;
|
||||
return;
|
||||
}
|
||||
dest = null;
|
||||
// Fixes the case when PDF has different page sizes.
|
||||
this._setScale(this.currentScaleValue, true);
|
||||
this._setScale(this._currentScaleValue, true);
|
||||
}
|
||||
if (!dest) {
|
||||
scrollIntoView(pageView.div);
|
||||
@ -4941,13 +4947,12 @@ var PDFViewer = (function pdfViewer() {
|
||||
y = dest[3];
|
||||
width = dest[4] - x;
|
||||
height = dest[5] - y;
|
||||
var viewerContainer = this.container;
|
||||
var hPadding = this.removePageBorders ? 0 : SCROLLBAR_PADDING;
|
||||
var vPadding = this.removePageBorders ? 0 : VERTICAL_PADDING;
|
||||
|
||||
widthScale = (viewerContainer.clientWidth - hPadding) /
|
||||
widthScale = (this.container.clientWidth - hPadding) /
|
||||
width / CSS_UNITS;
|
||||
heightScale = (viewerContainer.clientHeight - vPadding) /
|
||||
heightScale = (this.container.clientHeight - vPadding) /
|
||||
height / CSS_UNITS;
|
||||
scale = Math.min(Math.abs(widthScale), Math.abs(heightScale));
|
||||
break;
|
||||
@ -5176,22 +5181,19 @@ var PDFViewer = (function pdfViewer() {
|
||||
})();
|
||||
|
||||
var SimpleLinkService = (function SimpleLinkServiceClosure() {
|
||||
function SimpleLinkService(pdfViewer) {
|
||||
this.pdfViewer = pdfViewer;
|
||||
}
|
||||
function SimpleLinkService() {}
|
||||
|
||||
SimpleLinkService.prototype = {
|
||||
/**
|
||||
* @returns {number}
|
||||
*/
|
||||
get page() {
|
||||
return this.pdfViewer.currentPageNumber;
|
||||
return 0;
|
||||
},
|
||||
/**
|
||||
* @param {number} value
|
||||
*/
|
||||
set page(value) {
|
||||
this.pdfViewer.currentPageNumber = value;
|
||||
},
|
||||
set page(value) {},
|
||||
/**
|
||||
* @param dest - The PDF destination object.
|
||||
*/
|
||||
@ -5921,7 +5923,6 @@ var PDFViewerApplication = {
|
||||
/** @type {PDFHistory} */
|
||||
pdfHistory: null,
|
||||
pageRotation: 0,
|
||||
updateScaleControls: true,
|
||||
isInitialViewSet: false,
|
||||
animationStartedPromise: null,
|
||||
preferenceSidebarViewOnLoad: SidebarView.NONE,
|
||||
@ -6111,7 +6112,7 @@ var PDFViewerApplication = {
|
||||
newScale = Math.ceil(newScale * 10) / 10;
|
||||
newScale = Math.min(MAX_SCALE, newScale);
|
||||
} while (--ticks > 0 && newScale < MAX_SCALE);
|
||||
this.setScale(newScale, true);
|
||||
this.pdfViewer.currentScaleValue = newScale;
|
||||
},
|
||||
|
||||
zoomOut: function pdfViewZoomOut(ticks) {
|
||||
@ -6121,7 +6122,7 @@ var PDFViewerApplication = {
|
||||
newScale = Math.floor(newScale * 10) / 10;
|
||||
newScale = Math.max(MIN_SCALE, newScale);
|
||||
} while (--ticks > 0 && newScale > MIN_SCALE);
|
||||
this.setScale(newScale, true);
|
||||
this.pdfViewer.currentScaleValue = newScale;
|
||||
},
|
||||
|
||||
get pagesCount() {
|
||||
@ -6546,7 +6547,7 @@ var PDFViewerApplication = {
|
||||
store.get('exists', false)) {
|
||||
var pageNum = store.get('page', '1');
|
||||
var zoom = self.preferenceDefaultZoomValue ||
|
||||
store.get('zoom', self.pdfViewer.currentScale);
|
||||
store.get('zoom', DEFAULT_SCALE_VALUE);
|
||||
var left = store.get('scrollLeft', '0');
|
||||
var top = store.get('scrollTop', '0');
|
||||
|
||||
@ -6576,7 +6577,7 @@ var PDFViewerApplication = {
|
||||
self.fallback(PDFJS.UNSUPPORTED_FEATURES.javaScript);
|
||||
}
|
||||
// Hack to support auto printing.
|
||||
var regex = /\bprint\s*\(/g;
|
||||
var regex = /\bprint\s*\(/;
|
||||
for (var i = 0, ii = javaScript.length; i < ii; i++) {
|
||||
var js = javaScript[i];
|
||||
if (js && regex.test(js)) {
|
||||
@ -6703,11 +6704,10 @@ var PDFViewerApplication = {
|
||||
setInitialView: function pdfViewSetInitialView(storedHash, scale) {
|
||||
this.isInitialViewSet = true;
|
||||
|
||||
// When opening a new file (when one is already loaded in the viewer):
|
||||
// Reset 'currentPageNumber', since otherwise the page's scale will be wrong
|
||||
// if 'currentPageNumber' is larger than the number of pages in the file.
|
||||
// When opening a new file, when one is already loaded in the viewer,
|
||||
// ensure that the 'pageNumber' element displays the correct value.
|
||||
document.getElementById('pageNumber').value =
|
||||
this.pdfViewer.currentPageNumber = 1;
|
||||
this.pdfViewer.currentPageNumber;
|
||||
|
||||
if (this.initialDestination) {
|
||||
this.pdfLinkService.navigateTo(this.initialDestination);
|
||||
@ -6719,14 +6719,14 @@ var PDFViewerApplication = {
|
||||
} else if (storedHash) {
|
||||
this.pdfLinkService.setHash(storedHash);
|
||||
} else if (scale) {
|
||||
this.setScale(scale, true);
|
||||
this.pdfViewer.currentScaleValue = scale;
|
||||
this.page = 1;
|
||||
}
|
||||
|
||||
if (!this.pdfViewer.currentScaleValue) {
|
||||
// Scale was not initialized: invalid bookmark or scale was not specified.
|
||||
// Setting the default one.
|
||||
this.setScale(DEFAULT_SCALE_VALUE, true);
|
||||
this.pdfViewer.currentScaleValue = DEFAULT_SCALE_VALUE;
|
||||
}
|
||||
},
|
||||
|
||||
@ -6915,12 +6915,6 @@ var PDFViewerApplication = {
|
||||
this.forceRendering();
|
||||
},
|
||||
|
||||
setScale: function (value, resetAutoSettings) {
|
||||
this.updateScaleControls = !!resetAutoSettings;
|
||||
this.pdfViewer.currentScaleValue = value;
|
||||
this.updateScaleControls = true;
|
||||
},
|
||||
|
||||
rotatePages: function pdfViewRotatePages(delta) {
|
||||
var pageNumber = this.page;
|
||||
this.pageRotation = (this.pageRotation + 360 + delta) % 360;
|
||||
@ -7120,10 +7114,12 @@ function webViewerInitialized() {
|
||||
}
|
||||
});
|
||||
|
||||
document.getElementById('scaleSelect').addEventListener('change',
|
||||
function() {
|
||||
PDFViewerApplication.setScale(this.value, false);
|
||||
});
|
||||
document.getElementById('scaleSelect').addEventListener('change', function() {
|
||||
if (this.value === 'custom') {
|
||||
return;
|
||||
}
|
||||
PDFViewerApplication.pdfViewer.currentScaleValue = this.value;
|
||||
});
|
||||
|
||||
document.getElementById('presentationMode').addEventListener('click',
|
||||
SecondaryToolbar.presentationModeClick.bind(SecondaryToolbar));
|
||||
@ -7224,13 +7220,6 @@ window.addEventListener('presentationmodechanged', function (e) {
|
||||
active ? PresentationModeState.FULLSCREEN : PresentationModeState.NORMAL;
|
||||
});
|
||||
|
||||
function updateViewarea() {
|
||||
if (!PDFViewerApplication.initialized) {
|
||||
return;
|
||||
}
|
||||
PDFViewerApplication.pdfViewer.update();
|
||||
}
|
||||
|
||||
window.addEventListener('updateviewarea', function (evt) {
|
||||
if (!PDFViewerApplication.initialized) {
|
||||
return;
|
||||
@ -7270,15 +7259,21 @@ window.addEventListener('updateviewarea', function (evt) {
|
||||
}, true);
|
||||
|
||||
window.addEventListener('resize', function webViewerResize(evt) {
|
||||
if (PDFViewerApplication.initialized &&
|
||||
(document.getElementById('pageAutoOption').selected ||
|
||||
/* Note: the scale is constant for |pageActualOption|. */
|
||||
document.getElementById('pageFitOption').selected ||
|
||||
document.getElementById('pageWidthOption').selected)) {
|
||||
var selectedScale = document.getElementById('scaleSelect').value;
|
||||
PDFViewerApplication.setScale(selectedScale, false);
|
||||
if (PDFViewerApplication.initialized) {
|
||||
var currentScaleValue = PDFViewerApplication.pdfViewer.currentScaleValue;
|
||||
if (currentScaleValue === 'auto' ||
|
||||
currentScaleValue === 'page-fit' ||
|
||||
currentScaleValue === 'page-width') {
|
||||
// Note: the scale is constant for 'page-actual'.
|
||||
PDFViewerApplication.pdfViewer.currentScaleValue = currentScaleValue;
|
||||
} else if (!currentScaleValue) {
|
||||
// Normally this shouldn't happen, but if the scale wasn't initialized
|
||||
// we set it to the default value in order to prevent any issues.
|
||||
// (E.g. the document being rendered with the wrong scale on load.)
|
||||
PDFViewerApplication.pdfViewer.currentScaleValue = DEFAULT_SCALE_VALUE;
|
||||
}
|
||||
PDFViewerApplication.pdfViewer.update();
|
||||
}
|
||||
updateViewarea();
|
||||
|
||||
// Set the 'max-height' CSS property of the secondary toolbar.
|
||||
SecondaryToolbar.setMaxHeight(document.getElementById('viewerContainer'));
|
||||
@ -7302,7 +7297,7 @@ window.addEventListener('hashchange', function webViewerHashchange(evt) {
|
||||
function selectScaleOption(value) {
|
||||
var options = document.getElementById('scaleSelect').options;
|
||||
var predefinedValueFound = false;
|
||||
for (var i = 0; i < options.length; i++) {
|
||||
for (var i = 0, ii = options.length; i < ii; i++) {
|
||||
var option = options[i];
|
||||
if (option.value !== value) {
|
||||
option.selected = false;
|
||||
@ -7344,32 +7339,20 @@ window.addEventListener('scalechange', function scalechange(evt) {
|
||||
document.getElementById('zoomOut').disabled = (evt.scale === MIN_SCALE);
|
||||
document.getElementById('zoomIn').disabled = (evt.scale === MAX_SCALE);
|
||||
|
||||
var customScaleOption = document.getElementById('customScaleOption');
|
||||
customScaleOption.selected = false;
|
||||
|
||||
if (!PDFViewerApplication.updateScaleControls &&
|
||||
(document.getElementById('pageAutoOption').selected ||
|
||||
document.getElementById('pageActualOption').selected ||
|
||||
document.getElementById('pageFitOption').selected ||
|
||||
document.getElementById('pageWidthOption').selected)) {
|
||||
updateViewarea();
|
||||
return;
|
||||
}
|
||||
|
||||
if (evt.presetValue) {
|
||||
selectScaleOption(evt.presetValue);
|
||||
updateViewarea();
|
||||
return;
|
||||
}
|
||||
|
||||
var predefinedValueFound = selectScaleOption('' + evt.scale);
|
||||
// Update the 'scaleSelect' DOM element.
|
||||
var predefinedValueFound = selectScaleOption(evt.presetValue ||
|
||||
'' + evt.scale);
|
||||
if (!predefinedValueFound) {
|
||||
var customScaleOption = document.getElementById('customScaleOption');
|
||||
var customScale = Math.round(evt.scale * 10000) / 100;
|
||||
customScaleOption.textContent =
|
||||
mozL10n.get('page_scale_percent', { scale: customScale }, '{{scale}}%');
|
||||
customScaleOption.selected = true;
|
||||
}
|
||||
updateViewarea();
|
||||
if (!PDFViewerApplication.initialized) {
|
||||
return;
|
||||
}
|
||||
PDFViewerApplication.pdfViewer.update();
|
||||
}, true);
|
||||
|
||||
window.addEventListener('pagechange', function pagechange(evt) {
|
||||
@ -7496,7 +7479,7 @@ window.addEventListener('keydown', function keydown(evt) {
|
||||
// keeping it unhandled (to restore page zoom to 100%)
|
||||
setTimeout(function () {
|
||||
// ... and resetting the scale after browser adjusts its scale
|
||||
PDFViewerApplication.setScale(DEFAULT_SCALE_VALUE, true);
|
||||
pdfViewer.currentScaleValue = DEFAULT_SCALE_VALUE;
|
||||
});
|
||||
handled = false;
|
||||
}
|
||||
@ -7537,6 +7520,7 @@ window.addEventListener('keydown', function keydown(evt) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
var ensureViewerFocused = false;
|
||||
|
||||
if (cmd === 0) { // no control key pressed at all.
|
||||
switch (evt.keyCode) {
|
||||
@ -7595,6 +7579,7 @@ window.addEventListener('keydown', function keydown(evt) {
|
||||
if (isViewerInPresentationMode || PDFViewerApplication.page > 1) {
|
||||
PDFViewerApplication.page = 1;
|
||||
handled = true;
|
||||
ensureViewerFocused = true;
|
||||
}
|
||||
break;
|
||||
case 35: // end
|
||||
@ -7602,6 +7587,7 @@ window.addEventListener('keydown', function keydown(evt) {
|
||||
PDFViewerApplication.page < PDFViewerApplication.pagesCount)) {
|
||||
PDFViewerApplication.page = PDFViewerApplication.pagesCount;
|
||||
handled = true;
|
||||
ensureViewerFocused = true;
|
||||
}
|
||||
break;
|
||||
|
||||
@ -7636,17 +7622,10 @@ window.addEventListener('keydown', function keydown(evt) {
|
||||
if (!handled && !isViewerInPresentationMode) {
|
||||
// 33=Page Up 34=Page Down 35=End 36=Home
|
||||
// 37=Left 38=Up 39=Right 40=Down
|
||||
if (evt.keyCode >= 33 && evt.keyCode <= 40 &&
|
||||
!pdfViewer.containsElement(curElement)) {
|
||||
// The page container is not focused, but a page navigation key has been
|
||||
// pressed. Change the focus to the viewer container to make sure that
|
||||
// navigation by keyboard works as expected.
|
||||
pdfViewer.focus();
|
||||
}
|
||||
// 32=Spacebar
|
||||
if (evt.keyCode === 32 && curElementTagName !== 'BUTTON' &&
|
||||
!pdfViewer.containsElement(curElement)) {
|
||||
pdfViewer.focus();
|
||||
if ((evt.keyCode >= 33 && evt.keyCode <= 40) ||
|
||||
(evt.keyCode === 32 && curElementTagName !== 'BUTTON')) {
|
||||
ensureViewerFocused = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -7667,6 +7646,13 @@ window.addEventListener('keydown', function keydown(evt) {
|
||||
}
|
||||
}
|
||||
|
||||
if (ensureViewerFocused && !pdfViewer.containsElement(curElement)) {
|
||||
// The page container is not focused, but a page navigation key has been
|
||||
// pressed. Change the focus to the viewer container to make sure that
|
||||
// navigation by keyboard works as expected.
|
||||
pdfViewer.focus();
|
||||
}
|
||||
|
||||
if (handled) {
|
||||
evt.preventDefault();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user