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/display/display.js | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'ext/js/display/display.js') diff --git a/ext/js/display/display.js b/ext/js/display/display.js index c16f7cae..82364233 100644 --- a/ext/js/display/display.js +++ b/ext/js/display/display.js @@ -36,6 +36,11 @@ */ class Display extends EventDispatcher { + /** + * Information about how popup content should be shown, specifically related to the inner popup content. + * @typedef {object} ContentDetails + */ + constructor(tabId, frameId, pageType, japaneseUtil, documentFocusController, hotkeyHandler) { super(); this._tabId = tabId; @@ -341,6 +346,10 @@ class Display extends EventDispatcher { this.trigger('optionsUpdated', {options}); } + /** + * Updates the content of the display. + * @param {ContentDetails} details + */ setContent(details) { const {focus, params, state, content} = details; const historyMode = this._historyHasChanged ? details.historyMode : 'clear'; -- cgit v1.2.3