Bug 24305 - offsetLeft and offsetTop wrong when position of parent node is not static
Summary: offsetLeft and offsetTop wrong when position of parent node is not static
Status: RESOLVED CONFIGURATION CHANGED
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC Windows XP
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-03-02 16:06 PST by boris
Modified: 2022-07-28 13:17 PDT (History)
9 users (show)

See Also:


Attachments
Test case to reproduce the bug (2.61 KB, text/html)
2009-03-02 16:07 PST, boris
no flags Details
Another testcase (1.14 KB, text/html)
2010-12-14 06:19 PST, Jeremy Moskovich
no flags Details
Modified testcase that prints offsetParent element (2.75 KB, text/html)
2011-03-07 05:47 PST, Jeremy Moskovich
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description boris 2009-03-02 16:06:07 PST
offsetLeft and offsetTop do not include the border width of the parent node if the style property 'position' of the parent is not 'static'. In the test case the style property 'position' is changed from 'static' to 'relative'. This change makes Safari (and Firefox and Chrome) return different offsetLeft and offsetTop values. If you add the border width of 15px to those values you get the correct results again. If you open the test case in Internet Explorer and Opera you'll see that they return the same values no matter what 'position' is set to.
Comment 1 boris 2009-03-02 16:07:59 PST
Created attachment 28202 [details]
Test case to reproduce the bug
Comment 2 Jeremy Moskovich 2010-12-14 06:19:28 PST
Created attachment 76530 [details]
Another testcase
Comment 4 Alexey Proskuryakov 2010-12-14 11:24:38 PST
See also: <http://www.w3.org/TR/cssom-view/#offset-attributes>.
Comment 5 Jeremy Moskovich 2011-03-07 04:52:09 PST
Did you file a Mozilla bug for this?
Comment 6 Jeremy Moskovich 2011-03-07 05:47:57 PST
Created attachment 84938 [details]
Modified testcase that prints offsetParent element
Comment 7 Jeremy Moskovich 2011-03-07 06:46:01 PST
Looks like IE8 behaves differently in quirks and standards mode.
Comment 8 boris 2011-03-07 12:21:35 PST
Here's the Mozilla bug: https://bugzilla.mozilla.org/show_bug.cgi?id=481076
Comment 9 Ahmad Saleem 2022-07-28 12:39:18 PDT
I am unable to reproduce this bug using attached "Modified..." and all browsers (Chrome Canary 106, Firefox Nightly 105 and Safari 15.6 on macOS 12.5) shows following:

CSS property 'position' of <p> element: static
offsetLeft of <span> element: 35
offsetTop of <span> element: 25

Changing CSS property 'position' ...

CSS property 'position' of <p> element: relative
offsetLeft of <span> element: 20 (should be 35)
offsetTop of <span> element: 10 (should be 25)

____

Since all browsers are showing same, do we need to do something more? Thanks!
Comment 10 Ryosuke Niwa 2022-07-28 13:17:28 PDT
That sounds like config changed to me.