| 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 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 setSelectedIndex(optionIndex); | 246 setSelectedIndex(optionIndex); |
| 247 return; | 247 return; |
| 248 } | 248 } |
| 249 optionIndex++; | 249 optionIndex++; |
| 250 } | 250 } |
| 251 } | 251 } |
| 252 | 252 |
| 253 setSelectedIndex(-1); | 253 setSelectedIndex(-1); |
| 254 } | 254 } |
| 255 | 255 |
| 256 String HTMLSelectElement::suggestedValue() const |
| 257 { |
| 258 return m_suggestedValue; |
| 259 } |
| 260 |
| 261 void HTMLSelectElement::setSuggestedValue(const String& value) |
| 262 { |
| 263 m_suggestedValue = value; |
| 264 |
| 265 if (value.isNull()) { |
| 266 setSuggestedIndex(-1); |
| 267 return; |
| 268 } |
| 269 |
| 270 const Vector<HTMLElement*>& items = listItems(); |
| 271 unsigned optionIndex = 0; |
| 272 for (unsigned i = 0; i < items.size(); i++) { |
| 273 if (items[i]->hasLocalName(optionTag)) { |
| 274 if (toHTMLOptionElement(items[i])->value() == value) { |
| 275 setSuggestedIndex(optionIndex); |
| 276 return; |
| 277 } |
| 278 optionIndex++; |
| 279 } |
| 280 } |
| 281 |
| 282 setSuggestedIndex(-1); |
| 283 } |
| 284 |
| 256 bool HTMLSelectElement::isPresentationAttribute(const QualifiedName& name) const | 285 bool HTMLSelectElement::isPresentationAttribute(const QualifiedName& name) const |
| 257 { | 286 { |
| 258 if (name == alignAttr) { | 287 if (name == alignAttr) { |
| 259 // Don't map 'align' attribute. This matches what Firefox, Opera and IE
do. | 288 // Don't map 'align' attribute. This matches what Firefox, Opera and IE
do. |
| 260 // See http://bugs.webkit.org/show_bug.cgi?id=12072 | 289 // See http://bugs.webkit.org/show_bug.cgi?id=12072 |
| 261 return false; | 290 return false; |
| 262 } | 291 } |
| 263 | 292 |
| 264 return HTMLFormControlElementWithState::isPresentationAttribute(name); | 293 return HTMLFormControlElementWithState::isPresentationAttribute(name); |
| 265 } | 294 } |
| (...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 785 } | 814 } |
| 786 | 815 |
| 787 return -1; | 816 return -1; |
| 788 } | 817 } |
| 789 | 818 |
| 790 void HTMLSelectElement::setSelectedIndex(int index) | 819 void HTMLSelectElement::setSelectedIndex(int index) |
| 791 { | 820 { |
| 792 selectOption(index, DeselectOtherOptions); | 821 selectOption(index, DeselectOtherOptions); |
| 793 } | 822 } |
| 794 | 823 |
| 824 int HTMLSelectElement::suggestedIndex() const |
| 825 { |
| 826 return m_suggestedIndex; |
| 827 } |
| 828 |
| 829 void HTMLSelectElement::setSuggestedIndex(int suggestedIndex) |
| 830 { |
| 831 m_suggestedIndex = suggestedIndex; |
| 832 |
| 833 if (RenderObject* renderer = this->renderer()) { |
| 834 renderer->updateFromElement(); |
| 835 if (renderer->isListBox()) |
| 836 toRenderListBox(renderer)->scrollToRevealElementAtListIndex(suggeste
dIndex); |
| 837 } |
| 838 |
| 839 setNeedsValidityCheck(); |
| 840 } |
| 841 |
| 795 void HTMLSelectElement::optionSelectionStateChanged(HTMLOptionElement* option, b
ool optionIsSelected) | 842 void HTMLSelectElement::optionSelectionStateChanged(HTMLOptionElement* option, b
ool optionIsSelected) |
| 796 { | 843 { |
| 797 ASSERT(option->ownerSelectElement() == this); | 844 ASSERT(option->ownerSelectElement() == this); |
| 798 if (optionIsSelected) | 845 if (optionIsSelected) |
| 799 selectOption(option->index()); | 846 selectOption(option->index()); |
| 800 else if (!usesMenuList() || multiple()) | 847 else if (!usesMenuList() || multiple()) |
| 801 selectOption(-1); | 848 selectOption(-1); |
| 802 else | 849 else |
| 803 selectOption(nextSelectableListIndex(-1)); | 850 selectOption(nextSelectableListIndex(-1)); |
| 804 } | 851 } |
| (...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1561 { | 1608 { |
| 1562 return true; | 1609 return true; |
| 1563 } | 1610 } |
| 1564 | 1611 |
| 1565 bool HTMLSelectElement::supportsAutofocus() const | 1612 bool HTMLSelectElement::supportsAutofocus() const |
| 1566 { | 1613 { |
| 1567 return true; | 1614 return true; |
| 1568 } | 1615 } |
| 1569 | 1616 |
| 1570 } // namespace | 1617 } // namespace |
| OLD | NEW |