Fix up late patches to pdf.js and web/compatibility.js.
This commit is contained in:
parent
ebeff10a9a
commit
699c91b0aa
22
pdf.js
22
pdf.js
@ -3764,7 +3764,7 @@ var CanvasGraphics = (function() {
|
||||
transform: function(a, b, c, d, e, f) {
|
||||
this.ctx.transform(a, b, c, d, e, f);
|
||||
},
|
||||
|
||||
|
||||
// Path
|
||||
moveTo: function(x, y) {
|
||||
this.ctx.moveTo(x, y);
|
||||
@ -3825,7 +3825,7 @@ var CanvasGraphics = (function() {
|
||||
endPath: function() {
|
||||
this.consumePath();
|
||||
},
|
||||
|
||||
|
||||
// Clipping
|
||||
clip: function() {
|
||||
this.pendingClip = NORMAL_CLIP;
|
||||
@ -3833,7 +3833,7 @@ var CanvasGraphics = (function() {
|
||||
eoClip: function() {
|
||||
this.pendingClip = EO_CLIP;
|
||||
},
|
||||
|
||||
|
||||
// Text
|
||||
beginText: function() {
|
||||
this.current.textMatrix = IDENTITY_MATRIX;
|
||||
@ -3858,27 +3858,27 @@ var CanvasGraphics = (function() {
|
||||
this.current.leading = leading;
|
||||
},
|
||||
setFont: function(fontRef, size) {
|
||||
var font = this.xref.fetchIfRef(this.res.get("Font"));
|
||||
var font = this.xref.fetchIfRef(this.res.get('Font'));
|
||||
if (!IsDict(font))
|
||||
return;
|
||||
|
||||
|
||||
font = font.get(fontRef.name);
|
||||
font = this.xref.fetchIfRef(font);
|
||||
if (!font)
|
||||
return;
|
||||
|
||||
var fontName = "";
|
||||
var fontDescriptor = font.get("FontDescriptor");
|
||||
|
||||
var fontName = '';
|
||||
var fontDescriptor = font.get('FontDescriptor');
|
||||
if (fontDescriptor && fontDescriptor.num) {
|
||||
var fontDescriptor = this.xref.fetchIfRef(fontDescriptor);
|
||||
fontName = fontDescriptor.get("FontName").name.replace("+", "_");
|
||||
fontName = fontDescriptor.get('FontName').name.replace('+', '_');
|
||||
}
|
||||
|
||||
|
||||
if (!fontName) {
|
||||
// TODO: fontDescriptor is not available, fallback to default font
|
||||
fontName = 'sans-serif';
|
||||
}
|
||||
|
||||
|
||||
this.current.fontName = fontName;
|
||||
this.current.fontSize = size;
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
// Checking if the typed arrays are supported
|
||||
(function() {
|
||||
if (typeof Uint8Array !== "undefined")
|
||||
if (typeof Uint8Array !== 'undefined')
|
||||
return;
|
||||
|
||||
function subarray(start, end) {
|
||||
@ -18,7 +18,7 @@
|
||||
|
||||
function TypedArray(arg1) {
|
||||
var result;
|
||||
if (typeof arg1 === "number") {
|
||||
if (typeof arg1 === 'number') {
|
||||
result = new Array(arg1);
|
||||
for (var i = 0; i < arg1; ++i)
|
||||
result[i] = 0;
|
||||
@ -28,23 +28,23 @@
|
||||
result.buffer = result;
|
||||
result.byteLength = result.length;
|
||||
result.set = set_;
|
||||
if (typeof arg1 === "object" && arg1.buffer)
|
||||
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
|
||||
// so we can use the TypedArray as well
|
||||
window.Uint32Array = TypedArray;
|
||||
window.Int32Array = TypedArray;
|
||||
})();
|
||||
|
||||
// Object.create() ?
|
||||
(function() {
|
||||
if (typeof Object.create !== "undefined")
|
||||
if (typeof Object.create !== 'undefined')
|
||||
return;
|
||||
|
||||
Object.create = function(proto) {
|
||||
@ -56,16 +56,16 @@
|
||||
|
||||
// Object.defineProperty() ?
|
||||
(function() {
|
||||
if (typeof Object.defineProperty !== "undefined")
|
||||
if (typeof Object.defineProperty !== 'undefined')
|
||||
return;
|
||||
|
||||
Object.defineProperty = function(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) {
|
||||
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(value) {
|
||||
this.__defineGetter__(name, function() {
|
||||
return value;
|
||||
@ -80,16 +80,16 @@
|
||||
// No XMLHttpRequest.response ?
|
||||
(function() {
|
||||
var xhrPrototype = XMLHttpRequest.prototype;
|
||||
if ("response" in xhrPrototype ||
|
||||
"mozResponseArrayBuffer" in xhrPrototype ||
|
||||
"mozResponse" in xhrPrototype ||
|
||||
"responseArrayBuffer" in xhrPrototype)
|
||||
if ('response' in xhrPrototype ||
|
||||
'mozResponseArrayBuffer' in xhrPrototype ||
|
||||
'mozResponse' in xhrPrototype ||
|
||||
'responseArrayBuffer' in xhrPrototype)
|
||||
return;
|
||||
// IE ?
|
||||
if (typeof VBArray !== "undefined") {
|
||||
Object.defineProperty(xhrPrototype, "response", {
|
||||
if (typeof VBArray !== 'undefined') {
|
||||
Object.defineProperty(xhrPrototype, 'response', {
|
||||
get: function() {
|
||||
return new Uint8Array( new VBArray(this.responseBody).toArray() );
|
||||
return new Uint8Array(new VBArray(this.responseBody).toArray());
|
||||
}
|
||||
});
|
||||
return;
|
||||
@ -98,10 +98,11 @@
|
||||
// other browsers
|
||||
function responseTypeSetter() {
|
||||
// will be only called to set "arraybuffer"
|
||||
this.overrideMimeType("text/plain; charset=x-user-defined");
|
||||
this.overrideMimeType('text/plain; charset=x-user-defined');
|
||||
}
|
||||
if (typeof xhrPrototype.overrideMimeType === "function") {
|
||||
Object.defineProperty(xhrPrototype, "responseType", { set: responseTypeSetter });
|
||||
if (typeof xhrPrototype.overrideMimeType === 'function') {
|
||||
Object.defineProperty(xhrPrototype, 'responseType',
|
||||
{ set: responseTypeSetter });
|
||||
}
|
||||
function responseGetter() {
|
||||
var text = this.responseText;
|
||||
@ -111,18 +112,19 @@
|
||||
result[i] = text.charCodeAt(i) & 0xFF;
|
||||
return result;
|
||||
}
|
||||
Object.defineProperty(xhrPrototype, "response", { get: responseGetter });
|
||||
Object.defineProperty(xhrPrototype, 'response', { get: responseGetter });
|
||||
})();
|
||||
|
||||
// window.btoa (base64 encode function) ?
|
||||
(function() {
|
||||
if ("btoa" in window)
|
||||
if ('btoa' in window)
|
||||
return;
|
||||
|
||||
var digits = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
|
||||
var digits =
|
||||
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
|
||||
|
||||
window.btoa = function(chars) {
|
||||
var buffer = "";
|
||||
var buffer = '';
|
||||
var i, n;
|
||||
for (i = 0, n = chars.length; i < n; i += 3) {
|
||||
var b1 = chars.charCodeAt(i) & 0xFF;
|
||||
@ -131,15 +133,16 @@
|
||||
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);
|
||||
buffer += (digits.charAt(d1) + digits.charAt(d2) +
|
||||
digits.charAt(d3) + digits.charAt(d4));
|
||||
}
|
||||
return buffer;
|
||||
};
|
||||
};
|
||||
})();
|
||||
|
||||
// Function.prototype.bind ?
|
||||
(function() {
|
||||
if (typeof Function.prototype.bind !== "undefined")
|
||||
if (typeof Function.prototype.bind !== 'undefined')
|
||||
return;
|
||||
|
||||
Function.prototype.bind = function(obj) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user