Bug 1191597 part 4 - Use inner width and height for check window state. draft
authorXidorn Quan <quanxunzhen@gmail.com>
Thu, 07 Jan 2016 21:13:33 +1100
changeset 319975 540b9761d59fbd3e937c941f6e0ad155b2ac4b46
parent 319974 30ede73c4b964754c93e2e4323fd9d05b01121c9
child 319976 c20311140df7b37c78983acb9cd8b68a4f8c1053
push id9116
push userxquan@mozilla.com
push dateFri, 08 Jan 2016 09:53:58 +0000
bugs1191597
milestone46.0a1
Bug 1191597 part 4 - Use inner width and height for check window state. Inner width and height are more reliable than outer ones. Change to outer ones may not trigger resize event on content process.
dom/html/test/file_fullscreen-utils.js
--- a/dom/html/test/file_fullscreen-utils.js
+++ b/dom/html/test/file_fullscreen-utils.js
@@ -1,23 +1,23 @@
 
 // Returns true if the window occupies the entire screen.
 // Note this only returns true once the transition from normal to
 // fullscreen mode is complete.
 function inFullscreenMode(win) {
-  return win.outerWidth == win.screen.width &&
-         win.outerHeight == win.screen.height;
+  return win.innerWidth == win.screen.width &&
+         win.innerHeight == win.screen.height;
 }
 
 // Returns true if the window is in normal mode, i.e. non fullscreen mode.
 // Note this only returns true once the transition from fullscreen back to
 // normal mode is complete.
 function inNormalMode(win) {
-  return win.outerWidth == win.normalSize.w &&
-         win.outerHeight == win.normalSize.h;
+  return win.innerWidth == win.normalSize.w &&
+         win.innerHeight == win.normalSize.h;
 }
 
 // Adds a listener that will be called once a fullscreen transition
 // is complete. When type==='enter', callback is called when we've
 // received a fullscreenchange event, and the fullscreen transition is
 // complete. When type==='exit', callback is called when we've
 // received a fullscreenchange event and the window dimensions match
 // the window dimensions when the window opened (so don't resize the
@@ -25,18 +25,18 @@ function inNormalMode(win) {
 // the listeners are added on, if absent, the listeners are added to
 // the current document.
 function addFullscreenChangeContinuation(type, callback, inDoc) {
   var doc = inDoc || document;
   var topWin = doc.defaultView.top;
   // Remember the window size in non-fullscreen mode.
   if (!topWin.normalSize) {
     topWin.normalSize = {
-      w: window.outerWidth,
-      h: window.outerHeight
+      w: window.innerWidth,
+      h: window.innerHeight
     };
   }
   function checkCondition() {
     if (type == "enter") {
       return inFullscreenMode(topWin);
     } else if (type == "exit") {
       // If we just revert the state to a previous fullscreen state,
       // the window won't back to the normal mode. Hence we check