Mark PopupProxy internal functions as private
This commit is contained in:
parent
db7e179626
commit
bf02eb2ea1
@ -33,74 +33,76 @@ class PopupProxy {
|
|||||||
this.apiSender = new FrontendApiSender();
|
this.apiSender = new FrontendApiSender();
|
||||||
}
|
}
|
||||||
|
|
||||||
getPopupId() {
|
|
||||||
if (this.idPromise === null) {
|
|
||||||
this.idPromise = this.getPopupIdAsync();
|
|
||||||
}
|
|
||||||
return this.idPromise;
|
|
||||||
}
|
|
||||||
|
|
||||||
async getPopupIdAsync() {
|
|
||||||
const id = await this.invokeHostApi('createNestedPopup', {parentId: this.parentId});
|
|
||||||
this.id = id;
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
async setOptions(options) {
|
async setOptions(options) {
|
||||||
const id = await this.getPopupId();
|
const id = await this._getPopupId();
|
||||||
return await this.invokeHostApi('setOptions', {id, options});
|
return await this._invokeHostApi('setOptions', {id, options});
|
||||||
}
|
}
|
||||||
|
|
||||||
async hide(changeFocus) {
|
async hide(changeFocus) {
|
||||||
if (this.id === null) {
|
if (this.id === null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
return await this.invokeHostApi('hide', {id: this.id, changeFocus});
|
return await this._invokeHostApi('hide', {id: this.id, changeFocus});
|
||||||
}
|
}
|
||||||
|
|
||||||
async isVisibleAsync() {
|
async isVisibleAsync() {
|
||||||
const id = await this.getPopupId();
|
const id = await this._getPopupId();
|
||||||
return await this.invokeHostApi('isVisibleAsync', {id});
|
return await this._invokeHostApi('isVisibleAsync', {id});
|
||||||
}
|
}
|
||||||
|
|
||||||
async setVisibleOverride(visible) {
|
async setVisibleOverride(visible) {
|
||||||
const id = await this.getPopupId();
|
const id = await this._getPopupId();
|
||||||
return await this.invokeHostApi('setVisibleOverride', {id, visible});
|
return await this._invokeHostApi('setVisibleOverride', {id, visible});
|
||||||
}
|
}
|
||||||
|
|
||||||
async containsPoint(x, y) {
|
async containsPoint(x, y) {
|
||||||
if (this.id === null) {
|
if (this.id === null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return await this.invokeHostApi('containsPoint', {id: this.id, x, y});
|
return await this._invokeHostApi('containsPoint', {id: this.id, x, y});
|
||||||
}
|
}
|
||||||
|
|
||||||
async showContent(elementRect, writingMode, type=null, details=null) {
|
async showContent(elementRect, writingMode, type=null, details=null) {
|
||||||
const id = await this.getPopupId();
|
const id = await this._getPopupId();
|
||||||
elementRect = PopupProxy.DOMRectToJson(elementRect);
|
elementRect = PopupProxy._convertDOMRectToJson(elementRect);
|
||||||
return await this.invokeHostApi('showContent', {id, elementRect, writingMode, type, details});
|
return await this._invokeHostApi('showContent', {id, elementRect, writingMode, type, details});
|
||||||
}
|
}
|
||||||
|
|
||||||
async setCustomCss(css) {
|
async setCustomCss(css) {
|
||||||
const id = await this.getPopupId();
|
const id = await this._getPopupId();
|
||||||
return await this.invokeHostApi('setCustomCss', {id, css});
|
return await this._invokeHostApi('setCustomCss', {id, css});
|
||||||
}
|
}
|
||||||
|
|
||||||
async clearAutoPlayTimer() {
|
async clearAutoPlayTimer() {
|
||||||
if (this.id === null) {
|
if (this.id === null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
return await this.invokeHostApi('clearAutoPlayTimer', {id: this.id});
|
return await this._invokeHostApi('clearAutoPlayTimer', {id: this.id});
|
||||||
}
|
}
|
||||||
|
|
||||||
invokeHostApi(action, params={}) {
|
// Private
|
||||||
|
|
||||||
|
_getPopupId() {
|
||||||
|
if (this.idPromise === null) {
|
||||||
|
this.idPromise = this._getPopupIdAsync();
|
||||||
|
}
|
||||||
|
return this.idPromise;
|
||||||
|
}
|
||||||
|
|
||||||
|
async _getPopupIdAsync() {
|
||||||
|
const id = await this._invokeHostApi('createNestedPopup', {parentId: this.parentId});
|
||||||
|
this.id = id;
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
_invokeHostApi(action, params={}) {
|
||||||
if (typeof this.parentFrameId !== 'number') {
|
if (typeof this.parentFrameId !== 'number') {
|
||||||
return Promise.reject(new Error('Invalid frame'));
|
return Promise.reject(new Error('Invalid frame'));
|
||||||
}
|
}
|
||||||
return this.apiSender.invoke(action, params, `popup-proxy-host#${this.parentFrameId}`);
|
return this.apiSender.invoke(action, params, `popup-proxy-host#${this.parentFrameId}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
static DOMRectToJson(domRect) {
|
static _convertDOMRectToJson(domRect) {
|
||||||
return {
|
return {
|
||||||
x: domRect.x,
|
x: domRect.x,
|
||||||
y: domRect.y,
|
y: domRect.y,
|
||||||
|
Loading…
Reference in New Issue
Block a user