Syntax changed that will help minifiers/compilers (such as the Closure Compiler) in their processing. In particular, preventing said minifiers/compilers from making dangerous renames.
This commit is contained in:
parent
438e3c8f6d
commit
0fbbc5a840
@ -345,8 +345,9 @@ var PDFPageProxy = (function PDFPageProxyClosure() {
|
|||||||
var length = this.operatorList.fnArray.length;
|
var length = this.operatorList.fnArray.length;
|
||||||
var operatorList = this.operatorList;
|
var operatorList = this.operatorList;
|
||||||
var stepper = null;
|
var stepper = null;
|
||||||
if (PDFJS.pdfBug && StepperManager.enabled) {
|
if (PDFJS.pdfBug && 'StepperManager' in globalScope &&
|
||||||
stepper = StepperManager.create(this.pageNumber - 1);
|
globalScope['StepperManager'].enabled) {
|
||||||
|
stepper = globalScope['StepperManager'].create(this.pageNumber - 1);
|
||||||
stepper.init(operatorList);
|
stepper.init(operatorList);
|
||||||
stepper.nextBreakPoint = stepper.getNextBreakPoint();
|
stepper.nextBreakPoint = stepper.getNextBreakPoint();
|
||||||
}
|
}
|
||||||
|
@ -3141,8 +3141,9 @@ var Font = (function FontClosure() {
|
|||||||
var styleSheet = styleElement.sheet;
|
var styleSheet = styleElement.sheet;
|
||||||
styleSheet.insertRule(rule, styleSheet.cssRules.length);
|
styleSheet.insertRule(rule, styleSheet.cssRules.length);
|
||||||
|
|
||||||
if (PDFJS.pdfBug && FontInspector.enabled)
|
if (PDFJS.pdfBug && 'FontInspector' in globalScope &&
|
||||||
FontInspector.fontAdded(this, url);
|
globalScope['FontInspector'].enabled)
|
||||||
|
globalScope['FontInspector'].fontAdded(this, url);
|
||||||
|
|
||||||
return rule;
|
return rule;
|
||||||
},
|
},
|
||||||
|
@ -255,7 +255,7 @@ var JpxImage = (function JpxImageClosure() {
|
|||||||
cod.resetContextProbabilities ||
|
cod.resetContextProbabilities ||
|
||||||
cod.terminationOnEachCodingPass ||
|
cod.terminationOnEachCodingPass ||
|
||||||
cod.verticalyStripe || cod.predictableTermination)
|
cod.verticalyStripe || cod.predictableTermination)
|
||||||
throw 'Unsupported COD options: ' + uneval(cod);
|
throw 'Unsupported COD options: ' + globalScope.JSON.stringify(cod);
|
||||||
|
|
||||||
if (context.mainHeader)
|
if (context.mainHeader)
|
||||||
context.COD = cod;
|
context.COD = cod;
|
||||||
|
27
src/util.js
27
src/util.js
@ -5,12 +5,16 @@
|
|||||||
|
|
||||||
// Use only for debugging purposes. This should not be used in any code that is
|
// Use only for debugging purposes. This should not be used in any code that is
|
||||||
// in mozilla master.
|
// in mozilla master.
|
||||||
function log(msg) {
|
var log = (function() {
|
||||||
if (console && console.log)
|
if ('console' in globalScope && 'log' in globalScope['console']) {
|
||||||
console.log(msg);
|
return globalScope['console']['log'].bind(globalScope['console']);
|
||||||
else if (print)
|
} else if ('print' in globalScope) {
|
||||||
print(msg);
|
return globalScope['print'].bind(globalScope);
|
||||||
}
|
} else {
|
||||||
|
return function nop() {
|
||||||
|
};
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
|
||||||
// A notice for devs that will not trigger the fallback UI. These are good
|
// A notice for devs that will not trigger the fallback UI. These are good
|
||||||
// for things that are helpful to devs, such as warning that Workers were
|
// for things that are helpful to devs, such as warning that Workers were
|
||||||
@ -33,7 +37,16 @@ function warn(msg) {
|
|||||||
// Fatal errors that should trigger the fallback UI and halt execution by
|
// Fatal errors that should trigger the fallback UI and halt execution by
|
||||||
// throwing an exception.
|
// throwing an exception.
|
||||||
function error(msg) {
|
function error(msg) {
|
||||||
log('Error: ' + msg);
|
// If multiple arguments were passed, pass them all to the log function.
|
||||||
|
if (arguments.length > 1) {
|
||||||
|
var logArguments = ['Error:'];
|
||||||
|
logArguments.push.apply(logArguments, arguments);
|
||||||
|
log.apply(null, logArguments);
|
||||||
|
// Join the arguments into a single string for the lines below.
|
||||||
|
msg = [].join.call(arguments, ' ');
|
||||||
|
} else {
|
||||||
|
log('Error: ' + msg);
|
||||||
|
}
|
||||||
log(backtrace());
|
log(backtrace());
|
||||||
PDFJS.LogManager.notify('error', msg);
|
PDFJS.LogManager.notify('error', msg);
|
||||||
throw new Error(msg);
|
throw new Error(msg);
|
||||||
|
@ -11,11 +11,17 @@ function MessageHandler(name, comObj) {
|
|||||||
var ah = this.actionHandler = {};
|
var ah = this.actionHandler = {};
|
||||||
|
|
||||||
ah['console_log'] = [function ahConsoleLog(data) {
|
ah['console_log'] = [function ahConsoleLog(data) {
|
||||||
console.log.apply(console, data);
|
log.apply(null, data);
|
||||||
}];
|
|
||||||
ah['console_error'] = [function ahConsoleError(data) {
|
|
||||||
console.error.apply(console, data);
|
|
||||||
}];
|
}];
|
||||||
|
// If there's no console available, console_error in the action handler will do nothing.
|
||||||
|
if ('console' in globalScope) {
|
||||||
|
ah['console_error'] = [function ahConsoleError(data) {
|
||||||
|
globalScope['console'].error.apply(null, data);
|
||||||
|
}];
|
||||||
|
} else {
|
||||||
|
ah['console_error'] = [function ahConsoleError(data) {
|
||||||
|
}];
|
||||||
|
}
|
||||||
ah['_warn'] = [function ah_Warn(data) {
|
ah['_warn'] = [function ah_Warn(data) {
|
||||||
warn(data);
|
warn(data);
|
||||||
}];
|
}];
|
||||||
@ -263,7 +269,7 @@ var consoleTimer = {};
|
|||||||
var workerConsole = {
|
var workerConsole = {
|
||||||
log: function log() {
|
log: function log() {
|
||||||
var args = Array.prototype.slice.call(arguments);
|
var args = Array.prototype.slice.call(arguments);
|
||||||
postMessage({
|
globalScope.postMessage({
|
||||||
action: 'console_log',
|
action: 'console_log',
|
||||||
data: args
|
data: args
|
||||||
});
|
});
|
||||||
@ -271,7 +277,7 @@ var workerConsole = {
|
|||||||
|
|
||||||
error: function error() {
|
error: function error() {
|
||||||
var args = Array.prototype.slice.call(arguments);
|
var args = Array.prototype.slice.call(arguments);
|
||||||
postMessage({
|
globalScope.postMessage({
|
||||||
action: 'console_error',
|
action: 'console_error',
|
||||||
data: args
|
data: args
|
||||||
});
|
});
|
||||||
@ -299,7 +305,7 @@ if (typeof window === 'undefined') {
|
|||||||
// throw an exception which will be forwarded on automatically.
|
// throw an exception which will be forwarded on automatically.
|
||||||
PDFJS.LogManager.addLogger({
|
PDFJS.LogManager.addLogger({
|
||||||
warn: function(msg) {
|
warn: function(msg) {
|
||||||
postMessage({
|
globalScope.postMessage({
|
||||||
action: '_warn',
|
action: '_warn',
|
||||||
data: msg
|
data: msg
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user