whitespace fixes and move inheriting of dict props into the page since it only happens there

This commit is contained in:
Andreas Gal 2011-06-21 15:05:33 -04:00
parent bad69c984c
commit 5a96404705

48
pdf.js
View File

@ -784,16 +784,6 @@ var Dict = (function() {
get2: function(key1, key2) {
return this.get(key1) || this.get(key2);
},
getOrInherit: function(key, xref) {
var obj = this.map[key];
var dict = this;
while (!obj && dict) {
dict = xref.fetchIfRef(dict.get("Parent"));
if (dict)
obj = dict.get(key);
}
return obj;
},
has: function(key) {
return key in this.map;
},
@ -1707,15 +1697,28 @@ var Page = (function() {
}
constructor.prototype = {
getPageProp: function(key) {
return this.pageDict.get(key);
},
inheritPageProp: function(key) {
var dict = this.pageDict;
var obj = dict.get(key);
while (!obj) {
dict = this.xref.fetchIfRef(dict.get("Parent"));
if (!dict)
break;
obj = dict.get(key);
}
return obj;
},
get content() {
return shadow(this, "content", this.pageDict.get("Contents"));
return shadow(this, "content", this.getPageProp("Contents"));
},
get resources() {
return shadow(this, "resources",
this.pageDict.getOrInherit("Resources", this.xref));
return shadow(this, "resources", this.inheritPageProp("Resources"));
},
get mediaBox() {
var obj = this.pageDict.getOrInherit("MediaBox", this.xref);
var obj = this.inheritPageProp("MediaBox");
return shadow(this, "mediaBox", ((IsArray(obj) && obj.length == 4)
? obj
: null));
@ -2890,7 +2893,6 @@ var CanvasGraphics = (function() {
shadingFill: function(entryRef) {
var xref = this.xref;
var res = this.res;
var shadingRes = xref.fetchIfRef(res.get("Shading"));
if (!shadingRes)
error("No shading resource found");
@ -2915,8 +2917,10 @@ var CanvasGraphics = (function() {
if (background)
TODO("handle background colors");
const types = [null, this.fillFunctionShading,
this.fillAxialShading, this.fillRadialShading];
const types = [null,
this.fillFunctionShading,
this.fillAxialShading,
this.fillRadialShading];
var typeNum = shading.get("ShadingType");
var fillFn = types[typeNum];
@ -3101,7 +3105,6 @@ var CanvasGraphics = (function() {
csStream = colorSpaces.get(csStream);
var colorSpace = new ColorSpace(xref, csStream);
var decode = dict.get2("Decode", "D");
TODO("create color map");
@ -3313,7 +3316,6 @@ var ColorSpace = (function() {
break;
case "ICCBased":
var dict = stream.dict;
this.stream = stream;
this.dict = dict;
this.numComps = dict.get("N");
@ -3338,8 +3340,10 @@ var PDFFunction = (function() {
if (!dict)
dict = fn;
const types = [this.constructSampled, null,
this.constructInterpolated, this.constructStiched,
const types = [this.constructSampled,
null,
this.constructInterpolated,
this.constructStiched,
this.constructPostScript];
var typeNum = dict.get("FunctionType");
@ -3408,7 +3412,6 @@ var PDFFunction = (function() {
v = encode[i2] + ((v - domain[i2]) *
(encode[i2 + 1] - encode[i2]) /
(domain[i2 + 1] - domain[i2]));
// clip to the size
args[i] = clip(v, 0, size[i] - 1);
}
@ -3436,7 +3439,6 @@ var PDFFunction = (function() {
// decode
v = decode[i2] + (v * (decode[i2 + 1] - decode[i2]) /
((1 << bps) - 1));
// clip to the domain
output.push(clip(v, range[i2], range[i2 + 1]));
}