| 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, |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 } | 56 } |
| 57 const AtomicString& nameAttribute = element->getNameAttribute(); | 57 const AtomicString& nameAttribute = element->getNameAttribute(); |
| 58 if (!nameAttribute.isEmpty()) { | 58 if (!nameAttribute.isEmpty()) { |
| 59 HashSet<AtomicString>::AddResult addResult = existingNames.add(nameA
ttribute); | 59 HashSet<AtomicString>::AddResult addResult = existingNames.add(nameA
ttribute); |
| 60 if (addResult.isNewEntry) | 60 if (addResult.isNewEntry) |
| 61 names.append(nameAttribute); | 61 names.append(nameAttribute); |
| 62 } | 62 } |
| 63 } | 63 } |
| 64 } | 64 } |
| 65 | 65 |
| 66 PassRefPtrWillBeRawPtr<HTMLOptionsCollection> HTMLOptionsCollection::create(Cont
ainerNode& select, CollectionType) | 66 RawPtr<HTMLOptionsCollection> HTMLOptionsCollection::create(ContainerNode& selec
t, CollectionType) |
| 67 { | 67 { |
| 68 return adoptRefWillBeNoop(new HTMLOptionsCollection(select)); | 68 return new HTMLOptionsCollection(select); |
| 69 } | 69 } |
| 70 | 70 |
| 71 void HTMLOptionsCollection::add(const HTMLOptionElementOrHTMLOptGroupElement& el
ement, const HTMLElementOrLong& before, ExceptionState& exceptionState) | 71 void HTMLOptionsCollection::add(const HTMLOptionElementOrHTMLOptGroupElement& el
ement, const HTMLElementOrLong& before, ExceptionState& exceptionState) |
| 72 { | 72 { |
| 73 toHTMLSelectElement(ownerNode()).add(element, before, exceptionState); | 73 toHTMLSelectElement(ownerNode()).add(element, before, exceptionState); |
| 74 } | 74 } |
| 75 | 75 |
| 76 void HTMLOptionsCollection::remove(int index) | 76 void HTMLOptionsCollection::remove(int index) |
| 77 { | 77 { |
| 78 toHTMLSelectElement(ownerNode()).remove(index); | 78 toHTMLSelectElement(ownerNode()).remove(index); |
| 79 } | 79 } |
| 80 | 80 |
| 81 int HTMLOptionsCollection::selectedIndex() const | 81 int HTMLOptionsCollection::selectedIndex() const |
| 82 { | 82 { |
| 83 return toHTMLSelectElement(ownerNode()).selectedIndex(); | 83 return toHTMLSelectElement(ownerNode()).selectedIndex(); |
| 84 } | 84 } |
| 85 | 85 |
| 86 void HTMLOptionsCollection::setSelectedIndex(int index) | 86 void HTMLOptionsCollection::setSelectedIndex(int index) |
| 87 { | 87 { |
| 88 toHTMLSelectElement(ownerNode()).setSelectedIndex(index); | 88 toHTMLSelectElement(ownerNode()).setSelectedIndex(index); |
| 89 } | 89 } |
| 90 | 90 |
| 91 void HTMLOptionsCollection::setLength(unsigned length, ExceptionState& exception
State) | 91 void HTMLOptionsCollection::setLength(unsigned length, ExceptionState& exception
State) |
| 92 { | 92 { |
| 93 toHTMLSelectElement(ownerNode()).setLength(length, exceptionState); | 93 toHTMLSelectElement(ownerNode()).setLength(length, exceptionState); |
| 94 } | 94 } |
| 95 | 95 |
| 96 void HTMLOptionsCollection::namedGetter(const AtomicString& name, NodeListOrElem
ent& returnValue) | 96 void HTMLOptionsCollection::namedGetter(const AtomicString& name, NodeListOrElem
ent& returnValue) |
| 97 { | 97 { |
| 98 WillBeHeapVector<RefPtrWillBeMember<Element>> namedItems; | 98 HeapVector<Member<Element>> namedItems; |
| 99 this->namedItems(name, namedItems); | 99 this->namedItems(name, namedItems); |
| 100 | 100 |
| 101 if (!namedItems.size()) | 101 if (!namedItems.size()) |
| 102 return; | 102 return; |
| 103 | 103 |
| 104 if (namedItems.size() == 1) { | 104 if (namedItems.size() == 1) { |
| 105 returnValue.setElement(namedItems.at(0)); | 105 returnValue.setElement(namedItems.at(0)); |
| 106 return; | 106 return; |
| 107 } | 107 } |
| 108 | 108 |
| 109 // FIXME: The spec and Firefox do not return a NodeList. They always return
the first matching Element. | 109 // FIXME: The spec and Firefox do not return a NodeList. They always return
the first matching Element. |
| 110 returnValue.setNodeList(StaticElementList::adopt(namedItems)); | 110 returnValue.setNodeList(StaticElementList::adopt(namedItems)); |
| 111 } | 111 } |
| 112 | 112 |
| 113 bool HTMLOptionsCollection::anonymousIndexedSetter(unsigned index, PassRefPtrWil
lBeRawPtr<HTMLOptionElement> value, ExceptionState& exceptionState) | 113 bool HTMLOptionsCollection::anonymousIndexedSetter(unsigned index, RawPtr<HTMLOp
tionElement> value, ExceptionState& exceptionState) |
| 114 { | 114 { |
| 115 HTMLSelectElement& base = toHTMLSelectElement(ownerNode()); | 115 HTMLSelectElement& base = toHTMLSelectElement(ownerNode()); |
| 116 if (!value) { // undefined or null | 116 if (!value) { // undefined or null |
| 117 base.remove(index); | 117 base.remove(index); |
| 118 return true; | 118 return true; |
| 119 } | 119 } |
| 120 base.setOption(index, value.get(), exceptionState); | 120 base.setOption(index, value.get(), exceptionState); |
| 121 return true; | 121 return true; |
| 122 } | 122 } |
| 123 | 123 |
| 124 } // namespace blink | 124 } // namespace blink |
| OLD | NEW |