PDA

View Full Version : [CLOSED][3.??] getViewSize incorrect when parent element has style="width:x%"



fredemc
12 Jan 2010, 7:48 AM
Ext version tested:

Ext 3.1.0


Adapter used:

ext



css used:

only default ext-all.css




Browser versions tested against:

IE8 (Bug DOES NOT OCCUR in IE8)
FF 3.5.7 (with Firebug 1.4.5)


Operating System:

WinXP Pro


Description:

When a DOM element has a parent element whose width style is specified as a percentage (e.g. style="width:33%"), getComputedStyle returns a width string including a decimal fraction (e.g. "1052.43px"). When such a string is parsed inside Element.getViewSize, it gets only the fractional part of the width (43px). The bug occurs in Firefox 3.5.7, but in IE getComputedStyle seems to round to the neareast whole px value.


Test Case:



<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title id='title'>[3.1] Element.getViewSize sometimes fails to retrieve width correctly</title>

<link rel="stylesheet" type="text/css" href="js/ext-3.1.0/resources/css/ext-all.css" />

<script type="text/javascript" src="js/ext-3.1.0/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="js/ext-3.1.0/ext-all-debug.js"></script>


<script type="text/javascript">
Ext.BLANK_IMAGE_URL = 'js/ext-3.1.0/resources/images/default/s.gif';

Ext.onReady(function(){

var el = Ext.get("aDiv");
var gvs = el.getViewSize().width;
var actual = el.dom.offsetWidth;

if (gvs != actual)
alert("The reported width from Element.getViewSize is " + gvs +
" but the actual width is " + actual);

else
alert("Bug doesn't occur with this browser");


}); //end onReady
</script>

</head>
<body>
<div style="width:53%">
<div id="aDiv" >
This bug occurs on Firefox 3.5.7.
</div>
</div>

</body>
</html>


See this URL : http://


Steps to reproduce the problem:

Just run the test code.


The result that was expected:

Element.getViewSize should return the correct width, not the fraction.


The result that occurs instead:

Only the decimal fraction of the pixel width is returned.


Screenshot or Video:



Debugging already done:

The RegExp named "pxMatch" is at fault.


Possible fix:

not provided

Animal
12 Jan 2010, 7:54 AM
This has been reported and fixed in SVN.

The idea of returning fractional pixels was a bit of a surprise!

evant
17 Jan 2010, 1:52 PM
As Nige said, this is fixed in SVN. Marking this as closed.