| OLD | NEW |
| 1 /* | 1 /* |
| 2 * This file is part of the select element renderer in WebCore. | 2 * This file is part of the select element renderer in WebCore. |
| 3 * | 3 * |
| 4 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). | 4 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
| 5 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv
ed. | 5 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv
ed. |
| 6 * 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) | 6 * 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) |
| 7 * | 7 * |
| 8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
| 9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
| 10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 setNeedsLayoutAndPrefWidthsRecalc(); | 194 setNeedsLayoutAndPrefWidthsRecalc(); |
| 195 } | 195 } |
| 196 | 196 |
| 197 void RenderMenuList::updateFromElement() | 197 void RenderMenuList::updateFromElement() |
| 198 { | 198 { |
| 199 if (m_optionsChanged) { | 199 if (m_optionsChanged) { |
| 200 updateOptionsWidth(); | 200 updateOptionsWidth(); |
| 201 m_optionsChanged = false; | 201 m_optionsChanged = false; |
| 202 } | 202 } |
| 203 | 203 |
| 204 if (m_popupIsVisible) | 204 if (m_popupIsVisible) { |
| 205 m_popup->updateFromElement(); | 205 m_popup->updateFromElement(); |
| 206 else | 206 } else { |
| 207 setTextFromOption(selectElement()->selectedIndex()); | 207 if (selectElement()->suggestedIndex() >= 0) |
| 208 setTextFromOption(selectElement()->suggestedIndex()); |
| 209 else |
| 210 setTextFromOption(selectElement()->selectedIndex()); |
| 211 } |
| 208 } | 212 } |
| 209 | 213 |
| 210 void RenderMenuList::setTextFromOption(int optionIndex) | 214 void RenderMenuList::setTextFromOption(int optionIndex) |
| 211 { | 215 { |
| 212 HTMLSelectElement* select = selectElement(); | 216 HTMLSelectElement* select = selectElement(); |
| 213 const Vector<HTMLElement*>& listItems = select->listItems(); | 217 const Vector<HTMLElement*>& listItems = select->listItems(); |
| 214 int size = listItems.size(); | 218 int size = listItems.size(); |
| 215 | 219 |
| 216 int i = select->optionToListIndex(optionIndex); | 220 int i = select->optionToListIndex(optionIndex); |
| 217 String text = emptyString(); | 221 String text = emptyString(); |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 560 HTMLElement* element = listItems[listIndex]; | 564 HTMLElement* element = listItems[listIndex]; |
| 561 return isHTMLOptionElement(*element) && toHTMLOptionElement(*element).select
ed(); | 565 return isHTMLOptionElement(*element) && toHTMLOptionElement(*element).select
ed(); |
| 562 } | 566 } |
| 563 | 567 |
| 564 void RenderMenuList::setTextFromItem(unsigned listIndex) | 568 void RenderMenuList::setTextFromItem(unsigned listIndex) |
| 565 { | 569 { |
| 566 setTextFromOption(selectElement()->listToOptionIndex(listIndex)); | 570 setTextFromOption(selectElement()->listToOptionIndex(listIndex)); |
| 567 } | 571 } |
| 568 | 572 |
| 569 } | 573 } |
| OLD | NEW |