Closed Bug 119167 Opened 23 years ago Closed 22 years ago

offsetLeft & offsetTop wrong

Categories

(Core :: DOM: Core & HTML, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: michalsc, Assigned: jst)

References

()

Details

(Keywords: testcase)

Attachments

(1 file)

the offsetLeft and offsetTop of parents of DIV element are broken. Let's look at given URL. THere is: {div} x=6 y=6 (OK) {TD} x=130 y=10 (should be 134,14) {TR} x=0 y=10 (should be 14,14) {TBODY} x=0 y=10 (should be 14,14) {TABLE} x=8 y=8 (OK) This is true for mozilla 0.9.7 (BUILD ID: 2002010803). For previous browser the offset values were wrong, but hopefully offsetLeft and offsetTop for ANY element were the absolute positions (instead of relative) you should add the width of the border to y value of TD TR and TBODY, x value of TD. BEsides you should add cellspacing to x value of TR and TBODY THat's all for today :)
Hmm, this brings back vauge unpleasant memories of trying to make mozilla's offset* properties match IE's as closely as possible. Have a look at the if 0'ed code at: http://lxr.mozilla.org/seamonkey/source/content/html/content/src/nsGenericHTMLElement.cpp#715 The code that includes the borders of the element itself in .offsetLeft/Top was taken out to make those properties match IE's better, the reason was IIRC that IE incorrectly lays ouy absolutely positioned elements with borders, IIRC the width you specify in CSS for the element will include the borders in IE, where it correclty doesn't in Mozilla. Michal, would you be able to experiment with this and prove me wrong? :-) If you do, and there turns out to be a better compromise, I'll be happy to fix mozilla.
Michal, any chance of providing the info jst asked for?
The comment You've asked for. Due to low-bandwitch connection I cannot experiment with the code so here are my thought about that: 1. problems ;-) I was looking a bit at the nsGenericHTMLElement.cpp you've proposed. I agree with you with this #if 0 there. It would be more IE-incompatible with this section of code. But OTOH if you've missed other thing: when I query for offset values of TR and TBODY, mozilla should give me: x=mx + border value of the TABLE that TR belongs to y=my + border value of the same TABLE as above where mx and my are the values calculated in given cpp code right now. when I query for offset values of TD, mozilla should do a bit more werid calculations: x=mx + border*(col+2)/2 y=my + border*(row+2)/2 where border is the same border value as above and col means the current collumn of the table (starting from 0) and row is the current row in the table (starting from 0). I did this assumptions by creating dommy table with parameters changed by me. For the (0,0) position in the table I got the following (x,y)'s of TD: (10,10 => border=0), (14,14 => border=4). For the (0,1) position I've got: (130,10 => border=0), but (136, 14 => border=4). For (0,2) there is (250,10 => border=0) and (258,10 => border=4). 2. big problems. Dunno why, by your code reports offsetLeft=0 for both TR and TBODY elements while it should be (for my example) equal cellspacing (10) without assumptions given above. Could you check it please?
Status: UNCONFIRMED → NEW
Ever confirmed: true
Keywords: testcase
The patch in bug 163923 seems to fix this bug.
Depends on: 163923
fixed by checkin for bug 163923
Status: NEW → RESOLVED
Closed: 22 years ago
Resolution: --- → FIXED
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: