Ticket #3239 (closed bug: fixed)
innerHeight/outerHeight does not round up
|Reported by:||Tgr||Owned by:||brandon|
|Keywords:||Cc:||Tgr, flesler, brandon|
innerHeight and outerHeight are sometimes one pixel off from what one might expect, because they floor instead of rounding when there sizes are not integer in pixel.
On this page (the relevant code can be found here (the first function), the original, innerHeight-based version here) I tried to position a box to the bottom of another box, and the result was sometimes but not always one pixel off, depending on the contents. Casting the relevant css attributes (height, padding-top/bottom, border-top/bottom-width) to float and summing them resulted in 41.616699999999994; outerHeight returned 41. (Tested with Firefox 3 (Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:22.214.171.124) Gecko/2008070208 Firefox/3.0.1) on 1280x800.)
Not a bug in the strictest sense, but it makes pixel-perfect positioning with these functions impossible in certain cases. Rounding or returning the exact value seems more useful to me.
Also, from the source it seems that height, padding etc. are first cast to int and then summed; I haven't tested this, but it seems that rounding errors could grow to 6-7 pixels in unlucky cases.