From 2c8c6866eff1656c3ba5a04638534e4c1582739b Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Sun, 15 Dec 2019 17:03:46 -0500 Subject: [PATCH] jsonRectToDOMRect => convertJsonRectToDOMRect Also make static --- ext/fg/js/popup-proxy-host.js | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/ext/fg/js/popup-proxy-host.js b/ext/fg/js/popup-proxy-host.js index 83518f44..e932ae52 100644 --- a/ext/fg/js/popup-proxy-host.js +++ b/ext/fg/js/popup-proxy-host.js @@ -73,17 +73,6 @@ class PopupProxyHost { return popup; } - jsonRectToDOMRect(popup, jsonRect) { - let x = jsonRect.x; - let y = jsonRect.y; - if (popup.parent !== null) { - const popupRect = popup.parent.container.getBoundingClientRect(); - x += popupRect.x; - y += popupRect.y; - } - return new DOMRect(x, y, jsonRect.width, jsonRect.height); - } - // Message handlers async createNestedPopup(parentId) { @@ -117,7 +106,7 @@ class PopupProxyHost { async showContent(id, elementRect, writingMode, type, details) { const popup = this.getPopup(id); - elementRect = this.jsonRectToDOMRect(popup, elementRect); + elementRect = PopupProxyHost.convertJsonRectToDOMRect(popup, elementRect); if (!PopupProxyHost.popupCanShow(popup)) { return Promise.resolve(false); } return await popup.showContent(elementRect, writingMode, type, details); } @@ -132,6 +121,17 @@ class PopupProxyHost { return popup.clearAutoPlayTimer(); } + static convertJsonRectToDOMRect(popup, jsonRect) { + let x = jsonRect.x; + let y = jsonRect.y; + if (popup.parent !== null) { + const popupRect = popup.parent.container.getBoundingClientRect(); + x += popupRect.x; + y += popupRect.y; + } + return new DOMRect(x, y, jsonRect.width, jsonRect.height); + } + static popupCanShow(popup) { return popup.parent === null || popup.parent.isVisible(); }