Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cssom] Resolved value for width et al should be computed value for display:contents #482

Open
ghost opened this issue Sep 14, 2016 · 6 comments
Labels
cssom-1 Current Work

Comments

@ghost
Copy link

ghost commented Sep 14, 2016

The CSSOM spec currently says this should be the case for display:none. Should probably be the same for display:contents.

@ghost ghost added the cssom-1 Current Work label Sep 14, 2016
@zcorpan
Copy link
Member

zcorpan commented Sep 14, 2016

Yeah. That also seems to match what Gecko does.
http://software.hixie.ch/utilities/js/live-dom-viewer/saved/4470

@MatsPalmgren
Copy link

FYI, the relevant Gecko code is:
https://hg.mozilla.org/mozilla-central/annotate/8a494adbc5cc/layout/style/nsComputedDOMStyle.cpp#l4863

So, yes, when the element doesn't have a box, or is a non-replaced or SVG inline,
then 'calcWidth' is false and we use the else-branch on line 4887, which uses
the computed values. But note that min-/max-* are used as well, so it seems to be
a little more than just "use the computed 'width' value".

A few examples:
data:text/html,<div style="display:none; min-width:10px">
I get a resolved 'width' of 1293px (the content-width of the implicit )
data:text/html,<div style="display:none; max-width:10px">
results in width = 'auto'
data:text/html,<div style="display:none; width:20px; max-width:10px">
width = 10px
data:text/html,<div style="display:none; min-width:20px; max-width:10px;">
width = 'auto'
data:text/html,<div style="display:none; width:0; min-width:20px; max-width:10px;">
width = 20px

What do other UAs do in these cases?

@MatsPalmgren
Copy link

Correction,
data:text/html,<div style="display:none; min-width:10px">
is also width = 'auto'

So, it appears that a specified width:auto always resolves to 'auto' (when there is no box),
otherwise min/max is also applied. Here's the code that does this:
https://hg.mozilla.org/mozilla-central/annotate/8a494adbc5cc/layout/style/nsComputedDOMStyle.cpp#l5341

@upsuper
Copy link
Member

upsuper commented Sep 15, 2016

@MatsPalmgren note that, we are changing our behavior of min-width for computed style, because per spec, it should be computed value, not used value. And some other engines also return computed value for {min,max}-{width,height} conforming the spec. See bug 1292447.

@zcorpan
Copy link
Member

zcorpan commented Sep 28, 2016

Fixed the display:contents case in c65b958. Please open a new issue if there's something that needs to be fixed in the spec for min/max-width/height.

@zcorpan
Copy link
Member

zcorpan commented Sep 29, 2016

Reopening per #540 (comment)

@zcorpan zcorpan reopened this Sep 29, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cssom-1 Current Work
Projects
None yet
Development

No branches or pull requests

3 participants