summaryrefslogtreecommitdiff
path: root/Source/WebCore/html/HTMLOptionsCollection.cpp
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2016-04-10 09:28:39 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2016-04-10 09:28:39 +0000
commit32761a6cee1d0dee366b885b7b9c777e67885688 (patch)
treed6bec92bebfb216f4126356e55518842c2f476a1 /Source/WebCore/html/HTMLOptionsCollection.cpp
parenta4e969f4965059196ca948db781e52f7cfebf19e (diff)
downloadWebKitGtk-tarball-32761a6cee1d0dee366b885b7b9c777e67885688.tar.gz
webkitgtk-2.4.11webkitgtk-2.4.11
Diffstat (limited to 'Source/WebCore/html/HTMLOptionsCollection.cpp')
-rw-r--r--Source/WebCore/html/HTMLOptionsCollection.cpp33
1 files changed, 26 insertions, 7 deletions
diff --git a/Source/WebCore/html/HTMLOptionsCollection.cpp b/Source/WebCore/html/HTMLOptionsCollection.cpp
index b36c3f480..c8f12313d 100644
--- a/Source/WebCore/html/HTMLOptionsCollection.cpp
+++ b/Source/WebCore/html/HTMLOptionsCollection.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006, 2011, 2012 Apple Inc.
+ * Copyright (C) 2006, 2011, 2012 Apple Computer, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -27,23 +27,42 @@
namespace WebCore {
HTMLOptionsCollection::HTMLOptionsCollection(HTMLSelectElement& select)
- : CachedHTMLCollection<HTMLOptionsCollection, CollectionTypeTraits<SelectOptions>::traversalType>(select, SelectOptions)
+ : HTMLCollection(select, SelectOptions)
{
}
-Ref<HTMLOptionsCollection> HTMLOptionsCollection::create(HTMLSelectElement& select, CollectionType)
+PassRef<HTMLOptionsCollection> HTMLOptionsCollection::create(HTMLSelectElement& select, CollectionType)
{
return adoptRef(*new HTMLOptionsCollection(select));
}
-void HTMLOptionsCollection::add(HTMLElement* element, HTMLElement* beforeElement, ExceptionCode& ec)
+void HTMLOptionsCollection::add(PassRefPtr<HTMLOptionElement> element, ExceptionCode& ec)
{
- selectElement().add(element, beforeElement, ec);
+ add(element, length(), ec);
}
-void HTMLOptionsCollection::add(HTMLElement* element, int beforeIndex, ExceptionCode& ec)
+void HTMLOptionsCollection::add(PassRefPtr<HTMLOptionElement> element, int index, ExceptionCode& ec)
{
- add(element, item(beforeIndex), 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);
}
void HTMLOptionsCollection::remove(int index)