[webkit-dev] Can someone explain tx/ty?

David Hyatt hyatt at apple.com
Mon Aug 23 10:20:31 PDT 2010


On Aug 23, 2010, at 12:11 PM, David Hyatt wrote:

> 
>> (hopefully less verbose, but you get the idea). tx, ty could be named parentOffsetFromLayerCoordinates or something. This seems to be the intent of the names - that x,y is a point and tx, ty is a translation. But this doesn't work in point/size logic. You repeatedly add x(), y() to tx, ty to get a new tx, ty. But that means you're adding a point to a size and expecting to get a new size - but that's not how it works.
>> 
> 
> I think a helper method that does the right thing solves this problem (rather than having to flip what x/y and tx/ty mean just to do some math operation).
> 
> dave

Just to clarify, if tx/ty turned into an IntSize offset, I think you could just add a helper method like .asOffset() to IntPoint to solve this particular problem.

Instead of 

tx += x();
ty += y();

You could write:

offset += location().asOffset();

I'd also have no objection to just building that right into RenderBox...

offset += locationOffset();

dave
(hyatt at apple.com)




More information about the webkit-dev mailing list