Bug 1408186 - Remove nsIDOMHTMLSelectElement and nsIDOMHTMLOptionsCollection; r=bz

MozReview-Commit-ID: Gh3JwLUtmz9
This commit is contained in:
Kyle Machulis
2017-10-12 16:32:25 -07:00
parent 9bd113a350
commit f381de14a0
18 changed files with 57 additions and 362 deletions

View File

@@ -97,16 +97,13 @@ NS_INTERFACE_TABLE_HEAD(HTMLOptionsCollection)
NS_WRAPPERCACHE_INTERFACE_TABLE_ENTRY
NS_INTERFACE_TABLE(HTMLOptionsCollection,
nsIHTMLCollection,
nsIDOMHTMLOptionsCollection,
nsIDOMHTMLCollection)
NS_INTERFACE_TABLE_TO_MAP_SEGUE_CYCLE_COLLECTION(HTMLOptionsCollection)
NS_INTERFACE_MAP_END
NS_IMPL_CYCLE_COLLECTING_ADDREF(HTMLOptionsCollection)
NS_IMPL_CYCLE_COLLECTING_RELEASE(HTMLOptionsCollection)
JSObject*
HTMLOptionsCollection::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
{
@@ -121,14 +118,15 @@ HTMLOptionsCollection::GetLength(uint32_t* aLength)
return NS_OK;
}
NS_IMETHODIMP
HTMLOptionsCollection::SetLength(uint32_t aLength)
void
HTMLOptionsCollection::SetLength(uint32_t aLength, ErrorResult& aError)
{
if (!mSelect) {
return NS_ERROR_UNEXPECTED;
aError.Throw(NS_ERROR_UNEXPECTED);
return;
}
return mSelect->SetLength(aLength);
mSelect->SetLength(aLength, aError);
}
void
@@ -153,11 +151,8 @@ HTMLOptionsCollection::IndexedSetter(uint32_t aIndex,
if (aIndex > mElements.Length()) {
// Fill our array with blank options up to (but not including, since we're
// about to change it) aIndex, for compat with other browsers.
nsresult rv = SetLength(aIndex);
if (NS_WARN_IF(NS_FAILED(rv))) {
aError.Throw(rv);
return;
}
SetLength(aIndex, aError);
ENSURE_SUCCESS_VOID(aError);
}
NS_ASSERTION(aIndex <= mElements.Length(), "SetLength lied");
@@ -191,17 +186,7 @@ HTMLOptionsCollection::GetSelectedIndex(ErrorResult& aError)
return 0;
}
int32_t selectedIndex;
aError = mSelect->GetSelectedIndex(&selectedIndex);
return selectedIndex;
}
NS_IMETHODIMP
HTMLOptionsCollection::GetSelectedIndex(int32_t* aSelectedIndex)
{
ErrorResult rv;
*aSelectedIndex = GetSelectedIndex(rv);
return rv.StealNSResult();
return mSelect->SelectedIndex();
}
void
@@ -213,15 +198,7 @@ HTMLOptionsCollection::SetSelectedIndex(int32_t aSelectedIndex,
return;
}
aError = mSelect->SetSelectedIndex(aSelectedIndex);
}
NS_IMETHODIMP
HTMLOptionsCollection::SetSelectedIndex(int32_t aSelectedIndex)
{
ErrorResult rv;
SetSelectedIndex(aSelectedIndex, rv);
return rv.StealNSResult();
mSelect->SetSelectedIndex(aSelectedIndex, aError);
}
NS_IMETHODIMP
@@ -310,29 +287,6 @@ HTMLOptionsCollection::GetSupportedNames(nsTArray<nsString>& aNames)
}
}
NS_IMETHODIMP
HTMLOptionsCollection::GetSelect(nsIDOMHTMLSelectElement** aReturn)
{
NS_IF_ADDREF(*aReturn = mSelect);
return NS_OK;
}
NS_IMETHODIMP
HTMLOptionsCollection::Add(nsIDOMHTMLOptionElement* aOption,
nsIVariant* aBefore)
{
if (!aOption) {
return NS_ERROR_INVALID_ARG;
}
if (!mSelect) {
return NS_ERROR_NOT_INITIALIZED;
}
nsCOMPtr<nsIDOMHTMLElement> elem = do_QueryInterface(aOption);
return mSelect->Add(elem, aBefore);
}
void
HTMLOptionsCollection::Add(const HTMLOptionOrOptGroupElement& aElement,
const Nullable<HTMLElementOrLong>& aBefore,
@@ -354,20 +308,11 @@ HTMLOptionsCollection::Remove(int32_t aIndex, ErrorResult& aError)
return;
}
uint32_t len = 0;
mSelect->GetLength(&len);
uint32_t len = mSelect->Length();
if (aIndex < 0 || (uint32_t)aIndex >= len)
aIndex = 0;
aError = mSelect->Remove(aIndex);
}
NS_IMETHODIMP
HTMLOptionsCollection::Remove(int32_t aIndex)
{
ErrorResult rv;
Remove(aIndex, rv);
return rv.StealNSResult();
mSelect->Remove(aIndex);
}
} // namespace dom