Only trigger warning bar on certain unsupported features.
This commit is contained in:
parent
1bada35388
commit
2228343f77
11 changed files with 70 additions and 74 deletions
|
@ -14,7 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/* globals Util, isDict, isName, stringToPDFString, TODO, Dict, Stream,
|
||||
/* globals Util, isDict, isName, stringToPDFString, warn, Dict, Stream,
|
||||
stringToBytes, PDFJS, isWorker, assert, NotImplementedException,
|
||||
Promise, isArray, ObjectLoader, isValidUrl, OperatorList, OPS */
|
||||
|
||||
|
@ -266,7 +266,7 @@ var Annotation = (function AnnotationClosure() {
|
|||
if (annotation.isViewable()) {
|
||||
return annotation;
|
||||
} else {
|
||||
TODO('unimplemented annotation type: ' + subtype);
|
||||
warn('unimplemented annotation type: ' + subtype);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -358,7 +358,7 @@ var WidgetAnnotation = (function WidgetAnnotationClosure() {
|
|||
Util.inherit(WidgetAnnotation, Annotation, {
|
||||
isViewable: function WidgetAnnotation_isViewable() {
|
||||
if (this.data.fieldType === 'Sig') {
|
||||
TODO('unimplemented annotation type: Widget signature');
|
||||
warn('unimplemented annotation type: Widget signature');
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -643,7 +643,7 @@ var LinkAnnotation = (function LinkAnnotationClosure() {
|
|||
} else if (linkType === 'Named') {
|
||||
data.action = action.get('N').name;
|
||||
} else {
|
||||
TODO('unrecognized link type: ' + linkType);
|
||||
warn('unrecognized link type: ' + linkType);
|
||||
}
|
||||
} else if (dict.has('Dest')) {
|
||||
// simple destination link
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
/* globals error, info, isArray, isDict, isName, isStream, isString,
|
||||
PDFFunction, warn, shadow, TODO */
|
||||
PDFFunction, warn, shadow */
|
||||
|
||||
'use strict';
|
||||
|
||||
|
@ -671,7 +671,7 @@ var CalGrayCS = (function CalGrayCSClosure() {
|
|||
}
|
||||
|
||||
if (this.XB !== 0 || this.YB !== 0 || this.ZB !== 0) {
|
||||
TODO(this.name + ', BlackPoint: XB: ' + this.XB + ', YB: ' + this.YB +
|
||||
warn(this.name + ', BlackPoint: XB: ' + this.XB + ', YB: ' + this.YB +
|
||||
', ZB: ' + this.ZB + ', only default values are supported.');
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
||||
/* globals EOF, error, isArray, isBool, Lexer, TODO */
|
||||
/* Copyright 2012 Mozilla Foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
@ -15,6 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/* globals EOF, error, isArray, isBool, Lexer, info */
|
||||
|
||||
'use strict';
|
||||
|
||||
|
@ -122,7 +122,7 @@ var PDFFunction = (function PDFFunctionClosure() {
|
|||
if (order !== 1) {
|
||||
// No description how cubic spline interpolation works in PDF32000:2008
|
||||
// As in poppler, ignoring order, linear interpolation may work as good
|
||||
TODO('No support for cubic spline interpolation: ' + order);
|
||||
info('No support for cubic spline interpolation: ' + order);
|
||||
}
|
||||
|
||||
var encode = dict.get('Encode');
|
||||
|
|
|
@ -15,8 +15,8 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
/* globals CanvasGraphics, ColorSpace, DeviceRgbCS, error,
|
||||
info, isArray, isPDFFunction, isStream, PDFFunction, TODO, Util,
|
||||
warn, CachedCanvases */
|
||||
info, isArray, isPDFFunction, isStream, PDFFunction, Util,
|
||||
warn, CachedCanvases, UnsupportedManager, UNSUPPORTED_FEATURES */
|
||||
|
||||
'use strict';
|
||||
|
||||
|
@ -55,7 +55,7 @@ var Pattern = (function PatternClosure() {
|
|||
// Both radial and axial shadings are handled by RadialAxial shading.
|
||||
return new Shadings.RadialAxial(dict, matrix, xref, res);
|
||||
default:
|
||||
TODO('Unsupported shading type: ' + type);
|
||||
UnsupportedManager.notify(UNSUPPORTED_FEATURES.shadingPattern);
|
||||
return new Shadings.Dummy();
|
||||
}
|
||||
};
|
||||
|
@ -315,7 +315,7 @@ var TilingPattern = (function TilingPatternClosure() {
|
|||
var commonObjs = this.commonObjs;
|
||||
var ctx = this.ctx;
|
||||
|
||||
TODO('TilingType: ' + tilingType);
|
||||
info('TilingType: ' + tilingType);
|
||||
|
||||
var x0 = bbox[0], y0 = bbox[1], x1 = bbox[2], y1 = bbox[3];
|
||||
|
||||
|
|
|
@ -156,21 +156,19 @@ var log = (function() {
|
|||
}
|
||||
})();
|
||||
|
||||
// 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
|
||||
// disabled, which is important to devs but not end users.
|
||||
// A notice for devs. These are good for things that are helpful to devs, such
|
||||
// as warning that Workers were disabled, which is important to devs but not
|
||||
// end users.
|
||||
function info(msg) {
|
||||
if (PDFJS.verbosity >= PDFJS.VERBOSITY_LEVELS.infos) {
|
||||
log('Info: ' + msg);
|
||||
PDFJS.LogManager.notify('info', msg);
|
||||
}
|
||||
}
|
||||
|
||||
// Non-fatal warnings that should trigger the fallback UI.
|
||||
// Non-fatal warnings.
|
||||
function warn(msg) {
|
||||
if (PDFJS.verbosity >= PDFJS.VERBOSITY_LEVELS.warnings) {
|
||||
log('Warning: ' + msg);
|
||||
PDFJS.LogManager.notify('warn', msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -188,15 +186,10 @@ function error(msg) {
|
|||
log('Error: ' + msg);
|
||||
}
|
||||
log(backtrace());
|
||||
PDFJS.LogManager.notify('error', msg);
|
||||
UnsupportedManager.notify(UNSUPPORTED_FEATURES.unknown);
|
||||
throw new Error(msg);
|
||||
}
|
||||
|
||||
// Missing features that should trigger the fallback UI.
|
||||
function TODO(what) {
|
||||
warn('TODO: ' + what);
|
||||
}
|
||||
|
||||
function backtrace() {
|
||||
try {
|
||||
throw new Error();
|
||||
|
@ -210,6 +203,31 @@ function assert(cond, msg) {
|
|||
error(msg);
|
||||
}
|
||||
|
||||
var UNSUPPORTED_FEATURES = PDFJS.UNSUPPORTED_FEATURES = {
|
||||
unknown: 'unknown',
|
||||
forms: 'forms',
|
||||
javaScript: 'javaScript',
|
||||
smask: 'smask',
|
||||
shadingPattern: 'shadingPattern',
|
||||
font: 'font'
|
||||
};
|
||||
|
||||
var UnsupportedManager = PDFJS.UnsupportedManager =
|
||||
(function UnsupportedManagerClosure() {
|
||||
var listeners = [];
|
||||
return {
|
||||
listen: function (cb) {
|
||||
listeners.push(cb);
|
||||
},
|
||||
notify: function (featureId) {
|
||||
warn('Unsupported feature "' + featureId + '"');
|
||||
for (var i = 0, ii = listeners.length; i < ii; i++) {
|
||||
listeners[i](featureId);
|
||||
}
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
||||
// Combines two URLs. The baseUrl shall be absolute URL. If the url is an
|
||||
// absolute URL, it will be returned as is.
|
||||
function combineUrl(baseUrl, url) {
|
||||
|
@ -263,22 +281,6 @@ function assertWellFormed(cond, msg) {
|
|||
error(msg);
|
||||
}
|
||||
|
||||
var LogManager = PDFJS.LogManager = (function LogManagerClosure() {
|
||||
var loggers = [];
|
||||
return {
|
||||
addLogger: function logManager_addLogger(logger) {
|
||||
loggers.push(logger);
|
||||
},
|
||||
notify: function(type, message) {
|
||||
for (var i = 0, ii = loggers.length; i < ii; i++) {
|
||||
var logger = loggers[i];
|
||||
if (logger[type])
|
||||
logger[type](message);
|
||||
}
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
||||
function shadow(obj, prop, value) {
|
||||
Object.defineProperty(obj, prop, { value: value,
|
||||
enumerable: true,
|
||||
|
@ -1152,8 +1154,8 @@ function MessageHandler(name, comObj) {
|
|||
log.apply(null, data);
|
||||
}];
|
||||
}
|
||||
ah['_warn'] = [function ah_Warn(data) {
|
||||
warn(data);
|
||||
ah['_unsupported_feature'] = [function ah_unsupportedFeature(data) {
|
||||
UnsupportedManager.notify(data);
|
||||
}];
|
||||
|
||||
comObj.onmessage = function messageHandlerComObjOnMessage(event) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue