Re: [cssom-view] Why is body's offsetParent null ?

On Wed, 23 Apr 2008 13:37:43 +0200, Mike Wilson <mikewse@hotmail.com>  
wrote:
>>    http://lists.w3.org/Archives/Public/www-style/2008Apr/0366.html
>
> That's only the current behaviour of Firefox you're talking about, right?

No, if we followed Internet Explorer we would have to introduce  
differences between quirks and standards mode which is currently a  
non-goal of the specification. We'd also have to figure out how hasLayout  
affects everything as explained in this blog post:

   http://annevankesteren.nl/2006/05/offset

I don't think we want to go anywhere near that.


> The Firefox algorithm is admittedly broken
> https://bugzilla.mozilla.org/show_bug.cgi?id=255754
> and according to Boris Zbarsky they are waiting for your IE reverse-
> engineering (done for this spec) before they do any changes or fix the
> bugs.

Initially it was indeed IE reverse-engineering though ultimately that  
didn't seem the most optimal solution for these attributes.


> The offset behaviour in (standards mode) IE, when you have
> position:relative on the body element, will give you both offset between
> body and viewport edge and between body and other elements:

Actually, it's not the viewport. It's the initial containing block origin.


> offsetParent for/in: IE7        CSSOM
> HTML                 null       null
>  BODY                null       null
>   div1(pos=rel)      BODY       BODY
>    div2a             div1       div1
>    div2b             div1       div1
>     div3a(pos=abs)   div1       div1
>     div3b            div2b      div1
>
> offsetLeft for/in:   IE7        CSSOM
> HTML(4m,2b,1p)       0          0
>  BODY(32m,16b,8p)    39         0
>   div1(4m,2b,1p)     12         67
>    div2b(32m,16b,8p) 33         33
>     div3b(4m,2b,1p)  12/div2b   61/div1
>
> Note 1: IE gives you both BODY's offset against viewport and div1's
>         offset against BODY while CSSOM skips over BODY.
>
> Note 2: IE gives an ideal offset and offsetParent chain that will work
>         with any recursion wherever it stops.
>         (although ignoring most things on the root element)
>
> Note 3: IE honors the Containing Block algorithm for div3b for its
>         offsetParent choice.
>
> I think the above IE algorithm would be much preferred compared to the
> broken FF algorithm that CSSOM partly derives from.

I agree that some of this is more desirable and initially I thought it  
would be more like that, but I don't think it's worth going in this  
direction because:

   1. Emulating IE completely is not feasible anyway given hasLayout.
   2. This requires a different code path for quirks mode making browser  
unnessarily more complicated as better solutions for authors are available.
   3. This special cases the root element instead which is arguably  
somewhat of an improvement, but not much.
   4. This would be incompatible with three out of four browsers.


-- 
Anne van Kesteren
<http://annevankesteren.nl/>
<http://www.opera.com/>

Received on Wednesday, 23 April 2008 12:01:59 UTC