Re: [css-transforms] Value for perspective() function

2016年4月5日 上午9:56,"Tab Atkins Jr." <jackalmage@gmail.com>写道:
>
> On Sun, Apr 3, 2016 at 6:12 PM, Xidorn Quan <quanxunzhen@gmail.com> wrote:
> > Hi,
> >
> > The spec says, for value inside perspective() function:
> >> The value for depth must be greater than zero, otherwise the function
is
> >> invalid. [1]
> >
> > However, there there is a statement in the spec saying that
perspective(0)
> > is an netural function [2]. Either this one or the description above
should
> > be changed somehow.
> >
> > Currently, Gecko treats perspective(0) as invalid per spec, and thus
drops
> > the transform decl, while others treat that as perspective(infinity) (or
> > probably just ignore it), which becomes a webcompat issue [3], and
there is
> > discussion for the Compatibility Standard [4].
> >
> > It seems to me treating perspective(0) as perspective(infinity) doesn't
make
> > sense anyway. The spec should probably either change to making it
completely
> > invalid, or treating it as an infinitesimal small non-zero value, which
> > might benefit animation.
> >
> >
> > [1] https://drafts.csswg.org/css-transforms/#funcdef-perspective
> > [2] https://drafts.csswg.org/css-transforms/#neutral-element
> > [3] https://bugzilla.mozilla.org/show_bug.cgi?id=1009150
> > [4] https://github.com/whatwg/compat/issues/48
>
> Yeah, there are multiple problems here:
>
> 1. 0 is the EXACT OPPOSITE of a neutral value; the effect of
> perspective() is *magnified* as the argument approaches 0.  So that
> definition is just nonsense.  The actual neutral value is "infinity",
> but that's not animatable. :/

I'm actually not quite sure about what does the term "neutral" mean here.
There is already a concept called "identity transform function" defined,
which lists "perspective(infinity)". In addition, it seems to me "scale(0)"
etc. and "matrix(0)" etc. also map anything to nothing, just like what
"perspective(0)" would do if it were valid.

> 2. Making 0 invalid for floating-point values violates our rules for
> limited ranges, as it makes valid values an open range; it means that
> whether a *perfectly valid* value might become invalid due to browser
> rounding differently than expected. The spec should instead define a
> minimum perspective and clamp values to that.  Negative values can
> remain invalid.

Yeah... I believe Gecko has some bug due to rounding for this transform
function.

Then I guess we should make it valid. But treating it as
"perspective(infinity)" actually has the same rounding issue as marking it
invalid. So probably we should, as I suggested above, handle it as
infinitesimal, and then the corresponding component in the matrix becomes
infinity.

- Xidorn

Received on Tuesday, 5 April 2016 00:44:53 UTC