Re: [cssom-view] DOMRect with aliases x, y to left, top?

On Fri, 27 Sep 2013 00:37:32 +0200, Robert O'Callahan  
<robert@ocallahan.org> wrote:

> On Fri, Sep 27, 2013 at 9:44 AM, Henrik Andersson  
> <henke@henke37.cjb.net>wrote:
>
>> My point is how the width and right properties change when left and x
>> are set. X changes right, left changes width.
>>
>> One models the moveable rectangle and the other models the stretchy
>> rectangle.
>>
>
> I think making setting of x/y behave differently from top/left is just
> super confusing. Imagine trying to explain to authors with a straight  
> face
> why "x" is different from "left". It would be simpler to make them pure
> aliases and pick a consistent mutation behavior.

So we have three options:

(a) x and left change width.
(b) x and left change right.
(c) x changes right, left changes width.

For (a), the following code won't do what it looks like it does:

function resizeAndRepositionRect(rect, props) {
   rect.width = props.width;
   rect.height = props.height;
   rect.x = props.x;
   rect.y = props.y;
}

The width will be different from what it was set to.

Similarly for (b):

function setEdgesForRect(rect, props) {
   rect.top = props.top;
   rect.right = props.right;
   rect.bottom = props.bottom;
   rect.left = props.left;
}

Here, right won't be what it was set to.

(c) lets authors either work with x/y/width/height or  
top/right/bottom/left and get the values they were set to.


I guess there's a fourth option:

(d) Make top/right/bottom/left readonly and only allow mutating  
x/y/width/height.


Personally I think we shouldn't do (a) or (b), and I don't think (c) is  
that confusing. I'm OK with either (c) or (d).

-- 
Simon Pieters
Opera Software

Received on Friday, 27 September 2013 08:19:17 UTC