On Jun 6, 2014, at 6:12 PM, Rik Cabanier <caban...@gmail.com> wrote:

> 
> 
> 
> On Fri, Jun 6, 2014 at 8:57 AM, Milan Sreckovic <msrecko...@mozilla.com> 
> wrote:
> On Jun 5, 2014, at 18:34 , Rik Cabanier <caban...@gmail.com> wrote:
> 
>> On Thu, Jun 5, 2014 at 3:28 PM, Robert O'Callahan <rob...@ocallahan.org>
>> wrote:
>> 
>>> On Fri, Jun 6, 2014 at 9:07 AM, Rik Cabanier <caban...@gmail.com> wrote:
>>> 
>>>> ...
>> 
>> 
>>> Then there's this case:
>>> var m = new DOMMatrix();
>>> m.translate(-1,-1);
>>> m.translate(1,1);
>>> m.isIdentity() == false
>>> 
>>> I'm OK with that. Maybe we do need a better name though. Invert the
>>> meaning and call it "maybeHasTransform()"?
>>> 
>> 
>> That sounds good to me.
> 
> That just feels very wrong.  I understand not having an isIdentity() method 
> as Benoit proposes.  The argument being “is identity question is more 
> complicated than you think, so we won’t let you ask it, and instead you have 
> to do it manually, which means you understand what’s going on”.
> 
> I don’t understand having isIdentity() method and having it return false when 
> you actually have an identity transform.  If it was “hasBeenModified()” or 
> some such, I can understand having it behave that way.
> 
> I could live with that name as well. The problem is what "modified" means. 
> var m = DOMMatrix(2,0,0,1,0,0) ;
> m. hasBeenModified(); //?

isInitialisedIdentity()
isInitialisedToIdentity()
isInitialisedAndIdentity()
initialisedWithIdentity()

All three above seem to assume that the boolean never changed.

transformedNotIdentity()
transformedOrNotIdentity()
isUnmodifiedIdentity()
notTransformedIdentity()
isModifiedNotIdentity()
unmodifiedIdentity()

Definitely not isIdentity(). This just leads to wrong assumptions. Also, if we 
do not add real isIdentity checks, authors will extend DOMMatrix. And then they 
should be able to use isIdentity.


> 
> I've been thinking more and I'm leaning back towards isIdentity.
>  
> I’d much rather have “isIdentityExactly()” or "isCloseToIdentity(float 
> tolerance)” for a given definition of tolerance.  Or not have it at all and 
> write the JS utility myself.
> 
> Yes, you can do this yourself. You should ask yourself though if you would 
> really need to do this... As Benoit said, this might cause inconsistent 
> behavior.
> Moreover, non-identity matrices are very rare so you should ask yourself if 
> the fixed cost of always checking for true identity is worth it. 

It is a good point that checking all 16 elements every time is costy. But that 
is exactly what authors would expect the UA to do.

I still don’t buy the argument with unexpected results though. We never can 
guarantee exact results. 1 divided by 3 doesn’t give exact results but at least 
interoperable results as long as platforms follow IEEE. This is not the case 
for trigonometric functions. It is not possible to guarantee that 
sin(Math.PI/3) is the same on all platforms since implementations vary across 
platforms. This of course affects DOMMatrix when one uses rotate. So none of 
the values can be guaranteed to be interoperable across all platforms. That 
means that isIdentity might not be guaranteed to give exact results either. And 
this usually is fine. If isIdentity does return false, well then the engine has 
to do a bit more work and can’t return earlier… That is what isIdentity is used 
for anyway. Make sure that engines don’t do unnecessary transformations.

It is good that DOMMatrix can be extended by users to add this basic 
functionality that all drawing engines and browser engines use under the hood 
already.

Greetings,
Dirk

_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to