| 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 20 matching lines...) Expand all Loading... |
| 31 #include "core/html/HTMLSelectElement.h" | 31 #include "core/html/HTMLSelectElement.h" |
| 32 | 32 |
| 33 namespace blink { | 33 namespace blink { |
| 34 | 34 |
| 35 HTMLOptionsCollection::HTMLOptionsCollection(ContainerNode& select) | 35 HTMLOptionsCollection::HTMLOptionsCollection(ContainerNode& select) |
| 36 : HTMLCollection(select, SelectOptions, DoesNotOverrideItemAfter) { | 36 : HTMLCollection(select, SelectOptions, DoesNotOverrideItemAfter) { |
| 37 DCHECK(isHTMLSelectElement(select)); | 37 DCHECK(isHTMLSelectElement(select)); |
| 38 } | 38 } |
| 39 | 39 |
| 40 void HTMLOptionsCollection::supportedPropertyNames(Vector<String>& names) { | 40 void HTMLOptionsCollection::supportedPropertyNames(Vector<String>& names) { |
| 41 // As per http://www.whatwg.org/specs/web-apps/current-work/multipage/common-d
om-interfaces.html#htmloptionscollection: | 41 // As per |
| 42 // The supported property names consist of the non-empty values of all the id
and name attributes of all the elements | 42 // http://www.whatwg.org/specs/web-apps/current-work/multipage/common-dom-inte
rfaces.html#htmloptionscollection: |
| 43 // represented by the collection, in tree order, ignoring later duplicates, wi
th the id of an element preceding its | 43 // The supported property names consist of the non-empty values of all the id |
| 44 // name if it contributes both, they differ from each other, and neither is th
e duplicate of an earlier entry. | 44 // and name attributes of all the elements represented by the collection, in |
| 45 // tree order, ignoring later duplicates, with the id of an element preceding |
| 46 // its name if it contributes both, they differ from each other, and neither |
| 47 // is the duplicate of an earlier entry. |
| 45 HashSet<AtomicString> existingNames; | 48 HashSet<AtomicString> existingNames; |
| 46 unsigned length = this->length(); | 49 unsigned length = this->length(); |
| 47 for (unsigned i = 0; i < length; ++i) { | 50 for (unsigned i = 0; i < length; ++i) { |
| 48 Element* element = item(i); | 51 Element* element = item(i); |
| 49 DCHECK(element); | 52 DCHECK(element); |
| 50 const AtomicString& idAttribute = element->getIdAttribute(); | 53 const AtomicString& idAttribute = element->getIdAttribute(); |
| 51 if (!idAttribute.isEmpty()) { | 54 if (!idAttribute.isEmpty()) { |
| 52 HashSet<AtomicString>::AddResult addResult = | 55 HashSet<AtomicString>::AddResult addResult = |
| 53 existingNames.add(idAttribute); | 56 existingNames.add(idAttribute); |
| 54 if (addResult.isNewEntry) | 57 if (addResult.isNewEntry) |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 this->namedItems(name, namedItems); | 102 this->namedItems(name, namedItems); |
| 100 | 103 |
| 101 if (!namedItems.size()) | 104 if (!namedItems.size()) |
| 102 return; | 105 return; |
| 103 | 106 |
| 104 if (namedItems.size() == 1) { | 107 if (namedItems.size() == 1) { |
| 105 returnValue.setElement(namedItems.at(0)); | 108 returnValue.setElement(namedItems.at(0)); |
| 106 return; | 109 return; |
| 107 } | 110 } |
| 108 | 111 |
| 109 // FIXME: The spec and Firefox do not return a NodeList. They always return th
e first matching Element. | 112 // FIXME: The spec and Firefox do not return a NodeList. They always return |
| 113 // the first matching Element. |
| 110 returnValue.setNodeList(StaticElementList::adopt(namedItems)); | 114 returnValue.setNodeList(StaticElementList::adopt(namedItems)); |
| 111 } | 115 } |
| 112 | 116 |
| 113 bool HTMLOptionsCollection::anonymousIndexedSetter( | 117 bool HTMLOptionsCollection::anonymousIndexedSetter( |
| 114 unsigned index, | 118 unsigned index, |
| 115 HTMLOptionElement* value, | 119 HTMLOptionElement* value, |
| 116 ExceptionState& exceptionState) { | 120 ExceptionState& exceptionState) { |
| 117 HTMLSelectElement& base = toHTMLSelectElement(ownerNode()); | 121 HTMLSelectElement& base = toHTMLSelectElement(ownerNode()); |
| 118 if (!value) { // undefined or null | 122 if (!value) { // undefined or null |
| 119 base.remove(index); | 123 base.remove(index); |
| 120 return true; | 124 return true; |
| 121 } | 125 } |
| 122 base.setOption(index, value, exceptionState); | 126 base.setOption(index, value, exceptionState); |
| 123 return true; | 127 return true; |
| 124 } | 128 } |
| 125 | 129 |
| 126 } // namespace blink | 130 } // namespace blink |
| OLD | NEW |