WebCore:
[WebKit-https.git] / WebCore / html / HTMLSelectElement.cpp
index 50c4e74905bc3fc53ffc5ae67c190827b638eb44..12b078157da3f998c646993355d484e3e64ebfa0 100644 (file)
@@ -494,7 +494,7 @@ PassRefPtr<HTMLOptionsCollection> HTMLSelectElement::options()
     return new HTMLOptionsCollection(this);
 }
 
-void HTMLSelectElement::recalcListItems() const
+void HTMLSelectElement::recalcListItems(bool updateSelectedStates) const
 {
     m_listItems.clear();
     HTMLOptionElement* foundSelected = 0;
@@ -513,12 +513,14 @@ void HTMLSelectElement::recalcListItems() const
 
         if (current->hasTagName(optionTag)) {
             m_listItems.append(static_cast<HTMLElement*>(current));
-            if (!foundSelected && (usesMenuList() || (!m_multiple && static_cast<HTMLOptionElement*>(current)->selected()))) {
-                foundSelected = static_cast<HTMLOptionElement*>(current);
-                foundSelected->setSelectedState(true);
-            } else if (foundSelected && !m_multiple && static_cast<HTMLOptionElement*>(current)->selected()) {
-                foundSelected->setSelectedState(false);
-                foundSelected = static_cast<HTMLOptionElement*>(current);
+            if (updateSelectedStates) {
+                if (!foundSelected && (usesMenuList() || (!m_multiple && static_cast<HTMLOptionElement*>(current)->selected()))) {
+                    foundSelected = static_cast<HTMLOptionElement*>(current);
+                    foundSelected->setSelectedState(true);
+                } else if (foundSelected && !m_multiple && static_cast<HTMLOptionElement*>(current)->selected()) {
+                    foundSelected->setSelectedState(false);
+                    foundSelected = static_cast<HTMLOptionElement*>(current);
+                }
             }
         }
         if (current->hasTagName(hrTag))
@@ -1091,7 +1093,7 @@ void HTMLSelectElement::scrollToSelection()
 void HTMLSelectElement::checkListItems() const
 {
     Vector<HTMLElement*> items = m_listItems;
-    recalcListItems();
+    recalcListItems(false);
     ASSERT(items == m_listItems);
 }