Bug 24107

Summary: Fixed elements have 0 as an offsetLeft property
Product: WebKit Reporter: Frank DENIS <webkit>
Component: DOMAssignee: David Levin <levin>
Status: RESOLVED FIXED    
Severity: Normal CC: pennig
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Mac   
OS: OS X 10.5   
URL: http://download.pureftpd.org/misc/bugs/webkit/fixed-element-has-no-offsetleft.html
Attachments:
Description Flags
Modifies offsetTop/Left
none
Modifies offsetTop/Left
hyatt: review-
offsetLeft/Top patch + 2 tests hyatt: review+

Frank DENIS
Reported 2009-02-23 15:19:10 PST
In recent webkit revisions, fixed elements always have 0 as an offsetLeft property regardless of their actual position. It doesn't match the behavior of IE 7, Safar 3.2.1 and Opera 10a. <!doctype html> <html> <body onload="alert(document.getElementById('hop').offsetLeft);"> <div id="hop" style="position:fixed; right: 0;">Test</div> </body> </html>
Attachments
Modifies offsetTop/Left (9.39 KB, patch)
2009-02-23 20:49 PST, Matt Pennig
no flags
Modifies offsetTop/Left (10.46 KB, patch)
2009-02-23 22:41 PST, Matt Pennig
hyatt: review-
offsetLeft/Top patch + 2 tests (12.97 KB, patch)
2009-02-26 21:19 PST, Matt Pennig
hyatt: review+
Matt Pennig
Comment 1 2009-02-23 20:49:35 PST
Created attachment 27902 [details] Modifies offsetTop/Left
Matt Pennig
Comment 2 2009-02-23 22:41:27 PST
Created attachment 27905 [details] Modifies offsetTop/Left Previous patch had an issue with borders on the body and static- and relative-positioned elements.
Frank DENIS
Comment 3 2009-02-24 02:41:50 PST
I successfully tested the second patch, and it actually fixes the test case as well as the real-world issue it was based upon. Thank you, pennig@
Dave Hyatt
Comment 4 2009-02-26 15:41:35 PST
Comment on attachment 27905 [details] Modifies offsetTop/Left I'd like a root element test as well, since in theory that was broken also. Can you add that please? Make a test with <html> that is positioned: <html style="position:absolute;border:10px solid black;width:100px;height:100px;left:200px;top:200px"></html> I'm betting we return 0 for left/top prior to your patch and that you just fixed it. Might want to double-check that the spec says the root element should return the offset from the canvas origin also.
Matt Pennig
Comment 5 2009-02-26 21:09:07 PST
The spec says that "If the offsetParent of element A is null", then get the offset from the canvas origin, and the offsetParent for the root element is null. Seems clear enough.
Matt Pennig
Comment 6 2009-02-26 21:19:35 PST
Created attachment 28063 [details] offsetLeft/Top patch + 2 tests Includes additional test case as requested to check for proper behavior of offsetLeft/Top on positioned <html> elements.
Dave Hyatt
Comment 7 2009-02-27 11:53:47 PST
Comment on attachment 28063 [details] offsetLeft/Top patch + 2 tests r=me
David Levin
Comment 8 2009-02-27 16:10:07 PST
Assigning to levin for committing.
David Levin
Comment 9 2009-02-27 17:29:43 PST
Committed as r41312.
Note You need to log in before you can comment on or make changes to this bug.