Closed Bug 1716675 Opened 4 years ago Closed 4 years ago

audio element without control should be display:none even if we set display to other values

Categories

(Core :: Layout, defect, P3)

All
Unspecified
defect

Tracking

()

RESOLVED FIXED
91 Branch
Tracking Status
firefox91 --- fixed

People

(Reporter: boris, Assigned: boris)

References

Details

Attachments

(3 files, 1 obsolete file)

For example:

<audio style="width: 100px; height: 100px; background: green; display: block;"> </audio>

We see a 100x100 green box now on Firefox because the display:block overrides the display:none which defined in layout/style/res/html.css. In Chrome (and Safari), they define this with !important [1], so the user cannot override it by non-important rule. Perhaps we should do the similar thing.

[1] https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/core/html/resources/html.css;l=164-166?q=audio:not&ss=chromium%2Fchromium%2Fsrc

Attachment #9227306 - Attachment is obsolete: true
Attached file test.html
See Also: → 1716612

Reference: https://html.spec.whatwg.org/multipage/rendering.html#embedded-content-rendering-rules

The audio element, when it is exposing a user interface, is expected to be treated as a replaced element about one line high, as wide as is necessary to expose the user agent's user interface features. When an audio element is not exposing a user interface, the user agent is expected to force its 'display' property to compute to 'none', irrespective of CSS rules.

If the audio element doesn't have control, it is not exposing a user
interface, so the user agent is expected to force its display property
to compute to none, irrespective fo CSS rules.

https://html.spec.whatwg.org/multipage/rendering.html#embedded-content-rendering-rules

Assignee: nobody → boris.chiou
Status: NEW → ASSIGNED
Attachment #9227555 - Attachment description: Bug 1716675 - Set 'display:none' with important rule for audio element without control. → Bug 1716675 - Set 'display:none' with important rule for audio element without controls.

Hmm, I dislike !important in UA sheets in general. It's against web platform design principles for user agent implementors to impose UA declarations that cannot be overridden by authors. We should only do that if we have extremely good reasons to do so, e.g. security/privacy issues or "impossible to implement" etc.

That said, the HTML spec does indeed call for this behavior:

When an audio element is not exposing a user interface, the user agent is expected to force its 'display' property to compute to 'none', irrespective of CSS rules.

https://html.spec.whatwg.org/multipage/rendering.html#embedded-content-rendering-rules

Does anyone know how that formulation came to be in the spec? If the justification for it is weak, then perhaps we should argue for it to be removed and ask other UAs to remove !important in their UA sheets?

Personally, I don't see why <audio> should be special in this regard. We allow display:block on a <video> element in the same situation for example.

Anne, do you happen to know the discussion behind the spec text here?

Depends on: 449149

I found https://github.com/whatwg/html/commit/e6d0ca64f275c83fc094eef544ec5afc3b3a3e80 (I think gow stands for Gecko / Opera / WebKit being impacted, but not sure), but no context unfortunately. There are other things the HTML standard uses !important for so I don't feel too strongly about this, but I also wouldn't be opposed to it being changed if everyone can agree on that.

There are other things the HTML standard uses !important for ...

In my experience, !important in UA sheets are pretty much always misguided and unnecessary. And this is one example of that.

That said, I don't feel that strongly about this particular case given that it's been in the spec for over a decade...

I see. Thanks for all the information and suggestion. I'd keep this bug for tracking and not land these patches for now.

Attachment #9227555 - Attachment is obsolete: true
Attachment #9227568 - Attachment is obsolete: true
Assignee: boris.chiou → nobody
Status: ASSIGNED → NEW

Well, we should either land this or file an issue against the HTML Standard and reach out to other implementers, right? As long as they do not change anything here, there's a potential for this to result in compatibility issues.

I agree. We should probably just land it. Given that the spec change happened more than a decade ago, I doubt other vendors would be willing to change this.

ni=boris to proceed here, per recent comments.

Flags: needinfo?(boris.chiou)
Assignee: nobody → boris.chiou
Attachment #9227555 - Attachment is obsolete: false
Status: NEW → ASSIGNED
Attachment #9227568 - Attachment is obsolete: false

I see. Let's just land this.

Flags: needinfo?(boris.chiou)
Attachment #9227568 - Attachment description: Bug 1716675 - Move Gecko's internal tests of audio with controls into wpts. → Bug 1716675 - Move Gecko's internal tests of audio with controls into wpt.
Pushed by bchiou@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/041fb25cf007 Set 'display:none' with important rule for audio element without controls. r=emilio https://hg.mozilla.org/integration/autoland/rev/9c31f03fa2ba Move Gecko's internal tests of audio with controls into wpt. r=emilio
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/29449 for changes under testing/web-platform/tests

Backed out 2 changesets (Bug 1716675) for causing mochitest failures on test_group_touchevents-2.html.
Backout link
Push with failures
Failure Log

Flags: needinfo?(boris.chiou)
Upstream PR was closed without merging

Looks like we have to update the subtests in test_group_touchevents-2.html.

Flags: needinfo?(boris.chiou)
Pushed by bchiou@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/088b8c8940cd Set 'display:none' with important rule for audio element without controls. r=emilio,botond https://hg.mozilla.org/integration/autoland/rev/981d6d4958c4 Move Gecko's internal tests of audio with controls into wpt. r=emilio
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → 91 Branch
Upstream PR merged by moz-wptsync-bot
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: