summaryrefslogtreecommitdiff
path: root/Source/WebCore/html/HTMLOptionsCollection.cpp
diff options
context:
space:
mode:
authorKonstantin Tokarev <annulen@yandex.ru>2016-08-25 19:20:41 +0300
committerKonstantin Tokarev <annulen@yandex.ru>2017-02-02 12:30:55 +0000
commit6882a04fb36642862b11efe514251d32070c3d65 (patch)
treeb7959826000b061fd5ccc7512035c7478742f7b0 /Source/WebCore/html/HTMLOptionsCollection.cpp
parentab6df191029eeeb0b0f16f127d553265659f739e (diff)
downloadqtwebkit-6882a04fb36642862b11efe514251d32070c3d65.tar.gz
Imported QtWebKit TP3 (git b57bc6801f1876c3220d5a4bfea33d620d477443)
Change-Id: I3b1d8a2808782c9f34d50240000e20cb38d3680f Reviewed-by: Konstantin Tokarev <annulen@yandex.ru>
Diffstat (limited to 'Source/WebCore/html/HTMLOptionsCollection.cpp')
-rw-r--r--Source/WebCore/html/HTMLOptionsCollection.cpp53
1 files changed, 18 insertions, 35 deletions
diff --git a/Source/WebCore/html/HTMLOptionsCollection.cpp b/Source/WebCore/html/HTMLOptionsCollection.cpp
index ddcfcb486..b36c3f480 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
@@ -23,69 +23,52 @@
#include "ExceptionCode.h"
#include "HTMLOptionElement.h"
-#include "HTMLSelectElement.h"
namespace WebCore {
-HTMLOptionsCollection::HTMLOptionsCollection(Node* select)
- : HTMLCollection(select, SelectOptions, DoesNotOverrideItemAfter)
+HTMLOptionsCollection::HTMLOptionsCollection(HTMLSelectElement& select)
+ : CachedHTMLCollection<HTMLOptionsCollection, CollectionTypeTraits<SelectOptions>::traversalType>(select, SelectOptions)
{
- ASSERT(select->hasTagName(HTMLNames::selectTag));
}
-PassRefPtr<HTMLOptionsCollection> HTMLOptionsCollection::create(Node* select, CollectionType)
+Ref<HTMLOptionsCollection> HTMLOptionsCollection::create(HTMLSelectElement& select, CollectionType)
{
- return adoptRef(new HTMLOptionsCollection(select));
+ return adoptRef(*new HTMLOptionsCollection(select));
}
-void HTMLOptionsCollection::add(PassRefPtr<HTMLOptionElement> element, ExceptionCode& ec)
+void HTMLOptionsCollection::add(HTMLElement* element, HTMLElement* beforeElement, ExceptionCode& ec)
{
- add(element, length(), ec);
+ selectElement().add(element, beforeElement, ec);
}
-void HTMLOptionsCollection::add(PassRefPtr<HTMLOptionElement> element, int index, ExceptionCode& ec)
+void HTMLOptionsCollection::add(HTMLElement* element, int beforeIndex, ExceptionCode& ec)
{
- HTMLOptionElement* newOption = element.get();
-
- if (!newOption) {
- ec = TYPE_MISMATCH_ERR;
- return;
- }
-
- if (index < -1) {
- ec = INDEX_SIZE_ERR;
- return;
- }
-
- ec = 0;
- HTMLSelectElement* select = toHTMLSelectElement(ownerNode());
-
- if (index == -1 || unsigned(index) >= length())
- select->add(newOption, 0, ec);
- else
- select->add(newOption, toHTMLOptionElement(item(index)), ec);
-
- ASSERT(!ec);
+ add(element, item(beforeIndex), ec);
}
void HTMLOptionsCollection::remove(int index)
{
- toHTMLSelectElement(ownerNode())->remove(index);
+ selectElement().removeByIndex(index);
+}
+
+void HTMLOptionsCollection::remove(HTMLOptionElement* option)
+{
+ selectElement().remove(option);
}
int HTMLOptionsCollection::selectedIndex() const
{
- return toHTMLSelectElement(ownerNode())->selectedIndex();
+ return selectElement().selectedIndex();
}
void HTMLOptionsCollection::setSelectedIndex(int index)
{
- toHTMLSelectElement(ownerNode())->setSelectedIndex(index);
+ selectElement().setSelectedIndex(index);
}
void HTMLOptionsCollection::setLength(unsigned length, ExceptionCode& ec)
{
- toHTMLSelectElement(ownerNode())->setLength(length, ec);
+ selectElement().setLength(length, ec);
}
} //namespace