Re: [geometry] Why does DOMMatrix.setMatrixValue accept only a string transformList?

On Mon, 11 Jan 2016 23:02:11 +0100, /#!/JoePea <trusktr@gmail.com> wrote:

> I noticed that in the Editor's draft. Should I follow that instead? I
> wasn't sure.

In general I would recommend that, yes.

> I'm new to w3c specs in general. How do we know when a spec is finalized?

Well, formally, it's finalized when it says "Recommendation", but in  
practice the stability has more to do with how widely implemented and how  
widely used it is. The Geometry spec can still be changed, though it tries  
to be compatible with SVGMatrix as well as legacy proprietary interfaces  
(see e.g. https://github.com/whatwg/compat/issues/19 ).

> So, if we want to copy values from one DOMMatrix to another, we are
> expected to convert the values to a DOMString only so they can be
> converted back to numbers, which is extra overhead that we should
> avoid.

Yeah, though note that you can pass in a DOMMatrix to setMatrixValue() and  
it will stringify itself. *Possibly* an implementation could skip the  
stringification step (if toString hasn't been overridden etc).

> Since we wish to have setMatrixValue for compatibility with the other
> classes, but wish to avoid overloading (which I think is a good idea
> and can lead to code that is more readable (compare to my ugly
> overloaded constructor with all the conditional checks in it)), why
> not create some setter methods matching the static creator methods.
> For example, we have these static methods:
>
> ```
> [NewObject] static DOMMatrix fromMatrix(optional DOMMatrixInit other);
> [NewObject] static DOMMatrix fromString(DOMString transformList);
> [NewObject] static DOMMatrix fromFloat32Array(Float32Array array32);
> [NewObject] static DOMMatrix fromFloat64Array(Float64Array array64);
> ```
>
> Likewise we could have these instance methods:
>
> ```
> DOMMatrix setFromMatrix(optional DOMMatrixInit other);
> DOMMatrix setFromString(DOMString transformList);
> DOMMatrix setFromFloat32Array(Float32Array array32);
> DOMMatrix setFromFloat64Array(Float64Array array64);
> ```
>
> and we can make
>
> ```
> DOMMatrix setMatrixValue(DOMString transformList);
> ```
>
> simply an alias for
>
> ```
> DOMMatrix setFromString(DOMString transformList);
> ```
>
> What do you think of this idea?

This sounds OK to me. Maybe we could just drop setMatrixValue. What do  
implementors think?

-- 
Simon Pieters
Opera Software

Received on Wednesday, 13 January 2016 09:46:33 UTC