1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-25 17:48:07 +02:00

Only trigger warning bar on certain unsupported features.

This commit is contained in:
Brendan Dahl 2014-01-03 09:34:13 -08:00
parent 1bada35388
commit 2228343f77
11 changed files with 70 additions and 74 deletions

View file

@ -19,8 +19,9 @@
info, isArray, isCmd, isDict, isEOF, isName, isNum,
isStream, isString, JpegStream, Lexer, Metrics, Name, Parser,
Pattern, PDFImage, PDFJS, serifFonts, stdFontMap, symbolsFonts,
TilingPattern, TODO, warn, Util, Promise,
RefSetCache, isRef, TextRenderingMode, CMapFactory, OPS */
TilingPattern, warn, Util, Promise, UnsupportedManager,
RefSetCache, isRef, TextRenderingMode, CMapFactory, OPS,
UNSUPPORTED_FEATURES */
'use strict';
@ -407,9 +408,9 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
gStateObj.push([key, value]);
break;
case 'SMask':
// We support the default so don't trigger the TODO.
// We support the default so don't trigger a warning bar.
if (!isName(value) || value.name != 'None')
TODO('graphic state operator ' + key);
UnsupportedManager.notify(UNSUPPORTED_FEATURES.smask);
break;
// Only generate info log messages for the following since
// they are unlikey to have a big impact on the rendering.
@ -499,6 +500,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
try {
translated = this.translateFont(font, xref);
} catch (e) {
UnsupportedManager.notify(UNSUPPORTED_FEATURES.font);
translated = new ErrorFont(e instanceof Error ? e.message : e);
}
font.translated = translated;

View file

@ -17,7 +17,7 @@
/* globals assert, bytesToString, CIDToUnicodeMaps, error, ExpertCharset,
ExpertSubsetCharset, FileReaderSync, GlyphsUnicode,
info, isArray, isNum, ISOAdobeCharset, Stream,
stringToBytes, TextDecoder, TODO, warn, Lexer, Util,
stringToBytes, TextDecoder, warn, Lexer, Util,
FONT_IDENTITY_MATRIX, FontRendererFactory, shadow, isString */
'use strict';
@ -495,7 +495,7 @@ function sjis83pvToUnicode(str) {
// TODO: 83pv has incompatible mappings in ed40..ee9c range.
return decodeBytes(bytes, 'shift_jis', true);
} catch (e) {
TODO('Unsupported 83pv character found');
warn('Unsupported 83pv character found');
// Just retry without checking errors for now.
return decodeBytes(bytes, 'shift_jis');
}
@ -507,7 +507,7 @@ function sjis90pvToUnicode(str) {
// TODO: 90pv has incompatible mappings in 8740..879c and eb41..ee9c.
return decodeBytes(bytes, 'shift_jis', true);
} catch (e) {
TODO('Unsupported 90pv character found');
warn('Unsupported 90pv character found');
// Just retry without checking errors for now.
return decodeBytes(bytes, 'shift_jis');
}
@ -4339,7 +4339,7 @@ var Font = (function FontClosure() {
var cidEncoding = properties.cidEncoding;
if (properties.toUnicode) {
if (cidEncoding && cidEncoding.indexOf('Identity-') !== 0) {
TODO('Need to create a reverse mapping from \'ToUnicode\' CMap');
warn('Need to create a reverse mapping from \'ToUnicode\' CMap');
}
return; // 'ToUnicode' CMap will be used
}

View file

@ -15,7 +15,7 @@
* limitations under the License.
*/
/* globals ColorSpace, error, isArray, isStream, JpegStream, Name, Promise,
Stream, TODO, warn */
Stream, warn */
'use strict';
@ -54,7 +54,7 @@ var PDFImage = (function PDFImageClosure() {
if (image.getParams) {
// JPX/JPEG2000 streams directly contain bits per component
// and color space mode information.
TODO('get params from actual stream');
warn('get params from actual stream');
// var bits = ...
// var colorspace = ...
}
@ -87,7 +87,7 @@ var PDFImage = (function PDFImageClosure() {
if (!this.imageMask) {
var colorSpace = dict.get('ColorSpace', 'CS');
if (!colorSpace) {
TODO('JPX images (which don"t require color spaces');
warn('JPX images (which don"t require color spaces');
colorSpace = new Name('DeviceRGB');
}
this.colorSpace = ColorSpace.parse(colorSpace, xref, res);

View file

@ -429,15 +429,12 @@ var workerConsole = {
if (typeof window === 'undefined') {
globalScope.console = workerConsole;
// Add a logger so we can pass warnings on to the main thread, errors will
// throw an exception which will be forwarded on automatically.
PDFJS.LogManager.addLogger({
warn: function(msg) {
globalScope.postMessage({
action: '_warn',
data: msg
});
}
// Listen for unsupported features so we can pass them on to the main thread.
PDFJS.UnsupportedManager.listen(function (msg) {
globalScope.postMessage({
action: '_unsupported_feature',
data: msg
});
});
var handler = new MessageHandler('worker_processor', this);