Bug 1521964 - Make PictureInPictureChild use the cloneElementVisually API. r=Felipe
authorMike Conley <mconley@mozilla.com>
Fri, 01 Mar 2019 22:37:26 +0000
changeset 519925 d26b9b95a47e9eb0c879ba645e6dc89f4efda1f4
parent 519924 5ffd3605c75c66332e62c69251fda82a9fea00ff
child 519926 3ebabb9accebd7c078d2cbbf194ca3d04b9045b6
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersFelipe
bugs1521964
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1521964 - Make PictureInPictureChild use the cloneElementVisually API. r=Felipe Differential Revision: https://phabricator.services.mozilla.com/D21402
toolkit/actors/PictureInPictureChild.jsm
--- a/toolkit/actors/PictureInPictureChild.jsm
+++ b/toolkit/actors/PictureInPictureChild.jsm
@@ -73,47 +73,37 @@ class PictureInPictureChild extends Acto
         this.mm.addEventListener("load", resolve, {
           once: true,
           mozSystemGroup: true,
           capture: true,
         });
       });
     }
 
-    let stream = originatingVideo.mozCaptureStream();
-
     let doc = this.content.document;
-    let playerVideo = doc.createElement("video");
-    playerVideo.srcObject = stream;
+    let playerVideo = originatingVideo.cloneNode();
     playerVideo.removeAttribute("controls");
-    playerVideo.setAttribute("autoplay", "true");
 
     // Mute the video and rely on the originating video's audio playback.
     // This way, we sidestep the AutoplayPolicy blocking stuff.
     playerVideo.muted = true;
 
     // Force the player video to assume maximum height and width of the
     // containing window
     playerVideo.style.height = "100vh";
     playerVideo.style.width = "100vw";
 
     // And now try to get rid of as much surrounding whitespace as possible.
     playerVideo.style.margin = "0";
     doc.body.style.overflow = "hidden";
     doc.body.style.margin = "0";
 
-    playerVideo.play();
+    doc.body.appendChild(playerVideo);
 
-    // A little hack to make the current frame show up in the player
-    if (originatingVideo.paused) {
-      await originatingVideo.play();
-      await originatingVideo.pause();
-    }
-
-    doc.body.appendChild(playerVideo);
+    originatingVideo.cloneElementVisually(playerVideo);
 
     let originatingWindow = originatingVideo.ownerGlobal;
     originatingWindow.addEventListener("unload", (e) => {
       this.closePictureInPicture(originatingVideo);
     }, { once: true });
 
     this.content.addEventListener("unload", () => {
       gWeakVideo = null;