Bug 1270853 - Remove HTML5 video controls statistics. r=gijs, r=bz

MozReview-Commit-ID: 53BYXvHaaB9

--HG--
extra : source : 0d17446ad21a8360c5d209377786e8ff67415471
This commit is contained in:
Jared Wein 2016-05-17 20:52:00 -04:00
Родитель 7d096e7cdf
Коммит 176fbcaf33
8 изменённых файлов: 2 добавлений и 213 удалений

Просмотреть файл

@ -166,14 +166,6 @@
label="&mediaHideControls.label;"
accesskey="&mediaHideControls.accesskey;"
oncommand="gContextMenu.mediaCommand('hidecontrols');"/>
<menuitem id="context-video-showstats"
accesskey="&videoShowStats.accesskey;"
label="&videoShowStats.label;"
oncommand="gContextMenu.mediaCommand('showstats');"/>
<menuitem id="context-video-hidestats"
accesskey="&videoHideStats.accesskey;"
label="&videoHideStats.label;"
oncommand="gContextMenu.mediaCommand('hidestats');"/>
<menuitem id="context-video-fullscreen"
accesskey="&videoFullScreen.accesskey;"
label="&videoFullScreen.label;"

Просмотреть файл

@ -755,13 +755,6 @@ addMessageListener("ContextMenu:MediaCommand", (message) => {
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();

Просмотреть файл

@ -474,9 +474,6 @@ 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);
@ -506,8 +503,6 @@ 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);

Просмотреть файл

@ -117,7 +117,6 @@ 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,
@ -165,7 +164,6 @@ 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,
@ -192,7 +190,6 @@ 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,
@ -253,7 +250,6 @@ 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,

Просмотреть файл

@ -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-showstats",
"video-hidestats", "video-fullscreen", "leave-dom-fullscreen",
"media-showcontrols", "media-hidecontrols",
"video-fullscreen", "leave-dom-fullscreen",
"reloadimage", "viewimage", "viewvideo", "copyimage-contents", "copyimage",
"copyvideourl", "copyaudiourl", "saveimage", "shareimage", "sendimage",
"setDesktopBackground", "viewimageinfo", "viewimagedesc", "savevideo",

Просмотреть файл

@ -580,16 +580,6 @@ public:
SetHTMLBoolAttr(nsGkAtoms::muted, aMuted, aRv);
}
bool MozMediaStatisticsShowing() const
{
return mStatsShowing;
}
void SetMozMediaStatisticsShowing(bool aShow)
{
mStatsShowing = aShow;
}
bool MozAllowCasting() const
{
return mAllowCasting;

Просмотреть файл

@ -118,7 +118,6 @@ 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;

Просмотреть файл

@ -211,63 +211,6 @@
<label class="errorLabel" anonid="errorGeneric">&error.generic;</label>
</vbox>
<vbox class="statsOverlay" hidden="true">
<html:div class="statsDiv" xmlns="http://www.w3.org/1999/xhtml">
<table class="statsTable">
<tr>
<td class="statLabel">&stats.media;</td>
<td class="statValue filename"><span class="statFilename"/></td>
</tr>
<tr>
<td class="statLabel">&stats.size;</td>
<td class="statValue size"><span class="statSize"/></td>
</tr>
<tr style="height: 1em;"/>
<tr>
<td class="statLabel">&stats.activity;</td>
<td class="statValue activity">
<span class="statActivity">
<span class="statActivityPaused">&stats.activityPaused;</span>
<span class="statActivityPlaying">&stats.activityPlaying;</span>
<span class="statActivityEnded">&stats.activityEnded;</span>
<span class="statActivitySeeking">&stats.activitySeeking;</span>
</span>
</td>
</tr>
<tr>
<td class="statLabel">&stats.volume;</td> <td class="statValue"><span class="statVolume"/></td>
</tr>
<tr>
<!-- Localization note: readyState is a HTML5 API MediaElement-specific attribute and should not be localized. -->
<td class="statLabel">readyState</td> <td class="statValue"><span class="statReadyState"/></td>
</tr>
<tr>
<!-- Localization note: networkState is a HTML5 API MediaElement-specific attribute and should not be localized. -->
<td class="statLabel">networkState</td> <td class="statValue"><span class="statNetState"/></td>
</tr>
<tr style="height: 1em;"/>
<tr>
<td class="statLabel">&stats.framesParsed;</td>
<td class="statValue"><span class="statFramesParsed"/></td>
</tr>
<tr>
<td class="statLabel">&stats.framesDecoded;</td>
<td class="statValue"><span class="statFramesDecoded"/></td>
</tr>
<tr>
<td class="statLabel">&stats.framesPresented;</td>
<td class="statValue"><span class="statFramesPresented"/></td>
</tr>
<tr>
<td class="statLabel">&stats.framesPainted;</td>
<td class="statValue"><span class="statFramesPainted"/></td>
</tr>
</table>
</html:div>
</vbox>
<vbox class="controlsOverlay">
<stack flex="1">
<spacer class="controlsSpacer" flex="1"/>
@ -327,7 +270,6 @@
statusOverlay : null,
controlsSpacer : null,
clickToPlay : null,
stats : {},
controlsOverlay : null,
fullscreenButton : null,
@ -474,13 +416,6 @@
// _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() {
@ -503,12 +438,6 @@
this.startFade(this.controlBar, shouldShow, true);
},
handleCustomEvents : function (e) {
if (!e.isTrusted)
return;
this.showStatistics(e.detail);
},
get dynamicControls() {
// Don't fade controls for <audio> elements.
var enabled = !this.isAudioOnly;
@ -702,10 +631,6 @@
},
terminateEventListeners : function () {
if (this.statsInterval) {
clearInterval(this.statsInterval);
this.statsInterval = null;
}
for (let event of this.videoEvents)
this.video.removeEventListener(event, this, false);
@ -714,9 +639,6 @@
delete this.controlListeners;
this.video.removeEventListener("media-showStatistics", this._handleCustomEventsBound, false);
delete this._handleCustomEventsBound;
this.log("--- videocontrols terminated ---");
},
@ -1172,91 +1094,6 @@
return parseInt(value, 10);
},
STATS_INTERVAL_MS : 500,
statsInterval : null,
showStatistics : function(shouldShow) {
if (this.statsInterval) {
clearInterval(this.statsInterval);
this.statsInterval = null;
}
if (shouldShow) {
this.video.mozMediaStatisticsShowing = true;
this.statsOverlay.hidden = false;
this.statsInterval = setInterval(this.updateStats.bind(this), this.STATS_INTERVAL_MS);
this.updateStats();
} else {
this.video.mozMediaStatisticsShowing = false;
this.statsOverlay.hidden = true;
}
},
updateStats : function() {
if (this.videocontrols.randomID != this.randomID) {
this.terminateEventListeners();
return;
}
let v = this.video;
let s = this.stats;
let src = v.currentSrc || v.src || "(no source found)";
let srcParts = src.split('/');
let srcIdx = srcParts.length - 1;
if (src.lastIndexOf('/') == src.length - 1)
srcIdx--;
s.filename.textContent = decodeURI(srcParts[srcIdx]);
let size = v.videoWidth + "x" + v.videoHeight;
if (this._getComputedPropertyValueAsInt(this.video, "width") != v.videoWidth || this._getComputedPropertyValueAsInt(this.video, "height") != v.videoHeight)
size += " scaled to " + this._getComputedPropertyValueAsInt(this.video, "width") + "x" + this._getComputedPropertyValueAsInt(this.video, "height");
s.size.textContent = size;
let activity;
if (v.paused)
activity = "paused";
else
activity = "playing";
if (v.ended)
activity = "ended";
if (s.activity.getAttribute("activity") != activity)
s.activity.setAttribute("activity", activity);
if (v.seeking && !s.activity.hasAttribute("seeking"))
s.activity.setAttribute("seeking", true);
else if (s.activity.hasAttribute("seeking"))
s.activity.removeAttribute("seeking");
let readyState = v.readyState;
switch (readyState) {
case v.HAVE_NOTHING: readyState = "HAVE_NOTHING"; break;
case v.HAVE_METADATA: readyState = "HAVE_METADATA"; break;
case v.HAVE_CURRENT_DATA: readyState = "HAVE_CURRENT_DATA"; break;
case v.HAVE_FUTURE_DATA: readyState = "HAVE_FUTURE_DATA"; break;
case v.HAVE_ENOUGH_DATA: readyState = "HAVE_ENOUGH_DATA"; break;
}
s.readyState.textContent = readyState;
let networkState = v.networkState;
switch (networkState) {
case v.NETWORK_EMPTY: networkState = "NETWORK_EMPTY"; break;
case v.NETWORK_IDLE: networkState = "NETWORK_IDLE"; break;
case v.NETWORK_LOADING: networkState = "NETWORK_LOADING"; break;
case v.NETWORK_NO_SOURCE: networkState = "NETWORK_NO_SOURCE"; break;
}
s.netState.textContent = networkState;
s.framesParsed.textContent = v.mozParsedFrames;
s.framesDecoded.textContent = v.mozDecodedFrames;
s.framesPresented.textContent = v.mozPresentedFrames;
s.framesPainted.textContent = v.mozPaintedFrames;
let volume = Math.round(v.volume * 100) + "%";
if (v.muted)
volume += " (muted)";
s.volume.textContent = volume;
},
keyHandler : function(event) {
// Ignore keys when content might be providing its own.
if (!this.video.hasAttribute("controls"))
@ -1476,25 +1313,12 @@
this.durationLabel = document.getAnonymousElementByAttribute(binding, "class", "durationLabel");
this.positionLabel = document.getAnonymousElementByAttribute(binding, "class", "positionLabel");
this.statusOverlay = document.getAnonymousElementByAttribute(binding, "class", "statusOverlay");
this.statsOverlay = document.getAnonymousElementByAttribute(binding, "class", "statsOverlay");
this.controlsOverlay = document.getAnonymousElementByAttribute(binding, "class", "controlsOverlay");
this.controlsSpacer = document.getAnonymousElementByAttribute(binding, "class", "controlsSpacer");
this.clickToPlay = document.getAnonymousElementByAttribute(binding, "class", "clickToPlay");
this.fullscreenButton = document.getAnonymousElementByAttribute(binding, "class", "fullscreenButton");
this.volumeForeground = document.getAnonymousElementByAttribute(binding, "anonid", "volumeForeground");
this.statsTable = document.getAnonymousElementByAttribute(binding, "class", "statsTable");
this.stats.filename = document.getAnonymousElementByAttribute(binding, "class", "statFilename");
this.stats.size = document.getAnonymousElementByAttribute(binding, "class", "statSize");
this.stats.activity = document.getAnonymousElementByAttribute(binding, "class", "statActivity");
this.stats.volume = document.getAnonymousElementByAttribute(binding, "class", "statVolume");
this.stats.readyState = document.getAnonymousElementByAttribute(binding, "class", "statReadyState");
this.stats.netState = document.getAnonymousElementByAttribute(binding, "class", "statNetState");
this.stats.framesParsed = document.getAnonymousElementByAttribute(binding, "class", "statFramesParsed");
this.stats.framesDecoded = document.getAnonymousElementByAttribute(binding, "class", "statFramesDecoded");
this.stats.framesPresented = document.getAnonymousElementByAttribute(binding, "class", "statFramesPresented");
this.stats.framesPainted = document.getAnonymousElementByAttribute(binding, "class", "statFramesPainted");
this.isAudioOnly = (this.video instanceof HTMLAudioElement);
this.setupInitialState();
this.setupNewLoadState();