Skip to content

Commit

Permalink
fix: make popup show when a descendant of an iframe is made fullscreen
Browse files Browse the repository at this point in the history
Fixes #1015
  • Loading branch information
birtles committed Dec 1, 2022
1 parent 8ef7152 commit 81d8779
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ app.
([#1003](https://github.com/birchill/10ten-ja-reader/issues/1003)).
- (Firefox) Fixed occasional flicker on loading Web pages over slow connections
when the extension is enabled.
- Made the popup show for sites that make nested contents fullscreen such as
Crunchyroll
([#1015](https://github.com/birchill/10ten-ja-reader/issues/1015)).
- Fixed lookup of Japanese inside `display: contents` containers.
- Made the copy overlay not show if the user has selected text in the popup.
- Made shogi shorthand matches not show up when there is a longer word match.
Expand Down
21 changes: 21 additions & 0 deletions src/content/content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,17 @@ export class ContentHandler {
}

isTopMostWindow() {
// If a descendant of an iframe is being displayed full-screen, that iframe
// can temporarily act as the topmost window.
if (document.fullscreenElement) {
if (document.fullscreenElement.tagName === 'IFRAME') {
return false;
}
if (document.fullscreenElement.ownerDocument === document) {
return true;
}
}

return (
this.isEffectiveTopMostWindow || window.self === this.getTopMostWindow()
);
Expand Down Expand Up @@ -1202,6 +1213,16 @@ export class ContentHandler {
if (this.popupState?.display.mode === 'pinned') {
this.unpinPopup();
}

// If entering / leaving fullscreen caused a change in who is the topmost
// window we might have some setup / clean up to do.
if (this.isTopMostWindow()) {
this.applyPuckConfig();
} else {
removePopup();
this.clearResult();
this.tearDownPuck();
}
}

onInterFrameMessage(event: MessageEvent) {
Expand Down

0 comments on commit 81d8779

Please sign in to comment.