Chromium Code Reviews| 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; | |
|
keishi
2014/03/13 04:47:50
It doesn't matter yet, but, HTMLInputElement seems
ziran.sun
2014/03/13 11:20:52
Done.
| |
| 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 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 788 } | 817 } |
| 789 | 818 |
| 790 return -1; | 819 return -1; |
| 791 } | 820 } |
| 792 | 821 |
| 793 void HTMLSelectElement::setSelectedIndex(int index) | 822 void HTMLSelectElement::setSelectedIndex(int index) |
| 794 { | 823 { |
| 795 selectOption(index, DeselectOtherOptions); | 824 selectOption(index, DeselectOtherOptions); |
| 796 } | 825 } |
| 797 | 826 |
| 827 int HTMLSelectElement::suggestedIndex() const | |
| 828 { | |
| 829 return m_suggestedIndex; | |
| 830 } | |
| 831 | |
| 832 void HTMLSelectElement::setSuggestedIndex(int suggestedIndex) | |
| 833 { | |
| 834 m_suggestedIndex = suggestedIndex; | |
| 835 | |
| 836 if (RenderObject* renderer = this->renderer()) { | |
| 837 renderer->updateFromElement(); | |
| 838 if (renderer->isListBox()) | |
| 839 toRenderListBox(renderer)->scrollToRevealElementAtListIndex(suggeste dIndex); | |
| 840 } | |
| 841 | |
| 842 setNeedsValidityCheck(); | |
| 843 } | |
| 844 | |
| 798 void HTMLSelectElement::optionSelectionStateChanged(HTMLOptionElement* option, b ool optionIsSelected) | 845 void HTMLSelectElement::optionSelectionStateChanged(HTMLOptionElement* option, b ool optionIsSelected) |
| 799 { | 846 { |
| 800 ASSERT(option->ownerSelectElement() == this); | 847 ASSERT(option->ownerSelectElement() == this); |
| 801 if (optionIsSelected) | 848 if (optionIsSelected) |
| 802 selectOption(option->index()); | 849 selectOption(option->index()); |
| 803 else if (!usesMenuList() || multiple()) | 850 else if (!usesMenuList() || multiple()) |
| 804 selectOption(-1); | 851 selectOption(-1); |
| 805 else | 852 else |
| 806 selectOption(nextSelectableListIndex(-1)); | 853 selectOption(nextSelectableListIndex(-1)); |
| 807 } | 854 } |
| (...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1564 { | 1611 { |
| 1565 return true; | 1612 return true; |
| 1566 } | 1613 } |
| 1567 | 1614 |
| 1568 bool HTMLSelectElement::supportsAutofocus() const | 1615 bool HTMLSelectElement::supportsAutofocus() const |
| 1569 { | 1616 { |
| 1570 return true; | 1617 return true; |
| 1571 } | 1618 } |
| 1572 | 1619 |
| 1573 } // namespace | 1620 } // namespace |
| OLD | NEW |