W3C home > Mailing lists > Public > www-style@w3.org > September 2013

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

From: Simon Pieters <simonp@opera.com>
Date: Fri, 27 Sep 2013 10:18:44 +0200
To: "Henrik Andersson" <henke@henke37.cjb.net>, "Robert O'Callahan" <robert@ocallahan.org>
Cc: "Dirk Schulze" <dschulze@adobe.com>, "www-style list" <www-style@w3.org>
Message-ID: <op.w319didcidj3kv@simons-macbook-pro.local>
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  

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

This archive was generated by hypermail 2.4.0 : Monday, 23 January 2023 02:14:32 UTC