Re: [cssom-view] New WD "CSSOM View Module"

On Fri, 29 Feb 2008 03:09:23 +0100, Garrett Smith <dhtmlkitchen@gmail.com>  
wrote:
> That's why we got into the discussion about containing block.
> offsetParent is a containing block (of something), because
> offsetParent has to have position other than static -
>
> <div style="position: static"><div id="C"></div></div>
>
> - outer element is a containing block for child C when C is position:
> static|relative. Outer elem isn't a containing block.
>
> <body style="position:static"><div id="C"></div></body>
>
> - outer element is a containing block for child C when C is position:
> static|relative. Outer elem isn't a containing block.

You're probably falling asleep already, but I don't really understand what  
you're trying to say.


>>> Part of the reason the other browsers do this is that you've had an
>>> influence on them.
>>
>>  You mean that their behavior changed? (Other than Opera.)
>
> That is not what I said.
>
> Your documentation affirms the behavior - behavior which is
> odd/confusing/deviating - of other browsers (not IE).

You said that other browsers have a certain behavior because of my  
influence. Now you're saying something else...


>>  <!doctype html>
>>  <div id=x style=position:absolute;top:10px>xxx</div>
>>  <script> alert(document.getElementById('x').offsetTop) </script>
>
> The CSSOM, Opera, Mozilla, and Webkit say "body".

They'd say 10. IE7 too, fwiw.


> getComputedStyle(document.body,'').marginTop
>
> Reveals "8px" in 2 browsers.
>
> The offsetTop, according to CSSOM, should be the distance between the
> border edge of #x and the padding edge of it's offsetParent.
>
> x's border-edge is 10px from HTML
> BODY's padding edge is 8px from HTML
>
> 10px - 8px = 2px
>
> Then there's the special case for body. Here's where it's a problem.

This is what quirks mode expects and you need to special case at some  
point anyway. The HTML html element can be positioned too, etc. and you'd  
have the same issues. So I don't really see this as a problem. Also, this  
is a legacy API and people are already migrating their scripts to use  
getClientRects() and getBoundingClientRect() (see jquery for instance).


> These browsers will report "10" for offsetTop. The distance from the
> element to the element's containing block is, in fact, 10. But the
> containing block is not BODY. The containing block is HTML. We have an
> element that reports 10px from it's offsetParent, BODY.
>
> The example you provided does not tell us how far x is from the
> padding edge of its offsetParent. If offsetParent is BODY, then the
> actual distance of the border edge of #x to the padding edge of BODY
> is 2px -- not 10px.

True, offsetParent being the HTML body element is a special case.


>> Yet the function works fine with current implementations, including  
>> those where offsetParent is mostly <body>.
>
> When you say 'implementation' do you mean browser or web page?

Browser implementations that have to deal with existing Web pages.


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

Received on Friday, 29 February 2008 11:34:04 UTC