Bug 778681 part 1 - Make some nsHTMLSelectElement methods infallible; r=bz

This commit is contained in:
Aryeh Gregor 2012-07-30 16:48:02 +03:00
parent 5c39e0f895
commit 95bd12c12c
2 changed files with 7 additions and 8 deletions

View File

@ -334,8 +334,7 @@ nsHTMLSelectElement::InsertOptionsIntoListRecurse(nsIContent* aOptions,
nsHTMLOptionElement *optElement = nsHTMLOptionElement::FromContent(aOptions);
if (optElement) {
nsresult rv = mOptions->InsertOptionAt(optElement, *aInsertIndex);
NS_ENSURE_SUCCESS(rv, rv);
mOptions->InsertOptionAt(optElement, *aInsertIndex);
(*aInsertIndex)++;
return NS_OK;
}
@ -1809,7 +1808,6 @@ AddOptionsRecurse(nsIContent* aRoot, nsHTMLOptionCollection* aArray)
cur = cur->GetNextSibling()) {
nsHTMLOptionElement* opt = nsHTMLOptionElement::FromContent(cur);
if (opt) {
// If we fail here, then at least we've tried our best
aArray->AppendOption(opt);
} else if (cur->IsHTML(nsGkAtoms::optgroup)) {
AddOptionsRecurse(cur, aArray);

View File

@ -62,9 +62,9 @@ public:
* @param aOption the option to insert
* @param aIndex the index to insert at
*/
bool InsertOptionAt(nsHTMLOptionElement* aOption, PRUint32 aIndex)
void InsertOptionAt(nsHTMLOptionElement* aOption, PRUint32 aIndex)
{
return !!mElements.InsertElementAt(aIndex, aOption);
mElements.InsertElementAt(aIndex, aOption);
}
/**
@ -97,9 +97,9 @@ public:
/**
* Append an option to end of array
*/
bool AppendOption(nsHTMLOptionElement* aOption)
void AppendOption(nsHTMLOptionElement* aOption)
{
return !!mElements.AppendElement(aOption);
mElements.AppendElement(aOption);
}
/**
@ -122,7 +122,8 @@ public:
PRInt32* aIndex);
private:
/** The list of options (holds strong references) */
/** The list of options (holds strong references). This is infallible, so
* various members such as InsertOptionAt are also infallible. */
nsTArray<nsRefPtr<nsHTMLOptionElement> > mElements;
/** The select element that contains this array */
nsHTMLSelectElement* mSelect;