From 0a5e46abff72fc60179255ad822462e9917ca0e4 Mon Sep 17 00:00:00 2001 From: Mounir Lamouri Date: Fri, 25 Mar 2011 12:40:55 +0100 Subject: [PATCH] Bug 610212 - canvas.width and canvas.height should be reflected as unsigned int. r=jst --- content/canvas/test/test_canvas.html | 4 +-- .../html/content/src/nsHTMLCanvasElement.cpp | 6 ++-- content/html/content/test/Makefile.in | 1 + content/html/content/test/test_bug610212.html | 31 +++++++++++++++++++ .../html/nsIDOMHTMLCanvasElement.idl | 6 ++-- 5 files changed, 40 insertions(+), 8 deletions(-) create mode 100644 content/html/content/test/test_bug610212.html diff --git a/content/canvas/test/test_canvas.html b/content/canvas/test/test_canvas.html index ba2f9e2eb3f4..51c46a15dda5 100644 --- a/content/canvas/test/test_canvas.html +++ b/content/canvas/test/test_canvas.html @@ -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"); } diff --git a/content/html/content/src/nsHTMLCanvasElement.cpp b/content/html/content/src/nsHTMLCanvasElement.cpp index f06a0abc7c71..116dcf8372b9 100644 --- a/content/html/content/src/nsHTMLCanvasElement.cpp +++ b/content/html/content/src/nsHTMLCanvasElement.cpp @@ -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, diff --git a/content/html/content/test/Makefile.in b/content/html/content/test/Makefile.in index 4a43894c6594..fe70c08c0f6a 100644 --- a/content/html/content/test/Makefile.in +++ b/content/html/content/test/Makefile.in @@ -256,6 +256,7 @@ _TEST_FILES = \ test_bug622597.html \ test_bug636336.html \ test_bug630889.html \ + test_bug610212.html \ $(NULL) libs:: $(_TEST_FILES) diff --git a/content/html/content/test/test_bug610212.html b/content/html/content/test/test_bug610212.html new file mode 100644 index 000000000000..44cc9e255cac --- /dev/null +++ b/content/html/content/test/test_bug610212.html @@ -0,0 +1,31 @@ + + + + + Test for Bug 610212 + + + + + + +Mozilla Bug 610212 +

+ +
+
+
+ + diff --git a/dom/interfaces/html/nsIDOMHTMLCanvasElement.idl b/dom/interfaces/html/nsIDOMHTMLCanvasElement.idl index ae00d848e996..809e7bb94da7 100644 --- a/dom/interfaces/html/nsIDOMHTMLCanvasElement.idl +++ b/dom/interfaces/html/nsIDOMHTMLCanvasElement.idl @@ -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,