| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2011, 2012 Apple Computer, Inc. | 2 * Copyright (C) 2006, 2011, 2012 Apple Computer, Inc. |
| 3 * | 3 * |
| 4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
| 5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
| 6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
| 7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
| 8 * | 8 * |
| 9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 { | 34 { |
| 35 ASSERT(select->hasTagName(HTMLNames::selectTag)); | 35 ASSERT(select->hasTagName(HTMLNames::selectTag)); |
| 36 ScriptWrappable::init(this); | 36 ScriptWrappable::init(this); |
| 37 } | 37 } |
| 38 | 38 |
| 39 PassRefPtr<HTMLOptionsCollection> HTMLOptionsCollection::create(Node* select, Co
llectionType) | 39 PassRefPtr<HTMLOptionsCollection> HTMLOptionsCollection::create(Node* select, Co
llectionType) |
| 40 { | 40 { |
| 41 return adoptRef(new HTMLOptionsCollection(select)); | 41 return adoptRef(new HTMLOptionsCollection(select)); |
| 42 } | 42 } |
| 43 | 43 |
| 44 void HTMLOptionsCollection::add(PassRefPtr<HTMLOptionElement> element, Exception
State& es) | 44 void HTMLOptionsCollection::add(PassRefPtr<HTMLOptionElement> element, Exception
State& exceptionState) |
| 45 { | 45 { |
| 46 add(element, length(), es); | 46 add(element, length(), exceptionState); |
| 47 } | 47 } |
| 48 | 48 |
| 49 void HTMLOptionsCollection::add(PassRefPtr<HTMLOptionElement> element, int index
, ExceptionState& es) | 49 void HTMLOptionsCollection::add(PassRefPtr<HTMLOptionElement> element, int index
, ExceptionState& exceptionState) |
| 50 { | 50 { |
| 51 HTMLOptionElement* newOption = element.get(); | 51 HTMLOptionElement* newOption = element.get(); |
| 52 | 52 |
| 53 if (!newOption) { | 53 if (!newOption) { |
| 54 es.throwUninformativeAndGenericDOMException(TypeMismatchError); | 54 exceptionState.throwUninformativeAndGenericDOMException(TypeMismatchErro
r); |
| 55 return; | 55 return; |
| 56 } | 56 } |
| 57 | 57 |
| 58 if (index < -1) { | 58 if (index < -1) { |
| 59 es.throwUninformativeAndGenericDOMException(IndexSizeError); | 59 exceptionState.throwUninformativeAndGenericDOMException(IndexSizeError); |
| 60 return; | 60 return; |
| 61 } | 61 } |
| 62 | 62 |
| 63 HTMLSelectElement* select = toHTMLSelectElement(ownerNode()); | 63 HTMLSelectElement* select = toHTMLSelectElement(ownerNode()); |
| 64 | 64 |
| 65 if (index == -1 || unsigned(index) >= length()) | 65 if (index == -1 || unsigned(index) >= length()) |
| 66 select->add(newOption, 0, es); | 66 select->add(newOption, 0, exceptionState); |
| 67 else | 67 else |
| 68 select->add(newOption, toHTMLOptionElement(item(index)), es); | 68 select->add(newOption, toHTMLOptionElement(item(index)), exceptionState)
; |
| 69 | 69 |
| 70 ASSERT(!es.hadException()); | 70 ASSERT(!exceptionState.hadException()); |
| 71 } | 71 } |
| 72 | 72 |
| 73 void HTMLOptionsCollection::remove(int index) | 73 void HTMLOptionsCollection::remove(int index) |
| 74 { | 74 { |
| 75 toHTMLSelectElement(ownerNode())->remove(index); | 75 toHTMLSelectElement(ownerNode())->remove(index); |
| 76 } | 76 } |
| 77 | 77 |
| 78 void HTMLOptionsCollection::remove(HTMLOptionElement* option) | 78 void HTMLOptionsCollection::remove(HTMLOptionElement* option) |
| 79 { | 79 { |
| 80 return remove(option->index()); | 80 return remove(option->index()); |
| 81 } | 81 } |
| 82 | 82 |
| 83 int HTMLOptionsCollection::selectedIndex() const | 83 int HTMLOptionsCollection::selectedIndex() const |
| 84 { | 84 { |
| 85 return toHTMLSelectElement(ownerNode())->selectedIndex(); | 85 return toHTMLSelectElement(ownerNode())->selectedIndex(); |
| 86 } | 86 } |
| 87 | 87 |
| 88 void HTMLOptionsCollection::setSelectedIndex(int index) | 88 void HTMLOptionsCollection::setSelectedIndex(int index) |
| 89 { | 89 { |
| 90 toHTMLSelectElement(ownerNode())->setSelectedIndex(index); | 90 toHTMLSelectElement(ownerNode())->setSelectedIndex(index); |
| 91 } | 91 } |
| 92 | 92 |
| 93 void HTMLOptionsCollection::setLength(unsigned length, ExceptionState& es) | 93 void HTMLOptionsCollection::setLength(unsigned length, ExceptionState& exception
State) |
| 94 { | 94 { |
| 95 toHTMLSelectElement(ownerNode())->setLength(length, es); | 95 toHTMLSelectElement(ownerNode())->setLength(length, exceptionState); |
| 96 } | 96 } |
| 97 | 97 |
| 98 void HTMLOptionsCollection::anonymousNamedGetter(const AtomicString& name, bool&
returnValue0Enabled, RefPtr<NodeList>& returnValue0, bool& returnValue1Enabled,
RefPtr<Node>& returnValue1) | 98 void HTMLOptionsCollection::anonymousNamedGetter(const AtomicString& name, bool&
returnValue0Enabled, RefPtr<NodeList>& returnValue0, bool& returnValue1Enabled,
RefPtr<Node>& returnValue1) |
| 99 { | 99 { |
| 100 Vector<RefPtr<Node> > namedItems; | 100 Vector<RefPtr<Node> > namedItems; |
| 101 this->namedItems(name, namedItems); | 101 this->namedItems(name, namedItems); |
| 102 | 102 |
| 103 if (!namedItems.size()) | 103 if (!namedItems.size()) |
| 104 return; | 104 return; |
| 105 | 105 |
| 106 if (namedItems.size() == 1) { | 106 if (namedItems.size() == 1) { |
| 107 returnValue1Enabled = true; | 107 returnValue1Enabled = true; |
| 108 returnValue1 = namedItems.at(0); | 108 returnValue1 = namedItems.at(0); |
| 109 return; | 109 return; |
| 110 } | 110 } |
| 111 | 111 |
| 112 returnValue0Enabled = true; | 112 returnValue0Enabled = true; |
| 113 returnValue0 = NamedNodesCollection::create(namedItems); | 113 returnValue0 = NamedNodesCollection::create(namedItems); |
| 114 } | 114 } |
| 115 | 115 |
| 116 bool HTMLOptionsCollection::anonymousIndexedSetterRemove(unsigned index, Excepti
onState& es) | 116 bool HTMLOptionsCollection::anonymousIndexedSetterRemove(unsigned index, Excepti
onState& exceptionState) |
| 117 { | 117 { |
| 118 HTMLSelectElement* base = toHTMLSelectElement(ownerNode()); | 118 HTMLSelectElement* base = toHTMLSelectElement(ownerNode()); |
| 119 base->remove(index); | 119 base->remove(index); |
| 120 return true; | 120 return true; |
| 121 } | 121 } |
| 122 | 122 |
| 123 bool HTMLOptionsCollection::anonymousIndexedSetter(unsigned index, PassRefPtr<HT
MLOptionElement> value, ExceptionState& es) | 123 bool HTMLOptionsCollection::anonymousIndexedSetter(unsigned index, PassRefPtr<HT
MLOptionElement> value, ExceptionState& exceptionState) |
| 124 { | 124 { |
| 125 HTMLSelectElement* base = toHTMLSelectElement(ownerNode()); | 125 HTMLSelectElement* base = toHTMLSelectElement(ownerNode()); |
| 126 if (!value) { | 126 if (!value) { |
| 127 es.throwUninformativeAndGenericDOMException(TypeMismatchError); | 127 exceptionState.throwUninformativeAndGenericDOMException(TypeMismatchErro
r); |
| 128 return true; | 128 return true; |
| 129 } | 129 } |
| 130 base->setOption(index, value.get(), es); | 130 base->setOption(index, value.get(), exceptionState); |
| 131 return true; | 131 return true; |
| 132 } | 132 } |
| 133 | 133 |
| 134 } //namespace | 134 } //namespace |
| 135 | 135 |
| OLD | NEW |