Closed Bug 1041994 Opened 11 years ago Closed 11 years ago

calc( 0 ) is not accepted as a <length>

Categories

(Core :: Layout, defect)

33 Branch
x86_64
Linux
defect
Not set
normal

Tracking

()

RESOLVED INVALID

People

(Reporter: marek.aug, Unassigned)

References

()

Details

User Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.125 Safari/537.36 Steps to reproduce: Use e.g. `margin-right: calc( 0 )`. Example use case: http://codepen.io/marek-saji/full/KGmze/ Actual results: Propery is ignored. Expected results: `calc( 0 )` works exactly like `0`.
Opera and Safari seem to show the 'good' behavior.
Component: Untriaged → Layout
Product: Firefox → Core
Effectively, we're not applying the "Treat 0 as a length" special-case to 0 inside calc(), right? Note that this "treat 0 as a length" is a syntactic shortcut, not a semantic one, according to http://dev.w3.org/csswg/css-values/#length-value It's not clear to me what the right behavior here is per spec, but at least the following cases should be considered: calc(1 - 1) calc(0 * 1) calc((1 - 1) * 2)
Flags: needinfo?(dbaron)
The above also combines with http://dev.w3.org/csswg/css-values/#calc-type-checking : The resolved type of the expression is determined by the types of the values it contains. <number-token>s are of type <number> or <integer>. A <dimension-token>’s type is given by its unit (cm is <length>, deg is <angle>, etc.). So per the current spec, I think our behavior is correct. It also matches the general pattern that the 0-as-length behavior doesn't happen in contexts where <number> values are accepted.
Status: UNCONFIRMED → RESOLVED
Closed: 11 years ago
Flags: needinfo?(dbaron)
Resolution: --- → INVALID
Summary: calc( 0 ) does not work as expected → calc( 0 ) is not accepted as a <length>
Chrome seems to have the same behavior we do. I added a test for this case (and a few others) to the CSSWG test repository: https://hg.csswg.org/test/rev/60c7ad462121 https://hg.csswg.org/test/rev/78fd41d6c90a
You need to log in before you can comment on or make changes to this bug.