Bug 1536169 - Get rid of extra whitespace around Picture-in-Picture player. r=JSON_voorhees
authorMike Conley <mconley@mozilla.com>
Mon, 18 Mar 2019 19:30:48 +0000
changeset 464907 93efe527cad27e2b48df8c1e9787d489da1dfff1
parent 464906 195e208318babe02ee96b45a688ba44317536af2
child 464908 ba07eec3fac179d3b647f5aedd659a3bf4512f31
push id35727
push userdvarga@mozilla.com
push dateTue, 19 Mar 2019 09:48:59 +0000
treeherdermozilla-central@70baa37ae1eb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersJSON_voorhees
bugs1536169
milestone68.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 1536169 - Get rid of extra whitespace around Picture-in-Picture player. r=JSON_voorhees Differential Revision: https://phabricator.services.mozilla.com/D23909
toolkit/components/pictureinpicture/PictureInPicture.jsm
--- a/toolkit/components/pictureinpicture/PictureInPicture.jsm
+++ b/toolkit/components/pictureinpicture/PictureInPicture.jsm
@@ -130,35 +130,35 @@ var PictureInPicture = {
       // it to the associated max. Recalculate the other dimension to maintain
       // aspect ratio.
       if (videoWidth >= videoHeight) {
         // We're clamping the width, so the height must be adjusted to match
         // the original aspect ratio. Since aspect ratio is width over height,
         // that means we need to _divide_ the MAX_WIDTH by the aspect ratio to
         // calculate the appropriate height.
         resultWidth = MAX_WIDTH;
-        resultHeight = Math.floor(MAX_WIDTH / aspectRatio);
+        resultHeight = Math.round(MAX_WIDTH / aspectRatio);
       } else {
         // We're clamping the height, so the width must be adjusted to match
         // the original aspect ratio. Since aspect ratio is width over height,
         // this means we need to _multiply_ the MAX_HEIGHT by the aspect ratio
         // to calculate the appropriate width.
         resultHeight = MAX_HEIGHT;
-        resultWidth = Math.floor(MAX_HEIGHT * aspectRatio);
+        resultWidth = Math.round(MAX_HEIGHT * aspectRatio);
       }
     }
 
     // Now that we have the dimensions of the video, we need to figure out how
     // to position it in the bottom right corner. Since we know the width of the
     // available rect, we need to subtract the dimensions of the window we're
     // opening to get the top left coordinates that openWindow expects.
     let pipLeft = screenWidth.value - resultWidth;
     let pipTop = screenHeight.value - resultHeight;
     let features = `${PLAYER_FEATURES},top=${pipTop},left=${pipLeft},` +
-                   `width=${resultWidth},height=${resultHeight}`;
+                   `outerWidth=${resultWidth},outerHeight=${resultHeight}`;
 
     let pipWindow =
       Services.ww.openWindow(parentWin, PLAYER_URI, null, features, null);
 
     return new Promise(resolve => {
       pipWindow.addEventListener("load", () => {
         resolve(pipWindow);
       }, { once: true });