Merge remote-tracking branch 'pdf.js/epubjs'

Updated pdf.js
This commit is contained in:
Ozzieisaacs
2019-04-13 15:02:01 +02:00
235 changed files with 101020 additions and 65509 deletions

View File

@ -12,38 +12,35 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* eslint-disable no-var */
'use strict';
var FontInspector = (function FontInspectorClosure() {
var fonts;
var fonts, createObjectURL;
var active = false;
var fontAttribute = 'data-font-name';
function removeSelection() {
var divs = document.querySelectorAll('div[' + fontAttribute + ']');
for (var i = 0, ii = divs.length; i < ii; ++i) {
var div = divs[i];
let divs = document.querySelectorAll(`span[${fontAttribute}]`);
for (let div of divs) {
div.className = '';
}
}
function resetSelection() {
var divs = document.querySelectorAll('div[' + fontAttribute + ']');
for (var i = 0, ii = divs.length; i < ii; ++i) {
var div = divs[i];
let divs = document.querySelectorAll(`span[${fontAttribute}]`);
for (let div of divs) {
div.className = 'debuggerHideText';
}
}
function selectFont(fontName, show) {
var divs = document.querySelectorAll('div[' + fontAttribute + '=' +
fontName + ']');
for (var i = 0, ii = divs.length; i < ii; ++i) {
var div = divs[i];
let divs = document.querySelectorAll(`span[${fontAttribute}=${fontName}]`);
for (let div of divs) {
div.className = show ? 'debuggerShowText' : 'debuggerHideText';
}
}
function textLayerClick(e) {
if (!e.target.dataset.fontName ||
e.target.tagName.toUpperCase() !== 'DIV') {
e.target.tagName.toUpperCase() !== 'SPAN') {
return;
}
var fontName = e.target.dataset.fontName;
@ -74,6 +71,8 @@ var FontInspector = (function FontInspectorClosure() {
fonts = document.createElement('div');
panel.appendChild(fonts);
createObjectURL = pdfjsLib.createObjectURL;
},
cleanup: function cleanup() {
fonts.textContent = '';
@ -118,10 +117,7 @@ var FontInspector = (function FontInspectorClosure() {
url = /url\(['"]?([^\)"']+)/.exec(url);
download.href = url[1];
} else if (fontObj.data) {
url = URL.createObjectURL(new Blob([fontObj.data], {
type: fontObj.mimeType
}));
download.href = url;
download.href = createObjectURL(fontObj.data, fontObj.mimeType);
}
download.textContent = 'Download';
var logIt = document.createElement('a');
@ -149,12 +145,12 @@ var FontInspector = (function FontInspectorClosure() {
fonts.appendChild(font);
// Somewhat of a hack, should probably add a hook for when the text layer
// is done rendering.
setTimeout(function() {
setTimeout(() => {
if (this.active) {
resetSelection();
}
}.bind(this), 2000);
}
}, 2000);
},
};
})();
@ -243,7 +239,7 @@ var StepperManager = (function StepperManagerClosure() {
saveBreakPoints: function saveBreakPoints(pageIndex, bps) {
breakPoints[pageIndex] = bps;
sessionStorage.setItem('pdfjsBreakPoints', JSON.stringify(breakPoints));
}
},
};
})();
@ -262,7 +258,7 @@ var Stepper = (function StepperClosure() {
if (typeof args === 'string') {
var MAX_STRING_LENGTH = 75;
return args.length <= MAX_STRING_LENGTH ? args :
args.substr(0, MAX_STRING_LENGTH) + '...';
args.substring(0, MAX_STRING_LENGTH) + '...';
}
if (typeof args !== 'object' || args === null) {
return args;
@ -337,7 +333,7 @@ var Stepper = (function StepperClosure() {
line.className = 'line';
line.dataset.idx = i;
chunk.appendChild(line);
var checked = this.breakPoints.indexOf(i) !== -1;
var checked = this.breakPoints.includes(i);
var args = operatorList.argsArray[i] || [];
var breakCell = c('td');
@ -387,7 +383,9 @@ var Stepper = (function StepperClosure() {
this.table.appendChild(chunk);
},
getNextBreakPoint: function getNextBreakPoint() {
this.breakPoints.sort(function(a, b) { return a - b; });
this.breakPoints.sort(function(a, b) {
return a - b;
});
for (var i = 0; i < this.breakPoints.length; i++) {
if (this.breakPoints[i] > this.currentIdx) {
return this.breakPoints[i];
@ -431,7 +429,7 @@ var Stepper = (function StepperClosure() {
row.style.backgroundColor = null;
}
}
}
},
};
return Stepper;
})();
@ -457,14 +455,13 @@ var Stats = (function Stats() {
name: 'Stats',
panel: null,
manager: null,
init: function init(pdfjsLib) {
init(pdfjsLib) {
this.panel.setAttribute('style', 'padding: 5px;');
pdfjsLib.PDFJS.enableStats = true;
},
enabled: false,
active: false,
// Stats specific functions.
add: function(pageNumber, stat) {
add(pageNumber, stat) {
if (!stat) {
return;
}
@ -483,22 +480,24 @@ var Stats = (function Stats() {
statsDiv.textContent = stat.toString();
wrapper.appendChild(title);
wrapper.appendChild(statsDiv);
stats.push({ pageNumber: pageNumber, div: wrapper });
stats.sort(function(a, b) { return a.pageNumber - b.pageNumber; });
stats.push({ pageNumber, div: wrapper, });
stats.sort(function(a, b) {
return a.pageNumber - b.pageNumber;
});
clear(this.panel);
for (var i = 0, ii = stats.length; i < ii; ++i) {
this.panel.appendChild(stats[i].div);
}
},
cleanup: function () {
cleanup() {
stats = [];
clear(this.panel);
}
},
};
})();
// Manages all the debugging tools.
var PDFBug = (function PDFBugClosure() {
window.PDFBug = (function PDFBugClosure() {
var panelWidth = 300;
var buttons = [];
var activePanel = null;
@ -509,14 +508,14 @@ var PDFBug = (function PDFBugClosure() {
StepperManager,
Stats
],
enable: function(ids) {
enable(ids) {
var all = false, tools = this.tools;
if (ids.length === 1 && ids[0] === 'all') {
all = true;
}
for (var i = 0; i < tools.length; ++i) {
var tool = tools[i];
if (all || ids.indexOf(tool.id) !== -1) {
if (all || ids.includes(tool.id)) {
tool.enabled = true;
}
}
@ -531,7 +530,7 @@ var PDFBug = (function PDFBugClosure() {
});
}
},
init: function init(pdfjsLib, container) {
init(pdfjsLib, container) {
/*
* Basic Layout:
* PDFBug
@ -584,14 +583,14 @@ var PDFBug = (function PDFBugClosure() {
}
this.selectPanel(0);
},
cleanup: function cleanup() {
cleanup() {
for (var i = 0, ii = this.tools.length; i < ii; i++) {
if (this.tools[i].enabled) {
this.tools[i].cleanup();
}
}
},
selectPanel: function selectPanel(index) {
selectPanel(index) {
if (typeof index !== 'number') {
index = this.tools.indexOf(index);
}
@ -611,6 +610,6 @@ var PDFBug = (function PDFBugClosure() {
tools[j].panel.setAttribute('hidden', 'true');
}
}
}
},
};
})();