Opened 12 years ago

Closed 12 years ago

#3222 closed defect (fixed)

dojo.coords incorrect; borderBox in IE, contentBox in Firefox

Reported by: haysmark Owned by: sjmiles
Priority: high Milestone: 1.1
Component: HTML Version: 0.9
Keywords: Cc:
Blocked By: Blocking:

Description (last modified by haysmark)

Try the following very simple test of dojo.coords in Firefox and compare it to IE and Safari:

<html>
<head>
<script type="text/javascript" src="../../../dojo/dojo.js"></script>
</head>
<body>
<input type="text" style="border:20px solid red; position:absolute; left:0px; top:0px;" id="text">
<input type="button" style="position:absolute; left:0px; top:100px;" onClick="with(dojo.coords(document.getElementById('text'), true)){alert('x: '+x+' y: '+y);};" value="Where is the textbox?">
</body>
</html>

Other browsers will report tiny numbers (like 2,2 in IE). But guess what Firefox reports? 20,20! The Firefox code in dojo.coords is incorrectly calling getBoxObjectFor, which gets the content box, NOT the border box that gets calculated for all of the other browsers in dojo.coords. The Firefox case in dojo.coords needs to return the coordinates of the border box so it acts like the other browsers.

Change History (9)

comment:1 Changed 12 years ago by bill

Component: CoreHTML
Owner: changed from alex to sjmiles

Sounds like a bug to me; Scott wrote all the HTML code, right? Reassigning to him.

comment:2 Changed 12 years ago by bill

Owner: changed from sjmiles to alex

Hmm, Scott says he's not the owner of the html code. I'm confused. Anyway, switching it back to Alex for now.

comment:3 Changed 12 years ago by Adam Peller

Owner: changed from alex to haysmark

Mark, there were some changes recently in this area. Can you retest?

comment:4 Changed 12 years ago by haysmark

Description: modified (diff)
Owner: changed from haysmark to alex
Priority: highnormal
severity: majornormal
Summary: dojo.coords incorrect; throwing off Selectdojo.coords incorrect; borderBox in IE, contentBox in Firefox

IE and Safari still report 2,2, and FF still reports 20,20. That just has to be wrong.

comment:5 Changed 12 years ago by tk

I dont see how the stated problem is even correct....

dojo._getBorderBox is NEVER used.. it is the ONLY box model that has no getter/setter and no wrapper (dojo.borderBox()) function...

Since this isnt what I expected, I'll go open my ticket now, but I do find it odd that all the box models are fleshed out, but _getBorderBox()... an oversight maybe?

comment:6 Changed 12 years ago by Adam Peller

Cc: sjmiles added

comment:7 Changed 12 years ago by Douglas Hays

Cc: sjmiles removed
Owner: changed from alex to sjmiles

comment:8 Changed 12 years ago by sjmiles

Milestone: 0.91.0

To clear up confusion, I believe I am the module owner for the html code. What I said to Bill was that I did not actually write the coords or abs methods.

Unfortunately, there are major browser difference with respect to how margins are presented and we need some overhaul.

comment:9 Changed 12 years ago by bill

Resolution: fixed
Status: newclosed

(In [12079]) Fix dojo.coords() on FF to account for borders (rather than returning the content box). Fixes #3222, #3676, #5541. !strict

Note: See TracTickets for help on using tickets.