Bug 26020

Summary: The offsetLeft of an element with non-absolute position whose offsetParent is the position:static body does not include the html element's left margin
Product: WebKit Reporter: Aharon (Vladimir) Lanin <aharon>
Component: DOMAssignee: Nobody <webkit-unassigned>
Status: RESOLVED CONFIGURATION CHANGED    
Severity: Minor CC: ahmad.saleem792, ap, bfulgham, dglazkov, hyatt, mitz, playmobil, rniwa
Priority: P2 Keywords: GoogleBug
Version: 528+ (Nightly build)   
Hardware: PC   
OS: Windows XP   
Attachments:
Description Flags
test case none

Description Aharon (Vladimir) Lanin 2009-05-26 07:19:32 PDT
If you have:

<!DOCTYPE html>
<html>
  <head>
    <style type="text/css">
      html {margin-left: 10px}
      body {margin: 0px}
    </style>
  </head>
  <body>
    <div id="static">static</div>
    <div id="absolute" style="position:absolute">absolute</div>
  </body>
</html>

Then static.offsetLeft is 0. It should be 10, i.e. include the html margin, the same as absolute.offsetLeft. It already includes the html left border and padding and the body left margin and border and padding. This is the way it is in IE8, and it makes sense. In IE7, it only includes the body padding, which is a bug they fixed in IE8.
Comment 1 Aharon (Vladimir) Lanin 2009-05-26 07:20:43 PDT
Created attachment 30668 [details]
test case
Comment 2 Alexey Proskuryakov 2010-12-14 11:24:53 PST
See also: <http://www.w3.org/TR/cssom-view/#offset-attributes>
Comment 3 Jeremy Moskovich 2011-03-04 08:35:00 PST
Aharon: It appears that FF also behaves this way, up to and including FF4, have you filed a bug against them as well?
Comment 4 Jeremy Moskovich 2011-03-04 09:45:41 PST
Another bit of information: Operat matches IE8 here.
Comment 5 Aharon (Vladimir) Lanin 2011-03-08 09:13:26 PST
(In reply to comment #3)
> Aharon: It appears that FF also behaves this way, up to and including FF4, have you filed a bug against them as well?

As far as I can see from my notes at the time that I filed this bug, I tested it in FF (2 & 3), and found that it did *not* behave this way.
Comment 6 Aharon (Vladimir) Lanin 2011-03-08 09:21:57 PST
(In reply to comment #5)
> (In reply to comment #3)
> > Aharon: It appears that FF also behaves this way, up to and including FF4, have you filed a bug against them as well?
> 
> As far as I can see from my notes at the time that I filed this bug, I tested it in FF (2 & 3), and found that it did *not* behave this way.

To clarify, I see that FF 3.6.13 (which is what I currently have installed) behaves that way, but according to my notes the version of FF 3 I tested back then did not. Unfortunately, I did not note which version of FF 3 I had used.
Comment 7 Ahmad Saleem 2022-07-28 12:41:22 PDT
All browsers (Chrome Canary 106, Firefox Nightly 105 and Safari 15.6 on macOS 12.5) match with each other in attached test case show following:

___


static
absolute

static.offsetLeft: 0 (supposed to be 10)
absolute.offsetLeft: 10 (supposed to be 10)

___

Do we need to do anything more here as per web-spec or this can be marked as "RESOLVED CONFIGURATION CHANGED"? Thanks!
Comment 8 Ryosuke Niwa 2022-07-28 13:17:04 PDT
Nice!