зеркало из https://github.com/mozilla/gecko-dev.git
Fixing bug 67563. Adding null pointer checks to avoid crasing when accessing certain properties on orphan OPTION, TD and TH elements. r=harishd@netscape.com, r=nisheeth@netscape.com, sr=vidur@netscape.com
This commit is contained in:
Родитель
fd0cba1673
Коммит
f9f8015c1c
|
@ -95,8 +95,10 @@ protected:
|
||||||
nsresult GetPrimaryFrame(nsIFormControlFrame *&aFormControlFrame,
|
nsresult GetPrimaryFrame(nsIFormControlFrame *&aFormControlFrame,
|
||||||
PRBool aFlushNotifications = PR_TRUE);
|
PRBool aFlushNotifications = PR_TRUE);
|
||||||
|
|
||||||
// Get the select content element that contains this option
|
// Get the select content element that contains this option, this
|
||||||
nsresult GetSelect(nsIDOMHTMLSelectElement *&aSelectElement);
|
// intentionally does not return nsresult, all we care about is if
|
||||||
|
// there's a select associated with this option or not.
|
||||||
|
void GetSelect(nsIDOMHTMLSelectElement *&aSelectElement);
|
||||||
};
|
};
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
|
@ -193,6 +195,9 @@ nsHTMLOptionElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsHTMLOptionElement::GetForm(nsIDOMHTMLFormElement** aForm)
|
nsHTMLOptionElement::GetForm(nsIDOMHTMLFormElement** aForm)
|
||||||
{
|
{
|
||||||
|
NS_ENSURE_ARG_POINTER(aForm);
|
||||||
|
*aForm = nsnull;
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMHTMLSelectElement> selectElement;
|
nsCOMPtr<nsIDOMHTMLSelectElement> selectElement;
|
||||||
GetSelect(*getter_AddRefs(selectElement));
|
GetSelect(*getter_AddRefs(selectElement));
|
||||||
|
|
||||||
|
@ -270,7 +275,7 @@ nsHTMLOptionElement::SetSelected(PRBool aValue)
|
||||||
// Note: The select content obj maintains all the PresState
|
// Note: The select content obj maintains all the PresState
|
||||||
// so defer to it to get the answer
|
// so defer to it to get the answer
|
||||||
nsCOMPtr<nsIDOMNode> parentNode;
|
nsCOMPtr<nsIDOMNode> parentNode;
|
||||||
result = NS_ERROR_FAILURE;
|
result = NS_OK;
|
||||||
|
|
||||||
GetParentNode(getter_AddRefs(parentNode));
|
GetParentNode(getter_AddRefs(parentNode));
|
||||||
|
|
||||||
|
@ -597,7 +602,9 @@ nsHTMLOptionElement::GetPrimaryFrame(nsIFormControlFrame *&aIFormControlFrame,
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsIDOMHTMLSelectElement> selectElement;
|
nsCOMPtr<nsIDOMHTMLSelectElement> selectElement;
|
||||||
|
|
||||||
nsresult res = GetSelect(*getter_AddRefs(selectElement));
|
nsresult res = NS_ERROR_FAILURE; // This should be NS_OK;
|
||||||
|
|
||||||
|
GetSelect(*getter_AddRefs(selectElement));
|
||||||
|
|
||||||
if (selectElement) {
|
if (selectElement) {
|
||||||
nsCOMPtr<nsIHTMLContent> selectContent(do_QueryInterface(selectElement));
|
nsCOMPtr<nsIHTMLContent> selectContent(do_QueryInterface(selectElement));
|
||||||
|
@ -613,7 +620,7 @@ nsHTMLOptionElement::GetPrimaryFrame(nsIFormControlFrame *&aIFormControlFrame,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the select content element that contains this option
|
// Get the select content element that contains this option
|
||||||
nsresult
|
void
|
||||||
nsHTMLOptionElement::GetSelect(nsIDOMHTMLSelectElement *&aSelectElement)
|
nsHTMLOptionElement::GetSelect(nsIDOMHTMLSelectElement *&aSelectElement)
|
||||||
{
|
{
|
||||||
aSelectElement = nsnull;
|
aSelectElement = nsnull;
|
||||||
|
@ -621,11 +628,10 @@ nsHTMLOptionElement::GetSelect(nsIDOMHTMLSelectElement *&aSelectElement)
|
||||||
// Get the containing element (Either a select or an optGroup)
|
// Get the containing element (Either a select or an optGroup)
|
||||||
nsCOMPtr<nsIDOMNode> parentNode;
|
nsCOMPtr<nsIDOMNode> parentNode;
|
||||||
|
|
||||||
nsresult res = NS_ERROR_FAILURE;
|
|
||||||
|
|
||||||
GetParentNode(getter_AddRefs(parentNode));
|
GetParentNode(getter_AddRefs(parentNode));
|
||||||
|
|
||||||
if (parentNode) {
|
if (parentNode) {
|
||||||
|
nsresult res;
|
||||||
res = parentNode->QueryInterface(NS_GET_IID(nsIDOMHTMLSelectElement),
|
res = parentNode->QueryInterface(NS_GET_IID(nsIDOMHTMLSelectElement),
|
||||||
(void**)&aSelectElement);
|
(void**)&aSelectElement);
|
||||||
|
|
||||||
|
@ -647,13 +653,11 @@ nsHTMLOptionElement::GetSelect(nsIDOMHTMLSelectElement *&aSelectElement)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parentNode) {
|
if (parentNode) {
|
||||||
res = parentNode->QueryInterface(NS_GET_IID(nsIDOMHTMLSelectElement),
|
parentNode->QueryInterface(NS_GET_IID(nsIDOMHTMLSelectElement),
|
||||||
(void**)&aSelectElement);
|
(void**)&aSelectElement);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
|
|
|
@ -77,7 +77,9 @@ public:
|
||||||
NS_IMETHOD SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const;
|
NS_IMETHOD SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
nsresult GetRow(nsIDOMHTMLTableRowElement** aRow);
|
// This does not retunr a nsresult since all we care about is if we
|
||||||
|
// found the row element that this cell is in or not.
|
||||||
|
void GetRow(nsIDOMHTMLTableRowElement** aRow);
|
||||||
|
|
||||||
PRInt32 mColIndex;
|
PRInt32 mColIndex;
|
||||||
};
|
};
|
||||||
|
@ -171,14 +173,18 @@ NS_METHOD nsHTMLTableCellElement::SetColIndex (PRInt32 aColIndex)
|
||||||
}
|
}
|
||||||
|
|
||||||
// protected method
|
// protected method
|
||||||
nsresult
|
void
|
||||||
nsHTMLTableCellElement::GetRow(nsIDOMHTMLTableRowElement** aRow)
|
nsHTMLTableCellElement::GetRow(nsIDOMHTMLTableRowElement** aRow)
|
||||||
{
|
{
|
||||||
nsIDOMNode *rowNode;
|
*aRow = nsnull;
|
||||||
GetParentNode(&rowNode);
|
|
||||||
nsresult result = rowNode->QueryInterface(NS_GET_IID(nsIDOMHTMLTableRowElement), (void**)aRow);
|
nsCOMPtr<nsIDOMNode> rowNode;
|
||||||
NS_RELEASE(rowNode);
|
GetParentNode(getter_AddRefs(rowNode));
|
||||||
return result;
|
|
||||||
|
if (rowNode) {
|
||||||
|
rowNode->QueryInterface(NS_GET_IID(nsIDOMHTMLTableRowElement),
|
||||||
|
(void**)aRow);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
|
@ -190,10 +196,18 @@ nsHTMLTableCellElement::GetCellIndex(PRInt32* aCellIndex)
|
||||||
|
|
||||||
GetRow(getter_AddRefs(row));
|
GetRow(getter_AddRefs(row));
|
||||||
|
|
||||||
|
if (!row) {
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMHTMLCollection> cells;
|
nsCOMPtr<nsIDOMHTMLCollection> cells;
|
||||||
|
|
||||||
row->GetCells(getter_AddRefs(cells));
|
row->GetCells(getter_AddRefs(cells));
|
||||||
|
|
||||||
|
if (!cells) {
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
PRUint32 numCells;
|
PRUint32 numCells;
|
||||||
cells->GetLength(&numCells);
|
cells->GetLength(&numCells);
|
||||||
|
|
||||||
|
@ -227,10 +241,18 @@ nsHTMLTableCellElement::SetCellIndex(PRInt32 aCellIndex)
|
||||||
|
|
||||||
GetRow(getter_AddRefs(row));
|
GetRow(getter_AddRefs(row));
|
||||||
|
|
||||||
|
if (!row) {
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMHTMLCollection> cells;
|
nsCOMPtr<nsIDOMHTMLCollection> cells;
|
||||||
|
|
||||||
row->GetCells(getter_AddRefs(cells));
|
row->GetCells(getter_AddRefs(cells));
|
||||||
|
|
||||||
|
if (!cells) {
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
PRUint32 numCellsU;
|
PRUint32 numCellsU;
|
||||||
cells->GetLength(&numCellsU);
|
cells->GetLength(&numCellsU);
|
||||||
|
|
||||||
|
|
|
@ -95,8 +95,10 @@ protected:
|
||||||
nsresult GetPrimaryFrame(nsIFormControlFrame *&aFormControlFrame,
|
nsresult GetPrimaryFrame(nsIFormControlFrame *&aFormControlFrame,
|
||||||
PRBool aFlushNotifications = PR_TRUE);
|
PRBool aFlushNotifications = PR_TRUE);
|
||||||
|
|
||||||
// Get the select content element that contains this option
|
// Get the select content element that contains this option, this
|
||||||
nsresult GetSelect(nsIDOMHTMLSelectElement *&aSelectElement);
|
// intentionally does not return nsresult, all we care about is if
|
||||||
|
// there's a select associated with this option or not.
|
||||||
|
void GetSelect(nsIDOMHTMLSelectElement *&aSelectElement);
|
||||||
};
|
};
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
|
@ -193,6 +195,9 @@ nsHTMLOptionElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsHTMLOptionElement::GetForm(nsIDOMHTMLFormElement** aForm)
|
nsHTMLOptionElement::GetForm(nsIDOMHTMLFormElement** aForm)
|
||||||
{
|
{
|
||||||
|
NS_ENSURE_ARG_POINTER(aForm);
|
||||||
|
*aForm = nsnull;
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMHTMLSelectElement> selectElement;
|
nsCOMPtr<nsIDOMHTMLSelectElement> selectElement;
|
||||||
GetSelect(*getter_AddRefs(selectElement));
|
GetSelect(*getter_AddRefs(selectElement));
|
||||||
|
|
||||||
|
@ -270,7 +275,7 @@ nsHTMLOptionElement::SetSelected(PRBool aValue)
|
||||||
// Note: The select content obj maintains all the PresState
|
// Note: The select content obj maintains all the PresState
|
||||||
// so defer to it to get the answer
|
// so defer to it to get the answer
|
||||||
nsCOMPtr<nsIDOMNode> parentNode;
|
nsCOMPtr<nsIDOMNode> parentNode;
|
||||||
result = NS_ERROR_FAILURE;
|
result = NS_OK;
|
||||||
|
|
||||||
GetParentNode(getter_AddRefs(parentNode));
|
GetParentNode(getter_AddRefs(parentNode));
|
||||||
|
|
||||||
|
@ -597,7 +602,9 @@ nsHTMLOptionElement::GetPrimaryFrame(nsIFormControlFrame *&aIFormControlFrame,
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsIDOMHTMLSelectElement> selectElement;
|
nsCOMPtr<nsIDOMHTMLSelectElement> selectElement;
|
||||||
|
|
||||||
nsresult res = GetSelect(*getter_AddRefs(selectElement));
|
nsresult res = NS_ERROR_FAILURE; // This should be NS_OK;
|
||||||
|
|
||||||
|
GetSelect(*getter_AddRefs(selectElement));
|
||||||
|
|
||||||
if (selectElement) {
|
if (selectElement) {
|
||||||
nsCOMPtr<nsIHTMLContent> selectContent(do_QueryInterface(selectElement));
|
nsCOMPtr<nsIHTMLContent> selectContent(do_QueryInterface(selectElement));
|
||||||
|
@ -613,7 +620,7 @@ nsHTMLOptionElement::GetPrimaryFrame(nsIFormControlFrame *&aIFormControlFrame,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the select content element that contains this option
|
// Get the select content element that contains this option
|
||||||
nsresult
|
void
|
||||||
nsHTMLOptionElement::GetSelect(nsIDOMHTMLSelectElement *&aSelectElement)
|
nsHTMLOptionElement::GetSelect(nsIDOMHTMLSelectElement *&aSelectElement)
|
||||||
{
|
{
|
||||||
aSelectElement = nsnull;
|
aSelectElement = nsnull;
|
||||||
|
@ -621,11 +628,10 @@ nsHTMLOptionElement::GetSelect(nsIDOMHTMLSelectElement *&aSelectElement)
|
||||||
// Get the containing element (Either a select or an optGroup)
|
// Get the containing element (Either a select or an optGroup)
|
||||||
nsCOMPtr<nsIDOMNode> parentNode;
|
nsCOMPtr<nsIDOMNode> parentNode;
|
||||||
|
|
||||||
nsresult res = NS_ERROR_FAILURE;
|
|
||||||
|
|
||||||
GetParentNode(getter_AddRefs(parentNode));
|
GetParentNode(getter_AddRefs(parentNode));
|
||||||
|
|
||||||
if (parentNode) {
|
if (parentNode) {
|
||||||
|
nsresult res;
|
||||||
res = parentNode->QueryInterface(NS_GET_IID(nsIDOMHTMLSelectElement),
|
res = parentNode->QueryInterface(NS_GET_IID(nsIDOMHTMLSelectElement),
|
||||||
(void**)&aSelectElement);
|
(void**)&aSelectElement);
|
||||||
|
|
||||||
|
@ -647,13 +653,11 @@ nsHTMLOptionElement::GetSelect(nsIDOMHTMLSelectElement *&aSelectElement)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parentNode) {
|
if (parentNode) {
|
||||||
res = parentNode->QueryInterface(NS_GET_IID(nsIDOMHTMLSelectElement),
|
parentNode->QueryInterface(NS_GET_IID(nsIDOMHTMLSelectElement),
|
||||||
(void**)&aSelectElement);
|
(void**)&aSelectElement);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
|
|
|
@ -77,7 +77,9 @@ public:
|
||||||
NS_IMETHOD SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const;
|
NS_IMETHOD SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
nsresult GetRow(nsIDOMHTMLTableRowElement** aRow);
|
// This does not retunr a nsresult since all we care about is if we
|
||||||
|
// found the row element that this cell is in or not.
|
||||||
|
void GetRow(nsIDOMHTMLTableRowElement** aRow);
|
||||||
|
|
||||||
PRInt32 mColIndex;
|
PRInt32 mColIndex;
|
||||||
};
|
};
|
||||||
|
@ -171,14 +173,18 @@ NS_METHOD nsHTMLTableCellElement::SetColIndex (PRInt32 aColIndex)
|
||||||
}
|
}
|
||||||
|
|
||||||
// protected method
|
// protected method
|
||||||
nsresult
|
void
|
||||||
nsHTMLTableCellElement::GetRow(nsIDOMHTMLTableRowElement** aRow)
|
nsHTMLTableCellElement::GetRow(nsIDOMHTMLTableRowElement** aRow)
|
||||||
{
|
{
|
||||||
nsIDOMNode *rowNode;
|
*aRow = nsnull;
|
||||||
GetParentNode(&rowNode);
|
|
||||||
nsresult result = rowNode->QueryInterface(NS_GET_IID(nsIDOMHTMLTableRowElement), (void**)aRow);
|
nsCOMPtr<nsIDOMNode> rowNode;
|
||||||
NS_RELEASE(rowNode);
|
GetParentNode(getter_AddRefs(rowNode));
|
||||||
return result;
|
|
||||||
|
if (rowNode) {
|
||||||
|
rowNode->QueryInterface(NS_GET_IID(nsIDOMHTMLTableRowElement),
|
||||||
|
(void**)aRow);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
|
@ -190,10 +196,18 @@ nsHTMLTableCellElement::GetCellIndex(PRInt32* aCellIndex)
|
||||||
|
|
||||||
GetRow(getter_AddRefs(row));
|
GetRow(getter_AddRefs(row));
|
||||||
|
|
||||||
|
if (!row) {
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMHTMLCollection> cells;
|
nsCOMPtr<nsIDOMHTMLCollection> cells;
|
||||||
|
|
||||||
row->GetCells(getter_AddRefs(cells));
|
row->GetCells(getter_AddRefs(cells));
|
||||||
|
|
||||||
|
if (!cells) {
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
PRUint32 numCells;
|
PRUint32 numCells;
|
||||||
cells->GetLength(&numCells);
|
cells->GetLength(&numCells);
|
||||||
|
|
||||||
|
@ -227,10 +241,18 @@ nsHTMLTableCellElement::SetCellIndex(PRInt32 aCellIndex)
|
||||||
|
|
||||||
GetRow(getter_AddRefs(row));
|
GetRow(getter_AddRefs(row));
|
||||||
|
|
||||||
|
if (!row) {
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMHTMLCollection> cells;
|
nsCOMPtr<nsIDOMHTMLCollection> cells;
|
||||||
|
|
||||||
row->GetCells(getter_AddRefs(cells));
|
row->GetCells(getter_AddRefs(cells));
|
||||||
|
|
||||||
|
if (!cells) {
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
PRUint32 numCellsU;
|
PRUint32 numCellsU;
|
||||||
cells->GetLength(&numCellsU);
|
cells->GetLength(&numCellsU);
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче