Replaces all preprocessor directives with PDFJSDev calls.

This commit is contained in:
Yury Delendik 2016-10-14 10:57:53 -05:00
parent bf52ff156d
commit 0576c9c6c6
32 changed files with 1145 additions and 904 deletions

View file

@ -616,49 +616,49 @@ function isEvalSupported() {
}
}
//#if !(FIREFOX || MOZCENTRAL || CHROME)
var Uint32ArrayView = (function Uint32ArrayViewClosure() {
function Uint32ArrayView(buffer, length) {
this.buffer = buffer;
this.byteLength = buffer.length;
this.length = length === undefined ? (this.byteLength >> 2) : length;
ensureUint32ArrayViewProps(this.length);
}
Uint32ArrayView.prototype = Object.create(null);
var uint32ArrayViewSetters = 0;
function createUint32ArrayProp(index) {
return {
get: function () {
var buffer = this.buffer, offset = index << 2;
return (buffer[offset] | (buffer[offset + 1] << 8) |
(buffer[offset + 2] << 16) | (buffer[offset + 3] << 24)) >>> 0;
},
set: function (value) {
var buffer = this.buffer, offset = index << 2;
buffer[offset] = value & 255;
buffer[offset + 1] = (value >> 8) & 255;
buffer[offset + 2] = (value >> 16) & 255;
buffer[offset + 3] = (value >>> 24) & 255;
}
};
}
function ensureUint32ArrayViewProps(length) {
while (uint32ArrayViewSetters < length) {
Object.defineProperty(Uint32ArrayView.prototype,
uint32ArrayViewSetters,
createUint32ArrayProp(uint32ArrayViewSetters));
uint32ArrayViewSetters++;
if (typeof PDFJSDev === 'undefined' ||
!PDFJSDev.test('FIREFOX || MOZCENTRAL || CHROME')) {
var Uint32ArrayView = (function Uint32ArrayViewClosure() {
function Uint32ArrayView(buffer, length) {
this.buffer = buffer;
this.byteLength = buffer.length;
this.length = length === undefined ? (this.byteLength >> 2) : length;
ensureUint32ArrayViewProps(this.length);
}
}
Uint32ArrayView.prototype = Object.create(null);
return Uint32ArrayView;
})();
var uint32ArrayViewSetters = 0;
function createUint32ArrayProp(index) {
return {
get: function () {
var buffer = this.buffer, offset = index << 2;
return (buffer[offset] | (buffer[offset + 1] << 8) |
(buffer[offset + 2] << 16) | (buffer[offset + 3] << 24)) >>> 0;
},
set: function (value) {
var buffer = this.buffer, offset = index << 2;
buffer[offset] = value & 255;
buffer[offset + 1] = (value >> 8) & 255;
buffer[offset + 2] = (value >> 16) & 255;
buffer[offset + 3] = (value >>> 24) & 255;
}
};
}
exports.Uint32ArrayView = Uint32ArrayView;
//#endif
function ensureUint32ArrayViewProps(length) {
while (uint32ArrayViewSetters < length) {
Object.defineProperty(Uint32ArrayView.prototype,
uint32ArrayViewSetters,
createUint32ArrayProp(uint32ArrayViewSetters));
uint32ArrayViewSetters++;
}
}
return Uint32ArrayView;
})();
exports.Uint32ArrayView = Uint32ArrayView;
}
var IDENTITY_MATRIX = [1, 0, 0, 1, 0, 0];
@ -1199,7 +1199,8 @@ function createPromiseCapability() {
}
return;
}
//#if !MOZCENTRAL
if (typeof PDFJSDev === 'undefined' || !PDFJSDev.test('MOZCENTRAL')) {
var STATUS_PENDING = 0;
var STATUS_RESOLVED = 1;
var STATUS_REJECTED = 2;
@ -1317,7 +1318,7 @@ function createPromiseCapability() {
}
};
function Promise(resolver) {
var Promise = function Promise(resolver) {
this._status = STATUS_PENDING;
this._handlers = [];
try {
@ -1325,7 +1326,8 @@ function createPromiseCapability() {
} catch (e) {
this._reject(e);
}
}
};
/**
* Builds a promise that is resolved when all the passed in promises are
* resolved.
@ -1459,43 +1461,44 @@ function createPromiseCapability() {
};
globalScope.Promise = Promise;
//#else
//throw new Error('DOM Promise is not present');
//#endif
} else {
throw new Error('DOM Promise is not present');
}
})();
//#if !MOZCENTRAL
(function WeakMapClosure() {
if (globalScope.WeakMap) {
return;
}
var id = 0;
function WeakMap() {
this.id = '$weakmap' + (id++);
}
WeakMap.prototype = {
has: function(obj) {
return !!Object.getOwnPropertyDescriptor(obj, this.id);
},
get: function(obj, defaultValue) {
return this.has(obj) ? obj[this.id] : defaultValue;
},
set: function(obj, value) {
Object.defineProperty(obj, this.id, {
value: value,
enumerable: false,
configurable: true
});
},
delete: function(obj) {
delete obj[this.id];
if (typeof PDFJSDev === 'undefined' || !PDFJSDev.test('MOZCENTRAL')) {
(function WeakMapClosure() {
if (globalScope.WeakMap) {
return;
}
};
globalScope.WeakMap = WeakMap;
})();
//#endif
var id = 0;
function WeakMap() {
this.id = '$weakmap' + (id++);
}
WeakMap.prototype = {
has: function(obj) {
return !!Object.getOwnPropertyDescriptor(obj, this.id);
},
get: function(obj, defaultValue) {
return this.has(obj) ? obj[this.id] : defaultValue;
},
set: function(obj, value) {
Object.defineProperty(obj, this.id, {
value: value,
enumerable: false,
configurable: true
});
},
delete: function(obj) {
delete obj[this.id];
}
};
globalScope.WeakMap = WeakMap;
})();
}
var StatTimer = (function StatTimerClosure() {
function rpad(str, pad, length) {
@ -1736,8 +1739,8 @@ function loadJpegStream(id, imageUrl, objs) {
img.src = imageUrl;
}
//#if !(MOZCENTRAL)
//// Polyfill from https://github.com/Polymer/URL
if (typeof PDFJSDev === 'undefined' || !PDFJSDev.test('MOZCENTRAL')) {
// Polyfill from https://github.com/Polymer/URL
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
(function checkURLConstructor(scope) {
@ -2378,7 +2381,7 @@ function loadJpegStream(id, imageUrl, objs) {
scope.URL = JURL;
})(globalScope);
//#endif
}
exports.FONT_IDENTITY_MATRIX = FONT_IDENTITY_MATRIX;
exports.IDENTITY_MATRIX = IDENTITY_MATRIX;