summaryrefslogtreecommitdiff
path: root/Source/WebCore/html/HTMLOptionsCollection.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/html/HTMLOptionsCollection.cpp')
-rw-r--r--Source/WebCore/html/HTMLOptionsCollection.cpp45
1 files changed, 9 insertions, 36 deletions
diff --git a/Source/WebCore/html/HTMLOptionsCollection.cpp b/Source/WebCore/html/HTMLOptionsCollection.cpp
index c8f12313d..2f885de48 100644
--- a/Source/WebCore/html/HTMLOptionsCollection.cpp
+++ b/Source/WebCore/html/HTMLOptionsCollection.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006, 2011, 2012 Apple Computer, Inc.
+ * Copyright (C) 2006, 2011, 2012 Apple Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -21,56 +21,29 @@
#include "config.h"
#include "HTMLOptionsCollection.h"
-#include "ExceptionCode.h"
-#include "HTMLOptionElement.h"
-
namespace WebCore {
HTMLOptionsCollection::HTMLOptionsCollection(HTMLSelectElement& select)
- : HTMLCollection(select, SelectOptions)
+ : CachedHTMLCollection<HTMLOptionsCollection, CollectionTypeTraits<SelectOptions>::traversalType>(select, SelectOptions)
{
}
-PassRef<HTMLOptionsCollection> HTMLOptionsCollection::create(HTMLSelectElement& select, CollectionType)
+Ref<HTMLOptionsCollection> HTMLOptionsCollection::create(HTMLSelectElement& select, CollectionType)
{
return adoptRef(*new HTMLOptionsCollection(select));
}
-void HTMLOptionsCollection::add(PassRefPtr<HTMLOptionElement> element, ExceptionCode& ec)
+ExceptionOr<void> HTMLOptionsCollection::add(const OptionOrOptGroupElement& element, const std::optional<HTMLElementOrInt>& before)
{
- add(element, length(), ec);
-}
-
-void HTMLOptionsCollection::add(PassRefPtr<HTMLOptionElement> element, int index, ExceptionCode& ec)
-{
- HTMLOptionElement* newOption = element.get();
-
- if (!newOption) {
- ec = TYPE_MISMATCH_ERR;
- return;
- }
-
- if (index < -1) {
- ec = INDEX_SIZE_ERR;
- return;
- }
-
- ec = 0;
-
- if (index == -1 || unsigned(index) >= length())
- selectElement().add(newOption, 0, ec);
- else
- selectElement().add(newOption, toHTMLOptionElement(item(index)), ec);
-
- ASSERT(!ec);
+ return selectElement().add(element, before);
}
void HTMLOptionsCollection::remove(int index)
{
- selectElement().removeByIndex(index);
+ selectElement().remove(index);
}
-void HTMLOptionsCollection::remove(HTMLOptionElement* option)
+void HTMLOptionsCollection::remove(HTMLOptionElement& option)
{
selectElement().remove(option);
}
@@ -85,9 +58,9 @@ void HTMLOptionsCollection::setSelectedIndex(int index)
selectElement().setSelectedIndex(index);
}
-void HTMLOptionsCollection::setLength(unsigned length, ExceptionCode& ec)
+ExceptionOr<void> HTMLOptionsCollection::setLength(unsigned length)
{
- selectElement().setLength(length, ec);
+ return selectElement().setLength(length);
}
} //namespace