mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-26 10:08:06 +02:00
Replaces UnsupportedManager with callback.
This commit is contained in:
parent
84a47f8e53
commit
c9cb6a3025
7 changed files with 66 additions and 47 deletions
|
@ -19,9 +19,8 @@
|
|||
MurmurHash3_64, Name, Parser, Pattern, PDFImage, PDFJS, serifFonts,
|
||||
stdFontMap, symbolsFonts, getTilingPatternIR, warn, Util, Promise,
|
||||
RefSetCache, isRef, TextRenderingMode, IdentityToUnicodeMap,
|
||||
OPS, UNSUPPORTED_FEATURES, UnsupportedManager, NormalizedUnicodes,
|
||||
IDENTITY_MATRIX, reverseIfRtl, createPromiseCapability, ToUnicodeMap,
|
||||
getFontType */
|
||||
OPS, UNSUPPORTED_FEATURES, NormalizedUnicodes, IDENTITY_MATRIX,
|
||||
reverseIfRtl, createPromiseCapability, ToUnicodeMap, getFontType */
|
||||
|
||||
'use strict';
|
||||
|
||||
|
@ -322,6 +321,9 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||
then(function () {
|
||||
return translated;
|
||||
}, function (reason) {
|
||||
// Error in the font data -- sending unsupported feature notification.
|
||||
self.handler.send('UnsupportedFeature',
|
||||
{featureId: UNSUPPORTED_FEATURES.font});
|
||||
return new TranslatedFont('g_font_error',
|
||||
new ErrorFont('Type3 font load error: ' + reason), translated.font);
|
||||
});
|
||||
|
@ -546,6 +548,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||
translatedPromise = Promise.reject(e);
|
||||
}
|
||||
|
||||
var self = this;
|
||||
translatedPromise.then(function (translatedFont) {
|
||||
if (translatedFont.fontType !== undefined) {
|
||||
var xrefFontStats = xref.stats.fontTypes;
|
||||
|
@ -556,7 +559,9 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||
translatedFont, font));
|
||||
}, function (reason) {
|
||||
// TODO fontCapability.reject?
|
||||
UnsupportedManager.notify(UNSUPPORTED_FEATURES.font);
|
||||
// Error in the font data -- sending unsupported feature notification.
|
||||
self.handler.send('UnsupportedFeature',
|
||||
{featureId: UNSUPPORTED_FEATURES.font});
|
||||
|
||||
try {
|
||||
// error, but it's still nice to have font type reported
|
||||
|
@ -609,7 +614,8 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||
} else if (typeNum === SHADING_PATTERN) {
|
||||
var shading = dict.get('Shading');
|
||||
var matrix = dict.get('Matrix');
|
||||
pattern = Pattern.parseShading(shading, matrix, xref, resources);
|
||||
pattern = Pattern.parseShading(shading, matrix, xref, resources,
|
||||
this.handler);
|
||||
operatorList.addOp(fn, pattern.getIR());
|
||||
return Promise.resolve();
|
||||
} else {
|
||||
|
@ -846,7 +852,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||
}
|
||||
|
||||
var shadingFill = Pattern.parseShading(shading, null, xref,
|
||||
resources);
|
||||
resources, self.handler);
|
||||
var patternIR = shadingFill.getIR();
|
||||
args = [patternIR];
|
||||
fn = OPS.shadingFill;
|
||||
|
|
|
@ -13,8 +13,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
/* globals ColorSpace, PDFFunction, Util, error, warn, info, isArray, isStream,
|
||||
assert, isPDFFunction, UnsupportedManager, UNSUPPORTED_FEATURES,
|
||||
MissingDataException */
|
||||
assert, isPDFFunction, UNSUPPORTED_FEATURES, MissingDataException */
|
||||
|
||||
'use strict';
|
||||
|
||||
|
@ -43,7 +42,7 @@ var Pattern = (function PatternClosure() {
|
|||
};
|
||||
|
||||
Pattern.parseShading = function Pattern_parseShading(shading, matrix, xref,
|
||||
res) {
|
||||
res, handler) {
|
||||
|
||||
var dict = isStream(shading) ? shading.dict : shading;
|
||||
var type = dict.get('ShadingType');
|
||||
|
@ -66,7 +65,8 @@ var Pattern = (function PatternClosure() {
|
|||
if (ex instanceof MissingDataException) {
|
||||
throw ex;
|
||||
}
|
||||
UnsupportedManager.notify(UNSUPPORTED_FEATURES.shadingPattern);
|
||||
handler.send('UnsupportedFeature',
|
||||
{featureId: UNSUPPORTED_FEATURES.shadingPattern});
|
||||
warn(ex);
|
||||
return new Shadings.Dummy();
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
/* globals PDFJS, createPromiseCapability, LocalPdfManager, NetworkPdfManager,
|
||||
NetworkManager, isInt, MissingPDFException,
|
||||
NetworkManager, isInt, MissingPDFException, UNSUPPORTED_FEATURES,
|
||||
UnexpectedResponseException, PasswordException, Promise, warn,
|
||||
PasswordResponses, InvalidPDFException, UnknownErrorException,
|
||||
XRefParseException, Ref, info, globalScope, error, MessageHandler */
|
||||
|
@ -482,6 +482,11 @@ var WorkerMessageHandler = PDFJS.WorkerMessageHandler = {
|
|||
return; // ignoring errors from the terminated thread
|
||||
}
|
||||
|
||||
// For compatibility with older behavior, generating unknown
|
||||
// unsupported feature notification on errors.
|
||||
handler.send('UnsupportedFeature',
|
||||
{featureId: UNSUPPORTED_FEATURES.unknown});
|
||||
|
||||
var minimumStackMessage =
|
||||
'worker.js: while trying to getPage() and getOperatorList()';
|
||||
|
||||
|
@ -616,15 +621,6 @@ if (typeof window === 'undefined') {
|
|||
globalScope.console = workerConsole;
|
||||
}
|
||||
|
||||
// Listen for unsupported features so we can pass them on to the main thread.
|
||||
PDFJS.UnsupportedManager.listen(function (msg) {
|
||||
globalScope.postMessage({
|
||||
targetName: 'main',
|
||||
action: '_unsupported_feature',
|
||||
data: msg
|
||||
});
|
||||
});
|
||||
|
||||
var handler = new MessageHandler('worker', 'main', this);
|
||||
WorkerMessageHandler.setup(handler, this);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue