OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). | 2 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
3 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 3 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
4 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 4 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
5 * (C) 2001 Dirk Mueller (mueller@kde.org) | 5 * (C) 2001 Dirk Mueller (mueller@kde.org) |
6 * Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010, 2011 Apple Inc. All rights
reserved. | 6 * Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010, 2011 Apple Inc. All rights
reserved. |
7 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) | 7 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) |
8 * Copyright (C) 2010 Google Inc. All rights reserved. | 8 * Copyright (C) 2010 Google Inc. All rights reserved. |
9 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) | 9 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) |
10 * | 10 * |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 | 218 |
219 if (!element || !(isHTMLOptionElement(element) || isHTMLOptGroupElement(elem
ent) || isHTMLHRElement(element))) | 219 if (!element || !(isHTMLOptionElement(element) || isHTMLOptGroupElement(elem
ent) || isHTMLHRElement(element))) |
220 return; | 220 return; |
221 | 221 |
222 insertBefore(element, before, exceptionState); | 222 insertBefore(element, before, exceptionState); |
223 setNeedsValidityCheck(); | 223 setNeedsValidityCheck(); |
224 } | 224 } |
225 | 225 |
226 void HTMLSelectElement::addBeforeOptionAtIndex(HTMLElement* element, int beforeI
ndex, ExceptionState& exceptionState) | 226 void HTMLSelectElement::addBeforeOptionAtIndex(HTMLElement* element, int beforeI
ndex, ExceptionState& exceptionState) |
227 { | 227 { |
228 HTMLElement* beforeElement = toHTMLElement(options()->item(beforeIndex)); | 228 HTMLOptionElement* beforeElement = options()->item(beforeIndex); |
229 add(element, beforeElement, exceptionState); | 229 add(element, beforeElement, exceptionState); |
230 } | 230 } |
231 | 231 |
232 void HTMLSelectElement::remove(int optionIndex) | 232 void HTMLSelectElement::remove(int optionIndex) |
233 { | 233 { |
234 int listIndex = optionToListIndex(optionIndex); | 234 int listIndex = optionToListIndex(optionIndex); |
235 if (listIndex < 0) | 235 if (listIndex < 0) |
236 return; | 236 return; |
237 | 237 |
238 listItems()[listIndex]->remove(IGNORE_EXCEPTION); | 238 listItems()[listIndex]->remove(IGNORE_EXCEPTION); |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 void HTMLSelectElement::setSize(int size) | 445 void HTMLSelectElement::setSize(int size) |
446 { | 446 { |
447 setIntegralAttribute(sizeAttr, size); | 447 setIntegralAttribute(sizeAttr, size); |
448 } | 448 } |
449 | 449 |
450 Element* HTMLSelectElement::namedItem(const AtomicString& name) | 450 Element* HTMLSelectElement::namedItem(const AtomicString& name) |
451 { | 451 { |
452 return options()->namedItem(name); | 452 return options()->namedItem(name); |
453 } | 453 } |
454 | 454 |
455 Element* HTMLSelectElement::item(unsigned index) | 455 HTMLOptionElement* HTMLSelectElement::item(unsigned index) |
456 { | 456 { |
457 return options()->item(index); | 457 return options()->item(index); |
458 } | 458 } |
459 | 459 |
460 void HTMLSelectElement::setOption(unsigned index, HTMLOptionElement* option, Exc
eptionState& exceptionState) | 460 void HTMLSelectElement::setOption(unsigned index, HTMLOptionElement* option, Exc
eptionState& exceptionState) |
461 { | 461 { |
462 if (index > maxSelectItems - 1) | 462 if (index > maxSelectItems - 1) |
463 index = maxSelectItems - 1; | 463 index = maxSelectItems - 1; |
464 int diff = index - length(); | 464 int diff = index - length(); |
465 RefPtrWillBeRawPtr<HTMLElement> before = nullptr; | 465 RefPtrWillBeRawPtr<HTMLOptionElement> before = nullptr; |
466 // Out of array bounds? First insert empty dummies. | 466 // Out of array bounds? First insert empty dummies. |
467 if (diff > 0) { | 467 if (diff > 0) { |
468 setLength(index, exceptionState); | 468 setLength(index, exceptionState); |
469 // Replace an existing entry? | 469 // Replace an existing entry? |
470 } else if (diff < 0) { | 470 } else if (diff < 0) { |
471 before = toHTMLElement(options()->item(index+1)); | 471 before = options()->item(index + 1); |
472 remove(index); | 472 remove(index); |
473 } | 473 } |
474 // Finally add the new element. | 474 // Finally add the new element. |
475 if (!exceptionState.hadException()) { | 475 if (!exceptionState.hadException()) { |
476 add(option, before.get(), exceptionState); | 476 add(option, before.get(), exceptionState); |
477 if (diff >= 0 && option->selected()) | 477 if (diff >= 0 && option->selected()) |
478 optionSelectionStateChanged(option, true); | 478 optionSelectionStateChanged(option, true); |
479 } | 479 } |
480 } | 480 } |
481 | 481 |
(...skipping 1258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1740 int focusedIndex = activeSelectionEndListIndex(); | 1740 int focusedIndex = activeSelectionEndListIndex(); |
1741 if (focusedIndex < 0) | 1741 if (focusedIndex < 0) |
1742 focusedIndex = firstSelectableListIndex(); | 1742 focusedIndex = firstSelectableListIndex(); |
1743 if (focusedIndex < 0) | 1743 if (focusedIndex < 0) |
1744 return nullptr; | 1744 return nullptr; |
1745 HTMLElement* focused = listItems()[focusedIndex]; | 1745 HTMLElement* focused = listItems()[focusedIndex]; |
1746 return isHTMLOptionElement(focused) ? toHTMLOptionElement(focused) : nullptr
; | 1746 return isHTMLOptionElement(focused) ? toHTMLOptionElement(focused) : nullptr
; |
1747 } | 1747 } |
1748 | 1748 |
1749 } // namespace | 1749 } // namespace |
OLD | NEW |