From 63d37c872b786abe9233d70b2eff0362582cbc3a Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Mon, 16 May 2022 21:45:22 -0400 Subject: Popup positioning improvements (#2135) * Rename elementRect to sourceRect * Add getRects function to TextSourceElement and TextSourceRange * Add jsdocs * Remove unnecessary valid parameter * Remove default parameter * Make optionsContext optional * Remove unnecessary checks * Update sourceRect to use left/right rather than x/y * Update the return type of Popup*.getFrameRect * Rename some unrelated rect vars for disambiguation * Disambiguate between Popup.Rect and Popup.ValidRect * Move sourceRect destructuring * Pass multiple source rects * Simplify * Change Rect to use right/bottom rather than width/height * Update how popup offset is applied * Simplify frame offset * Remove _applyFrameOffset * Use right/bottom rather than width/height * Simplify some positioning settings * Update parameter names for clarity * Fix typos * Refactor data type for _getPosition* functions * Support using multiple source rects * Combine _getPosition functions * Refactor * Expose after dataset value * Consistently use this's property * Add jsdoc --- ext/js/app/popup-window.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'ext/js/app/popup-window.js') diff --git a/ext/js/app/popup-window.js b/ext/js/app/popup-window.js index edb3a181..6a63a9cb 100644 --- a/ext/js/app/popup-window.js +++ b/ext/js/app/popup-window.js @@ -168,8 +168,8 @@ class PopupWindow extends EventDispatcher { /** * Shows and updates the positioning and content of the popup. - * @param {{optionsContext: object, elementRect: {x: number, y: number, width: number, height: number}, writingMode: string}} details Settings for the outer popup. - * @param {object} displayDetails The details parameter passed to `Display.setContent`; see that function for details. + * @param {Popup.ContentDetails} details Settings for the outer popup. + * @param {Display.ContentDetails} displayDetails The details parameter passed to `Display.setContent`. * @returns {Promise} */ async showContent(_details, displayDetails) { @@ -229,11 +229,11 @@ class PopupWindow extends EventDispatcher { /** * Gets the rectangle of the DOM frame, synchronously. - * @returns {{x: number, y: number, width: number, height: number, valid: boolean}} The rect. + * @returns {Popup.ValidRect} The rect. * `valid` is `false` for `PopupProxy`, since the DOM node is hosted in a different frame. */ getFrameRect() { - return {x: 0, y: 0, width: 0, height: 0, valid: false}; + return {left: 0, top: 0, right: 0, bottom: 0, valid: false}; } /** -- cgit v1.2.3