From a1c8f75a2d29c17ac51d892d92c7db3d9372c7e1 Mon Sep 17 00:00:00 2001 From: Ryan VanderMeulen Date: Thu, 19 May 2016 11:27:58 -0400 Subject: [PATCH] Backed out changeset 83a1b9c7ae8d (bug 1270853) for browser_dbg_event-listeners-03.js failures. --- browser/base/content/browser-context.inc | 8 + browser/base/content/content.js | 7 + browser/base/content/nsContextMenu.js | 5 + .../test/general/browser_contextmenu.js | 4 + browser/modules/BrowserUITelemetry.jsm | 4 +- dom/html/HTMLMediaElement.h | 10 + dom/webidl/HTMLMediaElement.webidl | 1 + toolkit/content/widgets/videocontrols.xml | 176 ++++++++++++++++++ 8 files changed, 213 insertions(+), 2 deletions(-) diff --git a/browser/base/content/browser-context.inc b/browser/base/content/browser-context.inc index 17d67833d06f..bfb90913dd4a 100644 --- a/browser/base/content/browser-context.inc +++ b/browser/base/content/browser-context.inc @@ -166,6 +166,14 @@ label="&mediaHideControls.label;" accesskey="&mediaHideControls.accesskey;" oncommand="gContextMenu.mediaCommand('hidecontrols');"/> + + { case "showcontrols": media.setAttribute("controls", "true"); break; + case "hidestats": + case "showstats": + let event = media.ownerDocument.createEvent("CustomEvent"); + event.initCustomEvent("media-showStatistics", false, true, + message.data.command == "showstats"); + media.dispatchEvent(event); + break; case "fullscreen": if (content.document.fullscreenEnabled) media.requestFullscreen(); diff --git a/browser/base/content/nsContextMenu.js b/browser/base/content/nsContextMenu.js index c34a4112b930..fd2592439a12 100644 --- a/browser/base/content/nsContextMenu.js +++ b/browser/base/content/nsContextMenu.js @@ -474,6 +474,9 @@ nsContextMenu.prototype = { this.showItem("context-media-showcontrols", onMedia && !this.target.controls); this.showItem("context-media-hidecontrols", this.target.controls && (this.onVideo || (this.onAudio && !this.inSyntheticDoc))); this.showItem("context-video-fullscreen", this.onVideo && this.target.ownerDocument.fullscreenElement == null); + var statsShowing = this.onVideo && this.target.mozMediaStatisticsShowing; + this.showItem("context-video-showstats", this.onVideo && this.target.controls && !statsShowing); + this.showItem("context-video-hidestats", this.onVideo && this.target.controls && statsShowing); this.showItem("context-media-eme-learnmore", this.onDRMMedia); this.showItem("context-media-eme-separator", this.onDRMMedia); @@ -503,6 +506,8 @@ nsContextMenu.prototype = { let canSaveSnapshot = !this.onDRMMedia && this.target.readyState >= this.target.HAVE_CURRENT_DATA; this.setItemAttr("context-video-saveimage", "disabled", !canSaveSnapshot); this.setItemAttr("context-video-fullscreen", "disabled", hasError); + this.setItemAttr("context-video-showstats", "disabled", hasError); + this.setItemAttr("context-video-hidestats", "disabled", hasError); } } this.showItem("context-media-sep-commands", onMedia); diff --git a/browser/base/content/test/general/browser_contextmenu.js b/browser/base/content/test/general/browser_contextmenu.js index b024d0873a08..dca2dd34bc21 100644 --- a/browser/base/content/test/general/browser_contextmenu.js +++ b/browser/base/content/test/general/browser_contextmenu.js @@ -117,6 +117,7 @@ add_task(function* test_video_ok() { "context-media-playbackrate-200x", true], null, "context-media-loop", true, "context-media-hidecontrols", true, + "context-video-showstats", true, "context-video-fullscreen", true, "---", null, "context-viewvideo", true, @@ -164,6 +165,7 @@ add_task(function* test_video_bad() { "context-media-playbackrate-200x", false], null, "context-media-loop", true, "context-media-hidecontrols", false, + "context-video-showstats", false, "context-video-fullscreen", false, "---", null, "context-viewvideo", true, @@ -190,6 +192,7 @@ add_task(function* test_video_bad2() { "context-media-playbackrate-200x", false], null, "context-media-loop", true, "context-media-hidecontrols", false, + "context-video-showstats", false, "context-video-fullscreen", false, "---", null, "context-viewvideo", false, @@ -250,6 +253,7 @@ add_task(function* test_video_in_iframe() { "context-media-playbackrate-200x", true], null, "context-media-loop", true, "context-media-hidecontrols", true, + "context-video-showstats", true, "context-video-fullscreen", true, "---", null, "context-viewvideo", true, diff --git a/browser/modules/BrowserUITelemetry.jsm b/browser/modules/BrowserUITelemetry.jsm index 986e73e25616..88fe61cb82f5 100644 --- a/browser/modules/BrowserUITelemetry.jsm +++ b/browser/modules/BrowserUITelemetry.jsm @@ -699,8 +699,8 @@ this.BrowserUITelemetry = { "media-mute", "media-unmute", "media-playbackrate", "media-playbackrate-050x", "media-playbackrate-100x", "media-playbackrate-125x", "media-playbackrate-150x", "media-playbackrate-200x", - "media-showcontrols", "media-hidecontrols", - "video-fullscreen", "leave-dom-fullscreen", + "media-showcontrols", "media-hidecontrols", "video-showstats", + "video-hidestats", "video-fullscreen", "leave-dom-fullscreen", "reloadimage", "viewimage", "viewvideo", "copyimage-contents", "copyimage", "copyvideourl", "copyaudiourl", "saveimage", "shareimage", "sendimage", "setDesktopBackground", "viewimageinfo", "viewimagedesc", "savevideo", diff --git a/dom/html/HTMLMediaElement.h b/dom/html/HTMLMediaElement.h index 9b83da569c33..eadf98bf956b 100644 --- a/dom/html/HTMLMediaElement.h +++ b/dom/html/HTMLMediaElement.h @@ -580,6 +580,16 @@ public: SetHTMLBoolAttr(nsGkAtoms::muted, aMuted, aRv); } + bool MozMediaStatisticsShowing() const + { + return mStatsShowing; + } + + void SetMozMediaStatisticsShowing(bool aShow) + { + mStatsShowing = aShow; + } + bool MozAllowCasting() const { return mAllowCasting; diff --git a/dom/webidl/HTMLMediaElement.webidl b/dom/webidl/HTMLMediaElement.webidl index 55f8724a3395..92ce2d63653b 100644 --- a/dom/webidl/HTMLMediaElement.webidl +++ b/dom/webidl/HTMLMediaElement.webidl @@ -118,6 +118,7 @@ partial interface HTMLMediaElement { readonly attribute boolean mozAutoplayEnabled; // NB: for internal use with the video controls: + [Func="IsChromeOrXBL"] attribute boolean mozMediaStatisticsShowing; [Func="IsChromeOrXBL"] attribute boolean mozAllowCasting; [Func="IsChromeOrXBL"] attribute boolean mozIsCasting; diff --git a/toolkit/content/widgets/videocontrols.xml b/toolkit/content/widgets/videocontrols.xml index f8c4eee8bf00..56adea744080 100644 --- a/toolkit/content/widgets/videocontrols.xml +++ b/toolkit/content/widgets/videocontrols.xml @@ -211,6 +211,63 @@ + + @@ -270,6 +327,7 @@ statusOverlay : null, controlsSpacer : null, clickToPlay : null, + stats : {}, controlsOverlay : null, fullscreenButton : null, @@ -416,6 +474,13 @@ // _volumeControlWidth, since the volume slider implementation // depends on it. this.updateVolumeControls(); + + // Preserve Statistics when toggling fullscreen mode due to bug 714071. + if (this.video.mozMediaStatisticsShowing) + this.showStatistics(true); + + this._handleCustomEventsBound = this.handleCustomEvents.bind(this); + this.video.addEventListener("media-showStatistics", this._handleCustomEventsBound, false, true); }, setupNewLoadState : function() { @@ -438,6 +503,12 @@ this.startFade(this.controlBar, shouldShow, true); }, + handleCustomEvents : function (e) { + if (!e.isTrusted) + return; + this.showStatistics(e.detail); + }, + get dynamicControls() { // Don't fade controls for