Closed
Bug 81290
Opened 24 years ago
Closed 24 years ago
offsetTop and offsetLeft gives wrong values in relative and absolute positioned parents
Categories
(Core :: DOM: CSS Object Model, defect)
Core
DOM: CSS Object Model
Tracking
()
VERIFIED
FIXED
mozilla0.9.3
People
(Reporter: erik, Assigned: jst)
References
Details
(Whiteboard: [pdt+][nsBranch+][FIXED AND VERIFIED ON THE TRUNK])
Attachments
(4 files)
2.71 KB,
text/html
|
Details | |
3.14 KB,
text/html
|
Details | |
10.36 KB,
patch
|
Details | Diff | Splinter Review | |
10.43 KB,
patch
|
Details | Diff | Splinter Review |
The offsetLeft and offsetTop values (and getComputedStyle...) should give the
position in the current coordinate space and not the browser viewport space.
For example an absolute positioned element positioned at 100px left inside
another element with either position absolute or relative (fixed as well I
guess) should return an offsetLeft value of 100 and not 100 plus the offsetLeft
of the parent.
This is important because an element that has position absolute or relative
should not be moved by the following statement:
element.style.left = element.offsetLeft
The offsetLeft/Top should follow the same rules as style.left/top do when it
comes to coordinate spaces.
Build tested on: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:0.9+)
Gecko/20010510
Reporter | ||
Comment 1•24 years ago
|
||
Reporter | ||
Comment 2•24 years ago
|
||
Reporter | ||
Comment 3•24 years ago
|
||
The last test case shows that getComputedStyle seems to return the correct
value for an absolutetly positioned element even when it is located inside an
element defining its own coordinate space. Why that value is different from the
offset value is beyond me.
Assignee | ||
Comment 4•24 years ago
|
||
Nominating for mozilla0.9.2, not sure we can fix this completely in time for
mozilla0.9.2, but we can fix at least parts of it, and IMO that's worth doing
since this breaks alot of "dhtml".
Assignee | ||
Comment 7•24 years ago
|
||
Assignee | ||
Comment 8•24 years ago
|
||
The patch I just attached fixes .offsetXXX to work exactly like IE does in the
attached testcase, but now I need help. I need someone to apply the patch and
build mozilla with my patch and then go through all my, and vidur@netscape.com's
bugs (fixed, verified, unconfirmed, new, you name it) in bugzilla that have to
do with the .offsetXXX properties and make sure that I didn't break something
that used to work. Anyone up for doing that?
Comment 9•24 years ago
|
||
Ok, I applied the patch to 1.261 and merged with the changes from 1.262. Will
test and report in the appropriate bugs.
Assignee | ||
Comment 10•24 years ago
|
||
Assignee | ||
Comment 11•24 years ago
|
||
Moving to mozilla0.9.3
Target Milestone: mozilla0.9.2 → mozilla0.9.3
Assignee | ||
Comment 12•24 years ago
|
||
Fix checked in on the trunk, this should go onto the branch once we've let it
live on the trunk for a while.
Comment 13•24 years ago
|
||
current status ?
Assignee | ||
Comment 14•24 years ago
|
||
Fixed on the mozilla trunk, waiting for approval to check this into the Netscape
RTM branch.
nsBranch ok, IE compatibility, code path exercised only in this special case so
should not cause problems elsewhere.
Keywords: nsBranch
Comment 16•24 years ago
|
||
The testcases work fine.
Verified with build ID 20010070604.
Whiteboard: [FIX ON THE TRUNK] → [FIXED AND VERIFIED ON THE TRUNK]
Comment 17•24 years ago
|
||
This fix has baked on the trunk for more than a week. The only codepath that is
affected by this change is the offsetTop and offsetLeft property getter/setters.
These properties are not used by the scripts in the Mozilla suite of
applications so the possibility of regressions is low. These properties were
partially implemented and shipped in Netscape 6.0 to match IE's behaviour. With
this patch checked into Netscape 6.1, we will match IE's implementation much
more closely. Web developers will be able to use these properties to create
reliable cross-browser content.
Marking nsBranch+.
Whiteboard: [FIXED AND VERIFIED ON THE TRUNK] → [nsBranch+][FIXED AND VERIFIED ON THE TRUNK]
Updated•24 years ago
|
Whiteboard: [nsBranch+][FIXED AND VERIFIED ON THE TRUNK] → [pdt+][nsBranch+][FIXED AND VERIFIED ON THE TRUNK]
Assignee | ||
Comment 18•24 years ago
|
||
Fix checked in on the branch.
Status: ASSIGNED → RESOLVED
Closed: 24 years ago
Resolution: --- → FIXED
Comment 19•24 years ago
|
||
Ian - pls verify this on the branch builds at your earliest convenience. Thanks.
Comment 20•24 years ago
|
||
VERIFIED on branch per
http://bugzilla.mozilla.org/showattachment.cgi?attach_id=34822
Marking VERIFIED since trunk has already been verified.
Status: RESOLVED → VERIFIED
You need to log in
before you can comment on or make changes to this bug.
Description
•