diff options
author | wolfbeast <mcwerewolf@gmail.com> | 2018-11-03 09:06:25 +0100 |
---|---|---|
committer | wolfbeast <mcwerewolf@gmail.com> | 2018-11-03 09:06:25 +0100 |
commit | 1626b5d7041ea9c3db92200f91542da46e49dde6 (patch) | |
tree | e99c393052ef818645027da57774672990e29514 /application/palemoon/components/statusbar | |
parent | 314fb761d144b160d3aeb72840c89e31c4f21a4a (diff) | |
parent | 1d55939c7ca0e80555a24b240ff68d5bdbb48b4a (diff) | |
download | UXP-1626b5d7041ea9c3db92200f91542da46e49dde6.tar UXP-1626b5d7041ea9c3db92200f91542da46e49dde6.tar.gz UXP-1626b5d7041ea9c3db92200f91542da46e49dde6.tar.lz UXP-1626b5d7041ea9c3db92200f91542da46e49dde6.tar.xz UXP-1626b5d7041ea9c3db92200f91542da46e49dde6.zip |
Merge branch 'master' into Basilisk-releasev2018.11.04
Diffstat (limited to 'application/palemoon/components/statusbar')
4 files changed, 69 insertions, 20 deletions
diff --git a/application/palemoon/components/statusbar/Status.jsm b/application/palemoon/components/statusbar/Status.jsm index d888c7d94..19e12ddfd 100644 --- a/application/palemoon/components/statusbar/Status.jsm +++ b/application/palemoon/components/statusbar/Status.jsm @@ -35,7 +35,7 @@ S4EStatusService.prototype = _defaultStatus: { val: "", type: "" }, _isFullScreen: false, - _isFullScreenVideo: false, + _isVideo: false, _statusText: { val: "", type: "" }, _noUpdate: false, @@ -222,18 +222,10 @@ S4EStatusService.prototype = } }, - updateFullScreen: function() + setFullScreenState: function(isFullScreen, isVideo) { - this._isFullScreen = this._window.fullScreen; - this._isFullScreenVideo = false; - if(this._isFullScreen) - { - let fsEl = this._window.content.document.mozFullScreenElement; - if(fsEl && (fsEl.nodeName == "VIDEO" || fsEl.getElementsByTagName("VIDEO").length > 0)) - { - this._isFullScreenVideo = true; - } - } + this._isFullScreen = isFullScreen; + this._isVideo = isFullScreen && isVideo; this.clearStatusField(); this.updateStatusField(true); @@ -305,7 +297,7 @@ S4EStatusService.prototype = let label = null; - if(this._isFullScreen && this._service.advancedStatusDetectFullScreen) + if(this._isFullScreen) { switch(location) { @@ -330,7 +322,7 @@ S4EStatusService.prototype = break; case 3: // Popup default: - if(this._isFullScreenVideo && this._service.advancedStatusDetectVideo) + if(this._isVideo) { return; } diff --git a/application/palemoon/components/statusbar/Status4Evar.jsm b/application/palemoon/components/statusbar/Status4Evar.jsm index 055306a88..6400f2e2a 100644 --- a/application/palemoon/components/statusbar/Status4Evar.jsm +++ b/application/palemoon/components/statusbar/Status4Evar.jsm @@ -31,7 +31,7 @@ function Status4Evar(window, gBrowser, toolbox) this.statusService = new S4EStatusService(this._window, s4e_service, this.getters); this.progressMeter = new S4EProgressService(gBrowser, s4e_service, this.getters, this.statusService); this.downloadStatus = new S4EDownloadService(this._window, gBrowser, s4e_service, this.getters); - this.sizeModeService = new SizeModeService(this._window, this); + this.sizeModeService = new SizeModeService(this._window, gBrowser, this); this._window.addEventListener("unload", this, false); } @@ -232,20 +232,31 @@ S4EWindowGetters.prototype = } }; -function SizeModeService(window, s4e) +function SizeModeService(window, gBrowser, s4e) { this._window = window; + this._gBrowser = gBrowser; this._s4e = s4e; + this._mm = this._window.messageManager; this.lastFullScreen = this._window.fullScreen; this.lastwindowState = this._window.windowState; + + if(s4e_service.advancedStatusDetectFullScreen) + { + this._mm.addMessageListener("status4evar@caligonstudios.com:video-detect-answer", this) + this._mm.loadFrameScript("resource:///modules/statusbar/content-thunk.js", true); + } + this._window.addEventListener("sizemodechange", this, false); } SizeModeService.prototype = { _window: null, + _gBrowser: null, _s4e: null, + _mm: null, lastFullScreen: null, lastwindowState: null, @@ -254,7 +265,13 @@ SizeModeService.prototype = { this._window.removeEventListener("sizemodechange", this, false); - ["_window", "_s4e"].forEach(function(prop) + if(s4e_service.advancedStatusDetectFullScreen) + { + this._mm.removeDelayedFrameScript("resource:///modules/statusbar/content-thunk.js"); + this._mm.removeMessageListener("status4evar@caligonstudios.com:video-detect-answer", this); + } + + ["_window", "_gBrowser", "_s4e", "_mm"].forEach(function(prop) { delete this[prop]; }, this); @@ -262,10 +279,18 @@ SizeModeService.prototype = handleEvent: function(e) { - if(this._window.fullScreen != this.lastFullScreen) + if(this._window.fullScreen != this.lastFullScreen && s4e_service.advancedStatusDetectFullScreen) { this.lastFullScreen = this._window.fullScreen; - this._s4e.statusService.updateFullScreen(); + + if(this.lastFullScreen && s4e_service.advancedStatusDetectVideo) + { + this._gBrowser.selectedBrowser.messageManager.sendAsyncMessage("status4evar@caligonstudios.com:video-detect"); + } + else + { + this._s4e.statusService.setFullScreenState(this.lastFullScreen, false); + } } if(this._window.windowState != this.lastwindowState) @@ -275,5 +300,13 @@ SizeModeService.prototype = } }, - QueryInterface: XPCOMUtils.generateQI([ CI.nsIDOMEventListener ]) + receiveMessage: function(message) + { + if(message.name == "status4evar@caligonstudios.com:video-detect-answer") + { + this._s4e.statusService.setFullScreenState(this.lastFullScreen, message.data.isVideo); + } + }, + + QueryInterface: XPCOMUtils.generateQI([ CI.nsIDOMEventListener, CI.nsIMessageListener ]) }; diff --git a/application/palemoon/components/statusbar/content-thunk.js b/application/palemoon/components/statusbar/content-thunk.js new file mode 100644 index 000000000..fe1fbabad --- /dev/null +++ b/application/palemoon/components/statusbar/content-thunk.js @@ -0,0 +1,23 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +function handleVideoDetect(message) +{ + let isVideo = false; + + let fsEl = content.document.mozFullScreenElement; + if(fsEl) + { + isVideo = ( + fsEl.nodeName == "VIDEO" + || (fsEl.nodeName == "IFRAME" && fsEl.contentDocument && fsEl.contentDocument.getElementsByTagName("VIDEO").length > 0) + || fsEl.getElementsByTagName("VIDEO").length > 0 + ); + } + + sendAsyncMessage("status4evar@caligonstudios.com:video-detect-answer", {isVideo: isVideo}); +} + +addMessageListener("status4evar@caligonstudios.com:video-detect", handleVideoDetect); + diff --git a/application/palemoon/components/statusbar/moz.build b/application/palemoon/components/statusbar/moz.build index ba8cfef86..0f7f597a5 100644 --- a/application/palemoon/components/statusbar/moz.build +++ b/application/palemoon/components/statusbar/moz.build @@ -16,6 +16,7 @@ EXTRA_COMPONENTS += [ ] EXTRA_JS_MODULES.statusbar = [ + 'content-thunk.js', 'Downloads.jsm', 'Progress.jsm', 'Status.jsm', |