Title: [152330] trunk
- Revision
- 152330
- Author
- [email protected]
- Date
- 2013-07-02 17:20:03 -0700 (Tue, 02 Jul 2013)
Log 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 <[email protected]> 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.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (152329 => 152330)
--- trunk/LayoutTests/ChangeLog 2013-07-03 00:18:39 UTC (rev 152329)
+++ trunk/LayoutTests/ChangeLog 2013-07-03 00:20:03 UTC (rev 152330)
@@ -1,3 +1,20 @@
+2013-07-02 Ruth Fong <[email protected]>
+
+ 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>
+
+ Reviewed by Dean Jackson.
+
+ 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.
+
2013-07-02 David Farler <[email protected]>
Unreviewed rebaseline of media/video-controls-captions-trackmenu-localized after r151697.
Added: trunk/LayoutTests/fast/forms/select/listbox-click-on-scrollbar-expected.txt (0 => 152330)
--- trunk/LayoutTests/fast/forms/select/listbox-click-on-scrollbar-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/forms/select/listbox-click-on-scrollbar-expected.txt 2013-07-03 00:20:03 UTC (rev 152330)
@@ -0,0 +1,22 @@
+Click on a listbox scrollbar should not dispatch change evnet.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Click on the scrollbar. No change event should be fired.
+PASS selectElement.selectedIndex is -1
+PASS changeEventCounter is 0
+
+Click on the first option. A change event should be fired.
+A change event was dispatched.
+PASS selectElement.selectedIndex is 0
+PASS changeEventCounter is 1
+
+Add an option item and then click on the scrollbar again. No change event should be fired.
+PASS selectElement.selectedIndex is 0
+PASS changeEventCounter is 1
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/forms/select/listbox-click-on-scrollbar.html (0 => 152330)
--- trunk/LayoutTests/fast/forms/select/listbox-click-on-scrollbar.html (rev 0)
+++ trunk/LayoutTests/fast/forms/select/listbox-click-on-scrollbar.html 2013-07-03 00:20:03 UTC (rev 152330)
@@ -0,0 +1,61 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src=""
+<select id="selectElement" multiple size="4">
+<option>1</option>
+<option>2</option>
+<option>3</option>
+<option>4</option>
+<option>5</option>
+<option>6</option>
+<option>7</option>
+<option>8</option>
+</select>
+
+<script>
+description('Click on a listbox scrollbar should not dispatch change evnet.');
+jsTestIsAsync = true;
+var selectElement = document.getElementById('selectElement');
+var changeEventCounter = 0;
+selectElement._onchange_ = function() {
+ debug('A change event was dispatched.');
+ ++changeEventCounter;
+}
+
+window._onload_ = function() {
+ if (!window.eventSender)
+ debug('Click on the scrollbar. The test passes if nothing is printed.');
+ else {
+ debug('Click on the scrollbar. No change event should be fired.')
+ eventSender.mouseMoveTo(selectElement.offsetLeft + selectElement.offsetWidth - 2, selectElement.offsetTop + selectElement.offsetHeight - 2);
+ eventSender.mouseDown();
+ eventSender.mouseUp();
+ shouldBe('selectElement.selectedIndex', '-1');
+ shouldBe('changeEventCounter', '0');
+
+ debug('');
+ debug('Click on the first option. A change event should be fired.');
+ eventSender.mouseMoveTo(selectElement.offsetLeft + 4, selectElement.offsetTop + 4);
+ eventSender.mouseDown();
+ eventSender.mouseUp();
+ shouldBe('selectElement.selectedIndex', '0');
+ shouldBe('changeEventCounter', '1');
+
+ debug('');
+ debug('Add an option item and then click on the scrollbar again. No change event should be fired.');
+ selectElement.appendChild(new Option('9'));
+ eventSender.mouseMoveTo(selectElement.offsetLeft + selectElement.offsetWidth - 2, selectElement.offsetTop + selectElement.offsetHeight - 2);
+ eventSender.mouseDown();
+ eventSender.mouseUp();
+ shouldBe('selectElement.selectedIndex', '0');
+ shouldBe('changeEventCounter', '1');
+
+ debug('');
+ finishJSTest();
+ }
+};
+</script>
+
+<script src=""
+</html>
\ No newline at end of file
Modified: trunk/Source/WebCore/ChangeLog (152329 => 152330)
--- trunk/Source/WebCore/ChangeLog 2013-07-03 00:18:39 UTC (rev 152329)
+++ trunk/Source/WebCore/ChangeLog 2013-07-03 00:20:03 UTC (rev 152330)
@@ -1,3 +1,34 @@
+2013-07-02 Ruth Fong <[email protected]>
+
+ 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>
+
+ Reviewed by Dean Jackson.
+
+ 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.
+
2013-07-02 Alex Christensen <[email protected]>
Preparing Windows WebGL build system.
Modified: trunk/Source/WebCore/html/HTMLSelectElement.cpp (152329 => 152330)
--- trunk/Source/WebCore/html/HTMLSelectElement.cpp 2013-07-03 00:18:39 UTC (rev 152329)
+++ trunk/Source/WebCore/html/HTMLSelectElement.cpp 2013-07-03 00:20:03 UTC (rev 152330)
@@ -374,6 +374,7 @@
{
setRecalcListItems();
setNeedsValidityCheck();
+ m_lastOnChangeSelection.clear();
HTMLFormControlElementWithState::childrenChanged(changedByParser, beforeChange, afterChange, childCountDelta);
}
@@ -1347,6 +1348,9 @@
event->setDefaultHandled();
}
} else if (event->type() == eventNames().mouseupEvent && event->isMouseEvent() && static_cast<MouseEvent*>(event)->button() == LeftButton && document()->frame()->eventHandler()->autoscrollRenderer() != renderer()) {
+ // This click or drag event was not over any of the options.
+ if (m_lastOnChangeSelection.isEmpty())
+ return;
// This makes sure we fire dispatchFormControlChangeEvent for a single
// click. For drag selection, onChange will fire when the autoscroll
// timer stops.
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes