Changeset 152330 in webkit


Ignore:
Timestamp:
Jul 2, 2013 5:20:03 PM (11 years ago)
Author:
commit-queue@webkit.org
Message:

Change event should not be dispatched by clicking a scrollbar of select listbox
https://bugs.webkit.org/show_bug.cgi?id=118019
<rdar://problem/14297760>

Patch by Ruth Fong <ruth_fong@apple.com> on 2013-07-02
Reviewed by Dean Jackson.

Source/WebCore:

Test: fast/forms/select/listbox-click-on-scrollbar.html

Merge the following:
http://src.chromium.org/viewvc/blink?view=revision&revision=151689
https://chromium.googlesource.com/chromium/blink/+/492549b0fcaa58a85aa0797446b62985a263704f

Previously, a select element with the multiple attribute would dispatch
an onChanged event when the scrollbar is clicked. This patch corrects this
issue by only calling listBoxOnChange(), which fires the onChanged event,
when an actual option is clicked.

  • html/HTMLSelectElement.cpp:

(WebCore::HTMLSelectElement::childrenChanged): Updated to clear the list
of selected items when when an <option> element is added to/deleted from its <select> element.
(Without this addition, if a option was selected, and then JavaScript was used to modify
the <select> element, and then the scrollbar was clicked, an onChanged event would fire
because it remembers the previously selected option.)

(WebCore::HTMLSelectElement::listBoxOnChange):

(WebCore::HTMLSelectElement::listBoxDefaultEventHandler): Updated to
only call listBoxOnChange() if at least one option is selected.

LayoutTests:

Merge the following:
http://src.chromium.org/viewvc/blink?view=revision&revision=151689
https://chromium.googlesource.com/chromium/blink/+/492549b0fcaa58a85aa0797446b62985a263704f

  • fast/forms/select/listbox-click-on-scrollbar-expected.txt: Added.
  • fast/forms/select/listbox-click-on-scrollbar.html: Added.

Tests that an onChange() event is not fired when the scrollbar of a
<select multiple> element is clicked.

Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r152322 r152330  
     12013-07-02  Ruth Fong  <ruth_fong@apple.com>
     2
     3        Change event should not be dispatched by clicking a scrollbar of select listbox
     4        https://bugs.webkit.org/show_bug.cgi?id=118019
     5        <rdar://problem/14297760>
     6
     7        Reviewed by Dean Jackson.
     8
     9        Merge the following:
     10        http://src.chromium.org/viewvc/blink?view=revision&revision=151689
     11        https://chromium.googlesource.com/chromium/blink/+/492549b0fcaa58a85aa0797446b62985a263704f
     12
     13        * fast/forms/select/listbox-click-on-scrollbar-expected.txt: Added.
     14        * fast/forms/select/listbox-click-on-scrollbar.html: Added.
     15        Tests that an onChange() event is not fired when the scrollbar of a
     16        <select multiple> element is clicked.
     17
    1182013-07-02  David Farler  <dfarler@apple.com>
    219
  • trunk/Source/WebCore/ChangeLog

    r152329 r152330  
     12013-07-02  Ruth Fong  <ruth_fong@apple.com>
     2
     3        Change event should not be dispatched by clicking a scrollbar of select listbox
     4        https://bugs.webkit.org/show_bug.cgi?id=118019
     5        <rdar://problem/14297760>
     6
     7        Reviewed by Dean Jackson.
     8
     9        Test: fast/forms/select/listbox-click-on-scrollbar.html
     10
     11        Merge the following:
     12        http://src.chromium.org/viewvc/blink?view=revision&revision=151689
     13        https://chromium.googlesource.com/chromium/blink/+/492549b0fcaa58a85aa0797446b62985a263704f
     14
     15        Previously, a select element with the multiple attribute would dispatch
     16        an onChanged event when the scrollbar is clicked. This patch corrects this
     17        issue by only calling listBoxOnChange(), which fires the onChanged event,
     18        when an actual option is clicked.
     19
     20        * html/HTMLSelectElement.cpp:
     21        (WebCore::HTMLSelectElement::childrenChanged): Updated to clear the list
     22        of selected items when when an <option> element is added to/deleted from its <select> element.
     23        (Without this addition, if a option was selected, and then JavaScript was used to modify
     24        the <select> element, and then the scrollbar was clicked, an onChanged event would fire
     25        because it remembers the previously selected option.)
     26
     27        (WebCore::HTMLSelectElement::listBoxOnChange):
     28
     29        (WebCore::HTMLSelectElement::listBoxDefaultEventHandler): Updated to
     30        only call listBoxOnChange() if at least one option is selected.
     31
    1322013-07-02  Alex Christensen  <achristensen@apple.com>
    233
  • trunk/Source/WebCore/html/HTMLSelectElement.cpp

    r152211 r152330  
    375375    setRecalcListItems();
    376376    setNeedsValidityCheck();
     377    m_lastOnChangeSelection.clear();
    377378
    378379    HTMLFormControlElementWithState::childrenChanged(changedByParser, beforeChange, afterChange, childCountDelta);
     
    13481349        }
    13491350    } else if (event->type() == eventNames().mouseupEvent && event->isMouseEvent() && static_cast<MouseEvent*>(event)->button() == LeftButton && document()->frame()->eventHandler()->autoscrollRenderer() != renderer()) {
     1351        // This click or drag event was not over any of the options.
     1352        if (m_lastOnChangeSelection.isEmpty())
     1353            return;
    13501354        // This makes sure we fire dispatchFormControlChangeEvent for a single
    13511355        // click. For drag selection, onChange will fire when the autoscroll
Note: See TracChangeset for help on using the changeset viewer.