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 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
406 { | 406 { |
407 return options()->item(index); | 407 return options()->item(index); |
408 } | 408 } |
409 | 409 |
410 void HTMLSelectElement::setOption(unsigned index, HTMLOptionElement* option, Exc
eptionCode& ec) | 410 void HTMLSelectElement::setOption(unsigned index, HTMLOptionElement* option, Exc
eptionCode& ec) |
411 { | 411 { |
412 ec = 0; | 412 ec = 0; |
413 if (index > maxSelectItems - 1) | 413 if (index > maxSelectItems - 1) |
414 index = maxSelectItems - 1; | 414 index = maxSelectItems - 1; |
415 int diff = index - length(); | 415 int diff = index - length(); |
416 HTMLElement* before = 0; | 416 RefPtr<HTMLElement> before = 0; |
417 // Out of array bounds? First insert empty dummies. | 417 // Out of array bounds? First insert empty dummies. |
418 if (diff > 0) { | 418 if (diff > 0) { |
419 setLength(index, ec); | 419 setLength(index, ec); |
420 // Replace an existing entry? | 420 // Replace an existing entry? |
421 } else if (diff < 0) { | 421 } else if (diff < 0) { |
422 before = toHTMLElement(options()->item(index+1)); | 422 before = toHTMLElement(options()->item(index+1)); |
423 remove(index); | 423 remove(index); |
424 } | 424 } |
425 // Finally add the new element. | 425 // Finally add the new element. |
426 if (!ec) { | 426 if (!ec) { |
427 add(option, before, ec); | 427 add(option, before.get(), ec); |
428 if (diff >= 0 && option->selected()) | 428 if (diff >= 0 && option->selected()) |
429 optionSelectionStateChanged(option, true); | 429 optionSelectionStateChanged(option, true); |
430 } | 430 } |
431 } | 431 } |
432 | 432 |
433 void HTMLSelectElement::setLength(unsigned newLen, ExceptionCode& ec) | 433 void HTMLSelectElement::setLength(unsigned newLen, ExceptionCode& ec) |
434 { | 434 { |
435 ec = 0; | 435 ec = 0; |
436 if (newLen > maxSelectItems) | 436 if (newLen > maxSelectItems) |
437 newLen = maxSelectItems; | 437 newLen = maxSelectItems; |
(...skipping 1097 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1535 | 1535 |
1536 const HTMLSelectElement* toHTMLSelectElement(const Node* node) | 1536 const HTMLSelectElement* toHTMLSelectElement(const Node* node) |
1537 { | 1537 { |
1538 ASSERT(!node || node->hasTagName(selectTag)); | 1538 ASSERT(!node || node->hasTagName(selectTag)); |
1539 return static_cast<const HTMLSelectElement*>(node); | 1539 return static_cast<const HTMLSelectElement*>(node); |
1540 } | 1540 } |
1541 | 1541 |
1542 #endif | 1542 #endif |
1543 | 1543 |
1544 } // namespace | 1544 } // namespace |
OLD | NEW |