fx-compat: Replace eval with wrappedJSObject in PDF reader

This commit is contained in:
Martynas Bagdonas 2022-06-09 13:11:24 +03:00
parent 9a2e98360a
commit 64c652ea06

View file

@ -187,27 +187,27 @@ class ReaderInstance {
} }
isHandToolActive() { isHandToolActive() {
return this._iframeWindow.eval('PDFViewerApplication.pdfCursorTools.handTool.active'); return this._iframeWindow.wrappedJSObject.PDFViewerApplication.pdfCursorTools.handTool.active;
} }
isZoomAutoActive() { isZoomAutoActive() {
return this._iframeWindow.eval('PDFViewerApplication.pdfViewer.currentScaleValue === "auto"'); return this._iframeWindow.wrappedJSObject.PDFViewerApplication.pdfViewer.currentScaleValue === 'auto';
} }
isZoomPageWidthActive() { isZoomPageWidthActive() {
return this._iframeWindow.eval('PDFViewerApplication.pdfViewer.currentScaleValue === "page-width"'); return this._iframeWindow.wrappedJSObject.PDFViewerApplication.pdfViewer.currentScaleValue === 'page-width';
} }
isZoomPageHeightActive() { isZoomPageHeightActive() {
return this._iframeWindow.eval('PDFViewerApplication.pdfViewer.currentScaleValue === "page-fit"'); return this._iframeWindow.wrappedJSObject.PDFViewerApplication.pdfViewer.currentScaleValue === 'page-fit';
} }
allowNavigateFirstPage() { allowNavigateFirstPage() {
return this._iframeWindow.eval('PDFViewerApplication.pdfViewer.currentPageNumber > 1'); return this._iframeWindow.wrappedJSObject.PDFViewerApplication.pdfViewer.currentPageNumber > 1;
} }
allowNavigateLastPage() { allowNavigateLastPage() {
return this._iframeWindow.eval('PDFViewerApplication.pdfViewer.currentPageNumber < PDFViewerApplication.pdfViewer.pagesCount'); return this._iframeWindow.wrappedJSObject.PDFViewerApplication.pdfViewer.currentPageNumber < this._iframeWindow.wrappedJSObject.PDFViewerApplication.pdfViewer.pagesCount;
} }
allowNavigateBack() { allowNavigateBack() {
@ -893,15 +893,14 @@ class ReaderInstance {
if (this._isReaderInitialized) { if (this._isReaderInitialized) {
return; return;
} }
// let n = 0; let n = 0;
// while (!this._iframeWindow || !this._iframeWindow.eval('window.isReady')) { while (!this._iframeWindow || !this._iframeWindow.wrappedJSObject.isReady) {
// if (n >= 500) { if (n >= 500) {
// throw new Error('Waiting for reader failed'); throw new Error('Waiting for reader failed');
// } }
// await Zotero.Promise.delay(10); await Zotero.Promise.delay(10);
// n++; n++;
// } }
await Zotero.Promise.delay(300);
this._isReaderInitialized = true; this._isReaderInitialized = true;
} }