From 7d86fa859f759a116553898158ec676aa7031119 Mon Sep 17 00:00:00 2001 From: Tim van der Meij Date: Sun, 9 Mar 2014 12:41:01 +0100 Subject: [PATCH 1/2] Making src/display/metadat.js adhere to the style guide --- src/display/metadata.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/display/metadata.js b/src/display/metadata.js index 029ad77f5..575026f49 100644 --- a/src/display/metadata.js +++ b/src/display/metadata.js @@ -59,20 +59,22 @@ var Metadata = PDFJS.Metadata = (function MetadataClosure() { if (rdf.nodeName.toLowerCase() !== 'rdf:rdf') { // Wrapped in rdf = rdf.firstChild; - while (rdf && rdf.nodeName.toLowerCase() !== 'rdf:rdf') + while (rdf && rdf.nodeName.toLowerCase() !== 'rdf:rdf') { rdf = rdf.nextSibling; + } } var nodeName = (rdf) ? rdf.nodeName.toLowerCase() : null; - if (!rdf || nodeName !== 'rdf:rdf' || !rdf.hasChildNodes()) + if (!rdf || nodeName !== 'rdf:rdf' || !rdf.hasChildNodes()) { return; + } var children = rdf.childNodes, desc, entry, name, i, ii, length, iLength; - for (i = 0, length = children.length; i < length; i++) { desc = children[i]; - if (desc.nodeName.toLowerCase() !== 'rdf:description') + if (desc.nodeName.toLowerCase() !== 'rdf:description') { continue; + } for (ii = 0, iLength = desc.childNodes.length; ii < iLength; ii++) { if (desc.childNodes[ii].nodeName.toLowerCase() !== '#text') { From f1249bd49ea12d2fc7bda198fe91eb4bac97fa00 Mon Sep 17 00:00:00 2001 From: Tim van der Meij Date: Sun, 9 Mar 2014 12:45:51 +0100 Subject: [PATCH 2/2] Making src/display/font_loader.js adhere to the style guide --- src/display/font_loader.js | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/src/display/font_loader.js b/src/display/font_loader.js index 1b86e99bd..0d855f348 100644 --- a/src/display/font_loader.js +++ b/src/display/font_loader.js @@ -24,15 +24,16 @@ var FontLoader = { insertRule: function fontLoaderInsertRule(rule) { var styleElement = document.getElementById('PDFJS_FONT_STYLE_TAG'); if (!styleElement) { - styleElement = document.createElement('style'); - styleElement.id = 'PDFJS_FONT_STYLE_TAG'; - document.documentElement.getElementsByTagName('head')[0].appendChild( - styleElement); + styleElement = document.createElement('style'); + styleElement.id = 'PDFJS_FONT_STYLE_TAG'; + document.documentElement.getElementsByTagName('head')[0].appendChild( + styleElement); } var styleSheet = styleElement.sheet; styleSheet.insertRule(rule, styleSheet.cssRules.length); }, + clear: function fontLoaderClear() { var styleElement = document.getElementById('PDFJS_FONT_STYLE_TAG'); if (styleElement) { @@ -77,15 +78,17 @@ var FontLoader = { }, isSyncFontLoadingSupported: (function detectSyncFontLoadingSupport() { - if (isWorker) + if (isWorker) { return false; + } // User agent string sniffing is bad, but there is no reliable way to tell // if font is fully loaded and ready to be used with canvas. var userAgent = window.navigator.userAgent; var m = /Mozilla\/5.0.*?rv:(\d+).*? Gecko/.exec(userAgent); - if (m && m[1] >= 14) + if (m && m[1] >= 14) { return true; + } // TODO other browsers return false; })(), @@ -258,8 +261,9 @@ var FontLoader = { // // for (var i = 0, ii = fonts.length; i < ii; i++) { // var font = fonts[i]; -// if (font.attached) +// if (font.attached) { // continue; +// } // // font.attached = true; // font.bindDOM() @@ -284,8 +288,9 @@ var FontFace = (function FontFaceClosure() { } FontFace.prototype = { bindDOM: function FontFace_bindDOM() { - if (!this.data) + if (!this.data) { return null; + } if (PDFJS.disableFontFace) { this.disableFontFace = true; @@ -299,15 +304,16 @@ var FontFace = (function FontFaceClosure() { var url = ('url(data:' + this.mimetype + ';base64,' + window.btoa(data) + ');'); var rule = '@font-face { font-family:"' + fontName + '";src:' + url + '}'; - FontLoader.insertRule(rule); if (PDFJS.pdfBug && 'FontInspector' in globalScope && - globalScope['FontInspector'].enabled) + globalScope['FontInspector'].enabled) { globalScope['FontInspector'].fontAdded(this, url); + } return rule; }, + getPathGenerator: function (objs, character) { if (!(character in this.compiledGlyphs)) { var js = objs.get(this.loadedName + '_path_' + character);