diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
commit | 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch) | |
tree | 46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebCore/html/HTMLOptionsCollection.cpp | |
parent | 32761a6cee1d0dee366b885b7b9c777e67885688 (diff) | |
download | WebKitGtk-tarball-master.tar.gz |
webkitgtk-2.16.5HEADwebkitgtk-2.16.5master
Diffstat (limited to 'Source/WebCore/html/HTMLOptionsCollection.cpp')
-rw-r--r-- | Source/WebCore/html/HTMLOptionsCollection.cpp | 45 |
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 |