Remove destructuring from searchAt, containsPoint, docRangeFromPoint

This commit is contained in:
toasted-nutbread 2019-09-14 14:27:25 -04:00
parent 89941d404c
commit 6d3037f3d6
6 changed files with 13 additions and 13 deletions

View File

@ -89,7 +89,7 @@ function docImposterCreate(element, isTextarea) {
return [imposter, container]; return [imposter, container];
} }
function docRangeFromPoint({x, y}, options) { function docRangeFromPoint(x, y, options) {
const elements = document.elementsFromPoint(x, y); const elements = document.elementsFromPoint(x, y);
let imposter = null; let imposter = null;
let imposterContainer = null; let imposterContainer = null;

View File

@ -104,7 +104,7 @@ class Frontend {
const search = async () => { const search = async () => {
try { try {
await this.searchAt({x: e.clientX, y: e.clientY}, 'mouse'); await this.searchAt(e.clientX, e.clientY, 'mouse');
} catch (e) { } catch (e) {
this.onError(e); this.onError(e);
} }
@ -280,12 +280,12 @@ class Frontend {
} }
} }
async searchAt(point, type) { async searchAt(x, y, type) {
if (this.pendingLookup || await this.popup.containsPoint(point)) { if (this.pendingLookup || await this.popup.containsPoint(x, y)) {
return; return;
} }
const textSource = docRangeFromPoint(point, this.options); const textSource = docRangeFromPoint(x, y, this.options);
let hideResults = textSource === null; let hideResults = textSource === null;
let searched = false; let searched = false;
let success = false; let success = false;
@ -470,7 +470,7 @@ class Frontend {
const search = async () => { const search = async () => {
try { try {
await this.searchAt({x, y}, type); await this.searchAt(x, y, type);
} catch (e) { } catch (e) {
this.onError(e); this.onError(e);
} }

View File

@ -42,7 +42,7 @@ class PopupProxyHost {
showOrphaned: ({id, elementRect, options}) => this.show(id, elementRect, options), showOrphaned: ({id, elementRect, options}) => this.show(id, elementRect, options),
hide: ({id}) => this.hide(id), hide: ({id}) => this.hide(id),
setVisible: ({id, visible}) => this.setVisible(id, visible), setVisible: ({id, visible}) => this.setVisible(id, visible),
containsPoint: ({id, point}) => this.containsPoint(id, point), containsPoint: ({id, x, y}) => this.containsPoint(id, x, y),
termsShow: ({id, elementRect, writingMode, definitions, options, context}) => this.termsShow(id, elementRect, writingMode, definitions, options, context), termsShow: ({id, elementRect, writingMode, definitions, options, context}) => this.termsShow(id, elementRect, writingMode, definitions, options, context),
kanjiShow: ({id, elementRect, writingMode, definitions, options, context}) => this.kanjiShow(id, elementRect, writingMode, definitions, options, context), kanjiShow: ({id, elementRect, writingMode, definitions, options, context}) => this.kanjiShow(id, elementRect, writingMode, definitions, options, context),
clearAutoPlayTimer: ({id}) => this.clearAutoPlayTimer(id) clearAutoPlayTimer: ({id}) => this.clearAutoPlayTimer(id)
@ -108,9 +108,9 @@ class PopupProxyHost {
return popup.setVisible(visible); return popup.setVisible(visible);
} }
async containsPoint(id, point) { async containsPoint(id, x, y) {
const popup = this.getPopup(id); const popup = this.getPopup(id);
return await popup.containsPoint(point); return await popup.containsPoint(x, y);
} }
async termsShow(id, elementRect, writingMode, definitions, options, context) { async termsShow(id, elementRect, writingMode, definitions, options, context) {

View File

@ -69,11 +69,11 @@ class PopupProxy {
return await this.invokeHostApi('setVisible', {id, visible}); return await this.invokeHostApi('setVisible', {id, visible});
} }
async containsPoint(point) { async containsPoint(x, y) {
if (this.id === null) { if (this.id === null) {
return false; return false;
} }
return await this.invokeHostApi('containsPoint', {id: this.id, point}); return await this.invokeHostApi('containsPoint', {id: this.id, x, y});
} }
async termsShow(elementRect, writingMode, definitions, options, context) { async termsShow(elementRect, writingMode, definitions, options, context) {

View File

@ -251,7 +251,7 @@ class Popup {
} }
} }
async containsPoint({x, y}) { async containsPoint(x, y) {
for (let popup = this; popup !== null && popup.isVisible(); popup = popup.child) { for (let popup = this; popup !== null && popup.isVisible(); popup = popup.child) {
const rect = popup.container.getBoundingClientRect(); const rect = popup.container.getBoundingClientRect();
if (x >= rect.left && y >= rect.top && x < rect.right && y < rect.bottom) { if (x >= rect.left && y >= rect.top && x < rect.right && y < rect.bottom) {

View File

@ -81,7 +81,7 @@ class Display {
const {docRangeFromPoint, docSentenceExtract} = this.dependencies; const {docRangeFromPoint, docSentenceExtract} = this.dependencies;
const clickedElement = $(e.target); const clickedElement = $(e.target);
const textSource = docRangeFromPoint({x: e.clientX, y: e.clientY}, this.options); const textSource = docRangeFromPoint(e.clientX, e.clientY, this.options);
if (textSource === null) { if (textSource === null) {
return false; return false;
} }