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

Refactor class method names.

Also move functionality to more logical place in canvas.js and jpx.js.
This commit is contained in:
Kalervo Kujala 2012-04-04 23:43:26 +03:00
parent 921c1e82a3
commit 99440ab691
15 changed files with 1554 additions and 1543 deletions

View file

@ -22,7 +22,7 @@ var Cmd = (function CmdClosure() {
var cmdCache = {};
Cmd.get = function cmdGet(cmd) {
Cmd.get = function Cmd_get(cmd) {
var cmdValue = cmdCache[cmd];
if (cmdValue)
return cmdValue;
@ -39,7 +39,7 @@ var Dict = (function DictClosure() {
}
Dict.prototype = {
get: function dictGet(key1, key2, key3) {
get: function Dict_get(key1, key2, key3) {
var value;
if (typeof (value = this.map[key1]) != 'undefined' || key1 in this.map ||
typeof key2 == 'undefined') {
@ -53,15 +53,15 @@ var Dict = (function DictClosure() {
return this.map[key3] || null;
},
set: function dictSet(key, value) {
set: function Dict_set(key, value) {
this.map[key] = value;
},
has: function dictHas(key) {
has: function Dict_has(key) {
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]);
}
@ -90,11 +90,11 @@ var RefSet = (function RefSetClosure() {
}
RefSet.prototype = {
has: function refSetHas(ref) {
has: function RefSet_has(ref) {
return !!this.dict['R' + ref.num + '.' + ref.gen];
},
put: function refSetPut(ref) {
put: function RefSet_put(ref) {
this.dict['R' + ref.num + '.' + ref.gen] = ref;
}
};
@ -198,7 +198,7 @@ var Catalog = (function CatalogClosure() {
// shadow the prototype getter
return shadow(this, 'num', obj);
},
traverseKids: function catalogTraverseKids(pagesDict) {
traverseKids: function Catalog_traverseKids(pagesDict) {
var pageCache = this.pageCache;
var kids = pagesDict.get('Kids');
assertWellFormed(isArray(kids),
@ -268,7 +268,7 @@ var Catalog = (function CatalogClosure() {
}
return shadow(this, 'destinations', dests);
},
getPage: function catalogGetPage(n) {
getPage: function Catalog_getPage(n) {
var pageCache = this.pageCache;
if (!pageCache) {
pageCache = this.pageCache = [];
@ -304,7 +304,7 @@ var XRef = (function XRefClosure() {
}
XRef.prototype = {
readXRefTable: function readXRefTable(parser) {
readXRefTable: function XRef_readXRefTable(parser) {
// Example of cross-reference table:
// xref
// 0 1 <-- subsection header (first obj #, obj count)
@ -371,7 +371,7 @@ var XRef = (function XRefClosure() {
return dict;
},
readXRefStream: function readXRefStream(stream) {
readXRefStream: function XRef_readXRefStream(stream) {
var streamParameters = stream.parameters;
var byteWidths = streamParameters.get('W');
var range = streamParameters.get('Index');
@ -422,7 +422,7 @@ var XRef = (function XRefClosure() {
}
return streamParameters;
},
indexObjects: function indexObjects() {
indexObjects: function XRef_indexObjects() {
// Simple scan through the PDF content to find objects,
// trailers and XRef streams.
function readToken(data, offset) {
@ -531,7 +531,7 @@ var XRef = (function XRefClosure() {
// nothing helps
error('Invalid PDF structure');
},
readXRef: function readXref(startXRef) {
readXRef: function XRef_readXRef(startXRef) {
var stream = this.stream;
stream.pos = startXRef;
@ -584,18 +584,18 @@ var XRef = (function XRefClosure() {
warn('Indexing all PDF objects');
return this.indexObjects();
},
getEntry: function xRefGetEntry(i) {
getEntry: function XRef_getEntry(i) {
var e = this.entries[i];
if (e === null)
return null;
return e.free ? null : e; // returns null is the entry is free
},
fetchIfRef: function xRefFetchIfRef(obj) {
fetchIfRef: function XRef_fetchIfRef(obj) {
if (!isRef(obj))
return obj;
return this.fetch(obj);
},
fetch: function xRefFetch(ref, suppressEncryption) {
fetch: function XRef_fetch(ref, suppressEncryption) {
var num = ref.num;
if (num in this.cache)
return this.cache[num];
@ -682,7 +682,7 @@ var XRef = (function XRefClosure() {
}
return e;
},
getCatalogObj: function xRefGetCatalogObj() {
getCatalogObj: function XRef_getCatalogObj() {
return this.fetch(this.root);
}
};
@ -709,7 +709,7 @@ var PDFObjects = (function PDFObjectsClosure() {
* Ensures there is an object defined for `objId`. Stores `data` on the
* object *if* it is created.
*/
ensureObj: function pdfObjectsEnsureObj(objId, data) {
ensureObj: function PDFObjects_ensureObj(objId, data) {
if (this.objs[objId])
return this.objs[objId];
return this.objs[objId] = new Promise(objId, data);
@ -724,7 +724,7 @@ var PDFObjects = (function PDFObjectsClosure() {
* function and the object is already resolved, the callback gets called
* right away.
*/
get: function pdfObjectsGet(objId, callback) {
get: function PDFObjects_get(objId, callback) {
// If there is a callback, then the get can be async and the object is
// not required to be resolved right now
if (callback) {
@ -747,7 +747,7 @@ var PDFObjects = (function PDFObjectsClosure() {
/**
* Resolves the object `objId` with optional `data`.
*/
resolve: function pdfObjectsResolve(objId, data) {
resolve: function PDFObjects_resolve(objId, data) {
var objs = this.objs;
// In case there is a promise already on this object, just resolve it.
@ -758,11 +758,11 @@ var PDFObjects = (function PDFObjectsClosure() {
}
},
onData: function pdfObjectsOnData(objId, callback) {
onData: function PDFObjects_onData(objId, callback) {
this.ensureObj(objId).onData(callback);
},
isResolved: function pdfObjectsIsResolved(objId) {
isResolved: function PDFObjects_isResolved(objId) {
var objs = this.objs;
if (!objs[objId]) {
return false;
@ -771,7 +771,7 @@ var PDFObjects = (function PDFObjectsClosure() {
}
},
hasData: function pdfObjectsHasData(objId) {
hasData: function PDFObjects_hasData(objId) {
var objs = this.objs;
if (!objs[objId]) {
return false;
@ -783,7 +783,7 @@ var PDFObjects = (function PDFObjectsClosure() {
/**
* Sets the data of an object but *doesn't* resolve it.
*/
setData: function pdfObjectsSetData(objId, data) {
setData: function PDFObjects_setData(objId, data) {
// Watchout! If you call `this.ensureObj(objId, data)` you're going to
// create a *resolved* promise which shouldn't be the case!
this.ensureObj(objId).data = data;