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

Add a parameter to Page_getInheritedPageProp to make it possible to fetch (and dereference) Arrays, and use that for the MediaBox/CropBox getters (issue 7872)

This commit is contained in:
Jonas Jenwald 2016-12-06 10:21:42 +01:00 committed by Tim van der Meij
parent caf81685cb
commit 9be3aee9c9
4 changed files with 94 additions and 4 deletions

View file

@ -91,13 +91,14 @@ var Page = (function PageClosure() {
return this.pageDict.get(key);
},
getInheritedPageProp: function Page_getInheritedPageProp(key) {
getInheritedPageProp: function Page_getInheritedPageProp(key, getArray) {
var dict = this.pageDict, valueArray = null, loopCount = 0;
var MAX_LOOP_COUNT = 100;
getArray = getArray || false;
// Always walk up the entire parent chain, to be able to find
// e.g. \Resources placed on multiple levels of the tree.
while (dict) {
var value = dict.get(key);
var value = getArray ? dict.getArray(key) : dict.get(key);
if (value) {
if (!valueArray) {
valueArray = [];
@ -132,7 +133,7 @@ var Page = (function PageClosure() {
},
get mediaBox() {
var obj = this.getInheritedPageProp('MediaBox');
var obj = this.getInheritedPageProp('MediaBox', true);
// Reset invalid media box to letter size.
if (!isArray(obj) || obj.length !== 4) {
obj = LETTER_SIZE_MEDIABOX;
@ -150,7 +151,7 @@ var Page = (function PageClosure() {
get view() {
var mediaBox = this.mediaBox;
var cropBox = this.getInheritedPageProp('CropBox');
var cropBox = this.getInheritedPageProp('CropBox', true);
if (!isArray(cropBox) || cropBox.length !== 4) {
return shadow(this, 'view', mediaBox);
}