Fix computed style for large integers by using double instead of float. (Bug 470769) r+sr=bzbarsky

This commit is contained in:
L. David Baron 2008-12-23 09:06:59 -05:00
Родитель 993e374353
Коммит 420d8226e6
5 изменённых файлов: 42 добавлений и 9 удалений

Просмотреть файл

@ -3383,7 +3383,7 @@ nsComputedDOMStyle::SetValueToCoord(nsROCSSPrimitiveValue* aValue,
break;
case eStyleUnit_Integer:
aValue->SetNumber(aCoord.GetIntValue());
aValue->SetNumber(aCoord.GetIntValue()); // XXX This should really be integer
break;
case eStyleUnit_Enumerated:

Просмотреть файл

@ -372,12 +372,12 @@ nsROCSSPrimitiveValue::GetFloatValue(PRUint16 aUnitType, float* aReturn)
case CSS_PERCENTAGE :
if (mType != CSS_PERCENTAGE)
return NS_ERROR_DOM_INVALID_ACCESS_ERR;
*aReturn = mValue.mFloat * 100;
*aReturn = float(mValue.mFloat * 100);
break;
case CSS_NUMBER :
if (mType != CSS_NUMBER)
return NS_ERROR_DOM_INVALID_ACCESS_ERR;
*aReturn = mValue.mFloat;
*aReturn = float(mValue.mFloat);
break;
case CSS_UNKNOWN :
case CSS_EMS :

Просмотреть файл

@ -73,28 +73,28 @@ public:
void SetNumber(float aValue)
{
Reset();
mValue.mFloat = aValue;
mValue.mFloat = double(aValue);
mType = CSS_NUMBER;
}
void SetNumber(PRInt32 aValue)
{
Reset();
mValue.mFloat = float(aValue);
mValue.mFloat = double(aValue);
mType = CSS_NUMBER;
}
void SetNumber(PRUint32 aValue)
{
Reset();
mValue.mFloat = float(aValue);
mValue.mFloat = double(aValue);
mType = CSS_NUMBER;
}
void SetPercent(float aValue)
{
Reset();
mValue.mFloat = aValue;
mValue.mFloat = double(aValue);
mType = CSS_PERCENTAGE;
}
@ -230,10 +230,11 @@ private:
void GetEscapedURI(nsIURI *aURI, PRUnichar **aReturn);
PRUint16 mType;
PRInt32 mAppUnitsPerInch;
union {
nscoord mAppUnits;
float mFloat;
double mFloat;
nsDOMCSSRGBColor* mColor;
nsIDOMRect* mRect;
PRUnichar* mString;
@ -241,7 +242,6 @@ private:
nsIAtom* mAtom; // FIXME use nsCSSKeyword instead
} mValue;
PRInt32 mAppUnitsPerInch;
};
#endif /* nsROCSSPrimitiveValue_h___ */

Просмотреть файл

@ -82,6 +82,7 @@ _TEST_FILES = test_acid3_test46.html \
test_bug365932.html \
test_bug372770.html \
test_bug373293.html \
test_bug373875.html \
test_bug377947.html \
test_bug379440.html \
test_bug379741.html \

Просмотреть файл

@ -0,0 +1,32 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=373875
-->
<head>
<title>Test for Bug 373875</title>
<script type="application/javascript" src="/MochiKit/MochiKit.js"></script>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=373875">Mozilla Bug 373875</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script type="application/javascript">
/** Test for Bug 373875 **/
var e = document.getElementById("display");
e.setAttribute("style", "z-index: 2147483647"); // maximum signed 32-bit
is(e.style.zIndex, "2147483647", "element.style should roundtrip correctly");
is(window.getComputedStyle(e, "").zIndex, "2147483647",
"element.style should roundtrip correctly");
</script>
</pre>
</body>
</html>