[Basilisk] Revert "Update PDF.js to 2.3.235" as it breaks in e10s

This commit is contained in:
roytam1 2023-10-06 11:38:43 +08:00
commit e90473bdda
29 changed files with 56983 additions and 74493 deletions

View file

@ -12,35 +12,38 @@
* 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, createObjectURL;
var fonts;
var active = false;
var fontAttribute = 'data-font-name';
function removeSelection() {
let divs = document.querySelectorAll(`span[${fontAttribute}]`);
for (let div of divs) {
var divs = document.querySelectorAll('div[' + fontAttribute + ']');
for (var i = 0, ii = divs.length; i < ii; ++i) {
var div = divs[i];
div.className = '';
}
}
function resetSelection() {
let divs = document.querySelectorAll(`span[${fontAttribute}]`);
for (let div of divs) {
var divs = document.querySelectorAll('div[' + fontAttribute + ']');
for (var i = 0, ii = divs.length; i < ii; ++i) {
var div = divs[i];
div.className = 'debuggerHideText';
}
}
function selectFont(fontName, show) {
let divs = document.querySelectorAll(`span[${fontAttribute}=${fontName}]`);
for (let div of divs) {
var divs = document.querySelectorAll('div[' + fontAttribute + '=' +
fontName + ']');
for (var i = 0, ii = divs.length; i < ii; ++i) {
var div = divs[i];
div.className = show ? 'debuggerShowText' : 'debuggerHideText';
}
}
function textLayerClick(e) {
if (!e.target.dataset.fontName ||
e.target.tagName.toUpperCase() !== 'SPAN') {
e.target.tagName.toUpperCase() !== 'DIV') {
return;
}
var fontName = e.target.dataset.fontName;
@ -71,8 +74,6 @@ var FontInspector = (function FontInspectorClosure() {
fonts = document.createElement('div');
panel.appendChild(fonts);
createObjectURL = pdfjsLib.createObjectURL;
},
cleanup: function cleanup() {
fonts.textContent = '';
@ -117,7 +118,10 @@ var FontInspector = (function FontInspectorClosure() {
url = /url\(['"]?([^\)"']+)/.exec(url);
download.href = url[1];
} else if (fontObj.data) {
download.href = createObjectURL(fontObj.data, fontObj.mimeType);
url = URL.createObjectURL(new Blob([fontObj.data], {
type: fontObj.mimeType
}));
download.href = url;
}
download.textContent = 'Download';
var logIt = document.createElement('a');
@ -145,12 +149,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(() => {
setTimeout(function() {
if (this.active) {
resetSelection();
}
}, 2000);
},
}.bind(this), 2000);
}
};
})();
@ -239,7 +243,7 @@ var StepperManager = (function StepperManagerClosure() {
saveBreakPoints: function saveBreakPoints(pageIndex, bps) {
breakPoints[pageIndex] = bps;
sessionStorage.setItem('pdfjsBreakPoints', JSON.stringify(breakPoints));
},
}
};
})();
@ -258,7 +262,7 @@ var Stepper = (function StepperClosure() {
if (typeof args === 'string') {
var MAX_STRING_LENGTH = 75;
return args.length <= MAX_STRING_LENGTH ? args :
args.substring(0, MAX_STRING_LENGTH) + '...';
args.substr(0, MAX_STRING_LENGTH) + '...';
}
if (typeof args !== 'object' || args === null) {
return args;
@ -333,7 +337,7 @@ var Stepper = (function StepperClosure() {
line.className = 'line';
line.dataset.idx = i;
chunk.appendChild(line);
var checked = this.breakPoints.includes(i);
var checked = this.breakPoints.indexOf(i) !== -1;
var args = operatorList.argsArray[i] || [];
var breakCell = c('td');
@ -429,7 +433,7 @@ var Stepper = (function StepperClosure() {
row.style.backgroundColor = null;
}
}
},
}
};
return Stepper;
})();
@ -455,13 +459,14 @@ var Stats = (function Stats() {
name: 'Stats',
panel: null,
manager: null,
init(pdfjsLib) {
init: function init(pdfjsLib) {
this.panel.setAttribute('style', 'padding: 5px;');
pdfjsLib.PDFJS.enableStats = true;
},
enabled: false,
active: false,
// Stats specific functions.
add(pageNumber, stat) {
add: function(pageNumber, stat) {
if (!stat) {
return;
}
@ -480,7 +485,7 @@ var Stats = (function Stats() {
statsDiv.textContent = stat.toString();
wrapper.appendChild(title);
wrapper.appendChild(statsDiv);
stats.push({ pageNumber, div: wrapper, });
stats.push({ pageNumber: pageNumber, div: wrapper });
stats.sort(function(a, b) {
return a.pageNumber - b.pageNumber;
});
@ -489,15 +494,15 @@ var Stats = (function Stats() {
this.panel.appendChild(stats[i].div);
}
},
cleanup() {
cleanup: function () {
stats = [];
clear(this.panel);
},
}
};
})();
// Manages all the debugging tools.
window.PDFBug = (function PDFBugClosure() {
var PDFBug = (function PDFBugClosure() {
var panelWidth = 300;
var buttons = [];
var activePanel = null;
@ -508,14 +513,14 @@ window.PDFBug = (function PDFBugClosure() {
StepperManager,
Stats
],
enable(ids) {
enable: function(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.includes(tool.id)) {
if (all || ids.indexOf(tool.id) !== -1) {
tool.enabled = true;
}
}
@ -530,7 +535,7 @@ window.PDFBug = (function PDFBugClosure() {
});
}
},
init(pdfjsLib, container) {
init: function init(pdfjsLib, container) {
/*
* Basic Layout:
* PDFBug
@ -583,14 +588,14 @@ window.PDFBug = (function PDFBugClosure() {
}
this.selectPanel(0);
},
cleanup() {
cleanup: function cleanup() {
for (var i = 0, ii = this.tools.length; i < ii; i++) {
if (this.tools[i].enabled) {
this.tools[i].cleanup();
}
}
},
selectPanel(index) {
selectPanel: function selectPanel(index) {
if (typeof index !== 'number') {
index = this.tools.indexOf(index);
}
@ -610,6 +615,6 @@ window.PDFBug = (function PDFBugClosure() {
tools[j].panel.setAttribute('hidden', 'true');
}
}
},
}
};
})();