LayoutTests:
authoradele <adele@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 11 Jul 2006 23:32:34 +0000 (23:32 +0000)
committeradele <adele@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 11 Jul 2006 23:32:34 +0000 (23:32 +0000)
        Reviewed by Hyatt.

        Tests for http://bugzilla.opendarwin.org/show_bug.cgi?id=9861
        REGRESSION: Can't dynamically change list box to popup

        * fast/forms/select-change-listbox-to-popup-expected.checksum: Added.
        * fast/forms/select-change-listbox-to-popup-expected.png: Added.
        * fast/forms/select-change-listbox-to-popup-expected.txt: Added.
        * fast/forms/select-change-listbox-to-popup.html: Added.
        * fast/forms/select-change-popup-to-listbox.html:

WebCore:

        Reviewed by Hyatt.

        - Fix for http://bugzilla.opendarwin.org/show_bug.cgi?id=9861
        REGRESSION: Can't dynamically change list box to popup

        and updated fix for http://bugzilla.opendarwin.org/show_bug.cgi?id=9859
        REGRESSION: Can't dynamically change popup to list box

        The original fix for 9859 was in the renderer, and I think we can catch the change
        earlier in the element to detach and reattach.

        I also did some cleanup to remove the PopupButton code path from DeprecatedRenderSelect

        Test: fast/forms/select-change-listbox-to-popup.html

        * html/HTMLSelectElement.cpp:
        (WebCore::HTMLSelectElement::parseMappedAttribute): If the new attribute value is going to require us to change from listbox to popup or vice versa,
        and we're already attached, then detach and reattach to create the correct renderer.  If we're not attached, then we'll create the correct renderer
        when we attach.
        (WebCore::HTMLSelectElement::recalcStyle): Updated shouldUseMenuList since it no longer takes a RenderStyle.
        (WebCore::HTMLSelectElement::isKeyboardFocusable): ditto.
        (WebCore::HTMLSelectElement::isMouseFocusable): ditto.
        (WebCore::HTMLSelectElement::createRenderer): ditto.
        (WebCore::HTMLSelectElement::setRecalcListItems): ditto.
        (WebCore::HTMLSelectElement::reset): ditto.
        (WebCore::HTMLSelectElement::notifyOptionSelected): ditto.
        (WebCore::HTMLSelectElement::defaultEventHandler): ditto.

        * html/HTMLSelectElement.h: (WebCore::HTMLSelectElement::shouldUseMenuList):
        This method no longer takes a RenderStyle.  That was leftover from when we used to use the appearance
        to determine whether or not to use the new menu list implementation.

        * rendering/DeprecatedRenderSelect.h: Removed PopupButton code path.
        * rendering/DeprecatedRenderSelect.cpp:
        (WebCore::DeprecatedRenderSelect::DeprecatedRenderSelect):
        (WebCore::DeprecatedRenderSelect::setWidgetWritingDirection):
        (WebCore::DeprecatedRenderSelect::updateFromElement):
        (WebCore::DeprecatedRenderSelect::baselinePosition):
        (WebCore::DeprecatedRenderSelect::layout):
        (WebCore::DeprecatedRenderSelect::updateSelection):

        * rendering/RenderMenuList.cpp: (WebCore::RenderMenuList::updateFromElement):
        Backed out previous fix since this is now done in HTMLSelectElement.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@15359 268f45cc-cd09-0410-ab3c-d52691b4dbfc

12 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/forms/select-change-listbox-to-popup-expected.checksum [new file with mode: 0644]
LayoutTests/fast/forms/select-change-listbox-to-popup-expected.png [new file with mode: 0644]
LayoutTests/fast/forms/select-change-listbox-to-popup-expected.txt [new file with mode: 0644]
LayoutTests/fast/forms/select-change-listbox-to-popup.html [new file with mode: 0644]
LayoutTests/fast/forms/select-change-popup-to-listbox.html
WebCore/ChangeLog
WebCore/html/HTMLSelectElement.cpp
WebCore/html/HTMLSelectElement.h
WebCore/rendering/DeprecatedRenderSelect.cpp
WebCore/rendering/DeprecatedRenderSelect.h
WebCore/rendering/RenderMenuList.cpp

index c13f2a41455d5e0c9965ae8d290075eb11ffee38..7467c91fb451914856c9c8b3c5449cb1b7caed78 100644 (file)
@@ -1,3 +1,16 @@
+2006-07-11  Adele Peterson  <adele@apple.com>
+
+        Reviewed by Hyatt.
+
+        Tests for http://bugzilla.opendarwin.org/show_bug.cgi?id=9861
+        REGRESSION: Can't dynamically change list box to popup
+
+        * fast/forms/select-change-listbox-to-popup-expected.checksum: Added.
+        * fast/forms/select-change-listbox-to-popup-expected.png: Added.
+        * fast/forms/select-change-listbox-to-popup-expected.txt: Added.
+        * fast/forms/select-change-listbox-to-popup.html: Added.
+        * fast/forms/select-change-popup-to-listbox.html:
+
 2006-07-11  Justin Garcia  <justin.garcia@apple.com>
 
         Reviewed by levi & thatcher
diff --git a/LayoutTests/fast/forms/select-change-listbox-to-popup-expected.checksum b/LayoutTests/fast/forms/select-change-listbox-to-popup-expected.checksum
new file mode 100644 (file)
index 0000000..b1c40f9
--- /dev/null
@@ -0,0 +1 @@
+282875cf936efbab59d4c9ca2dc9657d
\ No newline at end of file
diff --git a/LayoutTests/fast/forms/select-change-listbox-to-popup-expected.png b/LayoutTests/fast/forms/select-change-listbox-to-popup-expected.png
new file mode 100644 (file)
index 0000000..600aa8c
Binary files /dev/null and b/LayoutTests/fast/forms/select-change-listbox-to-popup-expected.png differ
diff --git a/LayoutTests/fast/forms/select-change-listbox-to-popup-expected.txt b/LayoutTests/fast/forms/select-change-listbox-to-popup-expected.txt
new file mode 100644 (file)
index 0000000..50c58ec
--- /dev/null
@@ -0,0 +1,13 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderBlock {HTML} at (0,0) size 800x600
+    RenderBody {BODY} at (8,8) size 784x584
+      RenderText {#text} at (0,0) size 441x18
+        text run at (0,0) width 441: "This tests that you can dynamically change a list box to a popup menu"
+      RenderBR {BR} at (441,14) size 0x0
+      RenderMenuList {SELECT} at (2,20) size 225x18
+        RenderBlock (anonymous) at (8,2) size 194x13
+          RenderText at (0,0) size 195x13
+            text run at (0,0) width 195: "This should turn into a popup menu"
+      RenderText {#text} at (0,0) size 0x0
diff --git a/LayoutTests/fast/forms/select-change-listbox-to-popup.html b/LayoutTests/fast/forms/select-change-listbox-to-popup.html
new file mode 100644 (file)
index 0000000..2dec752
--- /dev/null
@@ -0,0 +1,12 @@
+<html>
+<head>
+<script>
+function test() {
+    document.getElementById('sl').size = 1;
+}
+</script>
+</head>
+<body onload="test()">
+This tests that you can dynamically change a list box to a popup menu<br>
+<select size=5 id="sl"><option>This should turn into a popup menu</option></select>
+</body>
\ No newline at end of file
index aaf2d917f94b09fa704c34b3d52266743ce9dc20..32feb990a0e501068bf32b7744ba46c0faf1c263 100644 (file)
@@ -1,5 +1,5 @@
 <html>
-<body onload="document.getElementById('sl').size = 5; document.getElementById('sl').focus()">
+<body onload="document.getElementById('sl').size = 5;">
 This tests that you can dynamically change a popup menu to a list box.
 <br>
 <select size=1 id="sl"><option>This should turn into a list box</option></select>
index b9d55630a29f19864aeea1667f0c87a749e8275a..a097d2d325679b402b3a149f60e7c553ad55fd45 100644 (file)
@@ -1,3 +1,49 @@
+2006-07-11  Adele Peterson  <adele@apple.com>
+
+        Reviewed by Hyatt.
+
+        - Fix for http://bugzilla.opendarwin.org/show_bug.cgi?id=9861
+        REGRESSION: Can't dynamically change list box to popup
+        
+        and updated fix for http://bugzilla.opendarwin.org/show_bug.cgi?id=9859
+        REGRESSION: Can't dynamically change popup to list box
+
+        The original fix for 9859 was in the renderer, and I think we can catch the change
+        earlier in the element to detach and reattach.
+
+        I also did some cleanup to remove the PopupButton code path from DeprecatedRenderSelect
+
+        Test: fast/forms/select-change-listbox-to-popup.html
+
+        * html/HTMLSelectElement.cpp:
+        (WebCore::HTMLSelectElement::parseMappedAttribute): If the new attribute value is going to require us to change from listbox to popup or vice versa,
+        and we're already attached, then detach and reattach to create the correct renderer.  If we're not attached, then we'll create the correct renderer
+        when we attach.
+        (WebCore::HTMLSelectElement::recalcStyle): Updated shouldUseMenuList since it no longer takes a RenderStyle.
+        (WebCore::HTMLSelectElement::isKeyboardFocusable): ditto.
+        (WebCore::HTMLSelectElement::isMouseFocusable): ditto.
+        (WebCore::HTMLSelectElement::createRenderer): ditto.
+        (WebCore::HTMLSelectElement::setRecalcListItems): ditto.
+        (WebCore::HTMLSelectElement::reset): ditto.
+        (WebCore::HTMLSelectElement::notifyOptionSelected): ditto.
+        (WebCore::HTMLSelectElement::defaultEventHandler): ditto.
+
+        * html/HTMLSelectElement.h: (WebCore::HTMLSelectElement::shouldUseMenuList):
+        This method no longer takes a RenderStyle.  That was leftover from when we used to use the appearance
+        to determine whether or not to use the new menu list implementation.
+
+        * rendering/DeprecatedRenderSelect.h: Removed PopupButton code path.
+        * rendering/DeprecatedRenderSelect.cpp:
+        (WebCore::DeprecatedRenderSelect::DeprecatedRenderSelect):
+        (WebCore::DeprecatedRenderSelect::setWidgetWritingDirection):
+        (WebCore::DeprecatedRenderSelect::updateFromElement):
+        (WebCore::DeprecatedRenderSelect::baselinePosition):
+        (WebCore::DeprecatedRenderSelect::layout):
+        (WebCore::DeprecatedRenderSelect::updateSelection):
+
+        * rendering/RenderMenuList.cpp: (WebCore::RenderMenuList::updateFromElement):
+        Backed out previous fix since this is now done in HTMLSelectElement.
+
 2006-07-11  Adele Peterson  <adele@apple.com>
 
         Reviewed by Hyatt.
index 03d39377b754fdab7f709bc4f8e533fe19ac0ed4..3706cae6b0493d1bf3123aabc4b71e10d490cf47 100644 (file)
@@ -77,7 +77,7 @@ bool HTMLSelectElement::checkDTD(const Node* newChild)
 void HTMLSelectElement::recalcStyle( StyleChange ch )
 {
     if (hasChangedChild() && renderer()) {
-        if (shouldUseMenuList(renderer()->style()))
+        if (shouldUseMenuList())
             static_cast<RenderMenuList*>(renderer())->setOptionsChanged(true);
         else
             static_cast<DeprecatedRenderSelect*>(renderer())->setOptionsChanged(true);
@@ -257,12 +257,21 @@ ContainerNode* HTMLSelectElement::addChild(PassRefPtr<Node> newChild)
 
 void HTMLSelectElement::parseMappedAttribute(MappedAttribute *attr)
 {
+    bool oldShouldUseMenuList = shouldUseMenuList();
     if (attr->name() == sizeAttr) {
         m_size = max(attr->value().toInt(), 1);
+        if (oldShouldUseMenuList != shouldUseMenuList() && attached()) {
+            detach();
+            attach();
+        }
     } else if (attr->name() == widthAttr) {
         m_minwidth = max(attr->value().toInt(), 0);
     } else if (attr->name() == multipleAttr) {
         m_multiple = (!attr->isNull());
+        if (oldShouldUseMenuList != shouldUseMenuList() && attached()) {
+            detach();
+            attach();
+        }
     } else if (attr->name() == accesskeyAttr) {
         // FIXME: ignore for the moment
     } else if (attr->name() == onfocusAttr) {
@@ -277,21 +286,21 @@ void HTMLSelectElement::parseMappedAttribute(MappedAttribute *attr)
 
 bool HTMLSelectElement::isKeyboardFocusable() const
 {
-    if (renderer() && shouldUseMenuList(renderer()->style()))
+    if (renderer() && shouldUseMenuList())
         return isFocusable();
     return HTMLGenericFormElement::isKeyboardFocusable();
 }
 
 bool HTMLSelectElement::isMouseFocusable() const
 {
-    if (renderer() && shouldUseMenuList(renderer()->style()))
+    if (renderer() && shouldUseMenuList())
         return isFocusable();
     return HTMLGenericFormElement::isMouseFocusable();
 }
 
 RenderObject *HTMLSelectElement::createRenderer(RenderArena *arena, RenderStyle *style)
 {
-    if (shouldUseMenuList(style))
+    if (shouldUseMenuList())
         return new (arena) RenderMenuList(this);
     return new (arena) DeprecatedRenderSelect(this);
 }
@@ -411,7 +420,7 @@ void HTMLSelectElement::setRecalcListItems()
 {
     m_recalcListItems = true;
     if (renderer()) {
-        if (shouldUseMenuList(renderer()->style()))
+        if (shouldUseMenuList())
             static_cast<RenderMenuList*>(renderer())->setOptionsChanged(true);
         else
             static_cast<DeprecatedRenderSelect*>(renderer())->setOptionsChanged(true);
@@ -440,7 +449,7 @@ void HTMLSelectElement::reset()
     if (!optionSelected && firstOption)
         firstOption->setSelected(true);
     if (renderer()) {
-        if (shouldUseMenuList(renderer()->style()))
+        if (shouldUseMenuList())
             static_cast<RenderMenuList*>(renderer())->setSelectionChanged(true);
         else
             static_cast<DeprecatedRenderSelect*>(renderer())->setSelectionChanged(true);
@@ -460,7 +469,7 @@ void HTMLSelectElement::notifyOptionSelected(HTMLOptionElement *selectedOption,
         }
     }
     if (renderer()) {
-        if (shouldUseMenuList(renderer()->style()))
+        if (shouldUseMenuList())
             static_cast<RenderMenuList*>(renderer())->setSelectionChanged(true);
         else
             static_cast<DeprecatedRenderSelect*>(renderer())->setSelectionChanged(true);
@@ -481,12 +490,12 @@ void HTMLSelectElement::defaultEventHandler(Event *evt)
             form()->submitClick();
             evt->setDefaultHandled();
         }
-        if ((keyIdentifier == "Down" || keyIdentifier == "Up" || keyIdentifier == "U+000020") && renderer() && shouldUseMenuList(renderer()->style())) {
+        if ((keyIdentifier == "Down" || keyIdentifier == "Up" || keyIdentifier == "U+000020") && renderer() && shouldUseMenuList()) {
             static_cast<RenderMenuList*>(renderer())->showPopup();
             evt->setDefaultHandled();
         }
     }
-    if (evt->type() == mousedownEvent && renderer() && shouldUseMenuList(renderer()->style())) {
+    if (evt->type() == mousedownEvent && renderer() && shouldUseMenuList()) {
         static_cast<RenderMenuList*>(renderer())->showPopup();
         evt->setDefaultHandled();
     }
index e91f43437121812771d72dc82773ab23b9754323..14e0f98e06a75e902801dc9cd8a82759defdcb13 100644 (file)
@@ -125,7 +125,7 @@ public:
 
 private:
     void recalcListItems();
-    bool shouldUseMenuList(RenderStyle* style) const { return !m_multiple && m_size <= 1; }
+    bool shouldUseMenuList() const { return !m_multiple && m_size <= 1; }
 
     mutable Vector<HTMLElement*> m_listItems;
     int m_minwidth;
index 4db0f33e6a607867a31c3aeff644ee6fa3815bc0..6df1c18f4c1ce69a4b7c56d56548068a66c975d3 100644 (file)
@@ -42,24 +42,17 @@ DeprecatedRenderSelect::DeprecatedRenderSelect(HTMLSelectElement* element)
     : RenderFormElement(element)
     , m_size(element->size())
     , m_multiple(element->multiple())
-    , m_useListBox(m_multiple || m_size > 1)
     , m_selectionChanged(true)
     , m_ignoreSelectEvents(false)
     , m_optionsChanged(true)
 {
-    if (m_useListBox)
-        setWidget(createListBox());
-    else
-        setWidget(new PopUpButton);
+    setWidget(createListBox());
 }
 
 void DeprecatedRenderSelect::setWidgetWritingDirection()
 {
     TextDirection d = style()->direction() == RTL ? RTL : LTR;
-    if (m_useListBox)
-        static_cast<ListBox*>(m_widget)->setWritingDirection(d);
-    else
-        static_cast<PopUpButton*>(m_widget)->setWritingDirection(d);
+    static_cast<ListBox*>(m_widget)->setWritingDirection(d);
 }
 
 void DeprecatedRenderSelect::setStyle(RenderStyle* s)
@@ -74,28 +67,10 @@ void DeprecatedRenderSelect::updateFromElement()
 
     // change widget type
     bool oldMultiple = m_multiple;
-    unsigned oldSize = m_size;
-    bool oldListbox = m_useListBox;
-
     m_multiple = static_cast<HTMLSelectElement*>(node())->multiple();
-    m_size = static_cast<HTMLSelectElement*>(node())->size();
-    m_useListBox = (m_multiple || m_size > 1);
-
-    if (oldMultiple != m_multiple || oldSize != m_size) {
-        if (m_useListBox != oldListbox) {
-            // type of select has changed
-            delete m_widget;
-
-            if (m_useListBox)
-                setWidget(createListBox());
-            else
-                setWidget(new PopUpButton);
-            setWidgetWritingDirection();
-        }
 
-        if (m_useListBox && oldMultiple != m_multiple) {
-            static_cast<ListBox*>(m_widget)->setSelectionMode(m_multiple ? ListBox::Extended : ListBox::Single);
-        }
+    if (oldMultiple != m_multiple) {
+        static_cast<ListBox*>(m_widget)->setSelectionMode(m_multiple ? ListBox::Extended : ListBox::Single);
         m_selectionChanged = true;
         m_optionsChanged = true;
     }
@@ -107,11 +82,8 @@ void DeprecatedRenderSelect::updateFromElement()
         Vector<HTMLElement*> listItems = static_cast<HTMLSelectElement*>(node())->listItems();
         int listIndex;
 
-        if (m_useListBox)
-            static_cast<ListBox*>(m_widget)->clear();
-        else
-            static_cast<PopUpButton*>(m_widget)->clear();
-
+        static_cast<ListBox*>(m_widget)->clear();
+        
         bool groupEnabled = true;
         for (listIndex = 0; listIndex < int(listItems.size()); listIndex++) {
             if (listItems[listIndex]->hasTagName(optgroupTag)) {
@@ -127,10 +99,8 @@ void DeprecatedRenderSelect::updateFromElement()
 
                 groupEnabled = optgroupElement->isEnabled();
                 
-                if (m_useListBox)
-                    static_cast<ListBox*>(m_widget)->appendGroupLabel(label, groupEnabled);
-                else
-                    static_cast<PopUpButton*>(m_widget)->appendGroupLabel(label);
+                static_cast<ListBox*>(m_widget)->appendGroupLabel(label, groupEnabled);
+
             } else if (listItems[listIndex]->hasTagName(optionTag)) {
                 HTMLOptionElement* optionElement = static_cast<HTMLOptionElement*>(listItems[listIndex]);
                 DeprecatedString itemText = optionElement->text().deprecatedString();
@@ -147,19 +117,12 @@ void DeprecatedRenderSelect::updateFromElement()
                 if (listItems[listIndex]->parentNode()->hasTagName(optgroupTag))
                     itemText.prepend("    ");
 
-                if (m_useListBox)
-                    static_cast<ListBox*>(m_widget)->appendItem(itemText, groupEnabled && optionElement->isEnabled());
-                else
-                    static_cast<PopUpButton*>(m_widget)->appendItem(itemText, groupEnabled && optionElement->isEnabled());
-            } else if (listItems[listIndex]->hasTagName(hrTag)) {
-                if (!m_useListBox)
-                    static_cast<PopUpButton*>(m_widget)->appendSeparator();
+                static_cast<ListBox*>(m_widget)->appendItem(itemText, groupEnabled && optionElement->isEnabled());
             } else
                 ASSERT(false);
             m_selectionChanged = true;
         }
-        if (m_useListBox)
-            static_cast<ListBox*>(m_widget)->doneAppendingItems();
+        static_cast<ListBox*>(m_widget)->doneAppendingItems();
         setNeedsLayoutAndMinMaxRecalc();
         m_optionsChanged = false;
     }
@@ -175,12 +138,9 @@ void DeprecatedRenderSelect::updateFromElement()
 
 short DeprecatedRenderSelect::baselinePosition(bool f, bool isRootLineBox) const
 {
-    if (m_useListBox) {
-        // FIXME: Should get the hardcoded constant of 7 by calling a ListBox function,
-        // as we do for other widget classes.
-        return RenderWidget::baselinePosition(f, isRootLineBox) - 7;
-    }
-    return RenderFormElement::baselinePosition(f, isRootLineBox);
+    // FIXME: Should get the hardcoded constant of 7 by calling a ListBox function,
+    // as we do for other widget classes.
+    return RenderWidget::baselinePosition(f, isRootLineBox) - 7;
 }
 
 void DeprecatedRenderSelect::calcMinMaxWidth()
@@ -209,28 +169,22 @@ void DeprecatedRenderSelect::layout()
     // first selected one)
 
     // calculate size
-    if (m_useListBox) {
-        ListBox* w = static_cast<ListBox*>(m_widget);
-
-
-        int size = m_size;
-        // check if multiple and size was not given or invalid
-        // Internet Exploder sets size to min(number of elements, 4)
-        // Netscape seems to simply set it to "number of elements"
-        // the average of that is IMHO min(number of elements, 10)
-        // so I did that ;-)
-        if (size < 1)
-            size = min(static_cast<ListBox*>(m_widget)->count(), 10U);
-
-        // Let the widget tell us how big it wants to be.
-        IntSize s(w->sizeForNumberOfLines(size));
-        setIntrinsicWidth(s.width());
-        setIntrinsicHeight(s.height());
-    } else {
-        IntSize s(m_widget->sizeHint());
-        setIntrinsicWidth(s.width());
-        setIntrinsicHeight(s.height());
-    }
+    ListBox* w = static_cast<ListBox*>(m_widget);
+
+
+    int size = m_size;
+    // check if multiple and size was not given or invalid
+    // Internet Exploder sets size to min(number of elements, 4)
+    // Netscape seems to simply set it to "number of elements"
+    // the average of that is IMHO min(number of elements, 10)
+    // so I did that ;-)
+    if (size < 1)
+        size = min(static_cast<ListBox*>(m_widget)->count(), 10U);
+
+    // Let the widget tell us how big it wants to be.
+    IntSize s(w->sizeForNumberOfLines(size));
+    setIntrinsicWidth(s.width());
+    setIntrinsicHeight(s.height());
 
     RenderFormElement::layout();
 
@@ -244,54 +198,6 @@ void DeprecatedRenderSelect::layout()
     m_widget->setEnabled(foundOption && ! static_cast<HTMLSelectElement*>(node())->disabled());
 }
 
-void DeprecatedRenderSelect::valueChanged(Widget*)
-{
-    if (m_ignoreSelectEvents)
-        return;
-
-    ASSERT(!m_useListBox);
-
-    int index = static_cast<PopUpButton*>(m_widget)->currentItem();
-
-    Vector<HTMLElement*> listItems = static_cast<HTMLSelectElement*>(node())->listItems();
-    if (index >= 0 && index < (int)listItems.size()) {
-        bool found = listItems[index]->hasTagName(optionTag);
-        if (!found) {
-            // this one is not selectable,  we need to find an option element
-            while ((unsigned) index < listItems.size()) {
-                if (listItems[index]->hasTagName(optionTag)) {
-                    found = true;
-                    break;
-                }
-                ++index;
-            }
-
-            if (!found) {
-                while (index >= 0) {
-                    if (listItems[index]->hasTagName(optionTag)) {
-                        found = true;
-                        break;
-                    }
-                    --index;
-                }
-            }
-        }
-
-        if (found) {
-            if (index != static_cast<PopUpButton*>(m_widget)->currentItem())
-                static_cast<PopUpButton*>(m_widget)->setCurrentItem(index);
-
-            for (unsigned i = 0; i < listItems.size(); ++i)
-                if (listItems[i]->hasTagName(optionTag) && i != (unsigned int) index)
-                    static_cast<HTMLOptionElement*>(listItems[i])->m_selected = false;
-
-            static_cast<HTMLOptionElement*>(listItems[index])->m_selected = true;
-        }
-    }
-
-    static_cast<HTMLSelectElement*>(node())->onChange();
-}
-
 void DeprecatedRenderSelect::selectionChanged(Widget*)
 {
     if (m_ignoreSelectEvents)
@@ -331,33 +237,15 @@ void DeprecatedRenderSelect::updateSelection()
 {
     Vector<HTMLElement*> listItems = static_cast<HTMLSelectElement*>(node())->listItems();
     int i;
-    if (m_useListBox) {
-        // if multi-select, we select only the new selected index
-        ListBox *listBox = static_cast<ListBox*>(m_widget);
-        int j = 0;
-        for (i = 0; i < int(listItems.size()); i++) {
-            listBox->setSelected(j, listItems[i]->hasTagName(optionTag) &&
-                                static_cast<HTMLOptionElement*>(listItems[i])->selected());
-            if (listItems[i]->hasTagName(optionTag) || listItems[i]->hasTagName(optgroupTag))
-                ++j;
-            
-        }
-    } else {
-        bool found = false;
-        unsigned firstOption = listItems.size();
-        i = listItems.size();
-        while (i--)
-            if (listItems[i]->hasTagName(optionTag)) {
-                if (found)
-                    static_cast<HTMLOptionElement*>(listItems[i])->m_selected = false;
-                else if (static_cast<HTMLOptionElement*>(listItems[i])->selected()) {
-                    static_cast<PopUpButton*>(m_widget)->setCurrentItem(i);
-                    found = true;
-                }
-                firstOption = i;
-            }
-
-        ASSERT(firstOption == listItems.size() || found);
+    // if multi-select, we select only the new selected index
+    ListBox *listBox = static_cast<ListBox*>(m_widget);
+    int j = 0;
+    for (i = 0; i < int(listItems.size()); i++) {
+        listBox->setSelected(j, listItems[i]->hasTagName(optionTag) &&
+                            static_cast<HTMLOptionElement*>(listItems[i])->selected());
+        if (listItems[i]->hasTagName(optionTag) || listItems[i]->hasTagName(optgroupTag))
+            ++j;
+        
     }
 
     m_selectionChanged = false;
index d8744270ac5beee54bb0d35817d72ee4bb5b8dd6..ffc1d6b86ddba8e3aeb8815fd53566e729b9021b 100644 (file)
@@ -56,7 +56,6 @@ namespace WebCore {
         void updateSelection();
 
     private:
-        virtual void valueChanged(Widget*);
         virtual void selectionChanged(Widget*);
 
     protected:
index 10f03823585c29c441caf8da87448e3bbfc7ffa4..94285a94b6618f145728e284da91fc4927571a6a 100644 (file)
@@ -100,12 +100,6 @@ void RenderMenuList::setStyle(RenderStyle* style)
 
 void RenderMenuList::updateFromElement()
 {
-    HTMLSelectElement* select = static_cast<HTMLSelectElement*>(node());
-    if (select->size() > 1 || select->multiple()) {
-        select->detach();
-        select->attach();
-        return;
-    }
     if (m_optionsChanged) {
         HTMLSelectElement* select = static_cast<HTMLSelectElement*>(node());
         if (select->m_recalcListItems)