mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-10 18:25:37 +02:00
Move the reporting of page Stats
into the API
This avoids having to add a couple of event listeners in the viewer, when debugging is enabled, and is consistent with the existing handling of `FontInspector` and `StepperManager` in the API.
This commit is contained in:
parent
b6765403a1
commit
4a8d742592
2 changed files with 8 additions and 16 deletions
|
@ -1510,8 +1510,14 @@ class PDFPageProxy {
|
||||||
internalRenderTask.capability.resolve();
|
internalRenderTask.capability.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
this._stats?.timeEnd("Rendering");
|
if (this._stats) {
|
||||||
this._stats?.timeEnd("Overall");
|
this._stats.timeEnd("Rendering");
|
||||||
|
this._stats.timeEnd("Overall");
|
||||||
|
|
||||||
|
if (globalThis.Stats?.enabled) {
|
||||||
|
globalThis.Stats.add(this.pageNumber, this._stats);
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const internalRenderTask = new InternalRenderTask({
|
const internalRenderTask = new InternalRenderTask({
|
||||||
|
|
14
web/app.js
14
web/app.js
|
@ -1898,10 +1898,6 @@ const PDFViewerApplication = {
|
||||||
signal,
|
signal,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (AppOptions.get("pdfBug")) {
|
|
||||||
eventBus._on("pagerendered", reportPageStatsPDFBug, { signal });
|
|
||||||
eventBus._on("pagechanging", reportPageStatsPDFBug, { signal });
|
|
||||||
}
|
|
||||||
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
|
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
|
||||||
eventBus._on("fileinputchange", webViewerFileInputChange, { signal });
|
eventBus._on("fileinputchange", webViewerFileInputChange, { signal });
|
||||||
eventBus._on("openfile", webViewerOpenFile, { signal });
|
eventBus._on("openfile", webViewerOpenFile, { signal });
|
||||||
|
@ -2187,16 +2183,6 @@ async function loadPDFBug(self) {
|
||||||
self._PDFBug = PDFBug;
|
self._PDFBug = PDFBug;
|
||||||
}
|
}
|
||||||
|
|
||||||
function reportPageStatsPDFBug({ pageNumber }) {
|
|
||||||
if (!globalThis.Stats?.enabled) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const pageView = PDFViewerApplication.pdfViewer.getPageView(
|
|
||||||
/* index = */ pageNumber - 1
|
|
||||||
);
|
|
||||||
globalThis.Stats.add(pageNumber, pageView?.pdfPage?.stats);
|
|
||||||
}
|
|
||||||
|
|
||||||
function webViewerPageRender({ pageNumber }) {
|
function webViewerPageRender({ pageNumber }) {
|
||||||
// If the page is (the most) visible when it starts rendering,
|
// If the page is (the most) visible when it starts rendering,
|
||||||
// ensure that the page number input loading indicator is displayed.
|
// ensure that the page number input loading indicator is displayed.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue