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

Anne van Kesteren wrote:

> 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:

Simple then, don't allow quirks mode. Only allow the offset behavior to 
work in standards mode.

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

How does of offsetLeft and offsetTop have any thing to do with hasLayout 
in this case. In your case giving hasLayout to the outer div causes the 
inner div margin edge to be offset against the content/padding edge of 
the outer div and not its' border edge. We offset against the parent, 
not particular parts of the parent. So content edge equal padding edge 
which equals border edge.

>> 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.

What part of Mike chain does hasLayout come into play?.

>   2. This requires a different code path for quirks mode making browser 
> unnessarily more complicated as better solutions for authors are available.

No more quirks mode. Why are you wishing to support this mode. The 
author should be coding for standard mode only or not using CSSOM at all.


Received on Wednesday, 23 April 2008 15:23:03 UTC