bug 114593, enable exceptions for table.insertCell r=me sr=jst patch by bz

git-svn-id: svn://10.0.0.236/trunk@111046 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
bernd.mielke%snafu.de 2001-12-23 16:21:10 +00:00
parent de73bb35c1
commit 55c2f72487

View File

@ -40,6 +40,7 @@
#include "nsIDOMHTMLTableSectionElem.h"
#include "nsIDOMHTMLTableCellElement.h"
#include "nsIDOMEventReceiver.h"
#include "nsDOMError.h"
#include "nsIHTMLContent.h"
#include "nsIHTMLAttributes.h"
#include "nsGenericHTMLElement.h"
@ -442,6 +443,9 @@ nsHTMLTableRowElement::InsertCell(PRInt32 aIndex, nsIDOMHTMLElement** aValue)
{
*aValue = nsnull;
if (aIndex < 0)
return NS_ERROR_DOM_INDEX_SIZE_ERR;
nsCOMPtr<nsIDOMHTMLCollection> cells;
GetCells(getter_AddRefs(cells));
@ -449,6 +453,9 @@ nsHTMLTableRowElement::InsertCell(PRInt32 aIndex, nsIDOMHTMLElement** aValue)
PRUint32 cellCount;
cells->GetLength(&cellCount);
if (aIndex > PRInt32(cellCount))
return NS_ERROR_DOM_INDEX_SIZE_ERR;
PRBool doInsert = (aIndex < PRInt32(cellCount));
// create the cell
@ -491,20 +498,26 @@ nsHTMLTableRowElement::InsertCell(PRInt32 aIndex, nsIDOMHTMLElement** aValue)
NS_IMETHODIMP
nsHTMLTableRowElement::DeleteCell(PRInt32 aValue)
{
if (aValue < 0)
return NS_ERROR_DOM_INDEX_SIZE_ERR;
nsCOMPtr<nsIDOMHTMLCollection> cells;
GetCells(getter_AddRefs(cells));
nsCOMPtr<nsIDOMNode> cell;
cells->Item(aValue, getter_AddRefs(cell));
nsresult rv = cells->Item(aValue, getter_AddRefs(cell));
NS_ENSURE_SUCCESS(rv, rv);
if (cell) {
nsCOMPtr<nsIDOMNode> retChild;
RemoveChild(cell, getter_AddRefs(retChild));
if (!cell) {
return NS_ERROR_DOM_INDEX_SIZE_ERR;
}
nsCOMPtr<nsIDOMNode> retChild;
RemoveChild(cell, getter_AddRefs(retChild));
return NS_OK;
}