Skip to content

[css-display] Define interaction of display:contents and replaced elements #540

Closed

Description

@zcorpan

https://drafts.csswg.org/css-display/#box-generation

w3c/csswg-test#1129

It was not clear to me from the spec what the expected result of applying display:contents to replaced elements is. The added test for replace contents matches what Gecko implemented.

The implemented behavior seems to be that display:contents on replaced elements and form controls (not all of those are actually replaced elements) is ignored, as far as I can tell.

cc @rune-opera @tabatkins @fantasai

Activity

  1. MatsPalmgren commented on Sep 28, 2016

    @MatsPalmgren

    We ignore display:contents in a few cases where it doesn't make sense, such as
    for replaced elements. (I can dig up the exact conditions if you need it.)

    So I think this change is basically wrong:
    c65b958
    rather than referring to literal display values, it would be better to use more general terms,
    e.g. "when the element has a principal box, use its size, otherwise use the computed value"

  2. fantasai commented on Jan 24, 2017

    @fantasai
    Collaborator

    The CSSWG decided to treat display: contents as display: inline on replaced elements and form controls. Edited in c588376 by making it compute to inline on such elements. Please let me know if you'd rather do something more magical.

  3. zcorpan commented on Jan 25, 2017

    @zcorpan
    ContributorAuthor

    LGTM

  4. MatsPalmgren commented on Feb 10, 2017

    @MatsPalmgren

    I fully agree with bz in #1024 (comment)

    The spec should say that contents computes to contents but the used value is inline for these elements.

    In general, adding new spec language that makes a computed value depend on layout stuff such as box construction is pretty much always bad.

  5. tabatkins commented on Feb 22, 2017

    @tabatkins
    Member

    WG discussed this today.

    Problem with making it "behaves as" is that there are plenty of other properties that care about the box that the element will generate; it's generally very significant whether something generates an inline, block, or no box at all. So we can't just push this to used-value with the "behaves as" language; this is fundamentally a computed-value issue.

    So impls either need to bite the bullet and allow this computed value to depend on form-control-ness (as, according to François, Firefox already does?), or shoot for a simpler resolution, like making display:contents suppress the box like normal (and, as a side-effect of being a form control, and thus half-replaced, also suppress its children's boxes, like display:none).

  6. 37 remaining items

  7. AmeliaBR commented on Mar 16, 2017

    @AmeliaBR
    Contributor

    the contents of progress/meter are fallback content, exposed to the a11y tree

    Not really, see: https://w3c.github.io/html-aam/#el-progress

    Although there's still open debate about how best to expose meter as something different from progress, they are both expected to be exposed as atomic widgets, with the actual numerical properties mapped to the accessibility API equivalents. The text content wouldn't be exposed through the API in a supporting browser. It's only there for older browsers.

    And embed/applet, I think.

    Yes for applet (I had to look it up, it works like object). No for embed (which is void, no child/fallback).

    But regardless, my main point was : ideally, try to be as consistent as possible, rather than special rules for each different element type. But I recognize that we don't live in an ideal world.

  8. astearns commented on May 2, 2017

    @astearns
    Member

    We went through the issue list in the new section at the Tokyo meeting. If there's anything remaining to go over, please re-add the agenda+ tag.

  9. tabatkins commented on May 15, 2017

    @tabatkins
    Member

    We edited in all the f2f resolutions.

    Please let us know if this is satisfactory, or if further work is required. A response would be appreciated @zcorpan @AmeliaBR @bzbarsky

  10. bzbarsky commented on May 16, 2017

    @bzbarsky

    Delegating to @MatsPalmgren.

  11. zcorpan commented on May 16, 2017

    @zcorpan
    ContributorAuthor

    I discussed with @rune-opera, at first we thought object and img could show the children when they're not replaced elements. But object loading depends on the style of the element -- it doesn't load for display:none. So then it could be a new race condition (if the style is async-loaded in some manner, which I believe is something web devs do these days) and be pretty confusing for object, if it ends up as display:none or rendering the children. So always display:none does seem better.

    So LGTM for resolving this bug. Further work could include upstreaming some of the logic to HTML, writing web-platform-tests, filing browser bugs... 😊

  12. bzbarsky commented on May 16, 2017

    @bzbarsky

    io then it could be a new race condition (if the style is async-loaded in some manner

    @zcorpan I'm not sure I follow. What sort of style are you envisioning async-loading?

  13. zcorpan commented on May 16, 2017

    @zcorpan
    ContributorAuthor
  14. bzbarsky commented on May 16, 2017

    @bzbarsky

    Yes, I understand what async-loading is. What I'm not sure is what you think is racing against what. As in, what specific rules are being async-loaded, and what does the DOM look like?

  15. zcorpan commented on May 16, 2017

    @zcorpan
    ContributorAuthor

    Oh, ok.

    If the behavior of display: contents were to act like display: none when object is a replaced element but render the children when object is showing fallback, then the end result would depend on which happens first: loading of the resource vs. applying the style. If it's first loaded, then the end result would be display: none. If the style is applied first, then the object element doesn't generate a box, so it's not "being rendered", and thus doesn't load anything, but continues to render the children.

    http://software.hixie.ch/utilities/js/live-dom-viewer/saved/5186 for object first
    http://software.hixie.ch/utilities/js/live-dom-viewer/saved/5187 for style first

  16. bzbarsky commented on May 17, 2017

    @bzbarsky

    Hmm. Do UAs actually implement that "being rendered" requirement across the board? I'm pretty sure Gecko doesn't unless the type is a plug-in type (and even then, I think it may only affect plug-in instantiation, not the actual load, since the type is not known until you do the load), so both your testcases render the image in Gecko.

    Per the letter of the spec, every time an , or any ancestor, gets toggled to display:none and back it should redo the fetch for its data attribute, which seems like a really weird behavior. I filed whatwg/html#2692

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions