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

Re: [CSSOM] Revisiting transforms and getBoundingClientRect()

From: Robert O'Callahan <robert@ocallahan.org>
Date: Fri, 9 Sep 2011 17:29:59 +1200
Message-ID: <CAOp6jLa_hhqQRNWaGC7Q3ZoPMhe7SgPoyJ9NE_GAe6GAQ4R=xA@mail.gmail.com>
To: Simon Fraser <smfr@me.com>
Cc: "Tab Atkins Jr." <jackalmage@gmail.com>, Andrew Dupont <w3@andrewdupont.net>, www-style@w3.org
On Fri, Sep 9, 2011 at 7:01 AM, Simon Fraser <smfr@me.com> wrote:

> Sure. With all these new point/quad methods, maybe we should bite the
> bullet and have a WebPoint class with x, y members. Then WebQuad can have 4
> WebPoints.
> The poorly-named ClientRect should become WebRect.

I don't think we should have "Web" prefixes on Web APIs. If we need a
prefix, maybe CSSRect.

> Having a variety of functions for the content, padding and margin rects
> seems like overkill; I would prefer one or two "bottleneck" quad mapping
> functions with helper methods to get the various boxes for a given element.
> >
> > I'm not quite sure what you mean. Can you suggest something?
> The basic pieces seem to be:
> 1. Get an element's padding, content, border and margin boxes relative to
> its own border-box, as rects.
> 2. Convert a rect to a quad.
> 3. Map arbitrary point from one element to another.
> 4. Map arbitrary quad from one element to another (mapping 4 points)
> We should make sure each of these steps is available to web developers,
> possibly with the addition of convenience wrappers.
> That suggests:
>  const CONTENT_BOX;
>  const PADDING_BOX;
>  const BORDER_BOX;
>  const MARGIN_BOX;
>  WebRectList element.localBoxes(boxType); // relative to border-box of
> first box.
> Quad to rect conversions:
>  WebQuad rect.toQuad();
>  WebRect quad.boundingRect();
> Would be nice to have a way to convert a WebRectList to a WebQuadList.
>  WebPoint element.mapPoint(WebPoint, [relativeTo])  // point is border-box
> relative on both ends.
>  WebQuad element.mapQuad(WebQuad, [relativeTo]) // quads are border-box
> relative on both eneds
>  WebQuadList element.mapQuads(WebQuadList, [relativeTo]) // ditto

That breakdown makes a lot of sense. I'd bikeshed a little over the syntax
for localBoxes() and boundingRect(). We should definitely use multiple
methods instead of a boxType parameter IMHO.

"If we claim to be without sin, we deceive ourselves and the truth is not in
us. If we confess our sins, he is faithful and just and will forgive us our
sins and purify us from all unrighteousness. If we claim we have not sinned,
we make him out to be a liar and his word is not in us." [1 John 1:8-10]
Received on Friday, 9 September 2011 05:30:28 UTC

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