- if ($.getCSS(e,"display") != 'none')
- return p == 'height' ?
- e.offsetHeight || parseInt(e.style.height) :
- e.offsetWidth || parseInt(e.style.width);
- var els = e.style;
- var ov = els.visibility;
- var op = els.position;
- var od = els.display;
- els.visibility = 'hidden';
- els.position = 'absolute';
- els.display = '';
- var oHeight = e.clientHeight || parseInt(e.style.height);
- var oWidth = e.clientWidth || parseInt(e.style.width);
- els.display = od;
- els.position = op;
- els.visibility = ov;
- return p == 'height' ? oHeight : oWidth;
+
+ // Handle extra width/height provided by the W3C box model
+ var ph = !$.boxModel ? 0 :
+ parseInt($.css(e,"paddingTop")) + parseInt($.css(e,"paddingBottom")) +
+ parseInt($.css(e,"borderTop")) + parseInt($.css(e,"borderBottom"));
+
+ var pw = !$.boxModel ? 0 :
+ parseInt($.css(e,"paddingLeft")) + parseInt($.css(e,"paddingRight")) +
+ parseInt($.css(e,"borderLeft")) + parseInt($.css(e,"borderRight"));
+
+ var oHeight, oWidth;
+
+ if ($.css(e,"display") != 'none') {
+ oHeight = e.offsetHeight || parseInt(e.style.height,10);
+ oWidth = e.offsetWidth || parseInt(e.style.width,10);
+ } else {
+ var els = e.style;
+ var ov = els.visibility;
+ var op = els.position;
+ var od = els.display;
+ els.visibility = 'hidden';
+ els.position = 'absolute';
+ els.display = '';
+ oHeight = e.clientHeight || parseInt(e.style.height,10);
+ oWidth = e.clientWidth || parseInt(e.style.width,10);
+ els.display = od;
+ els.position = op;
+ els.visibility = ov;
+ }
+
+ return p == 'height' ?
+ (oHeight - ph < 0 ? 0 : oHeight - ph) :
+ (oWidth - pw < 0 ? 0 : oWidth - pw);