Make muted content attribute affect muted IDL attribute only once#12473
Make muted content attribute affect muted IDL attribute only once#12473foolip wants to merge 1 commit into
Conversation
|
What do implementations do today? I'm pretty sure WebKit doesn't have a "set once" special case. |
|
Chromium reacts to Gecko seems to look at the WebKit has a tri-state optional bool |
|
For Gecko, the |
|
I see, perhaps observing the That would require changing the |
The purpose of this is to limit the cases where the muted IDL attribute can change without a volumechange event firing. The notion that user agents may remember volume and muted is removed as it would require additional muted states to handle correctly, but could be reinstated if there is implementer interest.
|
@annevk that works for me, I've updated this PR and tests in https://crrev.com/c/7857861 to match. |
annevk
left a comment
There was a problem hiding this comment.
What about the WebKit case of taking the muted content attribute into account when loading a new media resource?
| data-x="">default</code>". User agents may <span>set the muted state</span> of a <span>media | ||
| element</span> to true or false (e.g., remembering the last set value across sessions, on a | ||
| per-site basis or otherwise).</p> | ||
| state</dfn>, which is either true, false, or unset; it is initially unset.</p> |
There was a problem hiding this comment.
Why not keep "default" here? We don't really have precedence for "unset" as a standalone value.
There was a problem hiding this comment.
I'm also wondering why we'd remove the allowance for user agents changing this state on behalf of the user. Isn't that needed?
There was a problem hiding this comment.
I could keep it since it's not observable, any third state would do. But it doesn't line up defaultMuted any longer, in fact muted takes on the value of defaultMuted only when muted state is longer "default". How about "initial"?
I removed the allowance because I think no browser implements this and it would need a "remembered unmuted" state to prevent the muted content attribute from affecting .muted on insertion. But I can put it back and implementations can add whatever additional state they need to make it work.
| <p>A <span>media element</span> has a <dfn data-x="concept-media-volume">playback volume</dfn>, which is a fraction in the range 0.0 (silent) to 1.0 (loudest). | ||
| Initially, the volume should be 1.0, but user agents may remember the last set value across | ||
| sessions, on a per-site basis or otherwise, so the volume may start at other values.</p> | ||
| Initially, the volume should be 1.0.</p> |
There was a problem hiding this comment.
Why lose the language on letting it be configurable?
There was a problem hiding this comment.
I suspect it's spec fiction, but will put it back.
| <li> | ||
| <p>If <var>insertedNode</var> has a <code data-x="attr-media-muted">muted</code> attribute, | ||
| then set <var>insertedNode</var>'s <span data-x="concept-media-muted-state">muted state</span> | ||
| to true.</p> |
There was a problem hiding this comment.
Should we only set it to true if it's "default"?
There was a problem hiding this comment.
Oops, this is essential for the "only once" part. I think it's also what WebKit does, so I'd like to change this to match.
I'll just note that there's also the option of always setting the muted state on insertion if muted state is "default", so that after the first insertion it's always true or false. The difference would be when inserting an element, adding the muted content attributes, and then inserting the element somewhere else. I'm not sure there's any point in having the muted content attribute have an effect on that second insertion, so maybe we change "default" to "initial" and it only stays in that state until the first insertion? It's effectively a "has ever been inserted" flag. WDYT?
There was a problem hiding this comment.
In https://crrev.com/c/7857861 I have gone the route of always updating the muted state is post-insertion steps if muted was unset. I'll do that in the spec.
| data-x="dom-media-muted">muted</code> IDL attribute has changed. Fired after the relevant | ||
| attribute's setter has returned. The event is not fired in response to changes to <code | ||
| data-x="dom-media-playbackRate">playbackRate</code> or when inserting the element, even if | ||
| the <code data-x="dom-media-muted">muted</code> IDL attribute changes in response. |
There was a problem hiding this comment.
Since this is non-normative I'm not sure we should elaborate on all the ins and outs. That might make people think these are the actual requirements.
| <li> | ||
| <p>If <var>insertedNode</var> has a <code data-x="attr-media-muted">muted</code> attribute, | ||
| then set <var>insertedNode</var>'s <span data-x="concept-media-muted-state">muted state</span> | ||
| to true.</p> |
There was a problem hiding this comment.
What does this all mean with audio which works somewhat fine whether or not it is ever connected.
There was a problem hiding this comment.
The muted content attribute would have no effect on such an audio element. That's the same as the current behavior, AFAICT no browser would mute in this situation:
var a = document.createElement('audio')`;
a.setAttribute('muted', '');
a.src = '...';
a.play();If such code exists, it's silly but would continue to work.
There was a problem hiding this comment.
But if you create the audio element using innerHTML (on a disconnected element) and it has muted attribute, both Firefox and Chrome keep it muted.
The purpose of this is to limit the cases where the muted IDL attribute
can change without a volumechange event firing.
The notion that user agents may remember volume and muted is removed as
it would require additional muted states to handle correctly, but could
be reinstated if there is implementer interest.
(See WHATWG Working Mode: Changes for more details.)
/media.html ( diff )