Re: [matrix][cssom-view] DOMPoint, DOMPointLiteral definitions

On Sep 25, 2013, at 7:06 AM, Boris Zbarsky <bzbarsky@MIT.EDU> wrote:

> On 9/25/13 1:02 AM, Dirk Schulze wrote:
>> Are we discussing if the attributes(whole object) is immutable in certain situations or in general? I would not agree that DOMRect should always be immutable or that bottom/right should always be immutable. That should only be the case for live DOMRect objects where modifying these two attributes is not possible. And in these situations it is enough to have a prose saying that the returned object is immutable (or certain attributes).
> 
> This is actually hard-ish to do in prose right now.
> 
> The _right_ behavior for an immutable accessor property is to have a 
> getter and no setter.  This will throw on sets in strict mode and 
> silently no-op in non-strict mode.
> 
> That behavior is impossible to specify in prose: by the time your setter 
> has been invoked, you have no way to tell what mode the caller was in.
> 
> Again, the right solution to this sort of issue is to have separate 
> interfaces for the two different behaviors.  In my opinion.

I don't think so. We have this behavior in SVG for years. Lets assume we have an <svg> element with a 'viewBox' attribute.

svgElement.viewBox returns an SVGAnimatedRect object with access to the base value (.baseVal) and the animated value (.animVal). Both attributes return an SVGRect with the attributes x, y, width, height.

In the case of animated value this object is IMMUTABLE. In the case of base value it is MUTABLE. This behavior is implemented in all browsers.

You can not specify that in WebIDL, I agree. But you can state in prose when the object is mutable and when not. You can also describe what happens if it is not mutable and the author tries to modify the object. That is what I did for DOMMatrix [1].

I am also pretty sure that the SVG WG will be interested in DOMRect as a replacement for SVGRect as well (better like SVGMatrix, make SVGRect an alias for DOMRect). So the both WGs should work together for a unified API.

Greetings,
Dirk

[1] http://www.w3.org/TR/2013/WD-matrix-20130919/#two-dimensional-attributes

> 
> -Boris
> 

Received on Wednesday, 25 September 2013 05:28:13 UTC