LayoutTests:
authoradele <adele@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 31 Oct 2006 22:10:51 +0000 (22:10 +0000)
committeradele <adele@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 31 Oct 2006 22:10:51 +0000 (22:10 +0000)
commite8a648ea63d6d1e7f4478ea626b62b80d6484fa6
tree82980c634f82b901b2f7700ee4e7d00db1993888
parentcfcc4eb9a328e747a258fef8685bc10fd1d48bb0
LayoutTests:

        Reviewed by Adam.

        Tests for http://bugs.webkit.org/show_bug.cgi?id=11127 NativeListBox: arrow and drag selection should pivot around one list item
        and http://bugs.webkit.org/show_bug.cgi?id=11173 REGRESSION (NativeListBox): Shift-clicking items in list box doesn't expand the current selection
        and http://bugs.webkit.org/show_bug.cgi?id=11417 REGRESSION: onchange does not fire for list-style select elements

        * fast/forms/listbox-onchange-expected.txt: Added.
        * fast/forms/listbox-onchange.html: Added.
        * fast/forms/listbox-selection-expected.txt: Added.
        * fast/forms/listbox-selection.html: Added.

WebCore:

        Reviewed by Adam.

        - Fix for http://bugs.webkit.org/show_bug.cgi?id=11127 NativeListBox: arrow and drag selection should pivot around one list item
        and http://bugs.webkit.org/show_bug.cgi?id=11173 REGRESSION (NativeListBox): Shift-clicking items in list box doesn't expand the current selection
        and http://bugs.webkit.org/show_bug.cgi?id=11417 REGRESSION: onchange does not fire for list-style select elements

        Tests:
        * LayoutTests/fast/forms/listbox-selection.html
        * LayoutTests/fast/forms/listbox-onchange.html

        * html/HTMLSelectElement.h: Added m_selectedListIndexBase and m_selectedListIndexExtent to track indices for the active selection in progress.
          Added 2 vectors to cache selection state.  One is kept so that the previous selection state can be restored as the active selection grows and shrinks.
          And one for onChange, that is updated after onChange is fired.
          Added m_activeSelectionState to keep track of whether the current drag selection is selecting or deselecting.

        * html/HTMLSelectElement.cpp:
        (WebCore::HTMLSelectElement::HTMLSelectElement): Initialized new variables.
        (WebCore::HTMLSelectElement::setSelectedIndex): If needed, initialize m_selectedListIndexBase and m_selectedListIndexExtent.
        (WebCore::HTMLSelectElement::dispatchBlurEvent): Only fire the onChange event here for menu lists.
        (WebCore::HTMLSelectElement::listBoxDefaultEventHandler): Updates base and extent variables for mouse and key events.
        (WebCore::HTMLSelectElement::setBase): Added. Also caches the selection state.
        (WebCore::HTMLSelectElement::setExtent): Added.
        (WebCore::HTMLSelectElement::updateListBoxSelection): Added.
        (WebCore::HTMLSelectElement::listBoxOnChange): Added.

        * rendering/RenderListBox.cpp:
        (WebCore::RenderListBox::updateFromElement): Only scroll to reveal the first index if both the first and last indices aren't visible.
        (WebCore::RenderListBox::listIndexAtOffset): Added.  Replaces optionAtPoint, which is no longer used.
        (WebCore::RenderListBox::autoscroll): Now sets the selection using the select's base and extent.
        (WebCore::RenderListBox::stopAutoscroll): Added.  Tells the select element to fire onChange.  This is needed because the autoscroll can end from a mouseUp
         outside of the list box, and the select element won't get a mouseUp event directly.  But the frame will stop the autoscroll at that point, and now we can
         notify the select element from here.
        (WebCore::RenderListBox::scrollToRevealElementAtListIndex): Checks new listIndexIsVisible method.
        (WebCore::RenderListBox::listIndexIsVisible): Added.
        (WebCore::RenderListBox::valueChanged): Removed unnecessary printf.

        * page/Frame.cpp: (WebCore::Frame::stopAutoscrollTimer): Added rendererIsBeingDestroyed argument, so when the renderer calls this during destruction,
        we don't try to use the pointer to that renderer to call stopAutoscroll.  This is done so a renderer that's still alive has a chance to do some cleanup after autoscroll.
        * rendering/RenderListBox.h: (WebCore::RenderListBox::shouldAutoscroll): Always returns true now, since we're also updating selection from the autoscroll timer.
        * rendering/RenderObject.h: (WebCore::RenderObject::stopAutoscroll): Added.
        * rendering/RenderObject.cpp: (WebCore::RenderObject::destroy): Calls stopAutoscrollTimer with rendererIsBeingDestroyed argument.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@17498 268f45cc-cd09-0410-ab3c-d52691b4dbfc
14 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/forms/listbox-onchange-expected.txt [new file with mode: 0644]
LayoutTests/fast/forms/listbox-onchange.html [new file with mode: 0644]
LayoutTests/fast/forms/listbox-selection-expected.txt [new file with mode: 0644]
LayoutTests/fast/forms/listbox-selection.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/html/HTMLSelectElement.cpp
WebCore/html/HTMLSelectElement.h
WebCore/page/Frame.cpp
WebCore/page/Frame.h
WebCore/rendering/RenderListBox.cpp
WebCore/rendering/RenderListBox.h
WebCore/rendering/RenderObject.cpp
WebCore/rendering/RenderObject.h