From 86be737508d3148c90ea04d702fab30fdfb464d2 Mon Sep 17 00:00:00 2001 From: siikamiika Date: Sat, 7 Mar 2020 03:52:36 +0200 Subject: fix popup containsPoint offset --- ext/fg/js/popup-proxy-host.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'ext/fg/js') diff --git a/ext/fg/js/popup-proxy-host.js b/ext/fg/js/popup-proxy-host.js index bef2cb16..b9a5617c 100644 --- a/ext/fg/js/popup-proxy-host.js +++ b/ext/fg/js/popup-proxy-host.js @@ -116,7 +116,8 @@ class PopupProxyHost { async _onApiContainsPoint({id, x, y}) { const popup = this._getPopup(id); - return await popup.containsPoint(x, y); + const rootPagePoint = PopupProxyHost._convertPopupPointToRootPagePoint(popup, x, y); + return await popup.containsPoint(...rootPagePoint); } async _onApiShowContent({id, elementRect, writingMode, type, details}) { @@ -152,14 +153,17 @@ class PopupProxyHost { } static _convertJsonRectToDOMRect(popup, jsonRect) { - let x = jsonRect.x; - let y = jsonRect.y; + const [x, y] = PopupProxyHost._convertPopupPointToRootPagePoint(popup, jsonRect.x, jsonRect.y); + return new DOMRect(x, y, jsonRect.width, jsonRect.height); + } + + static _convertPopupPointToRootPagePoint(popup, x, y) { if (popup.parent !== null) { const popupRect = popup.parent.getContainerRect(); x += popupRect.x; y += popupRect.y; } - return new DOMRect(x, y, jsonRect.width, jsonRect.height); + return [x, y]; } static _popupCanShow(popup) { -- cgit v1.2.3 From 9fef0751f3dc7f213f158a50124371f0c6fb5a17 Mon Sep 17 00:00:00 2001 From: siikamiika Date: Sat, 7 Mar 2020 04:11:18 +0200 Subject: replace spread with destructuring --- ext/fg/js/popup-proxy-host.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'ext/fg/js') diff --git a/ext/fg/js/popup-proxy-host.js b/ext/fg/js/popup-proxy-host.js index b9a5617c..7d86aa67 100644 --- a/ext/fg/js/popup-proxy-host.js +++ b/ext/fg/js/popup-proxy-host.js @@ -116,8 +116,8 @@ class PopupProxyHost { async _onApiContainsPoint({id, x, y}) { const popup = this._getPopup(id); - const rootPagePoint = PopupProxyHost._convertPopupPointToRootPagePoint(popup, x, y); - return await popup.containsPoint(...rootPagePoint); + [x, y] = PopupProxyHost._convertPopupPointToRootPagePoint(popup, x, y); + return await popup.containsPoint(x, y); } async _onApiShowContent({id, elementRect, writingMode, type, details}) { -- cgit v1.2.3