Bug 610212 - canvas.width and canvas.height should be reflected as unsigned int. r=jst

This commit is contained in:
Mounir Lamouri 2011-03-25 12:40:55 +01:00
Родитель 8493ce2b20
Коммит 0a5e46abff
5 изменённых файлов: 40 добавлений и 8 удалений

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

@ -19871,7 +19871,7 @@ function test_size_attributes_parse_negative() {
var canvas = document.getElementById('c639');
var ctx = canvas.getContext('2d');
todo(canvas.width == 300, "canvas.width == 300");
ok(canvas.width == 300, "canvas.width == 300");
}
@ -20084,7 +20084,7 @@ var canvas = document.getElementById('c650');
var ctx = canvas.getContext('2d');
canvas.setAttribute('width', '-100');
todo(canvas.width == 300, "canvas.width == 300");
ok(canvas.width == 300, "canvas.width == 300");
}

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

@ -126,8 +126,8 @@ nsHTMLCanvasElement::GetWidthHeight()
return size;
}
NS_IMPL_INT_ATTR_DEFAULT_VALUE(nsHTMLCanvasElement, Width, width, DEFAULT_CANVAS_WIDTH)
NS_IMPL_INT_ATTR_DEFAULT_VALUE(nsHTMLCanvasElement, Height, height, DEFAULT_CANVAS_HEIGHT)
NS_IMPL_UINT_ATTR_DEFAULT_VALUE(nsHTMLCanvasElement, Width, width, DEFAULT_CANVAS_WIDTH)
NS_IMPL_UINT_ATTR_DEFAULT_VALUE(nsHTMLCanvasElement, Height, height, DEFAULT_CANVAS_HEIGHT)
NS_IMPL_BOOL_ATTR(nsHTMLCanvasElement, MozOpaque, moz_opaque)
nsresult
@ -190,7 +190,7 @@ nsHTMLCanvasElement::ParseAttribute(PRInt32 aNamespaceID,
{
if (aNamespaceID == kNameSpaceID_None &&
(aAttribute == nsGkAtoms::width || aAttribute == nsGkAtoms::height)) {
return aResult.ParseIntWithBounds(aValue, 0);
return aResult.ParseNonNegativeIntValue(aValue);
}
return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue,

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

@ -256,6 +256,7 @@ _TEST_FILES = \
test_bug622597.html \
test_bug636336.html \
test_bug630889.html \
test_bug610212.html \
$(NULL)
libs:: $(_TEST_FILES)

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

@ -0,0 +1,31 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=610212
-->
<head>
<title>Test for Bug 610212</title>
<script type="application/javascript" src="/MochiKit/packed.js"></script>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="reflect.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=610212">Mozilla Bug 610212</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script type="application/javascript">
/** Test for Bug 610212 **/
var canvas = document.createElement('canvas');
reflectUnsignedInt(canvas, "width", false, 300);
reflectUnsignedInt(canvas, "height", false, 150);
</script>
</pre>
</body>
</html>

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

@ -54,11 +54,11 @@
interface nsIDOMFile;
[scriptable, uuid(53ad994a-3cd0-48fa-8ffb-7f3d8cd19c50)]
[scriptable, uuid(6b44a95a-c0ad-41f9-beb5-579bdb8698f2)]
interface nsIDOMHTMLCanvasElement : nsIDOMHTMLElement
{
attribute long width;
attribute long height;
attribute unsigned long width;
attribute unsigned long height;
attribute boolean mozOpaque;
nsISupports getContext(in DOMString contextId,