This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 16183 - Make parsing of non-positive perspectives consistent
Summary: Make parsing of non-positive perspectives consistent
Status: RESOLVED FIXED
Alias: None
Product: CSS
Classification: Unclassified
Component: Transforms (show other bugs)
Version: unspecified
Hardware: All All
: P2 normal
Target Milestone: ---
Assignee: Simon Fraser
QA Contact: public-css-bugzilla
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-03-01 18:27 UTC by Aryeh Gregor
Modified: 2012-03-12 21:05 UTC (History)
6 users (show)

See Also:


Attachments

Description Aryeh Gregor 2012-03-01 18:27:51 UTC
The spec now says for the 'perspective' property

"""
If the value is ‘none’, less than or equal to 0 no perspective transform is applied.
"""
http://dev.w3.org/csswg/css3-transforms/#perspective-property

This means that nonpositive values are parsed as "none".  On the other hand, for perspective() it says

"The value for depth must be greater than zero, otherwise the function is invalid."
http://dev.w3.org/csswg/css3-transforms/#three-d-transform-functions

This means that nonpositive values are parse errors.  The behavior should be consistent.


Test-case for 'perspective':

data:text/html,<!doctype html>
<body style="perspective:200px;perspective:0">
<script>
document.body.textContent =
getComputedStyle(document.body).perspective
</script>

Also test replacing "0" with "-10px".  Results:

* In IE10 Developer Preview, "0" parses the same as "none", but "-10px" doesn't parse.
* In Chrome 18 dev, "0" parses the same as "none", but "-10px" doesn't parse.
* In mozilla-central (Firefox 13.0a1), "0" and "-10px" don't parse.

Testing with

data:text/html,<!doctype html>
<body style="transform:scale(2);transform:perspective(0)">
<script>
document.body.textContent =
getComputedStyle(document.body).transform
</script>

* In IE10 Developer Preview, "perspective(0)" is parsed as the identity matrix, while "perspective(-10px)" is a parse error.
* In Chrome 18 dev, "perspective(0)" is parsed as the identity matrix, while "perspective(-10px)" is a parse error.
* In Firefox 13.0a1, "perspective(0)" and "perspective(-10px)" both don't parse.

Thus we have two behaviors: in IE/Chrome, negative values don't parse for either the property or the function, but 0 parses as "none".  In Gecko, no nonpositive value parses.  The spec should match one or the other.

IMO, Gecko's behavior makes more sense.  A perspective of zero logically should result in everything disappearing; 'none' is equivalent to a perspective of infinity.  Moreover, there are already other, clearer ways of achieving the same effect: instead of "perspective: 0" one can write "perspective: none", and instead of "perspective(0)" one can omit the function from the transform list entirely.

However, Gecko is in the minority, and before Firefox 13 it behaved differently anyway (https://bugzilla.mozilla.org/show_bug.cgi?id=725036).  Does anyone think we should change the spec to match IE/Chrome?  If people feel strongly, I'll do that and patch Firefox and my tests so they match.  Otherwise, I'll change the spec so it matches Gecko, which also already matches the tests.  (I was just told I got my CVS access.)
Comment 1 Simon Fraser 2012-03-01 18:32:32 UTC
I think it would be OK to spec Gecko's behavior.
Comment 2 Aryeh Gregor 2012-03-12 21:05:58 UTC
Done: http://dvcs.w3.org/hg/csswg/rev/23f80019fad0