aboutsummaryrefslogtreecommitdiff
path: root/ext/fg/js/popup.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-08-15 17:27:03 -0400
committerGitHub <noreply@github.com>2020-08-15 17:27:03 -0400
commitd5865db457ef6f96aa32662a8219fdf73478ae20 (patch)
tree8144a77e4172a32d74fec60f13817fc251b461f2 /ext/fg/js/popup.js
parenta9b16bd9379a881bb7b875a1e56bffbd78440a6a (diff)
Popup API refactor (#732)
* Simplify how parent/child are set * Remove unused public frameId property * Change use of getFrame * Simplify parent access * Use property for the container * Remove isProxy * Public function API parity * Public property API parity
Diffstat (limited to 'ext/fg/js/popup.js')
-rw-r--r--ext/fg/js/popup.js50
1 files changed, 15 insertions, 35 deletions
diff --git a/ext/fg/js/popup.js b/ext/fg/js/popup.js
index 8ea1afd0..bdffd424 100644
--- a/ext/fg/js/popup.js
+++ b/ext/fg/js/popup.js
@@ -64,16 +64,28 @@ class Popup {
return this._parent;
}
+ set parent(value) {
+ this._parent = value;
+ }
+
get child() {
return this._child;
}
+ set child(value) {
+ this._child = value;
+ }
+
get depth() {
return this._depth;
}
- get frameId() {
- return this._frameId;
+ get frameContentWindow() {
+ return this._frame.contentWindow;
+ }
+
+ get container() {
+ return this._container;
}
// Public functions
@@ -86,10 +98,6 @@ class Popup {
yomichan.on('extensionUnloaded', this._onExtensionUnloaded.bind(this));
}
- isProxy() {
- return false;
- }
-
async setOptionsContext(optionsContext, source) {
this._optionsContext = optionsContext;
this._previousOptionsContextSource = source;
@@ -163,26 +171,6 @@ class Popup {
this._invokeSafe('setContentScale', {scale});
}
- // Popup-only public functions
-
- setParent(parent) {
- if (parent === null) {
- throw new Error('Cannot set popup parent to null');
- }
- if (this._parent !== null) {
- throw new Error('Popup already has a parent');
- }
- parent.setChild(this);
- this._parent = parent;
- }
-
- setChild(popup) {
- if (this._child !== null) {
- throw new Error('Popup already has a child');
- }
- this._child = popup;
- }
-
isVisibleSync() {
return (this._visibleOverride !== null ? this._visibleOverride : this._visible);
}
@@ -205,18 +193,10 @@ class Popup {
this._childrenSupported = value;
}
- getFrame() {
- return this._frame;
- }
-
getFrameRect() {
return this._frame.getBoundingClientRect();
}
- getContainer() {
- return this._container;
- }
-
// Private functions
_inject() {
@@ -418,7 +398,7 @@ class Popup {
_focusParent() {
if (this._parent !== null) {
// Chrome doesn't like focusing iframe without contentWindow.
- const contentWindow = this._parent.getFrame().contentWindow;
+ const contentWindow = this._parent.frameContentWindow;
if (contentWindow !== null) {
contentWindow.focus();
}