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 const Vector<HTMLElement*>& items = listItems(); | |
| 259 for (unsigned i = 0; i < items.size(); ++i) { | |
| 260 if (items[i]->hasLocalName(optionTag) && m_suggestedIndex >= 0) { | |
|
Inactive
2014/03/16 23:49:43
isHTMLOptionElement()
ziran.sun
2014/03/17 16:41:10
Done.
| |
| 261 if (i == (unsigned)m_suggestedIndex) | |
|
tkent
2014/03/16 23:34:04
We don't use C-style cast.
static_cast<unsigned>(m
ziran.sun
2014/03/17 16:41:10
Done.
| |
| 262 return toHTMLOptionElement(items[i])->value(); | |
| 263 } | |
| 264 } | |
| 265 return ""; | |
| 266 } | |
| 267 | |
| 268 void HTMLSelectElement::setSuggestedValue(const String& value) | |
| 269 { | |
| 270 if (value.isNull()) { | |
| 271 setSuggestedIndex(-1); | |
| 272 return; | |
| 273 } | |
| 274 | |
| 275 const Vector<HTMLElement*>& items = listItems(); | |
| 276 unsigned optionIndex = 0; | |
| 277 for (unsigned i = 0; i < items.size(); ++i) { | |
| 278 if (items[i]->hasLocalName(optionTag)) { | |
|
Inactive
2014/03/16 23:49:43
Ditto
ziran.sun
2014/03/17 16:41:10
Done.
| |
| 279 if (toHTMLOptionElement(items[i])->value() == value) { | |
| 280 setSuggestedIndex(optionIndex); | |
| 281 return; | |
| 282 } | |
| 283 optionIndex++; | |
| 284 } | |
| 285 } | |
| 286 | |
| 287 setSuggestedIndex(-1); | |
| 288 } | |
| 289 | |
| 256 bool HTMLSelectElement::isPresentationAttribute(const QualifiedName& name) const | 290 bool HTMLSelectElement::isPresentationAttribute(const QualifiedName& name) const |
| 257 { | 291 { |
| 258 if (name == alignAttr) { | 292 if (name == alignAttr) { |
| 259 // Don't map 'align' attribute. This matches what Firefox, Opera and IE do. | 293 // Don't map 'align' attribute. This matches what Firefox, Opera and IE do. |
| 260 // See http://bugs.webkit.org/show_bug.cgi?id=12072 | 294 // See http://bugs.webkit.org/show_bug.cgi?id=12072 |
| 261 return false; | 295 return false; |
| 262 } | 296 } |
| 263 | 297 |
| 264 return HTMLFormControlElementWithState::isPresentationAttribute(name); | 298 return HTMLFormControlElementWithState::isPresentationAttribute(name); |
| 265 } | 299 } |
| (...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 788 } | 822 } |
| 789 | 823 |
| 790 return -1; | 824 return -1; |
| 791 } | 825 } |
| 792 | 826 |
| 793 void HTMLSelectElement::setSelectedIndex(int index) | 827 void HTMLSelectElement::setSelectedIndex(int index) |
| 794 { | 828 { |
| 795 selectOption(index, DeselectOtherOptions); | 829 selectOption(index, DeselectOtherOptions); |
| 796 } | 830 } |
| 797 | 831 |
| 832 int HTMLSelectElement::suggestedIndex() const | |
| 833 { | |
| 834 return m_suggestedIndex; | |
| 835 } | |
| 836 | |
| 837 void HTMLSelectElement::setSuggestedIndex(int suggestedIndex) | |
| 838 { | |
| 839 m_suggestedIndex = suggestedIndex; | |
| 840 | |
| 841 if (RenderObject* renderer = this->renderer()) { | |
| 842 renderer->updateFromElement(); | |
| 843 if (renderer->isListBox()) | |
| 844 toRenderListBox(renderer)->scrollToRevealElementAtListIndex(suggeste dIndex); | |
| 845 } | |
| 846 } | |
| 847 | |
| 798 void HTMLSelectElement::optionSelectionStateChanged(HTMLOptionElement* option, b ool optionIsSelected) | 848 void HTMLSelectElement::optionSelectionStateChanged(HTMLOptionElement* option, b ool optionIsSelected) |
| 799 { | 849 { |
| 800 ASSERT(option->ownerSelectElement() == this); | 850 ASSERT(option->ownerSelectElement() == this); |
| 801 if (optionIsSelected) | 851 if (optionIsSelected) |
| 802 selectOption(option->index()); | 852 selectOption(option->index()); |
| 803 else if (!usesMenuList() || multiple()) | 853 else if (!usesMenuList() || multiple()) |
| 804 selectOption(-1); | 854 selectOption(-1); |
| 805 else | 855 else |
| 806 selectOption(nextSelectableListIndex(-1)); | 856 selectOption(nextSelectableListIndex(-1)); |
| 807 } | 857 } |
| (...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1564 { | 1614 { |
| 1565 return true; | 1615 return true; |
| 1566 } | 1616 } |
| 1567 | 1617 |
| 1568 bool HTMLSelectElement::supportsAutofocus() const | 1618 bool HTMLSelectElement::supportsAutofocus() const |
| 1569 { | 1619 { |
| 1570 return true; | 1620 return true; |
| 1571 } | 1621 } |
| 1572 | 1622 |
| 1573 } // namespace | 1623 } // namespace |
| OLD | NEW |