Bug 14722 - REGRESSION: border is not taken in account with offsetLeft (and probally offsetTop)
Summary: REGRESSION: border is not taken in account with offsetLeft (and probally offs...
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: 523.x (Safari 3)
Hardware: All All
: P1 Major
Assignee: Nobody
Keywords: HasReduction, InRadar, Regression
Depends on:
Reported: 2007-07-23 07:51 PDT by Sjoerd Mulder
Modified: 2007-08-02 13:45 PDT (History)
1 user (show)

See Also:

Testcase (883 bytes, text/html)
2007-07-23 07:53 PDT, Sjoerd Mulder
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Sjoerd Mulder 2007-07-23 07:51:46 PDT
See attached testcase where it should set the offsetLeft value with the size of the 50px border of the parent it does not take this in account. 

In Safari 2.0.4 it works correctly,

tested on Windows XP, Mac OSX 10.4.10 and Mac OSX 10.5
Comment 1 Sjoerd Mulder 2007-07-23 07:53:21 PDT
Created attachment 15649 [details]
Comment 2 David Kilzer (:ddkilzer) 2007-07-23 23:04:46 PDT
(In reply to comment #1)
> Created an attachment (id=15649) [edit]
> Testcase

So the test case passes if "border - left:78" is printed, but fails if "border - left:28" is printed?

Firefox and Safari 3.0 (522.12) + WebKit r24534 print "border - left:28".

Opera 9.21 and Safari 2.0.4 (419.3) + original WebKit print "border -left:78".

What does MSIE 6/7 print?

Comment 3 David Kilzer (:ddkilzer) 2007-07-23 23:05:55 PDT
Confirming difference between Safari 2.0 and Safari 3.0 + ToT WebKit, but I'm not sure if this is a regression or not.  (Assuming it is for now.)

Comment 4 Sjoerd Mulder 2007-07-24 00:53:34 PDT
I Agree that the change isnt a regression if this was intented. The problem is part of a bigger issue: measurement of layout,

- IE has getBoundingClientRect() (offsetTop / offsetLeft is not reliable)
- Gecko has getBoxObjectFor() (offsetTop / offsetLeft is not reliable)
- Opera / Webkit have offsetTop / offsetLeft / offsetParent working reliable.

In Safari 2 and Opera 9 the behavior is like expected, the 'offsetLeft' of the elements summed together is the value in pixels the element is positioned from the left side of the screen (78px).

In Safari 3 this changed, sure their can be an exception added for Safari 3 but it would be quite annoying if in Safari 3.0.1. the behavior is different again,.

That's why i reporting this bug as a regression, a lot of frameworks / toolkits which use 'offset' properties to measure position need to implement specific Safari 3 code
Comment 5 David Kilzer (:ddkilzer) 2007-07-24 07:09:49 PDT
(In reply to comment #2)
> So the test case passes if "border - left:78" is printed, but fails if "border
> - left:28" is printed?

Yes, per Comment #4.
Comment 6 David Kilzer (:ddkilzer) 2007-07-24 07:10:56 PDT
Comment 7 David Kilzer (:ddkilzer) 2007-07-24 07:36:53 PDT
Bug 13237, Comment #10:

Comment #10 From Dave Hyatt 2007-07-24 04:08 PDT [reply]

offsetLeft/Top are relative to your offsetParent.  I would guess we had
offsetParent wrong.  The goal here is to match IE.  What does IE return here?

Comment 8 Sjoerd Mulder 2007-07-24 08:56:51 PDT
I think the behavior of IE should not be matched with offsetParent / left / top. IE is complete buggy concerning to offsetParent / Left / Top (e.g. when mixing border / padding / margin / box-model / position / overflow) and though not reliable.

Better would be to keep matching Safari 2.0.4 (was working fine except for TR elements but that is solved) and Opera 9.x (i remember a discussion on the Opera lists a while ago, see: http://dump.testsuite.org/2006/dom/style/offset/spec)
Comment 9 Antti Koivisto 2007-08-02 10:56:20 PDT
In Safari 3.0 we are matching Firefox offset behavior on purpose, see bug 12687. I think this should be changed now.
Comment 10 Antti Koivisto 2007-08-02 10:57:08 PDT
I meant to say that this should _not_ be changed now.
Comment 11 John Sullivan 2007-08-02 13:45:06 PDT
In Radar, Dave Hyatt agrees that this should not be changed. Setting to WONTFIX