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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 names.append(nameAttribute); | 62 names.append(nameAttribute); |
63 } | 63 } |
64 } | 64 } |
65 } | 65 } |
66 | 66 |
67 PassRefPtrWillBeRawPtr<HTMLOptionsCollection> HTMLOptionsCollection::create(Cont
ainerNode& select, CollectionType) | 67 PassRefPtrWillBeRawPtr<HTMLOptionsCollection> HTMLOptionsCollection::create(Cont
ainerNode& select, CollectionType) |
68 { | 68 { |
69 return adoptRefWillBeNoop(new HTMLOptionsCollection(select)); | 69 return adoptRefWillBeNoop(new HTMLOptionsCollection(select)); |
70 } | 70 } |
71 | 71 |
72 void HTMLOptionsCollection::add(PassRefPtrWillBeRawPtr<HTMLOptionElement> elemen
t, ExceptionState& exceptionState) | 72 void HTMLOptionsCollection::add(const HTMLOptionElementOrHTMLOptGroupElement& el
ement, const HTMLElementOrLong& before, ExceptionState& exceptionState) |
73 { | 73 { |
74 add(element, length(), exceptionState); | 74 toHTMLSelectElement(ownerNode()).add(element, before, exceptionState); |
75 } | |
76 | |
77 void HTMLOptionsCollection::add(PassRefPtrWillBeRawPtr<HTMLOptionElement> elemen
t, int index, ExceptionState& exceptionState) | |
78 { | |
79 HTMLOptionElement* newOption = element.get(); | |
80 | |
81 if (!newOption) { | |
82 exceptionState.throwTypeError("The element provided was not an HTMLOptio
nElement."); | |
83 return; | |
84 } | |
85 | |
86 if (index < -1) { | |
87 exceptionState.throwDOMException(IndexSizeError, "The index provided ("
+ String::number(index) + ") is less than -1."); | |
88 return; | |
89 } | |
90 | |
91 HTMLSelectElement& select = toHTMLSelectElement(ownerNode()); | |
92 | |
93 if (index == -1 || unsigned(index) >= length()) | |
94 select.add(newOption, 0, exceptionState); | |
95 else | |
96 select.addBeforeOptionAtIndex(newOption, index, exceptionState); | |
97 | |
98 ASSERT(!exceptionState.hadException()); | |
99 } | 75 } |
100 | 76 |
101 void HTMLOptionsCollection::remove(int index) | 77 void HTMLOptionsCollection::remove(int index) |
102 { | 78 { |
103 toHTMLSelectElement(ownerNode()).remove(index); | 79 toHTMLSelectElement(ownerNode()).remove(index); |
104 } | 80 } |
105 | 81 |
106 int HTMLOptionsCollection::selectedIndex() const | 82 int HTMLOptionsCollection::selectedIndex() const |
107 { | 83 { |
108 return toHTMLSelectElement(ownerNode()).selectedIndex(); | 84 return toHTMLSelectElement(ownerNode()).selectedIndex(); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 if (!value) { // undefined or null | 117 if (!value) { // undefined or null |
142 base.remove(index); | 118 base.remove(index); |
143 return true; | 119 return true; |
144 } | 120 } |
145 base.setOption(index, value.get(), exceptionState); | 121 base.setOption(index, value.get(), exceptionState); |
146 return true; | 122 return true; |
147 } | 123 } |
148 | 124 |
149 } //namespace | 125 } //namespace |
150 | 126 |
OLD | NEW |