upgrade pdfjs to version 1.0.1040
This commit is contained in:
@@ -87,11 +87,10 @@ module.exports = (grunt) ->
|
|||||||
paths:
|
paths:
|
||||||
"moment": "libs/moment-2.9.0"
|
"moment": "libs/moment-2.9.0"
|
||||||
"mathjax": "/js/libs/mathjax/MathJax.js?config=TeX-AMS_HTML"
|
"mathjax": "/js/libs/mathjax/MathJax.js?config=TeX-AMS_HTML"
|
||||||
|
"libs/pdf": "libs/pdfjs-1.0.1040/pdf"
|
||||||
shim:
|
shim:
|
||||||
"libs/pdfListView/PdfListView":
|
|
||||||
deps: ["libs/pdf"]
|
|
||||||
"libs/pdf":
|
"libs/pdf":
|
||||||
deps: ["libs/compatibility"]
|
deps: ["libs/pdfjs-1.0.1040/compatibility"]
|
||||||
|
|
||||||
skipDirOptimize: true
|
skipDirOptimize: true
|
||||||
modules: [
|
modules: [
|
||||||
|
|||||||
@@ -23,9 +23,9 @@ for path in [
|
|||||||
"#{jsPath}main.js",
|
"#{jsPath}main.js",
|
||||||
"#{jsPath}libs.js",
|
"#{jsPath}libs.js",
|
||||||
"#{jsPath}ace/ace.js",
|
"#{jsPath}ace/ace.js",
|
||||||
"#{jsPath}libs/pdfjs-1.0.712/pdf.js",
|
"#{jsPath}libs/pdfjs-1.0.1040/pdf.js",
|
||||||
"#{jsPath}libs/pdfjs-1.0.712/pdf.worker.js",
|
"#{jsPath}libs/pdfjs-1.0.1040/pdf.worker.js",
|
||||||
"#{jsPath}libs/pdfjs-1.0.712/compatibility.js",
|
"#{jsPath}libs/pdfjs-1.0.1040/compatibility.js",
|
||||||
"/stylesheets/style.css"
|
"/stylesheets/style.css"
|
||||||
]
|
]
|
||||||
filePath = Path.join __dirname, "../../../", "public#{path}"
|
filePath = Path.join __dirname, "../../../", "public#{path}"
|
||||||
|
|||||||
@@ -89,15 +89,13 @@ block content
|
|||||||
"paths" : {
|
"paths" : {
|
||||||
"mathjax": "/js/libs/mathjax/MathJax.js?config=TeX-AMS_HTML",
|
"mathjax": "/js/libs/mathjax/MathJax.js?config=TeX-AMS_HTML",
|
||||||
"moment": "libs/moment-2.7.0",
|
"moment": "libs/moment-2.7.0",
|
||||||
"libs/pdf": "libs/pdfjs-1.0.712/pdf",
|
"libs/pdf": "libs/pdfjs-1.0.1040/pdf"
|
||||||
"libs/compatibility": "libs/pdfjs-1.0.712/compatibility"
|
|
||||||
|
|
||||||
},
|
},
|
||||||
"urlArgs" : "fingerprint=#{fingerprint(jsPath + 'ide.js')}-#{fingerprint(jsPath + 'libs.js')}",
|
"urlArgs" : "fingerprint=#{fingerprint(jsPath + 'ide.js')}-#{fingerprint(jsPath + 'libs.js')}",
|
||||||
"waitSeconds": 0,
|
"waitSeconds": 0,
|
||||||
"shim": {
|
"shim": {
|
||||||
"libs/pdf": {
|
"libs/pdf": {
|
||||||
deps: ["libs/compatibility"]
|
deps: ["libs/pdfjs-1.0.1040/compatibility"]
|
||||||
},
|
},
|
||||||
"ace/ext-searchbox": {
|
"ace/ext-searchbox": {
|
||||||
deps: ["ace/ace"]
|
deps: ["ace/ace"]
|
||||||
@@ -116,7 +114,7 @@ block content
|
|||||||
|
|
||||||
- locals.suppressDefaultJs = true
|
- locals.suppressDefaultJs = true
|
||||||
|
|
||||||
- var pdfPath = 'libs/pdfjs-1.0.712/pdf.worker.js'
|
- var pdfPath = 'libs/pdfjs-1.0.1040/pdf.worker.js'
|
||||||
- var fingerprintedPath = fingerprint(jsPath+pdfPath)
|
- var fingerprintedPath = fingerprint(jsPath+pdfPath)
|
||||||
- var pdfJsWorkerPath = jsPath+pdfPath+'?fingerprint='+fingerprintedPath
|
- var pdfJsWorkerPath = jsPath+pdfPath+'?fingerprint='+fingerprintedPath
|
||||||
script(type='text/javascript').
|
script(type='text/javascript').
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ define [
|
|||||||
"ide/pdfng/directives/pdfRenderer"
|
"ide/pdfng/directives/pdfRenderer"
|
||||||
"ide/pdfng/directives/pdfPage"
|
"ide/pdfng/directives/pdfPage"
|
||||||
"ide/pdfng/directives/pdfSpinner"
|
"ide/pdfng/directives/pdfSpinner"
|
||||||
"libs/pdf" # needs pdfjs-1.0.712, override the path in require.js to get it
|
"libs/pdf"
|
||||||
], (
|
], (
|
||||||
App
|
App
|
||||||
pdfTextLayer
|
pdfTextLayer
|
||||||
|
|||||||
@@ -1,483 +0,0 @@
|
|||||||
/* -*- 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 VBArray, PDFJS */
|
|
||||||
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
// Initializing PDFJS global object here, it case if we need to change/disable
|
|
||||||
// some PDF.js features, e.g. range requests
|
|
||||||
if (typeof PDFJS === 'undefined') {
|
|
||||||
(typeof window !== 'undefined' ? window : this).PDFJS = {};
|
|
||||||
}
|
|
||||||
|
|
||||||
// Checking if the typed arrays are supported
|
|
||||||
(function checkTypedArrayCompatibility() {
|
|
||||||
if (typeof Uint8Array !== 'undefined') {
|
|
||||||
// some mobile versions do not support subarray (e.g. safari 5 / iOS)
|
|
||||||
if (typeof Uint8Array.prototype.subarray === 'undefined') {
|
|
||||||
Uint8Array.prototype.subarray = function subarray(start, end) {
|
|
||||||
return new Uint8Array(this.slice(start, end));
|
|
||||||
};
|
|
||||||
Float32Array.prototype.subarray = function subarray(start, end) {
|
|
||||||
return new Float32Array(this.slice(start, end));
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
// some mobile version might not support Float64Array
|
|
||||||
if (typeof Float64Array === 'undefined')
|
|
||||||
window.Float64Array = Float32Array;
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
function subarray(start, end) {
|
|
||||||
return new TypedArray(this.slice(start, end));
|
|
||||||
}
|
|
||||||
|
|
||||||
function setArrayOffset(array, offset) {
|
|
||||||
if (arguments.length < 2)
|
|
||||||
offset = 0;
|
|
||||||
for (var i = 0, n = array.length; i < n; ++i, ++offset)
|
|
||||||
this[offset] = array[i] & 0xFF;
|
|
||||||
}
|
|
||||||
|
|
||||||
function TypedArray(arg1) {
|
|
||||||
var result;
|
|
||||||
if (typeof arg1 === 'number') {
|
|
||||||
result = [];
|
|
||||||
for (var i = 0; i < arg1; ++i)
|
|
||||||
result[i] = 0;
|
|
||||||
} else if ('slice' in arg1) {
|
|
||||||
result = arg1.slice(0);
|
|
||||||
} else {
|
|
||||||
result = [];
|
|
||||||
for (var i = 0, n = arg1.length; i < n; ++i) {
|
|
||||||
result[i] = arg1[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
result.subarray = subarray;
|
|
||||||
result.buffer = result;
|
|
||||||
result.byteLength = result.length;
|
|
||||||
result.set = setArrayOffset;
|
|
||||||
|
|
||||||
if (typeof arg1 === 'object' && arg1.buffer)
|
|
||||||
result.buffer = arg1.buffer;
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
window.Uint8Array = TypedArray;
|
|
||||||
|
|
||||||
// we don't need support for set, byteLength for 32-bit array
|
|
||||||
// so we can use the TypedArray as well
|
|
||||||
window.Uint32Array = TypedArray;
|
|
||||||
window.Int32Array = TypedArray;
|
|
||||||
window.Uint16Array = TypedArray;
|
|
||||||
window.Float32Array = TypedArray;
|
|
||||||
window.Float64Array = TypedArray;
|
|
||||||
})();
|
|
||||||
|
|
||||||
// URL = URL || webkitURL
|
|
||||||
(function normalizeURLObject() {
|
|
||||||
if (!window.URL) {
|
|
||||||
window.URL = window.webkitURL;
|
|
||||||
}
|
|
||||||
})();
|
|
||||||
|
|
||||||
// Object.create() ?
|
|
||||||
(function checkObjectCreateCompatibility() {
|
|
||||||
if (typeof Object.create !== 'undefined')
|
|
||||||
return;
|
|
||||||
|
|
||||||
Object.create = function objectCreate(proto) {
|
|
||||||
function Constructor() {}
|
|
||||||
Constructor.prototype = proto;
|
|
||||||
return new Constructor();
|
|
||||||
};
|
|
||||||
})();
|
|
||||||
|
|
||||||
// Object.defineProperty() ?
|
|
||||||
(function checkObjectDefinePropertyCompatibility() {
|
|
||||||
if (typeof Object.defineProperty !== 'undefined') {
|
|
||||||
var definePropertyPossible = true;
|
|
||||||
try {
|
|
||||||
// some browsers (e.g. safari) cannot use defineProperty() on DOM objects
|
|
||||||
// and thus the native version is not sufficient
|
|
||||||
Object.defineProperty(new Image(), 'id', { value: 'test' });
|
|
||||||
// ... another test for android gb browser for non-DOM objects
|
|
||||||
var Test = function Test() {};
|
|
||||||
Test.prototype = { get id() { } };
|
|
||||||
Object.defineProperty(new Test(), 'id',
|
|
||||||
{ value: '', configurable: true, enumerable: true, writable: false });
|
|
||||||
} catch (e) {
|
|
||||||
definePropertyPossible = false;
|
|
||||||
}
|
|
||||||
if (definePropertyPossible) return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Object.defineProperty = function objectDefineProperty(obj, name, def) {
|
|
||||||
delete obj[name];
|
|
||||||
if ('get' in def)
|
|
||||||
obj.__defineGetter__(name, def['get']);
|
|
||||||
if ('set' in def)
|
|
||||||
obj.__defineSetter__(name, def['set']);
|
|
||||||
if ('value' in def) {
|
|
||||||
obj.__defineSetter__(name, function objectDefinePropertySetter(value) {
|
|
||||||
this.__defineGetter__(name, function objectDefinePropertyGetter() {
|
|
||||||
return value;
|
|
||||||
});
|
|
||||||
return value;
|
|
||||||
});
|
|
||||||
obj[name] = def.value;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
})();
|
|
||||||
|
|
||||||
// Object.keys() ?
|
|
||||||
(function checkObjectKeysCompatibility() {
|
|
||||||
if (typeof Object.keys !== 'undefined')
|
|
||||||
return;
|
|
||||||
|
|
||||||
Object.keys = function objectKeys(obj) {
|
|
||||||
var result = [];
|
|
||||||
for (var i in obj) {
|
|
||||||
if (obj.hasOwnProperty(i))
|
|
||||||
result.push(i);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
})();
|
|
||||||
|
|
||||||
// No readAsArrayBuffer ?
|
|
||||||
(function checkFileReaderReadAsArrayBuffer() {
|
|
||||||
if (typeof FileReader === 'undefined')
|
|
||||||
return; // FileReader is not implemented
|
|
||||||
var frPrototype = FileReader.prototype;
|
|
||||||
// Older versions of Firefox might not have readAsArrayBuffer
|
|
||||||
if ('readAsArrayBuffer' in frPrototype)
|
|
||||||
return; // readAsArrayBuffer is implemented
|
|
||||||
Object.defineProperty(frPrototype, 'readAsArrayBuffer', {
|
|
||||||
value: function fileReaderReadAsArrayBuffer(blob) {
|
|
||||||
var fileReader = new FileReader();
|
|
||||||
var originalReader = this;
|
|
||||||
fileReader.onload = function fileReaderOnload(evt) {
|
|
||||||
var data = evt.target.result;
|
|
||||||
var buffer = new ArrayBuffer(data.length);
|
|
||||||
var uint8Array = new Uint8Array(buffer);
|
|
||||||
|
|
||||||
for (var i = 0, ii = data.length; i < ii; i++)
|
|
||||||
uint8Array[i] = data.charCodeAt(i);
|
|
||||||
|
|
||||||
Object.defineProperty(originalReader, 'result', {
|
|
||||||
value: buffer,
|
|
||||||
enumerable: true,
|
|
||||||
writable: false,
|
|
||||||
configurable: true
|
|
||||||
});
|
|
||||||
|
|
||||||
var event = document.createEvent('HTMLEvents');
|
|
||||||
event.initEvent('load', false, false);
|
|
||||||
originalReader.dispatchEvent(event);
|
|
||||||
};
|
|
||||||
fileReader.readAsBinaryString(blob);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
})();
|
|
||||||
|
|
||||||
// No XMLHttpRequest.response ?
|
|
||||||
(function checkXMLHttpRequestResponseCompatibility() {
|
|
||||||
var xhrPrototype = XMLHttpRequest.prototype;
|
|
||||||
if (!('overrideMimeType' in xhrPrototype)) {
|
|
||||||
// IE10 might have response, but not overrideMimeType
|
|
||||||
Object.defineProperty(xhrPrototype, 'overrideMimeType', {
|
|
||||||
value: function xmlHttpRequestOverrideMimeType(mimeType) {}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if ('response' in xhrPrototype ||
|
|
||||||
'mozResponseArrayBuffer' in xhrPrototype ||
|
|
||||||
'mozResponse' in xhrPrototype ||
|
|
||||||
'responseArrayBuffer' in xhrPrototype)
|
|
||||||
return;
|
|
||||||
// IE9 ?
|
|
||||||
if (typeof VBArray !== 'undefined') {
|
|
||||||
Object.defineProperty(xhrPrototype, 'response', {
|
|
||||||
get: function xmlHttpRequestResponseGet() {
|
|
||||||
return new Uint8Array(new VBArray(this.responseBody).toArray());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// other browsers
|
|
||||||
function responseTypeSetter() {
|
|
||||||
// will be only called to set "arraybuffer"
|
|
||||||
this.overrideMimeType('text/plain; charset=x-user-defined');
|
|
||||||
}
|
|
||||||
if (typeof xhrPrototype.overrideMimeType === 'function') {
|
|
||||||
Object.defineProperty(xhrPrototype, 'responseType',
|
|
||||||
{ set: responseTypeSetter });
|
|
||||||
}
|
|
||||||
function responseGetter() {
|
|
||||||
var text = this.responseText;
|
|
||||||
var i, n = text.length;
|
|
||||||
var result = new Uint8Array(n);
|
|
||||||
for (i = 0; i < n; ++i)
|
|
||||||
result[i] = text.charCodeAt(i) & 0xFF;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
Object.defineProperty(xhrPrototype, 'response', { get: responseGetter });
|
|
||||||
})();
|
|
||||||
|
|
||||||
// window.btoa (base64 encode function) ?
|
|
||||||
(function checkWindowBtoaCompatibility() {
|
|
||||||
if ('btoa' in window)
|
|
||||||
return;
|
|
||||||
|
|
||||||
var digits =
|
|
||||||
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
|
|
||||||
|
|
||||||
window.btoa = function windowBtoa(chars) {
|
|
||||||
var buffer = '';
|
|
||||||
var i, n;
|
|
||||||
for (i = 0, n = chars.length; i < n; i += 3) {
|
|
||||||
var b1 = chars.charCodeAt(i) & 0xFF;
|
|
||||||
var b2 = chars.charCodeAt(i + 1) & 0xFF;
|
|
||||||
var b3 = chars.charCodeAt(i + 2) & 0xFF;
|
|
||||||
var d1 = b1 >> 2, d2 = ((b1 & 3) << 4) | (b2 >> 4);
|
|
||||||
var d3 = i + 1 < n ? ((b2 & 0xF) << 2) | (b3 >> 6) : 64;
|
|
||||||
var d4 = i + 2 < n ? (b3 & 0x3F) : 64;
|
|
||||||
buffer += (digits.charAt(d1) + digits.charAt(d2) +
|
|
||||||
digits.charAt(d3) + digits.charAt(d4));
|
|
||||||
}
|
|
||||||
return buffer;
|
|
||||||
};
|
|
||||||
})();
|
|
||||||
|
|
||||||
// window.atob (base64 encode function) ?
|
|
||||||
(function checkWindowAtobCompatibility() {
|
|
||||||
if ('atob' in window)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// https://github.com/davidchambers/Base64.js
|
|
||||||
var digits =
|
|
||||||
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
|
|
||||||
window.atob = function (input) {
|
|
||||||
input = input.replace(/=+$/, '');
|
|
||||||
if (input.length % 4 == 1) throw new Error('bad atob input');
|
|
||||||
for (
|
|
||||||
// initialize result and counters
|
|
||||||
var bc = 0, bs, buffer, idx = 0, output = '';
|
|
||||||
// get next character
|
|
||||||
buffer = input.charAt(idx++);
|
|
||||||
// character found in table?
|
|
||||||
// initialize bit storage and add its ascii value
|
|
||||||
~buffer && (bs = bc % 4 ? bs * 64 + buffer : buffer,
|
|
||||||
// and if not first of each 4 characters,
|
|
||||||
// convert the first 8 bits to one ascii character
|
|
||||||
bc++ % 4) ? output += String.fromCharCode(255 & bs >> (-2 * bc & 6)) : 0
|
|
||||||
) {
|
|
||||||
// try to find character in table (0-63, not found => -1)
|
|
||||||
buffer = digits.indexOf(buffer);
|
|
||||||
}
|
|
||||||
return output;
|
|
||||||
};
|
|
||||||
})();
|
|
||||||
|
|
||||||
// Function.prototype.bind ?
|
|
||||||
(function checkFunctionPrototypeBindCompatibility() {
|
|
||||||
if (typeof Function.prototype.bind !== 'undefined')
|
|
||||||
return;
|
|
||||||
|
|
||||||
Function.prototype.bind = function functionPrototypeBind(obj) {
|
|
||||||
var fn = this, headArgs = Array.prototype.slice.call(arguments, 1);
|
|
||||||
var bound = function functionPrototypeBindBound() {
|
|
||||||
var args = Array.prototype.concat.apply(headArgs, arguments);
|
|
||||||
return fn.apply(obj, args);
|
|
||||||
};
|
|
||||||
return bound;
|
|
||||||
};
|
|
||||||
})();
|
|
||||||
|
|
||||||
// HTMLElement dataset property
|
|
||||||
(function checkDatasetProperty() {
|
|
||||||
var div = document.createElement('div');
|
|
||||||
if ('dataset' in div)
|
|
||||||
return; // dataset property exists
|
|
||||||
|
|
||||||
Object.defineProperty(HTMLElement.prototype, 'dataset', {
|
|
||||||
get: function() {
|
|
||||||
if (this._dataset)
|
|
||||||
return this._dataset;
|
|
||||||
|
|
||||||
var dataset = {};
|
|
||||||
for (var j = 0, jj = this.attributes.length; j < jj; j++) {
|
|
||||||
var attribute = this.attributes[j];
|
|
||||||
if (attribute.name.substring(0, 5) != 'data-')
|
|
||||||
continue;
|
|
||||||
var key = attribute.name.substring(5).replace(/\-([a-z])/g,
|
|
||||||
function(all, ch) { return ch.toUpperCase(); });
|
|
||||||
dataset[key] = attribute.value;
|
|
||||||
}
|
|
||||||
|
|
||||||
Object.defineProperty(this, '_dataset', {
|
|
||||||
value: dataset,
|
|
||||||
writable: false,
|
|
||||||
enumerable: false
|
|
||||||
});
|
|
||||||
return dataset;
|
|
||||||
},
|
|
||||||
enumerable: true
|
|
||||||
});
|
|
||||||
})();
|
|
||||||
|
|
||||||
// HTMLElement classList property
|
|
||||||
(function checkClassListProperty() {
|
|
||||||
var div = document.createElement('div');
|
|
||||||
if ('classList' in div)
|
|
||||||
return; // classList property exists
|
|
||||||
|
|
||||||
function changeList(element, itemName, add, remove) {
|
|
||||||
var s = element.className || '';
|
|
||||||
var list = s.split(/\s+/g);
|
|
||||||
if (list[0] === '') list.shift();
|
|
||||||
var index = list.indexOf(itemName);
|
|
||||||
if (index < 0 && add)
|
|
||||||
list.push(itemName);
|
|
||||||
if (index >= 0 && remove)
|
|
||||||
list.splice(index, 1);
|
|
||||||
element.className = list.join(' ');
|
|
||||||
return (index >= 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
var classListPrototype = {
|
|
||||||
add: function(name) {
|
|
||||||
changeList(this.element, name, true, false);
|
|
||||||
},
|
|
||||||
contains: function(name) {
|
|
||||||
return changeList(this.element, name, false, false);
|
|
||||||
},
|
|
||||||
remove: function(name) {
|
|
||||||
changeList(this.element, name, false, true);
|
|
||||||
},
|
|
||||||
toggle: function(name) {
|
|
||||||
changeList(this.element, name, true, true);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
Object.defineProperty(HTMLElement.prototype, 'classList', {
|
|
||||||
get: function() {
|
|
||||||
if (this._classList)
|
|
||||||
return this._classList;
|
|
||||||
|
|
||||||
var classList = Object.create(classListPrototype, {
|
|
||||||
element: {
|
|
||||||
value: this,
|
|
||||||
writable: false,
|
|
||||||
enumerable: true
|
|
||||||
}
|
|
||||||
});
|
|
||||||
Object.defineProperty(this, '_classList', {
|
|
||||||
value: classList,
|
|
||||||
writable: false,
|
|
||||||
enumerable: false
|
|
||||||
});
|
|
||||||
return classList;
|
|
||||||
},
|
|
||||||
enumerable: true
|
|
||||||
});
|
|
||||||
})();
|
|
||||||
|
|
||||||
// Check console compatibility
|
|
||||||
(function checkConsoleCompatibility() {
|
|
||||||
if (!('console' in window)) {
|
|
||||||
window.console = {
|
|
||||||
log: function() {},
|
|
||||||
error: function() {},
|
|
||||||
warn: function() {}
|
|
||||||
};
|
|
||||||
} else if (!('bind' in console.log)) {
|
|
||||||
// native functions in IE9 might not have bind
|
|
||||||
console.log = (function(fn) {
|
|
||||||
return function(msg) { return fn(msg); };
|
|
||||||
})(console.log);
|
|
||||||
console.error = (function(fn) {
|
|
||||||
return function(msg) { return fn(msg); };
|
|
||||||
})(console.error);
|
|
||||||
console.warn = (function(fn) {
|
|
||||||
return function(msg) { return fn(msg); };
|
|
||||||
})(console.warn);
|
|
||||||
}
|
|
||||||
})();
|
|
||||||
|
|
||||||
// Check onclick compatibility in Opera
|
|
||||||
(function checkOnClickCompatibility() {
|
|
||||||
// workaround for reported Opera bug DSK-354448:
|
|
||||||
// onclick fires on disabled buttons with opaque content
|
|
||||||
function ignoreIfTargetDisabled(event) {
|
|
||||||
if (isDisabled(event.target)) {
|
|
||||||
event.stopPropagation();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function isDisabled(node) {
|
|
||||||
return node.disabled || (node.parentNode && isDisabled(node.parentNode));
|
|
||||||
}
|
|
||||||
if (navigator.userAgent.indexOf('Opera') != -1) {
|
|
||||||
// use browser detection since we cannot feature-check this bug
|
|
||||||
document.addEventListener('click', ignoreIfTargetDisabled, true);
|
|
||||||
}
|
|
||||||
})();
|
|
||||||
|
|
||||||
// Checks if navigator.language is supported
|
|
||||||
(function checkNavigatorLanguage() {
|
|
||||||
if ('language' in navigator)
|
|
||||||
return;
|
|
||||||
Object.defineProperty(navigator, 'language', {
|
|
||||||
get: function navigatorLanguage() {
|
|
||||||
var language = navigator.userLanguage || 'en-US';
|
|
||||||
return language.substring(0, 2).toLowerCase() +
|
|
||||||
language.substring(2).toUpperCase();
|
|
||||||
},
|
|
||||||
enumerable: true
|
|
||||||
});
|
|
||||||
})();
|
|
||||||
|
|
||||||
(function checkRangeRequests() {
|
|
||||||
// Safari has issues with cached range requests see:
|
|
||||||
// https://github.com/mozilla/pdf.js/issues/3260
|
|
||||||
// Last tested with version 6.0.4.
|
|
||||||
var isSafari = Object.prototype.toString.call(
|
|
||||||
window.HTMLElement).indexOf('Constructor') > 0;
|
|
||||||
|
|
||||||
// Older versions of Android (pre 3.0) has issues with range requests, see:
|
|
||||||
// https://github.com/mozilla/pdf.js/issues/3381.
|
|
||||||
// Make sure that we only match webkit-based Android browsers,
|
|
||||||
// since Firefox/Fennec works as expected.
|
|
||||||
var regex = /Android\s[0-2][^\d]/;
|
|
||||||
var isOldAndroid = regex.test(navigator.userAgent);
|
|
||||||
|
|
||||||
if (isSafari || isOldAndroid) {
|
|
||||||
PDFJS.disableRange = true;
|
|
||||||
}
|
|
||||||
})();
|
|
||||||
|
|
||||||
// Check if the browser supports manipulation of the history.
|
|
||||||
(function checkHistoryManipulation() {
|
|
||||||
if (!window.history.pushState) {
|
|
||||||
PDFJS.disableHistory = true;
|
|
||||||
}
|
|
||||||
})();
|
|
||||||
File diff suppressed because it is too large
Load Diff
-1680
File diff suppressed because it is too large
Load Diff
+29
-18
@@ -167,6 +167,21 @@ if (typeof PDFJS === 'undefined') {
|
|||||||
// The worker will be using XHR, so we can save time and disable worker.
|
// The worker will be using XHR, so we can save time and disable worker.
|
||||||
PDFJS.disableWorker = true;
|
PDFJS.disableWorker = true;
|
||||||
|
|
||||||
|
Object.defineProperty(xhrPrototype, 'responseType', {
|
||||||
|
get: function xmlHttpRequestGetResponseType() {
|
||||||
|
return this._responseType || 'text';
|
||||||
|
},
|
||||||
|
set: function xmlHttpRequestSetResponseType(value) {
|
||||||
|
if (value === 'text' || value === 'arraybuffer') {
|
||||||
|
this._responseType = value;
|
||||||
|
if (value === 'arraybuffer' &&
|
||||||
|
typeof this.overrideMimeType === 'function') {
|
||||||
|
this.overrideMimeType('text/plain; charset=x-user-defined');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Support: IE9
|
// Support: IE9
|
||||||
if (typeof VBArray !== 'undefined') {
|
if (typeof VBArray !== 'undefined') {
|
||||||
Object.defineProperty(xhrPrototype, 'response', {
|
Object.defineProperty(xhrPrototype, 'response', {
|
||||||
@@ -181,25 +196,20 @@ if (typeof PDFJS === 'undefined') {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// other browsers
|
Object.defineProperty(xhrPrototype, 'response', {
|
||||||
function responseTypeSetter() {
|
get: function xmlHttpRequestResponseGet() {
|
||||||
// will be only called to set "arraybuffer"
|
if (this.responseType !== 'arraybuffer') {
|
||||||
this.overrideMimeType('text/plain; charset=x-user-defined');
|
return this.responseText;
|
||||||
}
|
}
|
||||||
if (typeof xhr.overrideMimeType === 'function') {
|
var text = this.responseText;
|
||||||
Object.defineProperty(xhrPrototype, 'responseType',
|
var i, n = text.length;
|
||||||
{ set: responseTypeSetter });
|
var result = new Uint8Array(n);
|
||||||
}
|
for (i = 0; i < n; ++i) {
|
||||||
function responseGetter() {
|
result[i] = text.charCodeAt(i) & 0xFF;
|
||||||
var text = this.responseText;
|
}
|
||||||
var i, n = text.length;
|
return result.buffer;
|
||||||
var result = new Uint8Array(n);
|
|
||||||
for (i = 0; i < n; ++i) {
|
|
||||||
result[i] = text.charCodeAt(i) & 0xFF;
|
|
||||||
}
|
}
|
||||||
return result.buffer;
|
});
|
||||||
}
|
|
||||||
Object.defineProperty(xhrPrototype, 'response', { get: responseGetter });
|
|
||||||
})();
|
})();
|
||||||
|
|
||||||
// window.btoa (base64 encode function) ?
|
// window.btoa (base64 encode function) ?
|
||||||
@@ -471,6 +481,7 @@ if (typeof PDFJS === 'undefined') {
|
|||||||
|
|
||||||
if (isSafari || isOldAndroid) {
|
if (isSafari || isOldAndroid) {
|
||||||
PDFJS.disableRange = true;
|
PDFJS.disableRange = true;
|
||||||
|
PDFJS.disableStream = true;
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
|
||||||
+273
-148
@@ -22,8 +22,8 @@ if (typeof PDFJS === 'undefined') {
|
|||||||
(typeof window !== 'undefined' ? window : this).PDFJS = {};
|
(typeof window !== 'undefined' ? window : this).PDFJS = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
PDFJS.version = '1.0.712';
|
PDFJS.version = '1.0.1040';
|
||||||
PDFJS.build = '6969ed4';
|
PDFJS.build = '997096f';
|
||||||
|
|
||||||
(function pdfjsWrapper() {
|
(function pdfjsWrapper() {
|
||||||
// Use strict in our context only - users might not want it
|
// Use strict in our context only - users might not want it
|
||||||
@@ -373,6 +373,7 @@ var PasswordException = (function PasswordExceptionClosure() {
|
|||||||
|
|
||||||
return PasswordException;
|
return PasswordException;
|
||||||
})();
|
})();
|
||||||
|
PDFJS.PasswordException = PasswordException;
|
||||||
|
|
||||||
var UnknownErrorException = (function UnknownErrorExceptionClosure() {
|
var UnknownErrorException = (function UnknownErrorExceptionClosure() {
|
||||||
function UnknownErrorException(msg, details) {
|
function UnknownErrorException(msg, details) {
|
||||||
@@ -386,6 +387,7 @@ var UnknownErrorException = (function UnknownErrorExceptionClosure() {
|
|||||||
|
|
||||||
return UnknownErrorException;
|
return UnknownErrorException;
|
||||||
})();
|
})();
|
||||||
|
PDFJS.UnknownErrorException = UnknownErrorException;
|
||||||
|
|
||||||
var InvalidPDFException = (function InvalidPDFExceptionClosure() {
|
var InvalidPDFException = (function InvalidPDFExceptionClosure() {
|
||||||
function InvalidPDFException(msg) {
|
function InvalidPDFException(msg) {
|
||||||
@@ -398,6 +400,7 @@ var InvalidPDFException = (function InvalidPDFExceptionClosure() {
|
|||||||
|
|
||||||
return InvalidPDFException;
|
return InvalidPDFException;
|
||||||
})();
|
})();
|
||||||
|
PDFJS.InvalidPDFException = InvalidPDFException;
|
||||||
|
|
||||||
var MissingPDFException = (function MissingPDFExceptionClosure() {
|
var MissingPDFException = (function MissingPDFExceptionClosure() {
|
||||||
function MissingPDFException(msg) {
|
function MissingPDFException(msg) {
|
||||||
@@ -410,6 +413,22 @@ var MissingPDFException = (function MissingPDFExceptionClosure() {
|
|||||||
|
|
||||||
return MissingPDFException;
|
return MissingPDFException;
|
||||||
})();
|
})();
|
||||||
|
PDFJS.MissingPDFException = MissingPDFException;
|
||||||
|
|
||||||
|
var UnexpectedResponseException =
|
||||||
|
(function UnexpectedResponseExceptionClosure() {
|
||||||
|
function UnexpectedResponseException(msg, status) {
|
||||||
|
this.name = 'UnexpectedResponseException';
|
||||||
|
this.message = msg;
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
|
||||||
|
UnexpectedResponseException.prototype = new Error();
|
||||||
|
UnexpectedResponseException.constructor = UnexpectedResponseException;
|
||||||
|
|
||||||
|
return UnexpectedResponseException;
|
||||||
|
})();
|
||||||
|
PDFJS.UnexpectedResponseException = UnexpectedResponseException;
|
||||||
|
|
||||||
var NotImplementedException = (function NotImplementedExceptionClosure() {
|
var NotImplementedException = (function NotImplementedExceptionClosure() {
|
||||||
function NotImplementedException(msg) {
|
function NotImplementedException(msg) {
|
||||||
@@ -582,10 +601,10 @@ var Util = PDFJS.Util = (function UtilClosure() {
|
|||||||
|
|
||||||
// makeCssRgb() can be called thousands of times. Using |rgbBuf| avoids
|
// makeCssRgb() can be called thousands of times. Using |rgbBuf| avoids
|
||||||
// creating many intermediate strings.
|
// creating many intermediate strings.
|
||||||
Util.makeCssRgb = function Util_makeCssRgb(rgb) {
|
Util.makeCssRgb = function Util_makeCssRgb(r, g, b) {
|
||||||
rgbBuf[1] = rgb[0];
|
rgbBuf[1] = r;
|
||||||
rgbBuf[3] = rgb[1];
|
rgbBuf[3] = g;
|
||||||
rgbBuf[5] = rgb[2];
|
rgbBuf[5] = b;
|
||||||
return rgbBuf.join('');
|
return rgbBuf.join('');
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1655,6 +1674,14 @@ PDFJS.workerSrc = (PDFJS.workerSrc === undefined ? null : PDFJS.workerSrc);
|
|||||||
PDFJS.disableRange = (PDFJS.disableRange === undefined ?
|
PDFJS.disableRange = (PDFJS.disableRange === undefined ?
|
||||||
false : PDFJS.disableRange);
|
false : PDFJS.disableRange);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disable streaming of PDF file data. By default PDF.js attempts to load PDF
|
||||||
|
* in chunks. This default behavior can be disabled.
|
||||||
|
* @var {boolean}
|
||||||
|
*/
|
||||||
|
PDFJS.disableStream = (PDFJS.disableStream === undefined ?
|
||||||
|
false : PDFJS.disableStream);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Disable pre-fetching of PDF file data. When range requests are enabled PDF.js
|
* Disable pre-fetching of PDF file data. When range requests are enabled PDF.js
|
||||||
* will automatically keep fetching more data even if it isn't needed to display
|
* will automatically keep fetching more data even if it isn't needed to display
|
||||||
@@ -1760,6 +1787,11 @@ PDFJS.maxCanvasPixels = (PDFJS.maxCanvasPixels === undefined ?
|
|||||||
* parameters: function that needs to be called with new password and reason
|
* parameters: function that needs to be called with new password and reason
|
||||||
* (see {PasswordResponses}).
|
* (see {PasswordResponses}).
|
||||||
*
|
*
|
||||||
|
* @param {function} progressCallback is optional. It is used to be able to
|
||||||
|
* monitor the loading progress of the PDF file (necessary to implement e.g.
|
||||||
|
* a loading bar). The callback receives an {Object} with the properties:
|
||||||
|
* {number} loaded and {number} total.
|
||||||
|
*
|
||||||
* @return {Promise} A promise that is resolved with {@link PDFDocumentProxy}
|
* @return {Promise} A promise that is resolved with {@link PDFDocumentProxy}
|
||||||
* object.
|
* object.
|
||||||
*/
|
*/
|
||||||
@@ -1848,10 +1880,20 @@ var PDFDocumentProxy = (function PDFDocumentProxyClosure() {
|
|||||||
/**
|
/**
|
||||||
* @return {Promise} A promise that is resolved with a lookup table for
|
* @return {Promise} A promise that is resolved with a lookup table for
|
||||||
* mapping named destinations to reference numbers.
|
* mapping named destinations to reference numbers.
|
||||||
|
*
|
||||||
|
* This can be slow for large documents: use getDestination instead
|
||||||
*/
|
*/
|
||||||
getDestinations: function PDFDocumentProxy_getDestinations() {
|
getDestinations: function PDFDocumentProxy_getDestinations() {
|
||||||
return this.transport.getDestinations();
|
return this.transport.getDestinations();
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
* @param {string} id The named destination to get.
|
||||||
|
* @return {Promise} A promise that is resolved with all information
|
||||||
|
* of the given named destination.
|
||||||
|
*/
|
||||||
|
getDestination: function PDFDocumentProxy_getDestination(id) {
|
||||||
|
return this.transport.getDestination(id);
|
||||||
|
},
|
||||||
/**
|
/**
|
||||||
* @return {Promise} A promise that is resolved with a lookup table for
|
* @return {Promise} A promise that is resolved with a lookup table for
|
||||||
* mapping named attachments to their content.
|
* mapping named attachments to their content.
|
||||||
@@ -2405,6 +2447,12 @@ var WorkerTransport = (function WorkerTransportClosure() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
pdfDataRangeTransport.addProgressiveReadListener(function(chunk) {
|
||||||
|
messageHandler.send('OnDataRange', {
|
||||||
|
chunk: chunk
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
messageHandler.on('RequestDataRange',
|
messageHandler.on('RequestDataRange',
|
||||||
function transportDataRange(data) {
|
function transportDataRange(data) {
|
||||||
pdfDataRangeTransport.requestDataRange(data.begin, data.end);
|
pdfDataRangeTransport.requestDataRange(data.begin, data.end);
|
||||||
@@ -2419,42 +2467,58 @@ var WorkerTransport = (function WorkerTransportClosure() {
|
|||||||
this.workerReadyCapability.resolve(pdfDocument);
|
this.workerReadyCapability.resolve(pdfDocument);
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
messageHandler.on('NeedPassword', function transportPassword(data) {
|
messageHandler.on('NeedPassword',
|
||||||
|
function transportNeedPassword(exception) {
|
||||||
if (this.passwordCallback) {
|
if (this.passwordCallback) {
|
||||||
return this.passwordCallback(updatePassword,
|
return this.passwordCallback(updatePassword,
|
||||||
PasswordResponses.NEED_PASSWORD);
|
PasswordResponses.NEED_PASSWORD);
|
||||||
}
|
}
|
||||||
this.workerReadyCapability.reject(data.exception.message,
|
this.workerReadyCapability.reject(
|
||||||
data.exception);
|
new PasswordException(exception.message, exception.code));
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
messageHandler.on('IncorrectPassword', function transportBadPass(data) {
|
messageHandler.on('IncorrectPassword',
|
||||||
|
function transportIncorrectPassword(exception) {
|
||||||
if (this.passwordCallback) {
|
if (this.passwordCallback) {
|
||||||
return this.passwordCallback(updatePassword,
|
return this.passwordCallback(updatePassword,
|
||||||
PasswordResponses.INCORRECT_PASSWORD);
|
PasswordResponses.INCORRECT_PASSWORD);
|
||||||
}
|
}
|
||||||
this.workerReadyCapability.reject(data.exception.message,
|
this.workerReadyCapability.reject(
|
||||||
data.exception);
|
new PasswordException(exception.message, exception.code));
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
messageHandler.on('InvalidPDF', function transportInvalidPDF(data) {
|
messageHandler.on('InvalidPDF', function transportInvalidPDF(exception) {
|
||||||
this.workerReadyCapability.reject(data.exception.name, data.exception);
|
this.workerReadyCapability.reject(
|
||||||
|
new InvalidPDFException(exception.message));
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
messageHandler.on('MissingPDF', function transportMissingPDF(data) {
|
messageHandler.on('MissingPDF', function transportMissingPDF(exception) {
|
||||||
this.workerReadyCapability.reject(data.exception.message,
|
this.workerReadyCapability.reject(
|
||||||
data.exception);
|
new MissingPDFException(exception.message));
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
messageHandler.on('UnknownError', function transportUnknownError(data) {
|
messageHandler.on('UnexpectedResponse',
|
||||||
this.workerReadyCapability.reject(data.exception.message,
|
function transportUnexpectedResponse(exception) {
|
||||||
data.exception);
|
this.workerReadyCapability.reject(
|
||||||
|
new UnexpectedResponseException(exception.message, exception.status));
|
||||||
|
}, this);
|
||||||
|
|
||||||
|
messageHandler.on('UnknownError',
|
||||||
|
function transportUnknownError(exception) {
|
||||||
|
this.workerReadyCapability.reject(
|
||||||
|
new UnknownErrorException(exception.message, exception.details));
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
messageHandler.on('DataLoaded', function transportPage(data) {
|
messageHandler.on('DataLoaded', function transportPage(data) {
|
||||||
this.downloadInfoCapability.resolve(data);
|
this.downloadInfoCapability.resolve(data);
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
|
messageHandler.on('PDFManagerReady', function transportPage(data) {
|
||||||
|
if (this.pdfDataRangeTransport) {
|
||||||
|
this.pdfDataRangeTransport.transportReady();
|
||||||
|
}
|
||||||
|
}, this);
|
||||||
|
|
||||||
messageHandler.on('StartRenderPage', function transportRender(data) {
|
messageHandler.on('StartRenderPage', function transportRender(data) {
|
||||||
var page = this.pageCache[data.pageIndex];
|
var page = this.pageCache[data.pageIndex];
|
||||||
|
|
||||||
@@ -2486,7 +2550,7 @@ var WorkerTransport = (function WorkerTransportClosure() {
|
|||||||
this.commonObjs.resolve(id, error);
|
this.commonObjs.resolve(id, error);
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
font = new FontFace(exportedData);
|
font = new FontFaceObject(exportedData);
|
||||||
}
|
}
|
||||||
|
|
||||||
FontLoader.bind(
|
FontLoader.bind(
|
||||||
@@ -2544,10 +2608,6 @@ var WorkerTransport = (function WorkerTransportClosure() {
|
|||||||
}
|
}
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
messageHandler.on('DocError', function transportDocError(data) {
|
|
||||||
this.workerReadyCapability.reject(data);
|
|
||||||
}, this);
|
|
||||||
|
|
||||||
messageHandler.on('PageError', function transportError(data) {
|
messageHandler.on('PageError', function transportError(data) {
|
||||||
var page = this.pageCache[data.pageNum - 1];
|
var page = this.pageCache[data.pageNum - 1];
|
||||||
var intentState = page.intentStates[data.intent];
|
var intentState = page.intentStates[data.intent];
|
||||||
@@ -2603,6 +2663,7 @@ var WorkerTransport = (function WorkerTransportClosure() {
|
|||||||
|
|
||||||
fetchDocument: function WorkerTransport_fetchDocument(source) {
|
fetchDocument: function WorkerTransport_fetchDocument(source) {
|
||||||
source.disableAutoFetch = PDFJS.disableAutoFetch;
|
source.disableAutoFetch = PDFJS.disableAutoFetch;
|
||||||
|
source.disableStream = PDFJS.disableStream;
|
||||||
source.chunkedViewerLoading = !!this.pdfDataRangeTransport;
|
source.chunkedViewerLoading = !!this.pdfDataRangeTransport;
|
||||||
this.messageHandler.send('GetDocRequest', {
|
this.messageHandler.send('GetDocRequest', {
|
||||||
source: source,
|
source: source,
|
||||||
@@ -2654,6 +2715,10 @@ var WorkerTransport = (function WorkerTransportClosure() {
|
|||||||
return this.messageHandler.sendWithPromise('GetDestinations', null);
|
return this.messageHandler.sendWithPromise('GetDestinations', null);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getDestination: function WorkerTransport_getDestination(id) {
|
||||||
|
return this.messageHandler.sendWithPromise('GetDestination', { id: id } );
|
||||||
|
},
|
||||||
|
|
||||||
getAttachments: function WorkerTransport_getAttachments() {
|
getAttachments: function WorkerTransport_getAttachments() {
|
||||||
return this.messageHandler.sendWithPromise('GetAttachments', null);
|
return this.messageHandler.sendWithPromise('GetAttachments', null);
|
||||||
},
|
},
|
||||||
@@ -3046,9 +3111,17 @@ var Metadata = PDFJS.Metadata = (function MetadataClosure() {
|
|||||||
|
|
||||||
// Minimal font size that would be used during canvas fillText operations.
|
// Minimal font size that would be used during canvas fillText operations.
|
||||||
var MIN_FONT_SIZE = 16;
|
var MIN_FONT_SIZE = 16;
|
||||||
|
// Maximum font size that would be used during canvas fillText operations.
|
||||||
|
var MAX_FONT_SIZE = 100;
|
||||||
var MAX_GROUP_SIZE = 4096;
|
var MAX_GROUP_SIZE = 4096;
|
||||||
|
|
||||||
|
// Heuristic value used when enforcing minimum line widths.
|
||||||
|
var MIN_WIDTH_FACTOR = 0.65;
|
||||||
|
|
||||||
var COMPILE_TYPE3_GLYPHS = true;
|
var COMPILE_TYPE3_GLYPHS = true;
|
||||||
|
var MAX_SIZE_TO_COMPILE = 1000;
|
||||||
|
|
||||||
|
var FULL_CHUNK_HEIGHT = 16;
|
||||||
|
|
||||||
function createScratchCanvas(width, height) {
|
function createScratchCanvas(width, height) {
|
||||||
var canvas = document.createElement('canvas');
|
var canvas = document.createElement('canvas');
|
||||||
@@ -3182,7 +3255,7 @@ var CachedCanvases = (function CachedCanvasesClosure() {
|
|||||||
getCanvas: function CachedCanvases_getCanvas(id, width, height,
|
getCanvas: function CachedCanvases_getCanvas(id, width, height,
|
||||||
trackTransform) {
|
trackTransform) {
|
||||||
var canvasEntry;
|
var canvasEntry;
|
||||||
if (id in cache) {
|
if (cache[id] !== undefined) {
|
||||||
canvasEntry = cache[id];
|
canvasEntry = cache[id];
|
||||||
canvasEntry.canvas.width = width;
|
canvasEntry.canvas.width = width;
|
||||||
canvasEntry.canvas.height = height;
|
canvasEntry.canvas.height = height;
|
||||||
@@ -3396,6 +3469,7 @@ var CanvasExtraState = (function CanvasExtraStateClosure() {
|
|||||||
// Default fore and background colors
|
// Default fore and background colors
|
||||||
this.fillColor = '#000000';
|
this.fillColor = '#000000';
|
||||||
this.strokeColor = '#000000';
|
this.strokeColor = '#000000';
|
||||||
|
this.patternFill = false;
|
||||||
// Note: fill alpha applies to all non-stroking operations
|
// Note: fill alpha applies to all non-stroking operations
|
||||||
this.fillAlpha = 1;
|
this.fillAlpha = 1;
|
||||||
this.strokeAlpha = 1;
|
this.strokeAlpha = 1;
|
||||||
@@ -3448,6 +3522,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|||||||
if (canvasCtx) {
|
if (canvasCtx) {
|
||||||
addContextCurrentTransform(canvasCtx);
|
addContextCurrentTransform(canvasCtx);
|
||||||
}
|
}
|
||||||
|
this.cachedGetSinglePixelWidth = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function putBinaryImageData(ctx, imgData) {
|
function putBinaryImageData(ctx, imgData) {
|
||||||
@@ -3468,13 +3543,11 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|||||||
// that's ok; any such pixels are ignored.
|
// that's ok; any such pixels are ignored.
|
||||||
|
|
||||||
var height = imgData.height, width = imgData.width;
|
var height = imgData.height, width = imgData.width;
|
||||||
var fullChunkHeight = 16;
|
var partialChunkHeight = height % FULL_CHUNK_HEIGHT;
|
||||||
var fracChunks = height / fullChunkHeight;
|
var fullChunks = (height - partialChunkHeight) / FULL_CHUNK_HEIGHT;
|
||||||
var fullChunks = Math.floor(fracChunks);
|
var totalChunks = partialChunkHeight === 0 ? fullChunks : fullChunks + 1;
|
||||||
var totalChunks = Math.ceil(fracChunks);
|
|
||||||
var partialChunkHeight = height - fullChunks * fullChunkHeight;
|
|
||||||
|
|
||||||
var chunkImgData = ctx.createImageData(width, fullChunkHeight);
|
var chunkImgData = ctx.createImageData(width, FULL_CHUNK_HEIGHT);
|
||||||
var srcPos = 0, destPos;
|
var srcPos = 0, destPos;
|
||||||
var src = imgData.data;
|
var src = imgData.data;
|
||||||
var dest = chunkImgData.data;
|
var dest = chunkImgData.data;
|
||||||
@@ -3494,7 +3567,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|||||||
0xFF000000 : 0x000000FF;
|
0xFF000000 : 0x000000FF;
|
||||||
for (i = 0; i < totalChunks; i++) {
|
for (i = 0; i < totalChunks; i++) {
|
||||||
thisChunkHeight =
|
thisChunkHeight =
|
||||||
(i < fullChunks) ? fullChunkHeight : partialChunkHeight;
|
(i < fullChunks) ? FULL_CHUNK_HEIGHT : partialChunkHeight;
|
||||||
destPos = 0;
|
destPos = 0;
|
||||||
for (j = 0; j < thisChunkHeight; j++) {
|
for (j = 0; j < thisChunkHeight; j++) {
|
||||||
var srcDiff = srcLength - srcPos;
|
var srcDiff = srcLength - srcPos;
|
||||||
@@ -3529,19 +3602,19 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|||||||
dest32[destPos++] = 0;
|
dest32[destPos++] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.putImageData(chunkImgData, 0, i * fullChunkHeight);
|
ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
|
||||||
}
|
}
|
||||||
} else if (imgData.kind === ImageKind.RGBA_32BPP) {
|
} else if (imgData.kind === ImageKind.RGBA_32BPP) {
|
||||||
// RGBA, 32-bits per pixel.
|
// RGBA, 32-bits per pixel.
|
||||||
|
|
||||||
j = 0;
|
j = 0;
|
||||||
elemsInThisChunk = width * fullChunkHeight * 4;
|
elemsInThisChunk = width * FULL_CHUNK_HEIGHT * 4;
|
||||||
for (i = 0; i < fullChunks; i++) {
|
for (i = 0; i < fullChunks; i++) {
|
||||||
dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));
|
dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));
|
||||||
srcPos += elemsInThisChunk;
|
srcPos += elemsInThisChunk;
|
||||||
|
|
||||||
ctx.putImageData(chunkImgData, 0, j);
|
ctx.putImageData(chunkImgData, 0, j);
|
||||||
j += fullChunkHeight;
|
j += FULL_CHUNK_HEIGHT;
|
||||||
}
|
}
|
||||||
if (i < totalChunks) {
|
if (i < totalChunks) {
|
||||||
elemsInThisChunk = width * partialChunkHeight * 4;
|
elemsInThisChunk = width * partialChunkHeight * 4;
|
||||||
@@ -3551,11 +3624,11 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|||||||
|
|
||||||
} else if (imgData.kind === ImageKind.RGB_24BPP) {
|
} else if (imgData.kind === ImageKind.RGB_24BPP) {
|
||||||
// RGB, 24-bits per pixel.
|
// RGB, 24-bits per pixel.
|
||||||
thisChunkHeight = fullChunkHeight;
|
thisChunkHeight = FULL_CHUNK_HEIGHT;
|
||||||
elemsInThisChunk = width * thisChunkHeight;
|
elemsInThisChunk = width * thisChunkHeight;
|
||||||
for (i = 0; i < totalChunks; i++) {
|
for (i = 0; i < totalChunks; i++) {
|
||||||
if (i >= fullChunks) {
|
if (i >= fullChunks) {
|
||||||
thisChunkHeight =partialChunkHeight;
|
thisChunkHeight = partialChunkHeight;
|
||||||
elemsInThisChunk = width * thisChunkHeight;
|
elemsInThisChunk = width * thisChunkHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3566,7 +3639,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|||||||
dest[destPos++] = src[srcPos++];
|
dest[destPos++] = src[srcPos++];
|
||||||
dest[destPos++] = 255;
|
dest[destPos++] = 255;
|
||||||
}
|
}
|
||||||
ctx.putImageData(chunkImgData, 0, i * fullChunkHeight);
|
ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
error('bad image kind: ' + imgData.kind);
|
error('bad image kind: ' + imgData.kind);
|
||||||
@@ -3575,20 +3648,18 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|||||||
|
|
||||||
function putBinaryImageMask(ctx, imgData) {
|
function putBinaryImageMask(ctx, imgData) {
|
||||||
var height = imgData.height, width = imgData.width;
|
var height = imgData.height, width = imgData.width;
|
||||||
var fullChunkHeight = 16;
|
var partialChunkHeight = height % FULL_CHUNK_HEIGHT;
|
||||||
var fracChunks = height / fullChunkHeight;
|
var fullChunks = (height - partialChunkHeight) / FULL_CHUNK_HEIGHT;
|
||||||
var fullChunks = Math.floor(fracChunks);
|
var totalChunks = partialChunkHeight === 0 ? fullChunks : fullChunks + 1;
|
||||||
var totalChunks = Math.ceil(fracChunks);
|
|
||||||
var partialChunkHeight = height - fullChunks * fullChunkHeight;
|
|
||||||
|
|
||||||
var chunkImgData = ctx.createImageData(width, fullChunkHeight);
|
var chunkImgData = ctx.createImageData(width, FULL_CHUNK_HEIGHT);
|
||||||
var srcPos = 0;
|
var srcPos = 0;
|
||||||
var src = imgData.data;
|
var src = imgData.data;
|
||||||
var dest = chunkImgData.data;
|
var dest = chunkImgData.data;
|
||||||
|
|
||||||
for (var i = 0; i < totalChunks; i++) {
|
for (var i = 0; i < totalChunks; i++) {
|
||||||
var thisChunkHeight =
|
var thisChunkHeight =
|
||||||
(i < fullChunks) ? fullChunkHeight : partialChunkHeight;
|
(i < fullChunks) ? FULL_CHUNK_HEIGHT : partialChunkHeight;
|
||||||
|
|
||||||
// Expand the mask so it can be used by the canvas. Any required
|
// Expand the mask so it can be used by the canvas. Any required
|
||||||
// inversion has already been handled.
|
// inversion has already been handled.
|
||||||
@@ -3605,7 +3676,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|||||||
mask >>= 1;
|
mask >>= 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ctx.putImageData(chunkImgData, 0, i * fullChunkHeight);
|
ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3615,14 +3686,14 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|||||||
'globalCompositeOperation', 'font'];
|
'globalCompositeOperation', 'font'];
|
||||||
for (var i = 0, ii = properties.length; i < ii; i++) {
|
for (var i = 0, ii = properties.length; i < ii; i++) {
|
||||||
var property = properties[i];
|
var property = properties[i];
|
||||||
if (property in sourceCtx) {
|
if (sourceCtx[property] !== undefined) {
|
||||||
destCtx[property] = sourceCtx[property];
|
destCtx[property] = sourceCtx[property];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ('setLineDash' in sourceCtx) {
|
if (sourceCtx.setLineDash !== undefined) {
|
||||||
destCtx.setLineDash(sourceCtx.getLineDash());
|
destCtx.setLineDash(sourceCtx.getLineDash());
|
||||||
destCtx.lineDashOffset = sourceCtx.lineDashOffset;
|
destCtx.lineDashOffset = sourceCtx.lineDashOffset;
|
||||||
} else if ('mozDash' in sourceCtx) {
|
} else if (sourceCtx.mozDashOffset !== undefined) {
|
||||||
destCtx.mozDash = sourceCtx.mozDash;
|
destCtx.mozDash = sourceCtx.mozDash;
|
||||||
destCtx.mozDashOffset = sourceCtx.mozDashOffset;
|
destCtx.mozDashOffset = sourceCtx.mozDashOffset;
|
||||||
}
|
}
|
||||||
@@ -3657,9 +3728,9 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|||||||
function composeSMaskLuminosity(maskData, layerData) {
|
function composeSMaskLuminosity(maskData, layerData) {
|
||||||
var length = maskData.length;
|
var length = maskData.length;
|
||||||
for (var i = 3; i < length; i += 4) {
|
for (var i = 3; i < length; i += 4) {
|
||||||
var y = ((maskData[i - 3] * 77) + // * 0.3 / 255 * 0x10000
|
var y = (maskData[i - 3] * 77) + // * 0.3 / 255 * 0x10000
|
||||||
(maskData[i - 2] * 152) + // * 0.59 ....
|
(maskData[i - 2] * 152) + // * 0.59 ....
|
||||||
(maskData[i - 1] * 28)) | 0; // * 0.11 ....
|
(maskData[i - 1] * 28); // * 0.11 ....
|
||||||
layerData[i] = (layerData[i] * y) >> 16;
|
layerData[i] = (layerData[i] * y) >> 16;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3679,7 +3750,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// processing image in chunks to save memory
|
// processing image in chunks to save memory
|
||||||
var PIXELS_TO_PROCESS = 65536;
|
var PIXELS_TO_PROCESS = 1048576;
|
||||||
var chunkSize = Math.min(height, Math.ceil(PIXELS_TO_PROCESS / width));
|
var chunkSize = Math.min(height, Math.ceil(PIXELS_TO_PROCESS / width));
|
||||||
for (var row = 0; row < height; row += chunkSize) {
|
for (var row = 0; row < height; row += chunkSize) {
|
||||||
var chunkHeight = Math.min(chunkSize, height - row);
|
var chunkHeight = Math.min(chunkSize, height - row);
|
||||||
@@ -3849,7 +3920,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|||||||
},
|
},
|
||||||
setDash: function CanvasGraphics_setDash(dashArray, dashPhase) {
|
setDash: function CanvasGraphics_setDash(dashArray, dashPhase) {
|
||||||
var ctx = this.ctx;
|
var ctx = this.ctx;
|
||||||
if ('setLineDash' in ctx) {
|
if (ctx.setLineDash !== undefined) {
|
||||||
ctx.setLineDash(dashArray);
|
ctx.setLineDash(dashArray);
|
||||||
ctx.lineDashOffset = dashPhase;
|
ctx.lineDashOffset = dashPhase;
|
||||||
} else {
|
} else {
|
||||||
@@ -3984,10 +4055,14 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|||||||
|
|
||||||
this.current = this.stateStack.pop();
|
this.current = this.stateStack.pop();
|
||||||
this.ctx.restore();
|
this.ctx.restore();
|
||||||
|
|
||||||
|
this.cachedGetSinglePixelWidth = null;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
transform: function CanvasGraphics_transform(a, b, c, d, e, f) {
|
transform: function CanvasGraphics_transform(a, b, c, d, e, f) {
|
||||||
this.ctx.transform(a, b, c, d, e, f);
|
this.ctx.transform(a, b, c, d, e, f);
|
||||||
|
|
||||||
|
this.cachedGetSinglePixelWidth = null;
|
||||||
},
|
},
|
||||||
|
|
||||||
// Path
|
// Path
|
||||||
@@ -4061,9 +4136,9 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|||||||
consumePath = typeof consumePath !== 'undefined' ? consumePath : true;
|
consumePath = typeof consumePath !== 'undefined' ? consumePath : true;
|
||||||
var ctx = this.ctx;
|
var ctx = this.ctx;
|
||||||
var strokeColor = this.current.strokeColor;
|
var strokeColor = this.current.strokeColor;
|
||||||
if (this.current.lineWidth === 0) {
|
// Prevent drawing too thin lines by enforcing a minimum line width.
|
||||||
ctx.lineWidth = this.getSinglePixelWidth();
|
ctx.lineWidth = Math.max(this.getSinglePixelWidth() * MIN_WIDTH_FACTOR,
|
||||||
}
|
this.current.lineWidth);
|
||||||
// For stroke we want to temporarily change the global alpha to the
|
// For stroke we want to temporarily change the global alpha to the
|
||||||
// stroking alpha.
|
// stroking alpha.
|
||||||
ctx.globalAlpha = this.current.strokeAlpha;
|
ctx.globalAlpha = this.current.strokeAlpha;
|
||||||
@@ -4092,10 +4167,10 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|||||||
consumePath = typeof consumePath !== 'undefined' ? consumePath : true;
|
consumePath = typeof consumePath !== 'undefined' ? consumePath : true;
|
||||||
var ctx = this.ctx;
|
var ctx = this.ctx;
|
||||||
var fillColor = this.current.fillColor;
|
var fillColor = this.current.fillColor;
|
||||||
|
var isPatternFill = this.current.patternFill;
|
||||||
var needRestore = false;
|
var needRestore = false;
|
||||||
|
|
||||||
if (fillColor && fillColor.hasOwnProperty('type') &&
|
if (isPatternFill) {
|
||||||
fillColor.type === 'Pattern') {
|
|
||||||
ctx.save();
|
ctx.save();
|
||||||
ctx.fillStyle = fillColor.getPattern(ctx, this);
|
ctx.fillStyle = fillColor.getPattern(ctx, this);
|
||||||
needRestore = true;
|
needRestore = true;
|
||||||
@@ -4246,9 +4321,9 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|||||||
// Keeping the font at minimal size and using the fontSizeScale to change
|
// Keeping the font at minimal size and using the fontSizeScale to change
|
||||||
// the current transformation matrix before the fillText/strokeText.
|
// the current transformation matrix before the fillText/strokeText.
|
||||||
// See https://bugzilla.mozilla.org/show_bug.cgi?id=726227
|
// See https://bugzilla.mozilla.org/show_bug.cgi?id=726227
|
||||||
var browserFontSize = size >= MIN_FONT_SIZE ? size : MIN_FONT_SIZE;
|
var browserFontSize = size < MIN_FONT_SIZE ? MIN_FONT_SIZE :
|
||||||
this.current.fontSizeScale = browserFontSize !== MIN_FONT_SIZE ? 1.0 :
|
size > MAX_FONT_SIZE ? MAX_FONT_SIZE : size;
|
||||||
size / MIN_FONT_SIZE;
|
this.current.fontSizeScale = size / browserFontSize;
|
||||||
|
|
||||||
var rule = italic + ' ' + bold + ' ' + browserFontSize + 'px ' + typeface;
|
var rule = italic + ' ' + bold + ' ' + browserFontSize + 'px ' + typeface;
|
||||||
this.ctx.font = rule;
|
this.ctx.font = rule;
|
||||||
@@ -4388,7 +4463,13 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|||||||
var lineWidth = current.lineWidth;
|
var lineWidth = current.lineWidth;
|
||||||
var scale = current.textMatrixScale;
|
var scale = current.textMatrixScale;
|
||||||
if (scale === 0 || lineWidth === 0) {
|
if (scale === 0 || lineWidth === 0) {
|
||||||
lineWidth = this.getSinglePixelWidth();
|
var fillStrokeMode = current.textRenderingMode &
|
||||||
|
TextRenderingMode.FILL_STROKE_MASK;
|
||||||
|
if (fillStrokeMode === TextRenderingMode.STROKE ||
|
||||||
|
fillStrokeMode === TextRenderingMode.FILL_STROKE) {
|
||||||
|
this.cachedGetSinglePixelWidth = null;
|
||||||
|
lineWidth = this.getSinglePixelWidth() * MIN_WIDTH_FACTOR;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
lineWidth /= scale;
|
lineWidth /= scale;
|
||||||
}
|
}
|
||||||
@@ -4483,9 +4564,11 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|||||||
var textHScale = current.textHScale * fontDirection;
|
var textHScale = current.textHScale * fontDirection;
|
||||||
var fontMatrix = current.fontMatrix || FONT_IDENTITY_MATRIX;
|
var fontMatrix = current.fontMatrix || FONT_IDENTITY_MATRIX;
|
||||||
var glyphsLength = glyphs.length;
|
var glyphsLength = glyphs.length;
|
||||||
|
var isTextInvisible =
|
||||||
|
current.textRenderingMode === TextRenderingMode.INVISIBLE;
|
||||||
var i, glyph, width;
|
var i, glyph, width;
|
||||||
|
|
||||||
if (fontSize === 0) {
|
if (isTextInvisible || fontSize === 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4567,16 +4650,18 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|||||||
},
|
},
|
||||||
setFillColorN: function CanvasGraphics_setFillColorN(/*...*/) {
|
setFillColorN: function CanvasGraphics_setFillColorN(/*...*/) {
|
||||||
this.current.fillColor = this.getColorN_Pattern(arguments);
|
this.current.fillColor = this.getColorN_Pattern(arguments);
|
||||||
|
this.current.patternFill = true;
|
||||||
},
|
},
|
||||||
setStrokeRGBColor: function CanvasGraphics_setStrokeRGBColor(r, g, b) {
|
setStrokeRGBColor: function CanvasGraphics_setStrokeRGBColor(r, g, b) {
|
||||||
var color = Util.makeCssRgb(arguments);
|
var color = Util.makeCssRgb(r, g, b);
|
||||||
this.ctx.strokeStyle = color;
|
this.ctx.strokeStyle = color;
|
||||||
this.current.strokeColor = color;
|
this.current.strokeColor = color;
|
||||||
},
|
},
|
||||||
setFillRGBColor: function CanvasGraphics_setFillRGBColor(r, g, b) {
|
setFillRGBColor: function CanvasGraphics_setFillRGBColor(r, g, b) {
|
||||||
var color = Util.makeCssRgb(arguments);
|
var color = Util.makeCssRgb(r, g, b);
|
||||||
this.ctx.fillStyle = color;
|
this.ctx.fillStyle = color;
|
||||||
this.current.fillColor = color;
|
this.current.fillColor = color;
|
||||||
|
this.current.patternFill = false;
|
||||||
},
|
},
|
||||||
|
|
||||||
shadingFill: function CanvasGraphics_shadingFill(patternIR) {
|
shadingFill: function CanvasGraphics_shadingFill(patternIR) {
|
||||||
@@ -4835,11 +4920,12 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|||||||
paintImageMaskXObject: function CanvasGraphics_paintImageMaskXObject(img) {
|
paintImageMaskXObject: function CanvasGraphics_paintImageMaskXObject(img) {
|
||||||
var ctx = this.ctx;
|
var ctx = this.ctx;
|
||||||
var width = img.width, height = img.height;
|
var width = img.width, height = img.height;
|
||||||
|
var fillColor = this.current.fillColor;
|
||||||
|
var isPatternFill = this.current.patternFill;
|
||||||
|
|
||||||
var glyph = this.processingType3;
|
var glyph = this.processingType3;
|
||||||
|
|
||||||
if (COMPILE_TYPE3_GLYPHS && glyph && !('compiled' in glyph)) {
|
if (COMPILE_TYPE3_GLYPHS && glyph && glyph.compiled === undefined) {
|
||||||
var MAX_SIZE_TO_COMPILE = 1000;
|
|
||||||
if (width <= MAX_SIZE_TO_COMPILE && height <= MAX_SIZE_TO_COMPILE) {
|
if (width <= MAX_SIZE_TO_COMPILE && height <= MAX_SIZE_TO_COMPILE) {
|
||||||
glyph.compiled =
|
glyph.compiled =
|
||||||
compileType3Glyph({data: img.data, width: width, height: height});
|
compileType3Glyph({data: img.data, width: width, height: height});
|
||||||
@@ -4861,9 +4947,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|||||||
|
|
||||||
maskCtx.globalCompositeOperation = 'source-in';
|
maskCtx.globalCompositeOperation = 'source-in';
|
||||||
|
|
||||||
var fillColor = this.current.fillColor;
|
maskCtx.fillStyle = isPatternFill ?
|
||||||
maskCtx.fillStyle = (fillColor && fillColor.hasOwnProperty('type') &&
|
|
||||||
fillColor.type === 'Pattern') ?
|
|
||||||
fillColor.getPattern(maskCtx, this) : fillColor;
|
fillColor.getPattern(maskCtx, this) : fillColor;
|
||||||
maskCtx.fillRect(0, 0, width, height);
|
maskCtx.fillRect(0, 0, width, height);
|
||||||
|
|
||||||
@@ -4877,7 +4961,8 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|||||||
scaleY, positions) {
|
scaleY, positions) {
|
||||||
var width = imgData.width;
|
var width = imgData.width;
|
||||||
var height = imgData.height;
|
var height = imgData.height;
|
||||||
var ctx = this.ctx;
|
var fillColor = this.current.fillColor;
|
||||||
|
var isPatternFill = this.current.patternFill;
|
||||||
|
|
||||||
var maskCanvas = CachedCanvases.getCanvas('maskCanvas', width, height);
|
var maskCanvas = CachedCanvases.getCanvas('maskCanvas', width, height);
|
||||||
var maskCtx = maskCanvas.context;
|
var maskCtx = maskCanvas.context;
|
||||||
@@ -4887,14 +4972,13 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|||||||
|
|
||||||
maskCtx.globalCompositeOperation = 'source-in';
|
maskCtx.globalCompositeOperation = 'source-in';
|
||||||
|
|
||||||
var fillColor = this.current.fillColor;
|
maskCtx.fillStyle = isPatternFill ?
|
||||||
maskCtx.fillStyle = (fillColor && fillColor.hasOwnProperty('type') &&
|
fillColor.getPattern(maskCtx, this) : fillColor;
|
||||||
fillColor.type === 'Pattern') ?
|
|
||||||
fillColor.getPattern(maskCtx, this) : fillColor;
|
|
||||||
maskCtx.fillRect(0, 0, width, height);
|
maskCtx.fillRect(0, 0, width, height);
|
||||||
|
|
||||||
maskCtx.restore();
|
maskCtx.restore();
|
||||||
|
|
||||||
|
var ctx = this.ctx;
|
||||||
for (var i = 0, ii = positions.length; i < ii; i += 2) {
|
for (var i = 0, ii = positions.length; i < ii; i += 2) {
|
||||||
ctx.save();
|
ctx.save();
|
||||||
ctx.transform(scaleX, 0, 0, scaleY, positions[i], positions[i + 1]);
|
ctx.transform(scaleX, 0, 0, scaleY, positions[i], positions[i + 1]);
|
||||||
@@ -4909,6 +4993,8 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|||||||
function CanvasGraphics_paintImageMaskXObjectGroup(images) {
|
function CanvasGraphics_paintImageMaskXObjectGroup(images) {
|
||||||
var ctx = this.ctx;
|
var ctx = this.ctx;
|
||||||
|
|
||||||
|
var fillColor = this.current.fillColor;
|
||||||
|
var isPatternFill = this.current.patternFill;
|
||||||
for (var i = 0, ii = images.length; i < ii; i++) {
|
for (var i = 0, ii = images.length; i < ii; i++) {
|
||||||
var image = images[i];
|
var image = images[i];
|
||||||
var width = image.width, height = image.height;
|
var width = image.width, height = image.height;
|
||||||
@@ -4921,9 +5007,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|||||||
|
|
||||||
maskCtx.globalCompositeOperation = 'source-in';
|
maskCtx.globalCompositeOperation = 'source-in';
|
||||||
|
|
||||||
var fillColor = this.current.fillColor;
|
maskCtx.fillStyle = isPatternFill ?
|
||||||
maskCtx.fillStyle = (fillColor && fillColor.hasOwnProperty('type') &&
|
|
||||||
fillColor.type === 'Pattern') ?
|
|
||||||
fillColor.getPattern(maskCtx, this) : fillColor;
|
fillColor.getPattern(maskCtx, this) : fillColor;
|
||||||
maskCtx.fillRect(0, 0, width, height);
|
maskCtx.fillRect(0, 0, width, height);
|
||||||
|
|
||||||
@@ -5126,11 +5210,14 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|||||||
ctx.beginPath();
|
ctx.beginPath();
|
||||||
},
|
},
|
||||||
getSinglePixelWidth: function CanvasGraphics_getSinglePixelWidth(scale) {
|
getSinglePixelWidth: function CanvasGraphics_getSinglePixelWidth(scale) {
|
||||||
var inverse = this.ctx.mozCurrentTransformInverse;
|
if (this.cachedGetSinglePixelWidth === null) {
|
||||||
// max of the current horizontal and vertical scale
|
var inverse = this.ctx.mozCurrentTransformInverse;
|
||||||
return Math.sqrt(Math.max(
|
// max of the current horizontal and vertical scale
|
||||||
(inverse[0] * inverse[0] + inverse[1] * inverse[1]),
|
this.cachedGetSinglePixelWidth = Math.sqrt(Math.max(
|
||||||
(inverse[2] * inverse[2] + inverse[3] * inverse[3])));
|
(inverse[0] * inverse[0] + inverse[1] * inverse[1]),
|
||||||
|
(inverse[2] * inverse[2] + inverse[3] * inverse[3])));
|
||||||
|
}
|
||||||
|
return this.cachedGetSinglePixelWidth;
|
||||||
},
|
},
|
||||||
getCanvasPosition: function CanvasGraphics_getCanvasPosition(x, y) {
|
getCanvasPosition: function CanvasGraphics_getCanvasPosition(x, y) {
|
||||||
var transform = this.ctx.mozCurrentTransform;
|
var transform = this.ctx.mozCurrentTransform;
|
||||||
@@ -5198,7 +5285,7 @@ var WebGLUtils = (function WebGLUtilsClosure() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var currentGL, currentCanvas;
|
var currentGL, currentCanvas;
|
||||||
function generageGL() {
|
function generateGL() {
|
||||||
if (currentGL) {
|
if (currentGL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -5256,7 +5343,7 @@ var WebGLUtils = (function WebGLUtilsClosure() {
|
|||||||
function initSmaskGL() {
|
function initSmaskGL() {
|
||||||
var canvas, gl;
|
var canvas, gl;
|
||||||
|
|
||||||
generageGL();
|
generateGL();
|
||||||
canvas = currentCanvas;
|
canvas = currentCanvas;
|
||||||
currentCanvas = null;
|
currentCanvas = null;
|
||||||
gl = currentGL;
|
gl = currentGL;
|
||||||
@@ -5388,7 +5475,7 @@ var WebGLUtils = (function WebGLUtilsClosure() {
|
|||||||
function initFiguresGL() {
|
function initFiguresGL() {
|
||||||
var canvas, gl;
|
var canvas, gl;
|
||||||
|
|
||||||
generageGL();
|
generateGL();
|
||||||
canvas = currentCanvas;
|
canvas = currentCanvas;
|
||||||
currentCanvas = null;
|
currentCanvas = null;
|
||||||
gl = currentGL;
|
gl = currentGL;
|
||||||
@@ -5556,7 +5643,7 @@ var WebGLUtils = (function WebGLUtilsClosure() {
|
|||||||
}
|
}
|
||||||
var enabled = false;
|
var enabled = false;
|
||||||
try {
|
try {
|
||||||
generageGL();
|
generateGL();
|
||||||
enabled = !!currentGL;
|
enabled = !!currentGL;
|
||||||
} catch (e) { }
|
} catch (e) { }
|
||||||
return shadow(this, 'isEnabled', enabled);
|
return shadow(this, 'isEnabled', enabled);
|
||||||
@@ -5949,7 +6036,7 @@ var TilingPattern = (function TilingPatternClosure() {
|
|||||||
context.strokeStyle = ctx.strokeStyle;
|
context.strokeStyle = ctx.strokeStyle;
|
||||||
break;
|
break;
|
||||||
case PaintType.UNCOLORED:
|
case PaintType.UNCOLORED:
|
||||||
var cssColor = Util.makeCssRgb(color);
|
var cssColor = Util.makeCssRgb(color[0], color[1], color[2]);
|
||||||
context.fillStyle = cssColor;
|
context.fillStyle = cssColor;
|
||||||
context.strokeStyle = cssColor;
|
context.strokeStyle = cssColor;
|
||||||
break;
|
break;
|
||||||
@@ -5995,6 +6082,10 @@ var FontLoader = {
|
|||||||
if (styleElement) {
|
if (styleElement) {
|
||||||
styleElement.parentNode.removeChild(styleElement);
|
styleElement.parentNode.removeChild(styleElement);
|
||||||
}
|
}
|
||||||
|
this.nativeFontFaces.forEach(function(nativeFontFace) {
|
||||||
|
document.fonts.delete(nativeFontFace);
|
||||||
|
});
|
||||||
|
this.nativeFontFaces.length = 0;
|
||||||
},
|
},
|
||||||
get loadTestFont() {
|
get loadTestFont() {
|
||||||
// This is a CFF font with 1 glyph for '.' that fills its entire width and
|
// This is a CFF font with 1 glyph for '.' that fills its entire width and
|
||||||
@@ -6051,10 +6142,21 @@ var FontLoader = {
|
|||||||
return false;
|
return false;
|
||||||
})(),
|
})(),
|
||||||
|
|
||||||
|
nativeFontFaces: [],
|
||||||
|
|
||||||
|
isFontLoadingAPISupported: !isWorker && !!document.fonts,
|
||||||
|
|
||||||
|
addNativeFontFace: function fontLoader_addNativeFontFace(nativeFontFace) {
|
||||||
|
this.nativeFontFaces.push(nativeFontFace);
|
||||||
|
document.fonts.add(nativeFontFace);
|
||||||
|
},
|
||||||
|
|
||||||
bind: function fontLoaderBind(fonts, callback) {
|
bind: function fontLoaderBind(fonts, callback) {
|
||||||
assert(!isWorker, 'bind() shall be called from main thread');
|
assert(!isWorker, 'bind() shall be called from main thread');
|
||||||
|
|
||||||
var rules = [], fontsToLoad = [];
|
var rules = [];
|
||||||
|
var fontsToLoad = [];
|
||||||
|
var fontLoadPromises = [];
|
||||||
for (var i = 0, ii = fonts.length; i < ii; i++) {
|
for (var i = 0, ii = fonts.length; i < ii; i++) {
|
||||||
var font = fonts[i];
|
var font = fonts[i];
|
||||||
|
|
||||||
@@ -6065,15 +6167,26 @@ var FontLoader = {
|
|||||||
}
|
}
|
||||||
font.attached = true;
|
font.attached = true;
|
||||||
|
|
||||||
var rule = font.bindDOM();
|
if (this.isFontLoadingAPISupported) {
|
||||||
if (rule) {
|
var nativeFontFace = font.createNativeFontFace();
|
||||||
rules.push(rule);
|
if (nativeFontFace) {
|
||||||
fontsToLoad.push(font);
|
fontLoadPromises.push(nativeFontFace.loaded);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
var rule = font.bindDOM();
|
||||||
|
if (rule) {
|
||||||
|
rules.push(rule);
|
||||||
|
fontsToLoad.push(font);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var request = FontLoader.queueLoadingCallback(callback);
|
var request = FontLoader.queueLoadingCallback(callback);
|
||||||
if (rules.length > 0 && !this.isSyncFontLoadingSupported) {
|
if (this.isFontLoadingAPISupported) {
|
||||||
|
Promise.all(fontsToLoad).then(function() {
|
||||||
|
request.complete();
|
||||||
|
});
|
||||||
|
} else if (rules.length > 0 && !this.isSyncFontLoadingSupported) {
|
||||||
FontLoader.prepareFontLoadEvent(rules, fontsToLoad, request);
|
FontLoader.prepareFontLoadEvent(rules, fontsToLoad, request);
|
||||||
} else {
|
} else {
|
||||||
request.complete();
|
request.complete();
|
||||||
@@ -6208,8 +6321,8 @@ var FontLoader = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var FontFace = (function FontFaceClosure() {
|
var FontFaceObject = (function FontFaceObjectClosure() {
|
||||||
function FontFace(name, file, properties) {
|
function FontFaceObject(name, file, properties) {
|
||||||
this.compiledGlyphs = {};
|
this.compiledGlyphs = {};
|
||||||
if (arguments.length === 1) {
|
if (arguments.length === 1) {
|
||||||
// importing translated data
|
// importing translated data
|
||||||
@@ -6220,8 +6333,29 @@ var FontFace = (function FontFaceClosure() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
FontFace.prototype = {
|
FontFaceObject.prototype = {
|
||||||
bindDOM: function FontFace_bindDOM() {
|
createNativeFontFace: function FontFaceObject_createNativeFontFace() {
|
||||||
|
if (!this.data) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (PDFJS.disableFontFace) {
|
||||||
|
this.disableFontFace = true;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
var nativeFontFace = new FontFace(this.loadedName, this.data, {});
|
||||||
|
|
||||||
|
FontLoader.addNativeFontFace(nativeFontFace);
|
||||||
|
|
||||||
|
if (PDFJS.pdfBug && 'FontInspector' in globalScope &&
|
||||||
|
globalScope['FontInspector'].enabled) {
|
||||||
|
globalScope['FontInspector'].fontAdded(this);
|
||||||
|
}
|
||||||
|
return nativeFontFace;
|
||||||
|
},
|
||||||
|
|
||||||
|
bindDOM: function FontFaceObject_bindDOM() {
|
||||||
if (!this.data) {
|
if (!this.data) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -6248,7 +6382,7 @@ var FontFace = (function FontFaceClosure() {
|
|||||||
return rule;
|
return rule;
|
||||||
},
|
},
|
||||||
|
|
||||||
getPathGenerator: function (objs, character) {
|
getPathGenerator: function FontLoader_getPathGenerator(objs, character) {
|
||||||
if (!(character in this.compiledGlyphs)) {
|
if (!(character in this.compiledGlyphs)) {
|
||||||
var js = objs.get(this.loadedName + '_path_' + character);
|
var js = objs.get(this.loadedName + '_path_' + character);
|
||||||
/*jshint -W054 */
|
/*jshint -W054 */
|
||||||
@@ -6257,11 +6391,10 @@ var FontFace = (function FontFaceClosure() {
|
|||||||
return this.compiledGlyphs[character];
|
return this.compiledGlyphs[character];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return FontFace;
|
return FontFaceObject;
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
|
||||||
var HIGHLIGHT_OFFSET = 4; // px
|
|
||||||
var ANNOT_MIN_SIZE = 10; // px
|
var ANNOT_MIN_SIZE = 10; // px
|
||||||
|
|
||||||
var AnnotationUtils = (function AnnotationUtilsClosure() {
|
var AnnotationUtils = (function AnnotationUtilsClosure() {
|
||||||
@@ -6288,43 +6421,36 @@ var AnnotationUtils = (function AnnotationUtilsClosure() {
|
|||||||
style.fontFamily = fontFamily + fallbackName;
|
style.fontFamily = fontFamily + fallbackName;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(mack): Remove this, it's not really that helpful.
|
function initContainer(item, drawBorder) {
|
||||||
function getEmptyContainer(tagName, rect, borderWidth) {
|
var container = document.createElement('section');
|
||||||
var bWidth = borderWidth || 0;
|
var cstyle = container.style;
|
||||||
var element = document.createElement(tagName);
|
var width = item.rect[2] - item.rect[0];
|
||||||
element.style.borderWidth = bWidth + 'px';
|
var height = item.rect[3] - item.rect[1];
|
||||||
var width = rect[2] - rect[0] - 2 * bWidth;
|
|
||||||
var height = rect[3] - rect[1] - 2 * bWidth;
|
|
||||||
element.style.width = width + 'px';
|
|
||||||
element.style.height = height + 'px';
|
|
||||||
return element;
|
|
||||||
}
|
|
||||||
|
|
||||||
function initContainer(item) {
|
var bWidth = item.borderWidth || 0;
|
||||||
var container = getEmptyContainer('section', item.rect, item.borderWidth);
|
if (bWidth) {
|
||||||
container.style.backgroundColor = item.color;
|
width = width - 2 * bWidth;
|
||||||
|
height = height - 2 * bWidth;
|
||||||
var color = item.color;
|
cstyle.borderWidth = bWidth + 'px';
|
||||||
var rgb = [];
|
var color = item.color;
|
||||||
for (var i = 0; i < 3; ++i) {
|
if (drawBorder && color) {
|
||||||
rgb[i] = Math.round(color[i] * 255);
|
cstyle.borderStyle = 'solid';
|
||||||
|
cstyle.borderColor = Util.makeCssRgb(Math.round(color[0] * 255),
|
||||||
|
Math.round(color[1] * 255),
|
||||||
|
Math.round(color[2] * 255));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
item.colorCssRgb = Util.makeCssRgb(rgb);
|
cstyle.width = width + 'px';
|
||||||
|
cstyle.height = height + 'px';
|
||||||
var highlight = document.createElement('div');
|
|
||||||
highlight.className = 'annotationHighlight';
|
|
||||||
highlight.style.left = highlight.style.top = -HIGHLIGHT_OFFSET + 'px';
|
|
||||||
highlight.style.right = highlight.style.bottom = -HIGHLIGHT_OFFSET + 'px';
|
|
||||||
highlight.setAttribute('hidden', true);
|
|
||||||
|
|
||||||
item.highlightElement = highlight;
|
|
||||||
container.appendChild(item.highlightElement);
|
|
||||||
|
|
||||||
return container;
|
return container;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getHtmlElementForTextWidgetAnnotation(item, commonObjs) {
|
function getHtmlElementForTextWidgetAnnotation(item, commonObjs) {
|
||||||
var element = getEmptyContainer('div', item.rect, 0);
|
var element = document.createElement('div');
|
||||||
|
var width = item.rect[2] - item.rect[0];
|
||||||
|
var height = item.rect[3] - item.rect[1];
|
||||||
|
element.style.width = width + 'px';
|
||||||
|
element.style.height = height + 'px';
|
||||||
element.style.display = 'table';
|
element.style.display = 'table';
|
||||||
|
|
||||||
var content = document.createElement('div');
|
var content = document.createElement('div');
|
||||||
@@ -6354,7 +6480,7 @@ var AnnotationUtils = (function AnnotationUtilsClosure() {
|
|||||||
rect[2] = rect[0] + (rect[3] - rect[1]); // make it square
|
rect[2] = rect[0] + (rect[3] - rect[1]); // make it square
|
||||||
}
|
}
|
||||||
|
|
||||||
var container = initContainer(item);
|
var container = initContainer(item, false);
|
||||||
container.className = 'annotText';
|
container.className = 'annotText';
|
||||||
|
|
||||||
var image = document.createElement('img');
|
var image = document.createElement('img');
|
||||||
@@ -6379,13 +6505,15 @@ var AnnotationUtils = (function AnnotationUtilsClosure() {
|
|||||||
var i, ii;
|
var i, ii;
|
||||||
if (item.hasBgColor) {
|
if (item.hasBgColor) {
|
||||||
var color = item.color;
|
var color = item.color;
|
||||||
var rgb = [];
|
|
||||||
for (i = 0; i < 3; ++i) {
|
// Enlighten the color (70%)
|
||||||
// Enlighten the color (70%)
|
var BACKGROUND_ENLIGHT = 0.7;
|
||||||
var c = Math.round(color[i] * 255);
|
var r = BACKGROUND_ENLIGHT * (1.0 - color[0]) + color[0];
|
||||||
rgb[i] = Math.round((255 - c) * 0.7) + c;
|
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(rgb);
|
content.style.backgroundColor = Util.makeCssRgb((r * 255) | 0,
|
||||||
|
(g * 255) | 0,
|
||||||
|
(b * 255) | 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
var title = document.createElement('h1');
|
var title = document.createElement('h1');
|
||||||
@@ -6461,12 +6589,9 @@ var AnnotationUtils = (function AnnotationUtilsClosure() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getHtmlElementForLinkAnnotation(item) {
|
function getHtmlElementForLinkAnnotation(item) {
|
||||||
var container = initContainer(item);
|
var container = initContainer(item, true);
|
||||||
container.className = 'annotLink';
|
container.className = 'annotLink';
|
||||||
|
|
||||||
container.style.borderColor = item.colorCssRgb;
|
|
||||||
container.style.borderStyle = 'solid';
|
|
||||||
|
|
||||||
var link = document.createElement('a');
|
var link = document.createElement('a');
|
||||||
link.href = link.title = item.url || '';
|
link.href = link.title = item.url || '';
|
||||||
|
|
||||||
@@ -7297,11 +7422,11 @@ var SVGGraphics = (function SVGGraphicsClosure() {
|
|||||||
this.current.miterLimit = limit;
|
this.current.miterLimit = limit;
|
||||||
},
|
},
|
||||||
setStrokeRGBColor: function SVGGraphics_setStrokeRGBColor(r, g, b) {
|
setStrokeRGBColor: function SVGGraphics_setStrokeRGBColor(r, g, b) {
|
||||||
var color = Util.makeCssRgb(arguments);
|
var color = Util.makeCssRgb(r, g, b);
|
||||||
this.current.strokeColor = color;
|
this.current.strokeColor = color;
|
||||||
},
|
},
|
||||||
setFillRGBColor: function SVGGraphics_setFillRGBColor(r, g, b) {
|
setFillRGBColor: function SVGGraphics_setFillRGBColor(r, g, b) {
|
||||||
var color = Util.makeCssRgb(arguments);
|
var color = Util.makeCssRgb(r, g, b);
|
||||||
this.current.fillColor = color;
|
this.current.fillColor = color;
|
||||||
this.current.tspan = document.createElementNS(NS, 'svg:tspan');
|
this.current.tspan = document.createElementNS(NS, 'svg:tspan');
|
||||||
this.current.xcoords = [];
|
this.current.xcoords = [];
|
||||||
+1258
-329
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user