Skip to content

Commit

Permalink
Merge pull request #606 from nextcloud/dependabot/npm_and_yarn/pdfjs-…
Browse files Browse the repository at this point in the history
…dist-2.14.305
  • Loading branch information
dependabot[bot] committed Jun 11, 2022
2 parents cf29601 + 58d2a50 commit 2afe14e
Show file tree
Hide file tree
Showing 67 changed files with 4,042 additions and 2,713 deletions.
1,695 changes: 1,157 additions & 538 deletions js/pdfjs/build/pdf.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/pdfjs/build/pdf.js.map

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions js/pdfjs/build/pdf.sandbox.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/pdfjs/build/pdf.sandbox.js.map

Large diffs are not rendered by default.

1,437 changes: 1,020 additions & 417 deletions js/pdfjs/build/pdf.worker.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/pdfjs/build/pdf.worker.js.map

Large diffs are not rendered by default.

103 changes: 103 additions & 0 deletions js/pdfjs/web/debugger.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
/* Copyright 2014 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#PDFBug {
background-color: rgba(255, 255, 255, 1);
border: 1px solid rgba(102, 102, 102, 1);
position: fixed;
top: 32px;
right: 0;
bottom: 0;
font-size: 10px;
padding: 0;
width: 300px;
}
#PDFBug .controls {
background: rgba(238, 238, 238, 1);
border-bottom: 1px solid rgba(102, 102, 102, 1);
padding: 3px;
}
#PDFBug .panels {
bottom: 0;
left: 0;
overflow: auto;
position: absolute;
right: 0;
top: 27px;
}
#PDFBug .panels > div {
padding: 5px;
}
#PDFBug button.active {
font-weight: bold;
}
.debuggerShowText,
.debuggerHideText:hover {
background-color: rgba(255, 255, 0, 1);
}
#PDFBug .stats {
font-family: courier;
font-size: 10px;
white-space: pre;
}
#PDFBug .stats .title {
font-weight: bold;
}
#PDFBug table {
font-size: 10px;
white-space: pre;
}
#PDFBug table.showText {
border-collapse: collapse;
text-align: center;
}
#PDFBug table.showText,
#PDFBug table.showText tr,
#PDFBug table.showText td {
border: 1px solid black;
padding: 1px;
}
#PDFBug table.showText td.advance {
color: grey;
}

#viewer.textLayer-visible .textLayer {
opacity: 1;
}

#viewer.textLayer-visible .canvasWrapper {
background-color: rgba(128, 255, 128, 1);
}

#viewer.textLayer-visible .canvasWrapper canvas {
mix-blend-mode: screen;
}

#viewer.textLayer-visible .textLayer span {
background-color: rgba(255, 255, 0, 0.1);
color: rgba(0, 0, 0, 1);
border: solid 1px rgba(255, 0, 0, 0.5);
box-sizing: border-box;
}

#viewer.textLayer-hover .textLayer span:hover {
background-color: rgba(255, 255, 255, 1);
color: rgba(0, 0, 0, 1);
}

#viewer.textLayer-shadow .textLayer span {
background-color: rgba(255, 255, 255, 0.6);
color: rgba(0, 0, 0, 1);
}
119 changes: 56 additions & 63 deletions js/pdfjs/web/debugger.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@
* limitations under the License.
*/

"use strict";
let opMap;

// eslint-disable-next-line no-var
var FontInspector = (function FontInspectorClosure() {
const FontInspector = (function FontInspectorClosure() {
let fonts;
let active = false;
const fontAttribute = "data-font-name";
Expand Down Expand Up @@ -49,8 +48,7 @@ var FontInspector = (function FontInspectorClosure() {
}
const fontName = e.target.dataset.fontName;
const selects = document.getElementsByTagName("input");
for (let i = 0; i < selects.length; ++i) {
const select = selects[i];
for (const select of selects) {
if (select.dataset.fontName !== fontName) {
continue;
}
Expand All @@ -65,7 +63,7 @@ var FontInspector = (function FontInspectorClosure() {
name: "Font Inspector",
panel: null,
manager: null,
init: function init(pdfjsLib) {
init(pdfjsLib) {
const panel = this.panel;
const tmp = document.createElement("button");
tmp.addEventListener("click", resetSelection);
Expand All @@ -75,7 +73,7 @@ var FontInspector = (function FontInspectorClosure() {
fonts = document.createElement("div");
panel.appendChild(fonts);
},
cleanup: function cleanup() {
cleanup() {
fonts.textContent = "";
},
enabled: false,
Expand All @@ -93,16 +91,16 @@ var FontInspector = (function FontInspectorClosure() {
}
},
// FontInspector specific functions.
fontAdded: function fontAdded(fontObj, url) {
fontAdded(fontObj, url) {
function properties(obj, list) {
const moreInfo = document.createElement("table");
for (let i = 0; i < list.length; i++) {
for (const entry of list) {
const tr = document.createElement("tr");
const td1 = document.createElement("td");
td1.textContent = list[i];
td1.textContent = entry;
tr.appendChild(td1);
const td2 = document.createElement("td");
td2.textContent = obj[list[i]].toString();
td2.textContent = obj[entry].toString();
tr.appendChild(td2);
moreInfo.appendChild(tr);
}
Expand Down Expand Up @@ -155,12 +153,8 @@ var FontInspector = (function FontInspectorClosure() {
};
})();

let opMap;

// Manages all the page steppers.
//
// eslint-disable-next-line no-var
var StepperManager = (function StepperManagerClosure() {
const StepperManager = (function StepperManagerClosure() {
let steppers = [];
let stepperDiv = null;
let stepperControls = null;
Expand All @@ -172,7 +166,7 @@ var StepperManager = (function StepperManagerClosure() {
name: "Stepper",
panel: null,
manager: null,
init: function init(pdfjsLib) {
init(pdfjsLib) {
const self = this;
stepperControls = document.createElement("div");
stepperChooser = document.createElement("select");
Expand All @@ -192,15 +186,15 @@ var StepperManager = (function StepperManagerClosure() {
opMap[pdfjsLib.OPS[key]] = key;
}
},
cleanup: function cleanup() {
cleanup() {
stepperChooser.textContent = "";
stepperDiv.textContent = "";
steppers = [];
},
enabled: false,
active: false,
// Stepper specific functions.
create: function create(pageIndex) {
create(pageIndex) {
const debug = document.createElement("div");
debug.id = "stepper" + pageIndex;
debug.hidden = true;
Expand All @@ -218,23 +212,19 @@ var StepperManager = (function StepperManagerClosure() {
}
return stepper;
},
selectStepper: function selectStepper(pageIndex, selectPanel) {
let i;
selectStepper(pageIndex, selectPanel) {
pageIndex |= 0;
if (selectPanel) {
this.manager.selectPanel(this);
}
for (i = 0; i < steppers.length; ++i) {
const stepper = steppers[i];
for (const stepper of steppers) {
stepper.panel.hidden = stepper.pageIndex !== pageIndex;
}
const options = stepperChooser.options;
for (i = 0; i < options.length; ++i) {
const option = options[i];
for (const option of stepperChooser.options) {
option.selected = (option.value | 0) === pageIndex;
}
},
saveBreakPoints: function saveBreakPoints(pageIndex, bps) {
saveBreakPoints(pageIndex, bps) {
breakPoints[pageIndex] = bps;
sessionStorage.setItem("pdfjsBreakPoints", JSON.stringify(breakPoints));
},
Expand Down Expand Up @@ -361,8 +351,7 @@ const Stepper = (function StepperClosure() {
const charCodeRow = c("tr");
const fontCharRow = c("tr");
const unicodeRow = c("tr");
for (let j = 0; j < glyphs.length; j++) {
const glyph = glyphs[j];
for (const glyph of glyphs) {
if (typeof glyph === "object" && glyph !== null) {
charCodeRow.appendChild(c("td", glyph.originalCharCode));
fontCharRow.appendChild(c("td", glyph.fontChar));
Expand Down Expand Up @@ -410,9 +399,9 @@ const Stepper = (function StepperClosure() {
this.breakPoints.sort(function (a, b) {
return a - b;
});
for (let i = 0; i < this.breakPoints.length; i++) {
if (this.breakPoints[i] > this.currentIdx) {
return this.breakPoints[i];
for (const breakPoint of this.breakPoints) {
if (breakPoint > this.currentIdx) {
return breakPoint;
}
}
return null;
Expand Down Expand Up @@ -444,8 +433,7 @@ const Stepper = (function StepperClosure() {

goTo(idx) {
const allRows = this.panel.getElementsByClassName("line");
for (let x = 0, xx = allRows.length; x < xx; ++x) {
const row = allRows[x];
for (const row of allRows) {
if ((row.dataset.idx | 0) === idx) {
row.style.backgroundColor = "rgb(251,250,207)";
row.scrollIntoView();
Expand All @@ -458,15 +446,14 @@ const Stepper = (function StepperClosure() {
return Stepper;
})();

// eslint-disable-next-line no-var
var Stats = (function Stats() {
const Stats = (function Stats() {
let stats = [];
function clear(node) {
node.textContent = ""; // Remove any `node` contents from the DOM.
}
function getStatIndex(pageNumber) {
for (let i = 0, ii = stats.length; i < ii; ++i) {
if (stats[i].pageNumber === pageNumber) {
for (const [i, stat] of stats.entries()) {
if (stat.pageNumber === pageNumber) {
return i;
}
}
Expand Down Expand Up @@ -505,8 +492,8 @@ var Stats = (function Stats() {
return a.pageNumber - b.pageNumber;
});
clear(this.panel);
for (let i = 0, ii = stats.length; i < ii; ++i) {
this.panel.appendChild(stats[i].div);
for (const entry of stats) {
this.panel.appendChild(entry.div);
}
},
cleanup() {
Expand All @@ -517,7 +504,7 @@ var Stats = (function Stats() {
})();

// Manages all the debugging tools.
window.PDFBug = (function PDFBugClosure() {
const PDFBug = (function PDFBugClosure() {
const panelWidth = 300;
const buttons = [];
let activePanel = null;
Expand All @@ -527,8 +514,7 @@ window.PDFBug = (function PDFBugClosure() {
enable(ids) {
const all = ids.length === 1 && ids[0] === "all";
const tools = this.tools;
for (let i = 0; i < tools.length; ++i) {
const tool = tools[i];
for (const tool of tools) {
if (all || ids.includes(tool.id)) {
tool.enabled = true;
}
Expand All @@ -545,6 +531,7 @@ window.PDFBug = (function PDFBugClosure() {
}
},
init(pdfjsLib, container, ids) {
this.loadCSS();
this.enable(ids);
/*
* Basic Layout:
Expand All @@ -570,22 +557,14 @@ window.PDFBug = (function PDFBugClosure() {
container.style.right = panelWidth + "px";

// Initialize all the debugging tools.
const tools = this.tools;
const self = this;
for (let i = 0; i < tools.length; ++i) {
const tool = tools[i];
for (const tool of this.tools) {
const panel = document.createElement("div");
const panelButton = document.createElement("button");
panelButton.textContent = tool.name;
panelButton.addEventListener(
"click",
(function (selected) {
return function (event) {
event.preventDefault();
self.selectPanel(selected);
};
})(i)
);
panelButton.addEventListener("click", event => {
event.preventDefault();
this.selectPanel(tool);
});
controls.appendChild(panelButton);
panels.appendChild(panel);
tool.panel = panel;
Expand All @@ -601,10 +580,19 @@ window.PDFBug = (function PDFBugClosure() {
}
this.selectPanel(0);
},
loadCSS() {
const { url } = import.meta;

const link = document.createElement("link");
link.rel = "stylesheet";
link.href = url.replace(/.js$/, ".css");

document.head.appendChild(link);
},
cleanup() {
for (let i = 0, ii = this.tools.length; i < ii; i++) {
if (this.tools[i].enabled) {
this.tools[i].cleanup();
for (const tool of this.tools) {
if (tool.enabled) {
tool.cleanup();
}
}
},
Expand All @@ -616,13 +604,18 @@ window.PDFBug = (function PDFBugClosure() {
return;
}
activePanel = index;
const tools = this.tools;
for (let j = 0; j < tools.length; ++j) {
for (const [j, tool] of this.tools.entries()) {
const isActive = j === index;
buttons[j].classList.toggle("active", isActive);
tools[j].active = isActive;
tools[j].panel.hidden = !isActive;
tool.active = isActive;
tool.panel.hidden = !isActive;
}
},
};
})();

globalThis.FontInspector = FontInspector;
globalThis.StepperManager = StepperManager;
globalThis.Stats = Stats;

export { PDFBug };
Loading

0 comments on commit 2afe14e

Please sign in to comment.