Merge pull request #4614 from kalisjoshua/code-cleanup--kalisjoshua
Refactor - remove redundant function and all references
This commit is contained in:
commit
816f2f7e1d
@ -14,7 +14,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
/* globals assertWellFormed, calculateMD5, Catalog, Dict, error, info, isArray,
|
/* globals assert, calculateMD5, Catalog, Dict, error, info, isArray,
|
||||||
isArrayBuffer, isName, isStream, isString, LegacyPromise,
|
isArrayBuffer, isName, isStream, isString, LegacyPromise,
|
||||||
Linearization, NullStream, PartialEvaluator, shadow, Stream, Lexer,
|
Linearization, NullStream, PartialEvaluator, shadow, Stream, Lexer,
|
||||||
StreamsSequenceStream, stringToPDFString, stringToBytes, Util, XRef,
|
StreamsSequenceStream, stringToPDFString, stringToBytes, Util, XRef,
|
||||||
@ -303,7 +303,7 @@ var PDFDocument = (function PDFDocumentClosure() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function init(pdfManager, stream, password) {
|
function init(pdfManager, stream, password) {
|
||||||
assertWellFormed(stream.length > 0, 'stream must have data');
|
assert(stream.length > 0, 'stream must have data');
|
||||||
this.pdfManager = pdfManager;
|
this.pdfManager = pdfManager;
|
||||||
this.stream = stream;
|
this.stream = stream;
|
||||||
var xref = new XRef(this.stream, password, pdfManager);
|
var xref = new XRef(this.stream, password, pdfManager);
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
/* globals assert, assertWellFormed, ColorSpace, DecodeStream, Dict, Encodings,
|
/* globals assert, ColorSpace, DecodeStream, Dict, Encodings,
|
||||||
error, ErrorFont, Font, FONT_IDENTITY_MATRIX, fontCharsToUnicode,
|
error, ErrorFont, Font, FONT_IDENTITY_MATRIX, fontCharsToUnicode,
|
||||||
FontFlags, ImageKind, info, isArray, isCmd, isDict, isEOF, isName,
|
FontFlags, ImageKind, info, isArray, isCmd, isDict, isEOF, isName,
|
||||||
isNum, isStream, isString, JpegStream, Lexer, Metrics,
|
isNum, isStream, isString, JpegStream, Lexer, Metrics,
|
||||||
@ -564,10 +564,10 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||||||
|
|
||||||
var xobj = xobjs.get(name);
|
var xobj = xobjs.get(name);
|
||||||
if (xobj) {
|
if (xobj) {
|
||||||
assertWellFormed(isStream(xobj), 'XObject should be a stream');
|
assert(isStream(xobj), 'XObject should be a stream');
|
||||||
|
|
||||||
var type = xobj.dict.get('Subtype');
|
var type = xobj.dict.get('Subtype');
|
||||||
assertWellFormed(isName(type),
|
assert(isName(type),
|
||||||
'XObject should have a Name subtype');
|
'XObject should have a Name subtype');
|
||||||
|
|
||||||
if ('Form' == type.name) {
|
if ('Form' == type.name) {
|
||||||
@ -942,10 +942,10 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||||||
if (!xobj) {
|
if (!xobj) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
assertWellFormed(isStream(xobj), 'XObject should be a stream');
|
assert(isStream(xobj), 'XObject should be a stream');
|
||||||
|
|
||||||
var type = xobj.dict.get('Subtype');
|
var type = xobj.dict.get('Subtype');
|
||||||
assertWellFormed(isName(type),
|
assert(isName(type),
|
||||||
'XObject should have a Name subtype');
|
'XObject should have a Name subtype');
|
||||||
|
|
||||||
if ('Form' !== type.name) {
|
if ('Form' !== type.name) {
|
||||||
@ -1287,7 +1287,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||||||
preEvaluateFont: function PartialEvaluator_preEvaluateFont(dict, xref) {
|
preEvaluateFont: function PartialEvaluator_preEvaluateFont(dict, xref) {
|
||||||
var baseDict = dict;
|
var baseDict = dict;
|
||||||
var type = dict.get('Subtype');
|
var type = dict.get('Subtype');
|
||||||
assertWellFormed(isName(type), 'invalid font Subtype');
|
assert(isName(type), 'invalid font Subtype');
|
||||||
|
|
||||||
var composite = false;
|
var composite = false;
|
||||||
var uint8array;
|
var uint8array;
|
||||||
@ -1303,7 +1303,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||||||
dict = (isArray(df) ? xref.fetchIfRef(df[0]) : df);
|
dict = (isArray(df) ? xref.fetchIfRef(df[0]) : df);
|
||||||
|
|
||||||
type = dict.get('Subtype');
|
type = dict.get('Subtype');
|
||||||
assertWellFormed(isName(type), 'invalid font Subtype');
|
assert(isName(type), 'invalid font Subtype');
|
||||||
composite = true;
|
composite = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1434,7 +1434,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||||||
}
|
}
|
||||||
fontName = (fontName || baseFont);
|
fontName = (fontName || baseFont);
|
||||||
|
|
||||||
assertWellFormed(isName(fontName), 'invalid font name');
|
assert(isName(fontName), 'invalid font name');
|
||||||
|
|
||||||
var fontFile = descriptor.get('FontFile', 'FontFile2', 'FontFile3');
|
var fontFile = descriptor.get('FontFile', 'FontFile2', 'FontFile3');
|
||||||
if (fontFile) {
|
if (fontFile) {
|
||||||
@ -1827,7 +1827,7 @@ var EvaluatorPreprocessor = (function EvaluatorPreprocessorClosure() {
|
|||||||
// argument
|
// argument
|
||||||
if (obj !== null && obj !== undefined) {
|
if (obj !== null && obj !== undefined) {
|
||||||
args.push((obj instanceof Dict ? obj.getAll() : obj));
|
args.push((obj instanceof Dict ? obj.getAll() : obj));
|
||||||
assertWellFormed(args.length <= 33, 'Too many arguments');
|
assert(args.length <= 33, 'Too many arguments');
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -14,10 +14,10 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
/* globals assertWellFormed, bytesToString, CipherTransformFactory, error, info,
|
/* globals assert, bytesToString, CipherTransformFactory, error, info,
|
||||||
InvalidPDFException, isArray, isCmd, isDict, isInt, isName, isRef,
|
InvalidPDFException, isArray, isCmd, isDict, isInt, isName, isRef,
|
||||||
isStream, Lexer, Page, Parser, Promise, shadow,
|
isStream, Lexer, Page, Parser, Promise, shadow,
|
||||||
stringToPDFString, stringToUTF8String, warn, isString, assert,
|
stringToPDFString, stringToUTF8String, warn, isString,
|
||||||
Promise, MissingDataException, XRefParseException, Stream,
|
Promise, MissingDataException, XRefParseException, Stream,
|
||||||
ChunkedStream, LegacyPromise */
|
ChunkedStream, LegacyPromise */
|
||||||
|
|
||||||
@ -296,7 +296,7 @@ var Catalog = (function CatalogClosure() {
|
|||||||
this.xref = xref;
|
this.xref = xref;
|
||||||
this.catDict = xref.getCatalogObj();
|
this.catDict = xref.getCatalogObj();
|
||||||
this.fontCache = new RefSetCache();
|
this.fontCache = new RefSetCache();
|
||||||
assertWellFormed(isDict(this.catDict),
|
assert(isDict(this.catDict),
|
||||||
'catalog object is not a dictionary');
|
'catalog object is not a dictionary');
|
||||||
|
|
||||||
this.pagePromises = [];
|
this.pagePromises = [];
|
||||||
@ -337,7 +337,7 @@ var Catalog = (function CatalogClosure() {
|
|||||||
},
|
},
|
||||||
get toplevelPagesDict() {
|
get toplevelPagesDict() {
|
||||||
var pagesObj = this.catDict.get('Pages');
|
var pagesObj = this.catDict.get('Pages');
|
||||||
assertWellFormed(isDict(pagesObj), 'invalid top-level pages dictionary');
|
assert(isDict(pagesObj), 'invalid top-level pages dictionary');
|
||||||
// shadow the prototype getter
|
// shadow the prototype getter
|
||||||
return shadow(this, 'toplevelPagesDict', pagesObj);
|
return shadow(this, 'toplevelPagesDict', pagesObj);
|
||||||
},
|
},
|
||||||
@ -411,7 +411,7 @@ var Catalog = (function CatalogClosure() {
|
|||||||
},
|
},
|
||||||
get numPages() {
|
get numPages() {
|
||||||
var obj = this.toplevelPagesDict.get('Count');
|
var obj = this.toplevelPagesDict.get('Count');
|
||||||
assertWellFormed(
|
assert(
|
||||||
isInt(obj),
|
isInt(obj),
|
||||||
'page count in top level pages object is not an integer'
|
'page count in top level pages object is not an integer'
|
||||||
);
|
);
|
||||||
@ -1114,7 +1114,7 @@ var XRef = (function XRefClosure() {
|
|||||||
},
|
},
|
||||||
|
|
||||||
fetch: function XRef_fetch(ref, suppressEncryption) {
|
fetch: function XRef_fetch(ref, suppressEncryption) {
|
||||||
assertWellFormed(isRef(ref), 'ref object is not a reference');
|
assert(isRef(ref), 'ref object is not a reference');
|
||||||
var num = ref.num;
|
var num = ref.num;
|
||||||
if (num in this.cache) {
|
if (num in this.cache) {
|
||||||
var cacheEntry = this.cache[num];
|
var cacheEntry = this.cache[num];
|
||||||
|
@ -283,14 +283,6 @@ function isValidUrl(url, allowRelative) {
|
|||||||
}
|
}
|
||||||
PDFJS.isValidUrl = isValidUrl;
|
PDFJS.isValidUrl = isValidUrl;
|
||||||
|
|
||||||
// In a well-formed PDF, |cond| holds. If it doesn't, subsequent
|
|
||||||
// behavior is undefined.
|
|
||||||
function assertWellFormed(cond, msg) {
|
|
||||||
if (!cond) {
|
|
||||||
error(msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function shadow(obj, prop, value) {
|
function shadow(obj, prop, value) {
|
||||||
Object.defineProperty(obj, prop, { value: value,
|
Object.defineProperty(obj, prop, { value: value,
|
||||||
enumerable: true,
|
enumerable: true,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user