From: Yury Delendik Date: Thu, 5 Apr 2012 15:03:49 +0000 (-0500) Subject: Merge remote-tracking branch 'mozilla/master' into mergexref-1 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=cea388201de63e5613a48dd36220968abcaec457;p=pdf.js.git Merge remote-tracking branch 'mozilla/master' into mergexref-1 Conflicts: src/core.js src/evaluator.js src/obj.js --- cea388201de63e5613a48dd36220968abcaec457 diff --cc src/colorspace.js index 9b89d7b,6e8a77e..8d82901 --- a/src/colorspace.js +++ b/src/colorspace.js @@@ -68,9 -68,9 +68,9 @@@ var ColorSpace = (function ColorSpaceCl return null; }; - ColorSpace.parseToIR = function colorSpaceParseToIR(cs, xref, res) { + ColorSpace.parseToIR = function ColorSpace_parseToIR(cs, xref, res) { if (isName(cs)) { - var colorSpaces = xref.fetchIfRef(res.get('ColorSpace')); + var colorSpaces = res.get('ColorSpace'); if (isDict(colorSpaces)) { var refcs = colorSpaces.get(cs.name); if (refcs) diff --cc src/core.js index bf0d2bb,a909743..10ae7d0 --- a/src/core.js +++ b/src/core.js @@@ -72,10 -72,10 +72,10 @@@ var Page = (function PageClosure() } Page.prototype = { - getPageProp: function pageGetPageProp(key) { + getPageProp: function Page_getPageProp(key) { - return this.xref.fetchIfRef(this.pageDict.get(key)); + return this.pageDict.get(key); }, - inheritPageProp: function pageInheritPageProp(key) { + inheritPageProp: function Page_inheritPageProp(key) { var dict = this.pageDict; var obj = dict.get(key); while (obj === undefined) { @@@ -595,10 -594,10 +595,10 @@@ var PDFDocModel = (function PDFDocModel // shadow the prototype getter return shadow(this, 'numPages', num); }, - getDocumentInfo: function pdfDocGetDocumentInfo() { + getDocumentInfo: function PDFDocModel_getDocumentInfo() { var info; if (this.xref.trailer.has('Info')) - info = this.xref.fetch(this.xref.trailer.get('Info')); + info = this.xref.trailer.get('Info'); return shadow(this, 'getDocumentInfo', info); }, diff --cc src/evaluator.js index 8db082d,10a9450..203247b --- a/src/evaluator.js +++ b/src/evaluator.js @@@ -518,9 -523,8 +520,8 @@@ var PartialEvaluator = (function Partia properties.hasEncoding = hasEncoding; }, - readToUnicode: - function partialEvaluatorReadToUnicode(toUnicode, xref) { + readToUnicode: function PartialEvaluator_readToUnicode(toUnicode, xref) { - var cmapObj = xref.fetchIfRef(toUnicode); + var cmapObj = toUnicode; var charToUnicode = []; if (isName(cmapObj)) { var isIdentityMap = cmapObj.name.substr(0, 9) == 'Identity-'; diff --cc src/obj.js index 675db3f,b6139fb..3baf98f --- a/src/obj.js +++ b/src/obj.js @@@ -42,34 -39,21 +42,34 @@@ var Dict = (function DictClosure() } Dict.prototype = { + // automatically dereferences Ref objects - get: function dictGet(key1, key2, key3) { + get: function Dict_get(key1, key2, key3) { var value; + var xref = this.xref; if (typeof (value = this.map[key1]) != 'undefined' || key1 in this.map || typeof key2 == 'undefined') { - return value; + return xref ? this.xref.fetchIfRef(value) : value; } if (typeof (value = this.map[key2]) != 'undefined' || key2 in this.map || typeof key3 == 'undefined') { - return value; + return xref ? this.xref.fetchIfRef(value) : value; } - - return this.map[key3] || null; + value = this.map[key3] || null; + return xref ? this.xref.fetchIfRef(value) : value; + }, + // no dereferencing - getRaw: function dictGetRaw(key) { ++ getRaw: function Dict_getRaw(key) { + return this.map[key]; + }, + // creates new map and dereferences all Refs - getAll: function dictGetAll() { ++ getAll: function Dict_getAll() { + var all = {}; + for (var key in this.map) + all[key] = this.get(key); + return all; }, - set: function dictSet(key, value) { + set: function Dict_set(key, value) { this.map[key] = value; }, @@@ -77,9 -61,9 +77,9 @@@ return key in this.map; }, - forEach: function dictForEach(callback) { + forEach: function Dict_forEach(callback) { for (var key in this.map) { - callback(key, this.map[key]); + callback(key, this.get(key)); } } }; @@@ -608,8 -595,7 +608,8 @@@ var XRef = (function XRefClosure() return obj; return this.fetch(obj); }, - fetch: function xRefFetch(ref, suppressEncryption) { + 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]; @@@ -696,8 -682,8 +696,8 @@@ } return e; }, - getCatalogObj: function xRefGetCatalogObj() { - return this.root; + getCatalogObj: function XRef_getCatalogObj() { - return this.fetch(this.root); ++ return this.this.root; } };