Bug 1237815 - Update pdf.js to version 1.3.161. r=bdahl

This commit is contained in:
Ryan VanderMeulen 2016-01-07 18:32:09 -05:00
Родитель 66594bfe75
Коммит fa3c69da64
5 изменённых файлов: 486 добавлений и 160 удалений

Просмотреть файл

@ -1,3 +1,3 @@
This is the pdf.js project output, https://github.com/mozilla/pdf.js This is the pdf.js project output, https://github.com/mozilla/pdf.js
Current extension version is: 1.3.142 Current extension version is: 1.3.161

Просмотреть файл

@ -13,21 +13,32 @@
* limitations under the License. * limitations under the License.
*/ */
/* jshint globalstrict: false */ /* jshint globalstrict: false */
/* globals PDFJS, global */ /* umdutils ignore */
// Initializing PDFJS global object (if still undefined) (function (root, factory) {
if (typeof PDFJS === 'undefined') { 'use strict';
(typeof window !== 'undefined' ? window : if (typeof define === 'function' && define.amd) {
typeof global !== 'undefined' ? global : this).PDFJS = {}; define('pdfjs-dist/build/pdf', ['exports'], factory);
} } else if (typeof exports !== 'undefined') {
factory(exports);
PDFJS.version = '1.3.142'; } else {
PDFJS.build = 'e8db825'; factory((root.pdfjsDistBuildPdf = {}));
}
(function pdfjsWrapper() { }(this, function (exports) {
// Use strict in our context only - users might not want it // Use strict in our context only - users might not want it
'use strict'; 'use strict';
var pdfjsVersion = '1.3.161';
var pdfjsBuild = '4a215f0';
var pdfjsFilePath =
typeof document !== 'undefined' && document.currentScript ?
document.currentScript.src : null;
var pdfjsLibs = {};
(function pdfjsWrapper() {
(function (root, factory) { (function (root, factory) {
@ -49,6 +60,13 @@ PDFJS.build = 'e8db825';
globalScope.PDFJS = {}; globalScope.PDFJS = {};
} }
if (typeof pdfjsVersion !== 'undefined') {
globalScope.PDFJS.version = pdfjsVersion;
}
if (typeof pdfjsVersion !== 'undefined') {
globalScope.PDFJS.build = pdfjsBuild;
}
globalScope.PDFJS.pdfBug = false; globalScope.PDFJS.pdfBug = false;
exports.globalScope = globalScope; exports.globalScope = globalScope;
@ -598,6 +616,16 @@ var XRefParseException = (function XRefParseExceptionClosure() {
return XRefParseException; return XRefParseException;
})(); })();
var NullCharactersRegExp = /\x00/g;
function removeNullCharacters(str) {
if (typeof str !== 'string') {
warn('The argument for removeNullCharacters must be a string.');
return str;
}
return str.replace(NullCharactersRegExp, '');
}
PDFJS.removeNullCharacters = removeNullCharacters;
function bytesToString(bytes) { function bytesToString(bytes) {
assert(bytes !== null && typeof bytes === 'object' && assert(bytes !== null && typeof bytes === 'object' &&
@ -1462,6 +1490,7 @@ exports.log2 = log2;
exports.readInt8 = readInt8; exports.readInt8 = readInt8;
exports.readUint16 = readUint16; exports.readUint16 = readUint16;
exports.readUint32 = readUint32; exports.readUint32 = readUint32;
exports.removeNullCharacters = removeNullCharacters;
exports.shadow = shadow; exports.shadow = shadow;
exports.string32 = string32; exports.string32 = string32;
exports.stringToBytes = stringToBytes; exports.stringToBytes = stringToBytes;
@ -1484,6 +1513,7 @@ var AnnotationType = sharedUtil.AnnotationType;
var Util = sharedUtil.Util; var Util = sharedUtil.Util;
var isExternalLinkTargetSet = sharedUtil.isExternalLinkTargetSet; var isExternalLinkTargetSet = sharedUtil.isExternalLinkTargetSet;
var LinkTargetStringMap = sharedUtil.LinkTargetStringMap; var LinkTargetStringMap = sharedUtil.LinkTargetStringMap;
var removeNullCharacters = sharedUtil.removeNullCharacters;
var warn = sharedUtil.warn; var warn = sharedUtil.warn;
var CustomStyle = displayDOMUtils.CustomStyle; var CustomStyle = displayDOMUtils.CustomStyle;
@ -1523,9 +1553,18 @@ AnnotationElementFactory.prototype =
case AnnotationType.POPUP: case AnnotationType.POPUP:
return new PopupAnnotationElement(parameters); return new PopupAnnotationElement(parameters);
case AnnotationType.HIGHLIGHT:
return new HighlightAnnotationElement(parameters);
case AnnotationType.UNDERLINE: case AnnotationType.UNDERLINE:
return new UnderlineAnnotationElement(parameters); return new UnderlineAnnotationElement(parameters);
case AnnotationType.SQUIGGLY:
return new SquigglyAnnotationElement(parameters);
case AnnotationType.STRIKEOUT:
return new StrikeOutAnnotationElement(parameters);
default: default:
throw new Error('Unimplemented annotation type "' + subtype + '"'); throw new Error('Unimplemented annotation type "' + subtype + '"');
} }
@ -1674,7 +1713,8 @@ var LinkAnnotationElement = (function LinkAnnotationElementClosure() {
this.container.className = 'linkAnnotation'; this.container.className = 'linkAnnotation';
var link = document.createElement('a'); var link = document.createElement('a');
link.href = link.title = this.data.url || ''; link.href = link.title = (this.data.url ?
removeNullCharacters(this.data.url) : '');
if (this.data.url && isExternalLinkTargetSet()) { if (this.data.url && isExternalLinkTargetSet()) {
link.target = LinkTargetStringMap[PDFJS.externalLinkTarget]; link.target = LinkTargetStringMap[PDFJS.externalLinkTarget];
@ -2054,6 +2094,33 @@ var PopupElement = (function PopupElementClosure() {
return PopupElement; return PopupElement;
})(); })();
/**
* @class
* @alias HighlightAnnotationElement
*/
var HighlightAnnotationElement = (
function HighlightAnnotationElementClosure() {
function HighlightAnnotationElement(parameters) {
AnnotationElement.call(this, parameters);
}
Util.inherit(HighlightAnnotationElement, AnnotationElement, {
/**
* Render the highlight annotation's HTML element in the empty container.
*
* @public
* @memberof HighlightAnnotationElement
* @returns {HTMLSectionElement}
*/
render: function HighlightAnnotationElement_render() {
this.container.className = 'highlightAnnotation';
return this.container;
}
});
return HighlightAnnotationElement;
})();
/** /**
* @class * @class
* @alias UnderlineAnnotationElement * @alias UnderlineAnnotationElement
@ -2081,6 +2148,59 @@ var UnderlineAnnotationElement = (
return UnderlineAnnotationElement; return UnderlineAnnotationElement;
})(); })();
/**
* @class
* @alias SquigglyAnnotationElement
*/
var SquigglyAnnotationElement = (function SquigglyAnnotationElementClosure() {
function SquigglyAnnotationElement(parameters) {
AnnotationElement.call(this, parameters);
}
Util.inherit(SquigglyAnnotationElement, AnnotationElement, {
/**
* Render the squiggly annotation's HTML element in the empty container.
*
* @public
* @memberof SquigglyAnnotationElement
* @returns {HTMLSectionElement}
*/
render: function SquigglyAnnotationElement_render() {
this.container.className = 'squigglyAnnotation';
return this.container;
}
});
return SquigglyAnnotationElement;
})();
/**
* @class
* @alias StrikeOutAnnotationElement
*/
var StrikeOutAnnotationElement = (
function StrikeOutAnnotationElementClosure() {
function StrikeOutAnnotationElement(parameters) {
AnnotationElement.call(this, parameters);
}
Util.inherit(StrikeOutAnnotationElement, AnnotationElement, {
/**
* Render the strikeout annotation's HTML element in the empty container.
*
* @public
* @memberof StrikeOutAnnotationElement
* @returns {HTMLSectionElement}
*/
render: function StrikeOutAnnotationElement_render() {
this.container.className = 'strikeoutAnnotation';
return this.container;
}
});
return StrikeOutAnnotationElement;
})();
/** /**
* @typedef {Object} AnnotationLayerParameters * @typedef {Object} AnnotationLayerParameters
* @property {PageViewport} viewport * @property {PageViewport} viewport
@ -5699,10 +5819,10 @@ exports.createScratchCanvas = createScratchCanvas;
{ {
factory((root.pdfjsDisplayAPI = {}), root.pdfjsSharedUtil, factory((root.pdfjsDisplayAPI = {}), root.pdfjsSharedUtil,
root.pdfjsDisplayFontLoader, root.pdfjsDisplayCanvas, root.pdfjsDisplayFontLoader, root.pdfjsDisplayCanvas,
root.pdfjsSharedGlobal); root.pdfjsDisplayMetadata, root.pdfjsSharedGlobal);
} }
}(this, function (exports, sharedUtil, displayFontLoader, displayCanvas, }(this, function (exports, sharedUtil, displayFontLoader, displayCanvas,
sharedGlobal, amdRequire) { displayMetadata, sharedGlobal, amdRequire) {
var InvalidPDFException = sharedUtil.InvalidPDFException; var InvalidPDFException = sharedUtil.InvalidPDFException;
var MessageHandler = sharedUtil.MessageHandler; var MessageHandler = sharedUtil.MessageHandler;
@ -5726,6 +5846,7 @@ var FontFaceObject = displayFontLoader.FontFaceObject;
var FontLoader = displayFontLoader.FontLoader; var FontLoader = displayFontLoader.FontLoader;
var CanvasGraphics = displayCanvas.CanvasGraphics; var CanvasGraphics = displayCanvas.CanvasGraphics;
var createScratchCanvas = displayCanvas.createScratchCanvas; var createScratchCanvas = displayCanvas.createScratchCanvas;
var Metadata = displayMetadata.Metadata;
var PDFJS = sharedGlobal.PDFJS; var PDFJS = sharedGlobal.PDFJS;
var globalScope = sharedGlobal.globalScope; var globalScope = sharedGlobal.globalScope;
@ -6844,6 +6965,13 @@ var PDFPageProxy = (function PDFPageProxyClosure() {
var PDFWorker = (function PDFWorkerClosure() { var PDFWorker = (function PDFWorkerClosure() {
var nextFakeWorkerId = 0; var nextFakeWorkerId = 0;
function getWorkerSrc() {
if (PDFJS.workerSrc) {
return PDFJS.workerSrc;
}
error('No PDFJS.workerSrc specified');
}
// Loads worker code into main thread. // Loads worker code into main thread.
function setupFakeWorkerGlobal() { function setupFakeWorkerGlobal() {
if (!PDFJS.fakeWorkerFilesLoadedCapability) { if (!PDFJS.fakeWorkerFilesLoadedCapability) {
@ -6852,7 +6980,7 @@ var PDFWorker = (function PDFWorkerClosure() {
// other files and resolves the promise. In production only the // other files and resolves the promise. In production only the
// pdf.worker.js file is needed. // pdf.worker.js file is needed.
var loader = fakeWorkerFilesLoader || function (callback) { var loader = fakeWorkerFilesLoader || function (callback) {
Util.loadScript(PDFJS.workerSrc, callback); Util.loadScript(getWorkerSrc(), callback);
}; };
loader(function () { loader(function () {
PDFJS.fakeWorkerFilesLoadedCapability.resolve(); PDFJS.fakeWorkerFilesLoadedCapability.resolve();
@ -6892,10 +7020,7 @@ var PDFWorker = (function PDFWorkerClosure() {
// Right now, the requirement is, that an Uint8Array is still an // Right now, the requirement is, that an Uint8Array is still an
// Uint8Array as it arrives on the worker. (Chrome added this with v.15.) // Uint8Array as it arrives on the worker. (Chrome added this with v.15.)
if (!globalScope.PDFJS.disableWorker && typeof Worker !== 'undefined') { if (!globalScope.PDFJS.disableWorker && typeof Worker !== 'undefined') {
var workerSrc = PDFJS.workerSrc; var workerSrc = getWorkerSrc();
if (!workerSrc) {
error('No PDFJS.workerSrc specified');
}
try { try {
// Some versions of FF can't create a worker on localhost, see: // Some versions of FF can't create a worker on localhost, see:
@ -7447,7 +7572,7 @@ var WorkerTransport = (function WorkerTransportClosure() {
then(function transportMetadata(results) { then(function transportMetadata(results) {
return { return {
info: results[0], info: results[0],
metadata: (results[1] ? new PDFJS.Metadata(results[1]) : null) metadata: (results[1] ? new Metadata(results[1]) : null)
}; };
}); });
}, },
@ -7780,7 +7905,22 @@ exports.PDFPageProxy = PDFPageProxy;
})); }));
}).call((typeof window === 'undefined') ? this : window); }).call(pdfjsLibs);
exports.PDFJS = pdfjsLibs.pdfjsSharedGlobal.PDFJS;
exports.getDocument = pdfjsLibs.pdfjsDisplayAPI.getDocument;
exports.PDFDataRangeTransport =
pdfjsLibs.pdfjsDisplayAPI.PDFDataRangeTransport;
exports.renderTextLayer = pdfjsLibs.pdfjsDisplayTextLayer.renderTextLayer;
exports.AnnotationLayer =
pdfjsLibs.pdfjsDisplayAnnotationLayer.AnnotationLayer;
exports.CustomStyle = pdfjsLibs.pdfjsDisplayDOMUtils.CustomStyle;
exports.PasswordResponses = pdfjsLibs.pdfjsSharedUtil.PasswordResponses;
exports.InvalidPDFException = pdfjsLibs.pdfjsSharedUtil.InvalidPDFException;
exports.MissingPDFException = pdfjsLibs.pdfjsSharedUtil.MissingPDFException;
exports.UnexpectedResponseException =
pdfjsLibs.pdfjsSharedUtil.UnexpectedResponseException;
}));

Просмотреть файл

@ -13,21 +13,32 @@
* limitations under the License. * limitations under the License.
*/ */
/* jshint globalstrict: false */ /* jshint globalstrict: false */
/* globals PDFJS, global */ /* umdutils ignore */
// Initializing PDFJS global object (if still undefined) (function (root, factory) {
if (typeof PDFJS === 'undefined') { 'use strict';
(typeof window !== 'undefined' ? window : if (typeof define === 'function' && define.amd) {
typeof global !== 'undefined' ? global : this).PDFJS = {}; define('pdfjs-dist/build/pdf.worker', ['exports'], factory);
} } else if (typeof exports !== 'undefined') {
factory(exports);
PDFJS.version = '1.3.142'; } else {
PDFJS.build = 'e8db825'; factory((root.pdfjsDistBuildPdfWorker = {}));
}
(function pdfjsWrapper() { }(this, function (exports) {
// Use strict in our context only - users might not want it // Use strict in our context only - users might not want it
'use strict'; 'use strict';
var pdfjsVersion = '1.3.161';
var pdfjsBuild = '4a215f0';
var pdfjsFilePath =
typeof document !== 'undefined' && document.currentScript ?
document.currentScript.src : null;
var pdfjsLibs = {};
(function pdfjsWrapper() {
(function (root, factory) { (function (root, factory) {
@ -8738,6 +8749,13 @@ exports.Metrics = Metrics;
globalScope.PDFJS = {}; globalScope.PDFJS = {};
} }
if (typeof pdfjsVersion !== 'undefined') {
globalScope.PDFJS.version = pdfjsVersion;
}
if (typeof pdfjsVersion !== 'undefined') {
globalScope.PDFJS.build = pdfjsBuild;
}
globalScope.PDFJS.pdfBug = false; globalScope.PDFJS.pdfBug = false;
exports.globalScope = globalScope; exports.globalScope = globalScope;
@ -9637,6 +9655,16 @@ var XRefParseException = (function XRefParseExceptionClosure() {
return XRefParseException; return XRefParseException;
})(); })();
var NullCharactersRegExp = /\x00/g;
function removeNullCharacters(str) {
if (typeof str !== 'string') {
warn('The argument for removeNullCharacters must be a string.');
return str;
}
return str.replace(NullCharactersRegExp, '');
}
PDFJS.removeNullCharacters = removeNullCharacters;
function bytesToString(bytes) { function bytesToString(bytes) {
assert(bytes !== null && typeof bytes === 'object' && assert(bytes !== null && typeof bytes === 'object' &&
@ -10501,6 +10529,7 @@ exports.log2 = log2;
exports.readInt8 = readInt8; exports.readInt8 = readInt8;
exports.readUint16 = readUint16; exports.readUint16 = readUint16;
exports.readUint32 = readUint32; exports.readUint32 = readUint32;
exports.removeNullCharacters = removeNullCharacters;
exports.shadow = shadow; exports.shadow = shadow;
exports.string32 = string32; exports.string32 = string32;
exports.stringToBytes = stringToBytes; exports.stringToBytes = stringToBytes;
@ -24015,6 +24044,9 @@ var HINTING_ENABLED = false;
// to control analysis of seac charstrings. // to control analysis of seac charstrings.
var SEAC_ANALYSIS_ENABLED = false; var SEAC_ANALYSIS_ENABLED = false;
// Maximum subroutine call depth of type 2 chartrings. Matches OTS.
var MAX_SUBR_NESTING = 10;
var FontFlags = { var FontFlags = {
FixedPitch: 1, FixedPitch: 1,
Serif: 2, Serif: 2,
@ -30044,10 +30076,7 @@ var CFFParser = (function CFFParserClosure() {
cff.isCIDFont = topDict.hasName('ROS'); cff.isCIDFont = topDict.hasName('ROS');
var charStringOffset = topDict.getByName('CharStrings'); var charStringOffset = topDict.getByName('CharStrings');
var charStringsAndSeacs = this.parseCharStrings(charStringOffset); var charStringIndex = this.parseIndex(charStringOffset).obj;
cff.charStrings = charStringsAndSeacs.charStrings;
cff.seacs = charStringsAndSeacs.seacs;
cff.widths = charStringsAndSeacs.widths;
var fontMatrix = topDict.getByName('FontMatrix'); var fontMatrix = topDict.getByName('FontMatrix');
if (fontMatrix) { if (fontMatrix) {
@ -30075,19 +30104,30 @@ var CFFParser = (function CFFParserClosure() {
// cid fonts don't have an encoding // cid fonts don't have an encoding
encoding = null; encoding = null;
charset = this.parseCharsets(topDict.getByName('charset'), charset = this.parseCharsets(topDict.getByName('charset'),
cff.charStrings.count, cff.strings, true); charStringIndex.count, cff.strings, true);
cff.fdSelect = this.parseFDSelect(topDict.getByName('FDSelect'), cff.fdSelect = this.parseFDSelect(topDict.getByName('FDSelect'),
cff.charStrings.count); charStringIndex.count);
} else { } else {
charset = this.parseCharsets(topDict.getByName('charset'), charset = this.parseCharsets(topDict.getByName('charset'),
cff.charStrings.count, cff.strings, false); charStringIndex.count, cff.strings, false);
encoding = this.parseEncoding(topDict.getByName('Encoding'), encoding = this.parseEncoding(topDict.getByName('Encoding'),
properties, properties,
cff.strings, charset.charset); cff.strings, charset.charset);
} }
cff.charset = charset; cff.charset = charset;
cff.encoding = encoding; cff.encoding = encoding;
var charStringsAndSeacs = this.parseCharStrings(
charStringIndex,
topDict.privateDict.subrsIndex,
globalSubrIndex.obj,
cff.fdSelect,
cff.fdArray);
cff.charStrings = charStringsAndSeacs.charStrings;
cff.seacs = charStringsAndSeacs.seacs;
cff.widths = charStringsAndSeacs.widths;
return cff; return cff;
}, },
parseHeader: function CFFParser_parseHeader() { parseHeader: function CFFParser_parseHeader() {
@ -30262,118 +30302,201 @@ var CFFParser = (function CFFParserClosure() {
} }
return cffDict; return cffDict;
}, },
parseCharStrings: function CFFParser_parseCharStrings(charStringOffset) { parseCharString: function CFFParser_parseCharString(state, data,
var charStrings = this.parseIndex(charStringOffset).obj; localSubrIndex,
globalSubrIndex) {
if (state.callDepth > MAX_SUBR_NESTING) {
return false;
}
var stackSize = state.stackSize;
var stack = state.stack;
var length = data.length;
for (var j = 0; j < length;) {
var value = data[j++];
var validationCommand = null;
if (value === 12) {
var q = data[j++];
if (q === 0) {
// The CFF specification state that the 'dotsection' command
// (12, 0) is deprecated and treated as a no-op, but all Type2
// charstrings processors should support them. Unfortunately
// the font sanitizer don't. As a workaround the sequence (12, 0)
// is replaced by a useless (0, hmoveto).
data[j - 2] = 139;
data[j - 1] = 22;
stackSize = 0;
} else {
validationCommand = CharstringValidationData12[q];
}
} else if (value === 28) { // number (16 bit)
stack[stackSize] = ((data[j] << 24) | (data[j + 1] << 16)) >> 16;
j += 2;
stackSize++;
} else if (value === 14) {
if (stackSize >= 4) {
stackSize -= 4;
if (SEAC_ANALYSIS_ENABLED) {
state.seac = stack.slice(stackSize, stackSize + 4);
return false;
}
}
validationCommand = CharstringValidationData[value];
} else if (value >= 32 && value <= 246) { // number
stack[stackSize] = value - 139;
stackSize++;
} else if (value >= 247 && value <= 254) { // number (+1 bytes)
stack[stackSize] = (value < 251 ?
((value - 247) << 8) + data[j] + 108 :
-((value - 251) << 8) - data[j] - 108);
j++;
stackSize++;
} else if (value === 255) { // number (32 bit)
stack[stackSize] = ((data[j] << 24) | (data[j + 1] << 16) |
(data[j + 2] << 8) | data[j + 3]) / 65536;
j += 4;
stackSize++;
} else if (value === 19 || value === 20) {
state.hints += stackSize >> 1;
// skipping right amount of hints flag data
j += (state.hints + 7) >> 3;
stackSize %= 2;
validationCommand = CharstringValidationData[value];
} else if (value === 10 || value === 29) {
var subrsIndex;
if (value === 10) {
subrsIndex = localSubrIndex;
} else {
subrsIndex = globalSubrIndex;
}
if (!subrsIndex) {
validationCommand = CharstringValidationData[value];
warn('Missing subrsIndex for ' + validationCommand.id);
return false;
}
var bias = 32768;
if (subrsIndex.count < 1240) {
bias = 107;
} else if (subrsIndex.count < 33900) {
bias = 1131;
}
var subrNumber = stack[--stackSize] + bias;
if (subrNumber < 0 || subrNumber >= subrsIndex.count) {
validationCommand = CharstringValidationData[value];
warn('Out of bounds subrIndex for ' + validationCommand.id);
return false;
}
state.stackSize = stackSize;
state.callDepth++;
var valid = this.parseCharString(state, subrsIndex.get(subrNumber),
localSubrIndex, globalSubrIndex);
if (!valid) {
return false;
}
state.callDepth--;
stackSize = state.stackSize;
continue;
} else if (value === 11) {
state.stackSize = stackSize;
return true;
} else {
validationCommand = CharstringValidationData[value];
}
if (validationCommand) {
if (validationCommand.stem) {
state.hints += stackSize >> 1;
}
if ('min' in validationCommand) {
if (!state.undefStack && stackSize < validationCommand.min) {
warn('Not enough parameters for ' + validationCommand.id +
'; actual: ' + stackSize +
', expected: ' + validationCommand.min);
return false;
}
}
if (state.firstStackClearing && validationCommand.stackClearing) {
state.firstStackClearing = false;
// the optional character width can be found before the first
// stack-clearing command arguments
stackSize -= validationCommand.min;
if (stackSize >= 2 && validationCommand.stem) {
// there are even amount of arguments for stem commands
stackSize %= 2;
} else if (stackSize > 1) {
warn('Found too many parameters for stack-clearing command');
}
if (stackSize > 0 && stack[stackSize - 1] >= 0) {
state.width = stack[stackSize - 1];
}
}
if ('stackDelta' in validationCommand) {
if ('stackFn' in validationCommand) {
validationCommand.stackFn(stack, stackSize);
}
stackSize += validationCommand.stackDelta;
} else if (validationCommand.stackClearing) {
stackSize = 0;
} else if (validationCommand.resetStack) {
stackSize = 0;
state.undefStack = false;
} else if (validationCommand.undefStack) {
stackSize = 0;
state.undefStack = true;
state.firstStackClearing = false;
}
}
}
state.stackSize = stackSize;
return true;
},
parseCharStrings: function CFFParser_parseCharStrings(charStrings,
localSubrIndex,
globalSubrIndex,
fdSelect,
fdArray) {
var seacs = []; var seacs = [];
var widths = []; var widths = [];
var count = charStrings.count; var count = charStrings.count;
for (var i = 0; i < count; i++) { for (var i = 0; i < count; i++) {
var charstring = charStrings.get(i); var charstring = charStrings.get(i);
var state = {
var stackSize = 0; callDepth: 0,
var stack = []; stackSize: 0,
var undefStack = true; stack: [],
var hints = 0; undefStack: true,
hints: 0,
firstStackClearing: true,
seac: null,
width: null
};
var valid = true; var valid = true;
var data = charstring; var localSubrToUse = null;
var length = data.length; if (fdSelect && fdArray.length) {
var firstStackClearing = true; var fdIndex = fdSelect.getFDIndex(i);
for (var j = 0; j < length;) { if (fdIndex === -1) {
var value = data[j++]; warn('Glyph index is not in fd select.');
var validationCommand = null; valid = false;
if (value === 12) {
var q = data[j++];
if (q === 0) {
// The CFF specification state that the 'dotsection' command
// (12, 0) is deprecated and treated as a no-op, but all Type2
// charstrings processors should support them. Unfortunately
// the font sanitizer don't. As a workaround the sequence (12, 0)
// is replaced by a useless (0, hmoveto).
data[j - 2] = 139;
data[j - 1] = 22;
stackSize = 0;
} else {
validationCommand = CharstringValidationData12[q];
}
} else if (value === 28) { // number (16 bit)
stack[stackSize] = ((data[j] << 24) | (data[j + 1] << 16)) >> 16;
j += 2;
stackSize++;
} else if (value === 14) {
if (stackSize >= 4) {
stackSize -= 4;
if (SEAC_ANALYSIS_ENABLED) {
seacs[i] = stack.slice(stackSize, stackSize + 4);
valid = false;
}
}
validationCommand = CharstringValidationData[value];
} else if (value >= 32 && value <= 246) { // number
stack[stackSize] = value - 139;
stackSize++;
} else if (value >= 247 && value <= 254) { // number (+1 bytes)
stack[stackSize] = (value < 251 ?
((value - 247) << 8) + data[j] + 108 :
-((value - 251) << 8) - data[j] - 108);
j++;
stackSize++;
} else if (value === 255) { // number (32 bit)
stack[stackSize] = ((data[j] << 24) | (data[j + 1] << 16) |
(data[j + 2] << 8) | data[j + 3]) / 65536;
j += 4;
stackSize++;
} else if (value === 19 || value === 20) {
hints += stackSize >> 1;
j += (hints + 7) >> 3; // skipping right amount of hints flag data
stackSize %= 2;
validationCommand = CharstringValidationData[value];
} else {
validationCommand = CharstringValidationData[value];
} }
if (validationCommand) { if (fdIndex >= fdArray.length) {
if (validationCommand.stem) { warn('Invalid fd index for glyph index.');
hints += stackSize >> 1; valid = false;
}
if ('min' in validationCommand) {
if (!undefStack && stackSize < validationCommand.min) {
warn('Not enough parameters for ' + validationCommand.id +
'; actual: ' + stackSize +
', expected: ' + validationCommand.min);
valid = false;
break;
}
}
if (firstStackClearing && validationCommand.stackClearing) {
firstStackClearing = false;
// the optional character width can be found before the first
// stack-clearing command arguments
stackSize -= validationCommand.min;
if (stackSize >= 2 && validationCommand.stem) {
// there are even amount of arguments for stem commands
stackSize %= 2;
} else if (stackSize > 1) {
warn('Found too many parameters for stack-clearing command');
}
if (stackSize > 0 && stack[stackSize - 1] >= 0) {
widths[i] = stack[stackSize - 1];
}
}
if ('stackDelta' in validationCommand) {
if ('stackFn' in validationCommand) {
validationCommand.stackFn(stack, stackSize);
}
stackSize += validationCommand.stackDelta;
} else if (validationCommand.stackClearing) {
stackSize = 0;
} else if (validationCommand.resetStack) {
stackSize = 0;
undefStack = false;
} else if (validationCommand.undefStack) {
stackSize = 0;
undefStack = true;
firstStackClearing = false;
}
} }
if (valid) {
localSubrToUse = fdArray[fdIndex].privateDict.subrsIndex;
}
} else if (localSubrIndex) {
localSubrToUse = localSubrIndex;
}
if (valid) {
valid = this.parseCharString(state, charstring, localSubrToUse,
globalSubrIndex);
}
if (state.width !== null) {
widths[i] = state.width;
}
if (state.seac !== null) {
seacs[i] = state.seac;
} }
if (!valid) { if (!valid) {
// resetting invalid charstring to single 'endchar' // resetting invalid charstring to single 'endchar'
@ -30868,6 +30991,14 @@ var CFFFDSelect = (function CFFFDSelectClosure() {
this.fdSelect = fdSelect; this.fdSelect = fdSelect;
this.raw = raw; this.raw = raw;
} }
CFFFDSelect.prototype = {
getFDIndex: function CFFFDSelect_get(glyphIndex) {
if (glyphIndex < 0 || glyphIndex >= this.fdSelect.length) {
return -1;
}
return this.fdSelect[glyphIndex];
}
};
return CFFFDSelect; return CFFFDSelect;
})(); })();
@ -34555,10 +34686,8 @@ var Pattern = (function PatternClosure() {
var Shadings = {}; var Shadings = {};
// A small number to offset the first/last color stops so we can insert ones to // A small number to offset the first/last color stops so we can insert ones to
// support extend. Number.MIN_VALUE appears to be too small and breaks the // support extend. Number.MIN_VALUE is too small and breaks the extend.
// extend. 1e-7 works in FF but chrome seems to use an even smaller sized number Shadings.SMALL_NUMBER = 1e-6;
// internally so we have to go bigger.
Shadings.SMALL_NUMBER = 1e-2;
// Radial and axial shading have very similar implementations // Radial and axial shading have very similar implementations
// If needed, the implementations can be broken into two classes // If needed, the implementations can be broken into two classes
@ -38295,9 +38424,18 @@ AnnotationFactory.prototype = /** @lends AnnotationFactory.prototype */ {
case 'Popup': case 'Popup':
return new PopupAnnotation(parameters); return new PopupAnnotation(parameters);
case 'Highlight':
return new HighlightAnnotation(parameters);
case 'Underline': case 'Underline':
return new UnderlineAnnotation(parameters); return new UnderlineAnnotation(parameters);
case 'Squiggly':
return new SquigglyAnnotation(parameters);
case 'StrikeOut':
return new StrikeOutAnnotation(parameters);
default: default:
warn('Unimplemented annotation type "' + subtype + '", ' + warn('Unimplemented annotation type "' + subtype + '", ' +
'falling back to base annotation'); 'falling back to base annotation');
@ -38988,6 +39126,22 @@ var PopupAnnotation = (function PopupAnnotationClosure() {
return PopupAnnotation; return PopupAnnotation;
})(); })();
var HighlightAnnotation = (function HighlightAnnotationClosure() {
function HighlightAnnotation(parameters) {
Annotation.call(this, parameters);
this.data.annotationType = AnnotationType.HIGHLIGHT;
this.data.hasHtml = true;
// PDF viewers completely ignore any border styles.
this.data.borderStyle.setWidth(0);
}
Util.inherit(HighlightAnnotation, Annotation, {});
return HighlightAnnotation;
})();
var UnderlineAnnotation = (function UnderlineAnnotationClosure() { var UnderlineAnnotation = (function UnderlineAnnotationClosure() {
function UnderlineAnnotation(parameters) { function UnderlineAnnotation(parameters) {
Annotation.call(this, parameters); Annotation.call(this, parameters);
@ -39004,6 +39158,38 @@ var UnderlineAnnotation = (function UnderlineAnnotationClosure() {
return UnderlineAnnotation; return UnderlineAnnotation;
})(); })();
var SquigglyAnnotation = (function SquigglyAnnotationClosure() {
function SquigglyAnnotation(parameters) {
Annotation.call(this, parameters);
this.data.annotationType = AnnotationType.SQUIGGLY;
this.data.hasHtml = true;
// PDF viewers completely ignore any border styles.
this.data.borderStyle.setWidth(0);
}
Util.inherit(SquigglyAnnotation, Annotation, {});
return SquigglyAnnotation;
})();
var StrikeOutAnnotation = (function StrikeOutAnnotationClosure() {
function StrikeOutAnnotation(parameters) {
Annotation.call(this, parameters);
this.data.annotationType = AnnotationType.STRIKEOUT;
this.data.hasHtml = true;
// PDF viewers completely ignore any border styles.
this.data.borderStyle.setWidth(0);
}
Util.inherit(StrikeOutAnnotation, Annotation, {});
return StrikeOutAnnotation;
})();
exports.Annotation = Annotation; exports.Annotation = Annotation;
exports.AnnotationBorderStyle = AnnotationBorderStyle; exports.AnnotationBorderStyle = AnnotationBorderStyle;
exports.AnnotationFactory = AnnotationFactory; exports.AnnotationFactory = AnnotationFactory;
@ -40418,7 +40604,10 @@ exports.WorkerMessageHandler = WorkerMessageHandler;
})); }));
}).call((typeof window === 'undefined') ? this : window); }).call(pdfjsLibs);
exports.PDFJS = pdfjsLibs.pdfjsSharedGlobal.PDFJS;
}));

Просмотреть файл

@ -129,7 +129,10 @@
padding-top: 0.2em; padding-top: 0.2em;
} }
.annotationLayer .underlineAnnotation { .annotationLayer .highlightAnnotation,
.annotationLayer .underlineAnnotation,
.annotationLayer .squigglyAnnotation,
.annotationLayer .strikeoutAnnotation {
cursor: pointer; cursor: pointer;
} }

Просмотреть файл

@ -52,12 +52,6 @@ var MAX_AUTO_SCALE = 1.25;
var SCROLLBAR_PADDING = 40; var SCROLLBAR_PADDING = 40;
var VERTICAL_PADDING = 5; var VERTICAL_PADDING = 5;
var NullCharactersRegExp = /\x00/g;
function removeNullCharacters(str) {
return str.replace(NullCharactersRegExp, '');
}
function getFileName(url) { function getFileName(url) {
var anchor = url.indexOf('#'); var anchor = url.indexOf('#');
var query = url.indexOf('?'); var query = url.indexOf('?');
@ -5828,7 +5822,7 @@ var PDFOutlineView = (function PDFOutlineViewClosure() {
div.className = 'outlineItem'; div.className = 'outlineItem';
var element = document.createElement('a'); var element = document.createElement('a');
this._bindLink(element, item); this._bindLink(element, item);
element.textContent = removeNullCharacters(item.title); element.textContent = PDFJS.removeNullCharacters(item.title);
div.appendChild(element); div.appendChild(element);
if (item.items.length > 0) { if (item.items.length > 0) {
@ -5932,7 +5926,7 @@ var PDFAttachmentView = (function PDFAttachmentViewClosure() {
div.className = 'attachmentsItem'; div.className = 'attachmentsItem';
var button = document.createElement('button'); var button = document.createElement('button');
this._bindLink(button, item.content, filename); this._bindLink(button, item.content, filename);
button.textContent = removeNullCharacters(filename); button.textContent = PDFJS.removeNullCharacters(filename);
div.appendChild(button); div.appendChild(button);
this.container.appendChild(div); this.container.appendChild(div);
} }