| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2011, 2012 Apple Computer, Inc. | 2 * Copyright (C) 2006, 2011, 2012 Apple Computer, Inc. |
| 3 * Copyright (C) 2014 Samsung Electronics. All rights reserved. | 3 * Copyright (C) 2014 Samsung Electronics. All rights reserved. |
| 4 * | 4 * |
| 5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
| 6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
| 7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
| 8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
| 9 * | 9 * |
| 10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
| 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 * Library General Public License for more details. | 13 * Library General Public License for more details. |
| 14 * | 14 * |
| 15 * You should have received a copy of the GNU Library General Public License | 15 * You should have received a copy of the GNU Library General Public License |
| 16 * along with this library; see the file COPYING.LIB. If not, write to | 16 * along with this library; see the file COPYING.LIB. If not, write to |
| 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 18 * Boston, MA 02110-1301, USA. | 18 * Boston, MA 02110-1301, USA. |
| 19 * | 19 * |
| 20 */ | 20 */ |
| 21 | 21 |
| 22 #include "config.h" | 22 #include "config.h" |
| 23 #include "core/html/HTMLOptionsCollection.h" | 23 #include "core/html/HTMLOptionsCollection.h" |
| 24 | 24 |
| 25 #include "bindings/core/v8/ExceptionMessages.h" | 25 #include "bindings/core/v8/ExceptionMessages.h" |
| 26 #include "bindings/core/v8/ExceptionState.h" | 26 #include "bindings/core/v8/ExceptionState.h" |
| 27 #include "bindings/core/v8/UnionTypesCore.h" |
| 27 #include "core/dom/ExceptionCode.h" | 28 #include "core/dom/ExceptionCode.h" |
| 28 #include "core/dom/StaticNodeList.h" | 29 #include "core/dom/StaticNodeList.h" |
| 29 #include "core/html/HTMLOptionElement.h" | 30 #include "core/html/HTMLOptionElement.h" |
| 30 #include "core/html/HTMLSelectElement.h" | 31 #include "core/html/HTMLSelectElement.h" |
| 31 | 32 |
| 32 namespace blink { | 33 namespace blink { |
| 33 | 34 |
| 34 HTMLOptionsCollection::HTMLOptionsCollection(ContainerNode& select) | 35 HTMLOptionsCollection::HTMLOptionsCollection(ContainerNode& select) |
| 35 : HTMLCollection(select, SelectOptions, DoesNotOverrideItemAfter) | 36 : HTMLCollection(select, SelectOptions, DoesNotOverrideItemAfter) |
| 36 { | 37 { |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 void HTMLOptionsCollection::setSelectedIndex(int index) | 111 void HTMLOptionsCollection::setSelectedIndex(int index) |
| 111 { | 112 { |
| 112 toHTMLSelectElement(ownerNode()).setSelectedIndex(index); | 113 toHTMLSelectElement(ownerNode()).setSelectedIndex(index); |
| 113 } | 114 } |
| 114 | 115 |
| 115 void HTMLOptionsCollection::setLength(unsigned length, ExceptionState& exception
State) | 116 void HTMLOptionsCollection::setLength(unsigned length, ExceptionState& exception
State) |
| 116 { | 117 { |
| 117 toHTMLSelectElement(ownerNode()).setLength(length, exceptionState); | 118 toHTMLSelectElement(ownerNode()).setLength(length, exceptionState); |
| 118 } | 119 } |
| 119 | 120 |
| 120 void HTMLOptionsCollection::namedGetter(const AtomicString& name, RefPtrWillBeRa
wPtr<NodeList>& returnValue0, RefPtrWillBeRawPtr<Element>& returnValue1) | 121 void HTMLOptionsCollection::namedGetter(const AtomicString& name, NodeListOrElem
ent& returnValue) |
| 121 { | 122 { |
| 122 WillBeHeapVector<RefPtrWillBeMember<Element> > namedItems; | 123 WillBeHeapVector<RefPtrWillBeMember<Element> > namedItems; |
| 123 this->namedItems(name, namedItems); | 124 this->namedItems(name, namedItems); |
| 124 | 125 |
| 125 if (!namedItems.size()) | 126 if (!namedItems.size()) |
| 126 return; | 127 return; |
| 127 | 128 |
| 128 if (namedItems.size() == 1) { | 129 if (namedItems.size() == 1) { |
| 129 returnValue1 = namedItems.at(0); | 130 returnValue.setElement(namedItems.at(0)); |
| 130 return; | 131 return; |
| 131 } | 132 } |
| 132 | 133 |
| 133 // FIXME: The spec and Firefox do not return a NodeList. They always return
the first matching Element. | 134 // FIXME: The spec and Firefox do not return a NodeList. They always return
the first matching Element. |
| 134 returnValue0 = StaticElementList::adopt(namedItems); | 135 returnValue.setNodeList(StaticElementList::adopt(namedItems)); |
| 135 } | 136 } |
| 136 | 137 |
| 137 bool HTMLOptionsCollection::anonymousIndexedSetter(unsigned index, PassRefPtrWil
lBeRawPtr<HTMLOptionElement> value, ExceptionState& exceptionState) | 138 bool HTMLOptionsCollection::anonymousIndexedSetter(unsigned index, PassRefPtrWil
lBeRawPtr<HTMLOptionElement> value, ExceptionState& exceptionState) |
| 138 { | 139 { |
| 139 HTMLSelectElement& base = toHTMLSelectElement(ownerNode()); | 140 HTMLSelectElement& base = toHTMLSelectElement(ownerNode()); |
| 140 if (!value) { // undefined or null | 141 if (!value) { // undefined or null |
| 141 base.remove(index); | 142 base.remove(index); |
| 142 return true; | 143 return true; |
| 143 } | 144 } |
| 144 base.setOption(index, value.get(), exceptionState); | 145 base.setOption(index, value.get(), exceptionState); |
| 145 return true; | 146 return true; |
| 146 } | 147 } |
| 147 | 148 |
| 148 } //namespace | 149 } //namespace |
| 149 | 150 |
| OLD | NEW |