From ee2a420fc8e0658b7ab8bb89401ec3cea2168546 Mon Sep 17 00:00:00 2001 From: Gijs Kruitbosch Date: Fri, 6 Jun 2014 17:33:50 +0100 Subject: [PATCH] Bug 1021969, r=bholley,jaws --HG-- extra : rebase_source : f8bc835a5bfcd62e1d59b31d75841d1cc6339634 --- browser/base/content/nsContextMenu.js | 2 +- content/html/content/public/HTMLMediaElement.h | 14 ++++++++++++++ content/html/content/src/HTMLMediaElement.cpp | 1 + dom/webidl/HTMLMediaElement.webidl | 3 +++ toolkit/content/widgets/videocontrols.xml | 8 +++----- 5 files changed, 22 insertions(+), 6 deletions(-) diff --git a/browser/base/content/nsContextMenu.js b/browser/base/content/nsContextMenu.js index 5235e23283fc..981d4397b336 100644 --- a/browser/base/content/nsContextMenu.js +++ b/browser/base/content/nsContextMenu.js @@ -445,7 +445,7 @@ nsContextMenu.prototype = { this.showItem("context-media-showcontrols", onMedia && !this.target.controls); this.showItem("context-media-hidecontrols", onMedia && this.target.controls); this.showItem("context-video-fullscreen", this.onVideo && this.target.ownerDocument.mozFullScreenElement == null); - var statsShowing = this.onVideo && XPCNativeWrapper.unwrap(this.target).mozMediaStatisticsShowing; + 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); diff --git a/content/html/content/public/HTMLMediaElement.h b/content/html/content/public/HTMLMediaElement.h index 045c4156c427..885be0025b5b 100644 --- a/content/html/content/public/HTMLMediaElement.h +++ b/content/html/content/public/HTMLMediaElement.h @@ -478,6 +478,16 @@ public: SetHTMLBoolAttr(nsGkAtoms::muted, aMuted, aRv); } + bool MozMediaStatisticsShowing() const + { + return mStatsShowing; + } + + void SetMozMediaStatisticsShowing(bool aShow) + { + mStatsShowing = aShow; + } + already_AddRefed GetMozSrcObject() const; void SetMozSrcObject(DOMMediaStream& aValue); @@ -1078,6 +1088,10 @@ protected: uint32_t mMuted; + // True if the media statistics are currently being shown by the builtin + // video controls + bool mStatsShowing; + // True if the sound is being captured. bool mAudioCaptured; diff --git a/content/html/content/src/HTMLMediaElement.cpp b/content/html/content/src/HTMLMediaElement.cpp index 2bd1d9c84f66..7b2bc61afa8d 100644 --- a/content/html/content/src/HTMLMediaElement.cpp +++ b/content/html/content/src/HTMLMediaElement.cpp @@ -1987,6 +1987,7 @@ HTMLMediaElement::HTMLMediaElement(already_AddRefed& aNodeInfo) mLoadedFirstFrame(false), mAutoplaying(true), mAutoplayEnabled(true), + mStatsShowing(false), mPaused(true), mMuted(0), mAudioCaptured(false), diff --git a/dom/webidl/HTMLMediaElement.webidl b/dom/webidl/HTMLMediaElement.webidl index 148480cfe8c1..f2ba3cec167d 100644 --- a/dom/webidl/HTMLMediaElement.webidl +++ b/dom/webidl/HTMLMediaElement.webidl @@ -102,6 +102,9 @@ partial interface HTMLMediaElement { attribute boolean mozPreservesPitch; readonly attribute boolean mozAutoplayEnabled; + // NB: for internal use with the video controls: + [Func="IsChromeOrXBL"] attribute boolean mozMediaStatisticsShowing; + // Mozilla extension: stream capture [Throws] MediaStream mozCaptureStream(); diff --git a/toolkit/content/widgets/videocontrols.xml b/toolkit/content/widgets/videocontrols.xml index de2bdf6e45b7..50f0c43baa8b 100644 --- a/toolkit/content/widgets/videocontrols.xml +++ b/toolkit/content/widgets/videocontrols.xml @@ -477,7 +477,7 @@ this.adjustControlSize(); // Preserve Statistics when toggling fullscreen mode due to bug 714071. - if (XPCNativeWrapper.unwrap(this.video).mozMediaStatisticsShowing) + if (this.video.mozMediaStatisticsShowing) this.showStatistics(true); this._handleCustomEventsBound = this.handleCustomEvents.bind(this); @@ -1152,15 +1152,13 @@ this.statsInterval = null; } - let unwrappedVideo = XPCNativeWrapper.unwrap(this.video); if (shouldShow) { - unwrappedVideo.mozMediaStatisticsShowing = true; - + this.video.mozMediaStatisticsShowing = true; this.statsOverlay.hidden = false; this.statsInterval = setInterval(this.updateStats.bind(this), this.STATS_INTERVAL_MS); this.updateStats(); } else { - delete unwrappedVideo.mozMediaStatisticsShowing; + this.video.mozMediaStatisticsShowing = false; this.statsOverlay.hidden = true; } },