RE: [cssom-view] padding edge / border edge for offsetTop/offsetLeft?

Hi Sylvain, 

> In
> the spirit of contributing to your effort, I've added an IE8 
> column to your tables below. 

Interesting, thanks!

> Note that hasLayout is always 
> reported as true by IE8 so there's only one column.

That makes sense as hasLayout=true in many cases correlates to
standards mode behaviour and hasLayout=false to quirks, and
IE8 mode is standards mode.

> [1. code unchanged = all DIV.position=static]
>                IE7        IE7        IE8b1
> DIV.hasLayout  false      true   <always true>
> div1           4/BODY     4/BODY     4/BODY
> div2           39/BODY    33/div1    35/div1
> div3           67/BODY    12/div2    28/div2
> 
> Note that the div2' and div3' offsetLefts now go from outer 
> border edge to outer border edge.

Yes, agreed.

> [2. code + div2.pos=rel]
>                IE7        IE7        IE8b1
> DIV.hasLayout  false      true   <always true>
> div1           4/BODY     4/BODY     4/BODY
> div2           39/HTML    39/HTML    35/div1
> div3           67*/div2   12/div2    28/div2
> *=bug
> 
> Same as in #1.

Yes.
BTW: I like that IE8's offsetParent chain allows you to get
your offset relative to BODY (if desired). This will not be
possible using offset* props when following CSSOM.

> [3. code + div1.pos=rel and div3.pos=abs,left/top=0]
>                IE7        IE7        IE8b1
> DIV.hasLayout  false      true   <always true>
> div1           4/HTML     4/HTML     4/BODY
> div2           39/div1    33/div1    35/div1
> div3           10/div1    4/div1     20/div1
> 
> div3 is now offset by the parent's border + its margin. If I 
> understand your errata, it should really be 8 ?

I'm not sure if what you describe is a positioning problem or
offset reporting problem. With the given 0/0 position on div3 
I would expect it to appear in div1's top-left corner, with a
4px "empty space" between the borders of div1 and div3. If this
is the case, offsetLeft should return 4 when measuring padding
edge to border edge (IE7) but should return 6 when measuring
border edge to border edge (IE8).
So, I can't say where 20 or 8 would come from but maybe that
becomes clearer if you report where in the layout div3 appears?

> Bottom line, I believe that at a minimum :
> 1. We must fix IE8's body offsetParent to return null instead 
>    of HTML

If you want IE8 to be compatible with the current CSSOM then
the rest of your offsetParent chain should be changed to 
something more like the IE7/hasLayout=false case, f ex in 
table 1 all DIVs link to BODY as offsetParent.

> 2. We must fix our offsetLeft calculation for #2 and #3 to 
> match IE7 and prior, the spec and...well, everyone else.

Agreed.

> 3. I don't fully grok #3 yet but I suspect we have another 
> adjustment to make.

Yes, to at least one of positioning algorithm or offset calc ;-).

Best regards
Mike Wilson

Received on Wednesday, 30 April 2008 18:41:47 UTC