Use .bind instead of () => {}
This commit is contained in:
parent
78dc501d02
commit
fc08cd74fe
@ -34,16 +34,16 @@ class PopupProxyHost {
|
|||||||
if (typeof frameId !== 'number') { return; }
|
if (typeof frameId !== 'number') { return; }
|
||||||
|
|
||||||
this._apiReceiver = new FrontendApiReceiver(`popup-proxy-host#${frameId}`, new Map([
|
this._apiReceiver = new FrontendApiReceiver(`popup-proxy-host#${frameId}`, new Map([
|
||||||
['getOrCreatePopup', ({id, parentId}) => this._onApiGetOrCreatePopup(id, parentId)],
|
['getOrCreatePopup', this._onApiGetOrCreatePopup.bind(this)],
|
||||||
['setOptions', ({id, options}) => this._onApiSetOptions(id, options)],
|
['setOptions', this._onApiSetOptions.bind(this)],
|
||||||
['hide', ({id, changeFocus}) => this._onApiHide(id, changeFocus)],
|
['hide', this._onApiHide.bind(this)],
|
||||||
['isVisible', ({id}) => this._onApiIsVisibleAsync(id)],
|
['isVisible', this._onApiIsVisibleAsync.bind(this)],
|
||||||
['setVisibleOverride', ({id, visible}) => this._onApiSetVisibleOverride(id, visible)],
|
['setVisibleOverride', this._onApiSetVisibleOverride.bind(this)],
|
||||||
['containsPoint', ({id, x, y}) => this._onApiContainsPoint(id, x, y)],
|
['containsPoint', this._onApiContainsPoint.bind(this)],
|
||||||
['showContent', ({id, elementRect, writingMode, type, details}) => this._onApiShowContent(id, elementRect, writingMode, type, details)],
|
['showContent', this._onApiShowContent.bind(this)],
|
||||||
['setCustomCss', ({id, css}) => this._onApiSetCustomCss(id, css)],
|
['setCustomCss', this._onApiSetCustomCss.bind(this)],
|
||||||
['clearAutoPlayTimer', ({id}) => this._onApiClearAutoPlayTimer(id)],
|
['clearAutoPlayTimer', this._onApiClearAutoPlayTimer.bind(this)],
|
||||||
['setContentScale', ({id, scale}) => this._onApiSetContentScale(id, scale)]
|
['setContentScale', this._onApiSetContentScale.bind(this)]
|
||||||
]));
|
]));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,56 +87,56 @@ class PopupProxyHost {
|
|||||||
|
|
||||||
// Message handlers
|
// Message handlers
|
||||||
|
|
||||||
async _onApiGetOrCreatePopup(id, parentId) {
|
async _onApiGetOrCreatePopup({id, parentId}) {
|
||||||
const popup = this.getOrCreatePopup(id, parentId);
|
const popup = this.getOrCreatePopup(id, parentId);
|
||||||
return {
|
return {
|
||||||
id: popup.id
|
id: popup.id
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
async _onApiSetOptions(id, options) {
|
async _onApiSetOptions({id, options}) {
|
||||||
const popup = this._getPopup(id);
|
const popup = this._getPopup(id);
|
||||||
return await popup.setOptions(options);
|
return await popup.setOptions(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
async _onApiHide(id, changeFocus) {
|
async _onApiHide({id, changeFocus}) {
|
||||||
const popup = this._getPopup(id);
|
const popup = this._getPopup(id);
|
||||||
return popup.hide(changeFocus);
|
return popup.hide(changeFocus);
|
||||||
}
|
}
|
||||||
|
|
||||||
async _onApiIsVisibleAsync(id) {
|
async _onApiIsVisibleAsync({id}) {
|
||||||
const popup = this._getPopup(id);
|
const popup = this._getPopup(id);
|
||||||
return await popup.isVisible();
|
return await popup.isVisible();
|
||||||
}
|
}
|
||||||
|
|
||||||
async _onApiSetVisibleOverride(id, visible) {
|
async _onApiSetVisibleOverride({id, visible}) {
|
||||||
const popup = this._getPopup(id);
|
const popup = this._getPopup(id);
|
||||||
return await popup.setVisibleOverride(visible);
|
return await popup.setVisibleOverride(visible);
|
||||||
}
|
}
|
||||||
|
|
||||||
async _onApiContainsPoint(id, x, y) {
|
async _onApiContainsPoint({id, x, y}) {
|
||||||
const popup = this._getPopup(id);
|
const popup = this._getPopup(id);
|
||||||
return await popup.containsPoint(x, y);
|
return await popup.containsPoint(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
async _onApiShowContent(id, elementRect, writingMode, type, details) {
|
async _onApiShowContent({id, elementRect, writingMode, type, details}) {
|
||||||
const popup = this._getPopup(id);
|
const popup = this._getPopup(id);
|
||||||
elementRect = PopupProxyHost._convertJsonRectToDOMRect(popup, elementRect);
|
elementRect = PopupProxyHost._convertJsonRectToDOMRect(popup, elementRect);
|
||||||
if (!PopupProxyHost._popupCanShow(popup)) { return; }
|
if (!PopupProxyHost._popupCanShow(popup)) { return; }
|
||||||
return await popup.showContent(elementRect, writingMode, type, details);
|
return await popup.showContent(elementRect, writingMode, type, details);
|
||||||
}
|
}
|
||||||
|
|
||||||
async _onApiSetCustomCss(id, css) {
|
async _onApiSetCustomCss({id, css}) {
|
||||||
const popup = this._getPopup(id);
|
const popup = this._getPopup(id);
|
||||||
return popup.setCustomCss(css);
|
return popup.setCustomCss(css);
|
||||||
}
|
}
|
||||||
|
|
||||||
async _onApiClearAutoPlayTimer(id) {
|
async _onApiClearAutoPlayTimer({id}) {
|
||||||
const popup = this._getPopup(id);
|
const popup = this._getPopup(id);
|
||||||
return popup.clearAutoPlayTimer();
|
return popup.clearAutoPlayTimer();
|
||||||
}
|
}
|
||||||
|
|
||||||
async _onApiSetContentScale(id, scale) {
|
async _onApiSetContentScale({id, scale}) {
|
||||||
const popup = this._getPopup(id);
|
const popup = this._getPopup(id);
|
||||||
return popup.setContentScale(scale);
|
return popup.setContentScale(scale);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user