1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-26 10:08:06 +02:00

Make getOperatorList() calls independent and merge queues at end

This commit is contained in:
Mack Duan 2013-04-08 15:14:56 -07:00
parent 6b2c6fc223
commit dbccbaaa27
10 changed files with 1208 additions and 753 deletions

View file

@ -18,7 +18,7 @@
InvalidPDFException, isArray, isCmd, isDict, isInt, isName, isRef,
isStream, JpegStream, Lexer, log, Page, Parser, Promise, shadow,
stringToPDFString, stringToUTF8String, warn, isString, assert, PDFJS,
MissingDataException, XRefParseException */
MissingDataException, XRefParseException, Stream */
'use strict';
@ -151,7 +151,8 @@ var RefSet = (function RefSetClosure() {
})();
var Catalog = (function CatalogClosure() {
function Catalog(xref) {
function Catalog(pdfManager, xref) {
this.pdfManager = pdfManager;
this.xref = xref;
this.catDict = xref.getCatalogObj();
assertWellFormed(isDict(this.catDict),
@ -363,7 +364,8 @@ var Catalog = (function CatalogClosure() {
var kid = this.xref.fetch(kidRef);
if (isDict(kid, 'Page') || (isDict(kid) && !kid.has('Kids'))) {
var pageIndex = this.currPageIndex++;
var page = new Page(this.xref, pageIndex, kid, kidRef);
var page = new Page(this.pdfManager, this.xref, pageIndex, kid,
kidRef);
if (!(pageIndex in this.pagePromises)) {
this.pagePromises[pageIndex] = new PDFJS.Promise();
}
@ -832,10 +834,16 @@ var XRef = (function XRefClosure() {
fetch: function XRef_fetch(ref, suppressEncryption) {
assertWellFormed(isRef(ref), 'ref object is not a reference');
var num = ref.num;
if (num in this.cache)
return this.cache[num];
var e;
if (num in this.cache) {
e = this.cache[num];
if (e instanceof Stream) {
return e.makeSubStream(e.start, e.length, e.dict);
}
return e;
}
var e = this.getEntry(num);
e = this.getEntry(num);
// the referenced entry can be free
if (e === null)
@ -877,9 +885,16 @@ var XRef = (function XRefClosure() {
} else {
e = parser.getObj();
}
// Don't cache streams since they are mutable (except images).
if (!isStream(e) || e instanceof JpegStream)
if (!isStream(e) || e instanceof JpegStream) {
this.cache[num] = e;
} else if (e instanceof Stream) {
e = e.makeSubStream(e.start, e.length, e.dict);
this.cache[num] = e;
} else if ('readBlock' in e) {
e.getBytes();
e = e.makeSubStream(0, e.bufferLength, e.dict);
this.cache[num] = e;
}
return e;
}