Closed Bug 400258 Opened 13 years ago Closed 7 months ago

offsetLeft includes borders when box-sizing is border-box

Categories

(Core :: DOM: CSS Object Model, defect, P2)

1.8 Branch
defect

Tracking

()

RESOLVED FIXED
mozilla71
Tracking Status
firefox71 --- fixed

People

(Reporter: marcus, Assigned: mats, NeedInfo)

References

()

Details

Attachments

(4 files)

User-Agent:       Mozilla/5.0 (compatible; Konqueror/3.5; Linux) KHTML/3.5.7 (like Gecko) (Debian)
Build Identifier: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.6) Gecko/20070723 Iceweasel/2.0.0.6

The offsetParent's border is usually not included in the offsetLeft value. However if the parent's -moz-box-sizing is "border-box", then the border _is_ included.

This is contrary to how MSIE 7 and WebKit behave (see http://bugs.webkit.org/show_bug.cgi?id=15539).

Reproducible: Always
Version: unspecified → 1.8 Branch
Attached file Test case
This shows the values that are included in the offsetLeft of the div2 element. The box turns red if the test fails. Expected results are 384,384 (div2 margin plus div2 top/left).

(Note that the bug equally affects offsetTop.)

Spec: https://drafts.csswg.org/cssom-view/#dom-htmlelement-offsetleft
I don't see any special handling for box-sizing: border-box in the spec so this definitely looks like a bug to me.
Incidentally, it also makes us erroneously fail some WPTs that use offsetLeft/offsetTop to verify the correct layout.
https://searchfox.org/mozilla-central/search?q=checkLayout(

Yikes, I can't believe this bug has been open for 12 years without anyone investigating it...

Assignee: nobody → mats
Status: UNCONFIRMED → NEW
Component: Layout: Block and Inline → DOM: CSS Object Model
Ever confirmed: true
OS: Linux → All
Priority: -- → P2
Hardware: x86 → All
Blocks: 1549620
Pushed by mpalmgren@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/2a9d67d7b2d2
Use the padding edge as the origin for offsetLeft/offsetTop also for box-sizing:border-box boxes.  r=emilio
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/19057 for changes under testing/web-platform/tests
Status: NEW → RESOLVED
Closed: 7 months ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla71
Regressions: 1581340
Pushed by james@hoppipolla.co.uk:
https://hg.mozilla.org/integration/autoland/rev/42cdcfe496d6
Move CSSOM test to load Ahem as a webfont, r=emilio
Upstream web-platform-tests status checks passed, PR will merge once commit reaches central.
Upstream PR merged by moz-wptsync-bot
You need to log in before you can comment on or make changes to this bug.