Bug 648910 - Make nsIDOMHTMLImageElement widths and heights unsigned to match the HTML5 spec. r=jst

This commit is contained in:
Mats Palmgren 2011-07-11 22:18:26 +02:00
parent c8375f12ac
commit 8f3490e2d0
2 changed files with 21 additions and 13 deletions

View File

@ -287,11 +287,13 @@ nsHTMLImageElement::GetWidthHeight()
}
}
NS_ASSERTION(size.width >= 0, "negative width");
NS_ASSERTION(size.height >= 0, "negative height");
return size;
}
NS_IMETHODIMP
nsHTMLImageElement::GetHeight(PRInt32* aHeight)
nsHTMLImageElement::GetHeight(PRUint32* aHeight)
{
*aHeight = GetWidthHeight().height;
@ -299,7 +301,7 @@ nsHTMLImageElement::GetHeight(PRInt32* aHeight)
}
NS_IMETHODIMP
nsHTMLImageElement::SetHeight(PRInt32 aHeight)
nsHTMLImageElement::SetHeight(PRUint32 aHeight)
{
nsAutoString val;
val.AppendInt(aHeight);
@ -309,7 +311,7 @@ nsHTMLImageElement::SetHeight(PRInt32 aHeight)
}
NS_IMETHODIMP
nsHTMLImageElement::GetWidth(PRInt32* aWidth)
nsHTMLImageElement::GetWidth(PRUint32* aWidth)
{
*aWidth = GetWidthHeight().width;
@ -317,7 +319,7 @@ nsHTMLImageElement::GetWidth(PRInt32* aWidth)
}
NS_IMETHODIMP
nsHTMLImageElement::SetWidth(PRInt32 aWidth)
nsHTMLImageElement::SetWidth(PRUint32 aWidth)
{
nsAutoString val;
val.AppendInt(aWidth);
@ -576,7 +578,7 @@ nsHTMLImageElement::Initialize(nsISupports* aOwner, JSContext* aContext,
}
NS_IMETHODIMP
nsHTMLImageElement::GetNaturalHeight(PRInt32* aNaturalHeight)
nsHTMLImageElement::GetNaturalHeight(PRUint32* aNaturalHeight)
{
NS_ENSURE_ARG_POINTER(aNaturalHeight);
@ -592,12 +594,15 @@ nsHTMLImageElement::GetNaturalHeight(PRInt32* aNaturalHeight)
return NS_OK;
}
image->GetHeight(aNaturalHeight);
PRInt32 height;
if (NS_SUCCEEDED(image->GetHeight(&height))) {
*aNaturalHeight = height;
}
return NS_OK;
}
NS_IMETHODIMP
nsHTMLImageElement::GetNaturalWidth(PRInt32* aNaturalWidth)
nsHTMLImageElement::GetNaturalWidth(PRUint32* aNaturalWidth)
{
NS_ENSURE_ARG_POINTER(aNaturalWidth);
@ -613,7 +618,10 @@ nsHTMLImageElement::GetNaturalWidth(PRInt32* aNaturalWidth)
return NS_OK;
}
image->GetWidth(aNaturalWidth);
PRInt32 width;
if (NS_SUCCEEDED(image->GetWidth(&width))) {
*aNaturalWidth = width;
}
return NS_OK;
}

View File

@ -50,17 +50,17 @@
* http://www.whatwg.org/specs/web-apps/current-work/
*/
[scriptable, uuid(cf8a8744-ec3b-474e-8f2b-8def3da2344a)]
[scriptable, uuid(4bedb0a0-f901-4c61-a93a-a43c1b7674d4)]
interface nsIDOMHTMLImageElement : nsIDOMHTMLElement
{
attribute DOMString alt;
attribute DOMString src;
attribute DOMString useMap;
attribute boolean isMap;
attribute long width;
attribute long height;
readonly attribute long naturalWidth;
readonly attribute long naturalHeight;
attribute unsigned long width;
attribute unsigned long height;
readonly attribute unsigned long naturalWidth;
readonly attribute unsigned long naturalHeight;
readonly attribute boolean complete;