Only consider player gone if really no longer part of the visible DOM
ClosedPublic

Authored by broulik on Apr 15 2019, 6:04 PM.

Details

Summary

We listen for the player being removed from the DOM so we can detect when a player was removed dynamically when e.g. an overlay div closes.
However, when the player is just reparented elsewhere, we get a DOM add and remove dance, and then it becomes racy who will be given controls: previous player on another tab or the same player again when it becomes known again.
To avoid this just ignore player removal when it remains part of the visible page DOM.

Test Plan

Switching full screen back and forth in YouTube works fine now (now, really! :D)
Verified that closing a twitter video overlay still considers the player gone (which was the main point of this mutation observer, detecting when a video player is removed dynamically)

Diff Detail

Repository
R856 Plasma Browser Integration
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
broulik created this revision.Apr 15 2019, 6:04 PM
Restricted Application added a project: Plasma. · View Herald TranscriptApr 15 2019, 6:04 PM
Restricted Application added a subscriber: plasma-devel. · View Herald Transcript
broulik requested review of this revision.Apr 15 2019, 6:04 PM
broulik edited the summary of this revision. (Show Details)Apr 15 2019, 6:07 PM
fvogt added a comment.Apr 15 2019, 6:12 PM

I see an opportunity for code decuplication here... Not sure how though - maybe

var players = Array.prototype.slice.call(node.querySelectorAll("video,audio"));
if (node.matches("video,audio")) {
    players.unshift(node);
}
broulik updated this revision to Diff 56361.Apr 16 2019, 9:29 AM
  • Rebase
fvogt accepted this revision.Apr 16 2019, 9:31 AM
This revision is now accepted and ready to land.Apr 16 2019, 9:31 AM
This revision was automatically updated to reflect the committed changes.