Bug 845555 - Fix statistics menu item, r=jaws

This commit is contained in:
Gijs Kruitbosch 2013-04-15 23:06:12 -07:00
parent 6173eb92b6
commit 2039d2843a
2 changed files with 8 additions and 11 deletions

View File

@ -396,7 +396,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 && this.target.wrappedJSObject.mozMediaStatisticsShowing;
var statsShowing = this.onVideo && XPCNativeWrapper.unwrap(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);
@ -1505,14 +1505,10 @@ nsContextMenu.prototype = {
case "showcontrols":
media.setAttribute("controls", "true");
break;
case "showstats":
var event = document.createEvent("CustomEvent");
event.initCustomEvent("media-showStatistics", false, true, true);
media.dispatchEvent(event);
break;
case "hidestats":
var event = document.createEvent("CustomEvent");
event.initCustomEvent("media-showStatistics", false, true, false);
case "showstats":
var event = media.ownerDocument.createEvent("CustomEvent");
event.initCustomEvent("media-showStatistics", false, true, command == "showstats");
media.dispatchEvent(event);
break;
}

View File

@ -456,7 +456,7 @@
this.adjustControlSize();
// Preserve Statistics when toggling fullscreen mode due to bug 714071.
if (this.video.mozMediaStatisticsShowing)
if (XPCNativeWrapper.unwrap(this.video).mozMediaStatisticsShowing)
this.showStatistics(true);
this._handleCustomEventsBound = this.handleCustomEvents.bind(this);
@ -1094,14 +1094,15 @@
this.statsInterval = null;
}
let unwrappedVideo = XPCNativeWrapper.unwrap(this.video);
if (shouldShow) {
this.video.mozMediaStatisticsShowing = true;
unwrappedVideo.mozMediaStatisticsShowing = true;
this.statsOverlay.hidden = false;
this.statsInterval = setInterval(this.updateStats.bind(this), this.STATS_INTERVAL_MS);
this.updateStats();
} else {
delete this.video.mozMediaStatisticsShowing;
delete unwrappedVideo.mozMediaStatisticsShowing;
this.statsOverlay.hidden = true;
}
},