Bug 1347791 - part1 : rename the attribute for the tab which has blocked the autoplay audio and would show the play-tab icon. r=mikedeboer

The "blocked" attribute is too general to indicate the real usage, so rename it
to "activemedia-blocked".

This attribute indicates that whether the tab has blocked the autoplay media.

MozReview-Commit-ID: 58U7DJSMtss

--HG--
extra : rebase_source : 762bfd2be06e21a964fd93076867b4f72a085adc
This commit is contained in:
Alastor Wu 2017-06-29 04:48:38 -07:00
Родитель 6010728f95
Коммит ade6cb9314
5 изменённых файлов: 32 добавлений и 37 удалений

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

@ -8320,7 +8320,7 @@ var TabContextMenu = {
// Adjust the state of the toggle mute menu item. // Adjust the state of the toggle mute menu item.
let toggleMute = document.getElementById("context_toggleMuteTab"); let toggleMute = document.getElementById("context_toggleMuteTab");
if (this.contextTab.hasAttribute("blocked")) { if (this.contextTab.hasAttribute("activemedia-blocked")) {
toggleMute.label = gNavigatorBundle.getString("playTab.label"); toggleMute.label = gNavigatorBundle.getString("playTab.label");
toggleMute.accessKey = gNavigatorBundle.getString("playTab.accesskey"); toggleMute.accessKey = gNavigatorBundle.getString("playTab.accesskey");
} else if (this.contextTab.hasAttribute("muted")) { } else if (this.contextTab.hasAttribute("muted")) {

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

@ -24,7 +24,7 @@
.tab-icon-image:not([src]):not([pinned]):not([crashed]):not([sharing]), .tab-icon-image:not([src]):not([pinned]):not([crashed]):not([sharing]),
.tab-icon-image[busy], .tab-icon-image[busy],
.tab-throbber:not([busy]), .tab-throbber:not([busy]),
.tab-icon-sound:not([soundplaying]):not([muted]):not([blocked]), .tab-icon-sound:not([soundplaying]):not([muted]):not([activemedia-blocked]),
.tab-icon-sound[pinned], .tab-icon-sound[pinned],
.tab-sharing-icon-overlay, .tab-sharing-icon-overlay,
.tab-icon-overlay { .tab-icon-overlay {
@ -34,7 +34,7 @@
.tab-sharing-icon-overlay[sharing]:not([selected]), .tab-sharing-icon-overlay[sharing]:not([selected]),
.tab-icon-overlay[soundplaying][pinned], .tab-icon-overlay[soundplaying][pinned],
.tab-icon-overlay[muted][pinned], .tab-icon-overlay[muted][pinned],
.tab-icon-overlay[blocked][pinned], .tab-icon-overlay[activemedia-blocked][pinned],
.tab-icon-overlay[crashed] { .tab-icon-overlay[crashed] {
display: -moz-box; display: -moz-box;
} }

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

@ -5740,9 +5740,9 @@
return; return;
} }
if (!tab.hasAttribute("blocked")) { if (!tab.hasAttribute("activemedia-blocked")) {
tab.setAttribute("blocked", true); tab.setAttribute("activemedia-blocked", true);
this._tabAttrModified(tab, ["blocked"]); this._tabAttrModified(tab, ["activemedia-blocked"]);
tab.startMediaBlockTimer(); tab.startMediaBlockTimer();
} }
]]> ]]>
@ -5754,9 +5754,9 @@
return; return;
} }
if (tab.hasAttribute("blocked")) { if (tab.hasAttribute("activemedia-blocked")) {
tab.removeAttribute("blocked"); tab.removeAttribute("activemedia-blocked");
this._tabAttrModified(tab, ["blocked"]); this._tabAttrModified(tab, ["activemedia-blocked"]);
let hist = Services.telemetry.getHistogramById("TAB_AUDIO_INDICATOR_USED"); let hist = Services.telemetry.getHistogramById("TAB_AUDIO_INDICATOR_USED");
hist.add(2 /* unblockByVisitingTab */); hist.add(2 /* unblockByVisitingTab */);
tab.finishMediaBlockTimer(); tab.finishMediaBlockTimer();
@ -7352,7 +7352,7 @@
anonid="sharing-icon" anonid="sharing-icon"
class="tab-sharing-icon-overlay" class="tab-sharing-icon-overlay"
role="presentation"/> role="presentation"/>
<xul:image xbl:inherits="crashed,busy,soundplaying,soundplaying-scheduledremoval,pinned,muted,blocked,selected=visuallyselected" <xul:image xbl:inherits="crashed,busy,soundplaying,soundplaying-scheduledremoval,pinned,muted,blocked,selected=visuallyselected,activemedia-blocked"
anonid="overlay-icon" anonid="overlay-icon"
class="tab-icon-overlay" class="tab-icon-overlay"
role="presentation"/> role="presentation"/>
@ -7365,7 +7365,7 @@
xbl:inherits="xbl:text=label,accesskey,fadein,pinned,selected=visuallyselected,attention" xbl:inherits="xbl:text=label,accesskey,fadein,pinned,selected=visuallyselected,attention"
role="presentation"/> role="presentation"/>
</xul:hbox> </xul:hbox>
<xul:image xbl:inherits="soundplaying,soundplaying-scheduledremoval,pinned,muted,blocked,selected=visuallyselected" <xul:image xbl:inherits="soundplaying,soundplaying-scheduledremoval,pinned,muted,blocked,selected=visuallyselected,activemedia-blocked"
anonid="soundplaying-icon" anonid="soundplaying-icon"
class="tab-icon-sound" class="tab-icon-sound"
role="presentation"/> role="presentation"/>
@ -7438,11 +7438,6 @@
return this.getAttribute("muted") == "true"; return this.getAttribute("muted") == "true";
</getter> </getter>
</property> </property>
<property name="blocked" readonly="true">
<getter>
return this.getAttribute("blocked") == "true";
</getter>
</property>
<!-- <!--
Describes how the tab ended up in this mute state. May be any of: Describes how the tab ended up in this mute state. May be any of:
@ -7467,9 +7462,9 @@
</getter> </getter>
</property> </property>
<property name="soundBlocked" readonly="true"> <property name="activeMediaBlocked" readonly="true">
<getter> <getter>
return this.getAttribute("blocked") == "true"; return this.getAttribute("activemedia-blocked") == "true";
</getter> </getter>
</property> </property>
@ -7490,7 +7485,7 @@
<getter><![CDATA[ <getter><![CDATA[
let iconVisible = this.hasAttribute("soundplaying") || let iconVisible = this.hasAttribute("soundplaying") ||
this.hasAttribute("muted") || this.hasAttribute("muted") ||
this.hasAttribute("blocked"); this.hasAttribute("activemedia-blocked");
let soundPlayingIcon = let soundPlayingIcon =
document.getAnonymousElementByAttribute(this, "anonid", "soundplaying-icon"); document.getAnonymousElementByAttribute(this, "anonid", "soundplaying-icon");
let overlayIcon = let overlayIcon =
@ -7588,8 +7583,8 @@
let hist = Services.telemetry.getHistogramById("TAB_AUDIO_INDICATOR_USED"); let hist = Services.telemetry.getHistogramById("TAB_AUDIO_INDICATOR_USED");
if (browser.audioBlocked) { if (browser.audioBlocked) {
this.removeAttribute("blocked"); this.removeAttribute("activemedia-blocked");
modifiedAttrs.push("blocked"); modifiedAttrs.push("activemedia-blocked");
browser.resumeMedia(); browser.resumeMedia();
hist.add(3 /* unblockByClickingIcon */); hist.add(3 /* unblockByClickingIcon */);

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

@ -143,13 +143,13 @@
.tab-icon-overlay[soundplaying], .tab-icon-overlay[soundplaying],
.tab-icon-overlay[muted]:not([crashed]), .tab-icon-overlay[muted]:not([crashed]),
.tab-icon-overlay[blocked]:not([crashed]) { .tab-icon-overlay[activemedia-blocked]:not([crashed]) {
border-radius: 10px; border-radius: 10px;
} }
.tab-icon-overlay[soundplaying]:hover, .tab-icon-overlay[soundplaying]:hover,
.tab-icon-overlay[muted]:not([crashed]):hover, .tab-icon-overlay[muted]:not([crashed]):hover,
.tab-icon-overlay[blocked]:not([crashed]):hover { .tab-icon-overlay[activemedia-blocked]:not([crashed]):hover {
background-color: white; background-color: white;
} }
@ -161,7 +161,7 @@
list-style-image: url("chrome://browser/skin/tabbrowser/tab-audio-small.svg#tab-audio-muted"); list-style-image: url("chrome://browser/skin/tabbrowser/tab-audio-small.svg#tab-audio-muted");
} }
.tab-icon-overlay[blocked]:not([crashed]) { .tab-icon-overlay[activemedia-blocked]:not([crashed]) {
list-style-image: url("chrome://browser/skin/tabbrowser/tab-audio-small.svg#tab-audio-blocked"); list-style-image: url("chrome://browser/skin/tabbrowser/tab-audio-small.svg#tab-audio-blocked");
} }
@ -175,8 +175,8 @@
list-style-image: url("chrome://browser/skin/tabbrowser/tab-audio-small.svg#tab-audio-white-muted"); list-style-image: url("chrome://browser/skin/tabbrowser/tab-audio-small.svg#tab-audio-white-muted");
} }
#TabsToolbar[brighttext] .tab-icon-overlay[blocked]:not([crashed]):not([selected]):not(:hover), #TabsToolbar[brighttext] .tab-icon-overlay[activemedia-blocked]:not([crashed]):not([selected]):not(:hover),
.tab-icon-overlay[blocked][selected]:-moz-lwtheme-brighttext:not(:hover) { .tab-icon-overlay[activemedia-blocked][selected]:-moz-lwtheme-brighttext:not(:hover) {
list-style-image: url("chrome://browser/skin/tabbrowser/tab-audio-small.svg#tab-audio-white-blocked"); list-style-image: url("chrome://browser/skin/tabbrowser/tab-audio-small.svg#tab-audio-white-blocked");
} }
@ -208,7 +208,7 @@
.tab-icon-sound[soundplaying], .tab-icon-sound[soundplaying],
.tab-icon-sound[muted], .tab-icon-sound[muted],
.tab-icon-sound[blocked] { .tab-icon-sound[activemedia-blocked] {
list-style-image: url(chrome://browser/skin/tabbrowser/tab-audio-playing.svg); list-style-image: url(chrome://browser/skin/tabbrowser/tab-audio-playing.svg);
-moz-context-properties: fill; -moz-context-properties: fill;
fill: currentColor; fill: currentColor;
@ -218,25 +218,25 @@
list-style-image: url(chrome://browser/skin/tabbrowser/tab-audio-muted.svg); list-style-image: url(chrome://browser/skin/tabbrowser/tab-audio-muted.svg);
} }
.tab-icon-sound[blocked] { .tab-icon-sound[activemedia-blocked] {
list-style-image: url(chrome://browser/skin/tabbrowser/tab-audio-blocked.svg); list-style-image: url(chrome://browser/skin/tabbrowser/tab-audio-blocked.svg);
} }
.tab-icon-sound:-moz-lwtheme-darktext[soundplaying], .tab-icon-sound:-moz-lwtheme-darktext[soundplaying],
.tab-icon-sound:-moz-lwtheme-darktext[muted], .tab-icon-sound:-moz-lwtheme-darktext[muted],
.tab-icon-sound:-moz-lwtheme-darktext[blocked] { .tab-icon-sound:-moz-lwtheme-darktext[activemedia-blocked] {
filter: drop-shadow(1px 1px 1px white); filter: drop-shadow(1px 1px 1px white);
} }
.tab-icon-sound:-moz-lwtheme-brighttext[soundplaying], .tab-icon-sound:-moz-lwtheme-brighttext[soundplaying],
.tab-icon-sound:-moz-lwtheme-brighttext[muted], .tab-icon-sound:-moz-lwtheme-brighttext[muted],
.tab-icon-sound:-moz-lwtheme-brighttext[blocked] { .tab-icon-sound:-moz-lwtheme-brighttext[activemedia-blocked] {
filter: drop-shadow(1px 1px 1px black); filter: drop-shadow(1px 1px 1px black);
} }
.tab-icon-sound[soundplaying]:not(:hover), .tab-icon-sound[soundplaying]:not(:hover),
.tab-icon-sound[muted]:not(:hover), .tab-icon-sound[muted]:not(:hover),
.tab-icon-sound[blocked]:not(:hover) { .tab-icon-sound[activemedia-blocked]:not(:hover) {
opacity: .8; opacity: .8;
} }
@ -455,7 +455,7 @@
.tabs-newtab-button, .tabs-newtab-button,
.tab-icon-overlay[soundplaying], .tab-icon-overlay[soundplaying],
.tab-icon-overlay[muted]:not([crashed]), .tab-icon-overlay[muted]:not([crashed]),
.tab-icon-overlay[blocked]:not([crashed]), .tab-icon-overlay[activemedia-blocked]:not([crashed]),
.tab-icon-sound, .tab-icon-sound,
.tab-close-button { .tab-close-button {
pointer-events: auto; pointer-events: auto;
@ -591,7 +591,7 @@
.alltabs-endimage[soundplaying], .alltabs-endimage[soundplaying],
.alltabs-endimage[muted], .alltabs-endimage[muted],
.alltabs-endimage[blocked] { .alltabs-endimage[activemedia-blocked] {
list-style-image: url(chrome://browser/skin/tabbrowser/tab-audio-playing.svg); list-style-image: url(chrome://browser/skin/tabbrowser/tab-audio-playing.svg);
-moz-context-properties: fill; -moz-context-properties: fill;
fill: currentColor; fill: currentColor;
@ -601,7 +601,7 @@
list-style-image: url(chrome://browser/skin/tabbrowser/tab-audio-muted.svg); list-style-image: url(chrome://browser/skin/tabbrowser/tab-audio-muted.svg);
} }
.alltabs-endimage[blocked] { .alltabs-endimage[activemedia-blocked] {
list-style-image: url(chrome://browser/skin/tabbrowser/tab-audio-blocked.svg); list-style-image: url(chrome://browser/skin/tabbrowser/tab-audio-blocked.svg);
} }

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

@ -34,13 +34,13 @@ function pushPrefs(...aPrefs) {
* Used to check whether the audio unblocking icon is in the tab. * Used to check whether the audio unblocking icon is in the tab.
*/ */
async function waitForTabBlockEvent(tab, expectBlocked) { async function waitForTabBlockEvent(tab, expectBlocked) {
if (tab.soundBlocked == expectBlocked) { if (tab.activeMediaBlocked == expectBlocked) {
ok(true, "The tab should " + (expectBlocked ? "" : "not ") + "be blocked"); ok(true, "The tab should " + (expectBlocked ? "" : "not ") + "be blocked");
} else { } else {
info("Block state doens't match, wait for attributes changes."); info("Block state doens't match, wait for attributes changes.");
await BrowserTestUtils.waitForEvent(tab, "TabAttrModified", false, (event) => { await BrowserTestUtils.waitForEvent(tab, "TabAttrModified", false, (event) => {
if (event.detail.changed.indexOf("blocked") >= 0) { if (event.detail.changed.indexOf("activemedia-blocked") >= 0) {
is(tab.soundBlocked, expectBlocked, "The tab should " + (expectBlocked ? "" : "not ") + "be blocked"); is(tab.activeMediaBlocked, expectBlocked, "The tab should " + (expectBlocked ? "" : "not ") + "be blocked");
return true; return true;
} }
return false; return false;