| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 void HTMLOptionsCollection::add(PassRefPtr<HTMLOptionElement> element, Exception
State& exceptionState) | 45 void HTMLOptionsCollection::add(PassRefPtr<HTMLOptionElement> element, Exception
State& exceptionState) |
| 46 { | 46 { |
| 47 add(element, length(), exceptionState); | 47 add(element, length(), exceptionState); |
| 48 } | 48 } |
| 49 | 49 |
| 50 void HTMLOptionsCollection::add(PassRefPtr<HTMLOptionElement> element, int index
, ExceptionState& exceptionState) | 50 void HTMLOptionsCollection::add(PassRefPtr<HTMLOptionElement> element, int index
, ExceptionState& exceptionState) |
| 51 { | 51 { |
| 52 HTMLOptionElement* newOption = element.get(); | 52 HTMLOptionElement* newOption = element.get(); |
| 53 | 53 |
| 54 if (!newOption) { | 54 if (!newOption) { |
| 55 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::f
ailedToExecute("add", "HTMLOptionsCollection", "The element provided was not an
HTMLOptionElement.")); | 55 exceptionState.throwTypeError("The element provided was not an HTMLOptio
nElement."); |
| 56 return; | 56 return; |
| 57 } | 57 } |
| 58 | 58 |
| 59 if (index < -1) { | 59 if (index < -1) { |
| 60 exceptionState.throwDOMException(IndexSizeError, ExceptionMessages::fail
edToExecute("add", "HTMLOptionsCollection", "The index provided (" + String::num
ber(index) + ") is less than -1.")); | 60 exceptionState.throwDOMException(IndexSizeError, "The index provided ("
+ String::number(index) + ") is less than -1."); |
| 61 return; | 61 return; |
| 62 } | 62 } |
| 63 | 63 |
| 64 HTMLSelectElement* select = toHTMLSelectElement(ownerNode()); | 64 HTMLSelectElement* select = toHTMLSelectElement(ownerNode()); |
| 65 | 65 |
| 66 if (index == -1 || unsigned(index) >= length()) | 66 if (index == -1 || unsigned(index) >= length()) |
| 67 select->add(newOption, 0, exceptionState); | 67 select->add(newOption, 0, exceptionState); |
| 68 else | 68 else |
| 69 select->add(newOption, toHTMLOptionElement(item(index)), exceptionState)
; | 69 select->add(newOption, toHTMLOptionElement(item(index)), exceptionState)
; |
| 70 | 70 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 { | 118 { |
| 119 HTMLSelectElement* base = toHTMLSelectElement(ownerNode()); | 119 HTMLSelectElement* base = toHTMLSelectElement(ownerNode()); |
| 120 base->remove(index); | 120 base->remove(index); |
| 121 return true; | 121 return true; |
| 122 } | 122 } |
| 123 | 123 |
| 124 bool HTMLOptionsCollection::anonymousIndexedSetter(unsigned index, PassRefPtr<HT
MLOptionElement> value, ExceptionState& exceptionState) | 124 bool HTMLOptionsCollection::anonymousIndexedSetter(unsigned index, PassRefPtr<HT
MLOptionElement> value, ExceptionState& exceptionState) |
| 125 { | 125 { |
| 126 HTMLSelectElement* base = toHTMLSelectElement(ownerNode()); | 126 HTMLSelectElement* base = toHTMLSelectElement(ownerNode()); |
| 127 if (!value) { | 127 if (!value) { |
| 128 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::f
ailedToSet(String::number(index), "HTMLOptionsCollection", "The element provided
was not an HTMLOptionElement.")); | 128 exceptionState.throwTypeError(ExceptionMessages::failedToSet(String::num
ber(index), "HTMLOptionsCollection", "The element provided was not an HTMLOption
Element.")); |
| 129 return true; | 129 return true; |
| 130 } | 130 } |
| 131 base->setOption(index, value.get(), exceptionState); | 131 base->setOption(index, value.get(), exceptionState); |
| 132 return true; | 132 return true; |
| 133 } | 133 } |
| 134 | 134 |
| 135 } //namespace | 135 } //namespace |
| 136 | 136 |
| OLD | NEW |