Bug 1191597 part 4 - Use inner width and height for check window state. r=smaug

Inner width and height are more reliable than outer ones. Change to
outer ones may not trigger resize event on content process.
This commit is contained in:
Xidorn Quan
2016-01-11 09:38:53 +11:00
parent f723da00e7
commit aa14734e5c

View File

@@ -3,16 +3,16 @@
// Note this only returns true once the transition from normal to // Note this only returns true once the transition from normal to
// fullscreen mode is complete. // fullscreen mode is complete.
function inFullscreenMode(win) { function inFullscreenMode(win) {
return win.outerWidth == win.screen.width && return win.innerWidth == win.screen.width &&
win.outerHeight == win.screen.height; win.innerHeight == win.screen.height;
} }
// Returns true if the window is in normal mode, i.e. non fullscreen mode. // 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 // Note this only returns true once the transition from fullscreen back to
// normal mode is complete. // normal mode is complete.
function inNormalMode(win) { function inNormalMode(win) {
return win.outerWidth == win.normalSize.w && return win.innerWidth == win.normalSize.w &&
win.outerHeight == win.normalSize.h; win.innerHeight == win.normalSize.h;
} }
// Adds a listener that will be called once a fullscreen transition // Adds a listener that will be called once a fullscreen transition
@@ -30,8 +30,8 @@ function addFullscreenChangeContinuation(type, callback, inDoc) {
// Remember the window size in non-fullscreen mode. // Remember the window size in non-fullscreen mode.
if (!topWin.normalSize) { if (!topWin.normalSize) {
topWin.normalSize = { topWin.normalSize = {
w: window.outerWidth, w: window.innerWidth,
h: window.outerHeight h: window.innerHeight
}; };
} }
function checkCondition() { function checkCondition() {