Diff
Modified: branches/safari-537-branch/LayoutTests/ChangeLog (152659 => 152660)
--- branches/safari-537-branch/LayoutTests/ChangeLog 2013-07-15 22:42:26 UTC (rev 152659)
+++ branches/safari-537-branch/LayoutTests/ChangeLog 2013-07-15 22:50:55 UTC (rev 152660)
@@ -1,5 +1,26 @@
2013-07-15 Lucas Forschler <[email protected]>
+ Merge r152330
+
+ 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-15 Lucas Forschler <[email protected]>
+
Merge r152320
2013-07-02 Radu Stavila <[email protected]>
Copied: branches/safari-537-branch/LayoutTests/fast/forms/select/listbox-click-on-scrollbar-expected.txt (from rev 152330, trunk/LayoutTests/fast/forms/select/listbox-click-on-scrollbar-expected.txt) (0 => 152660)
--- branches/safari-537-branch/LayoutTests/fast/forms/select/listbox-click-on-scrollbar-expected.txt (rev 0)
+++ branches/safari-537-branch/LayoutTests/fast/forms/select/listbox-click-on-scrollbar-expected.txt 2013-07-15 22:50:55 UTC (rev 152660)
@@ -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
+
Copied: branches/safari-537-branch/LayoutTests/fast/forms/select/listbox-click-on-scrollbar.html (from rev 152330, trunk/LayoutTests/fast/forms/select/listbox-click-on-scrollbar.html) (0 => 152660)
--- branches/safari-537-branch/LayoutTests/fast/forms/select/listbox-click-on-scrollbar.html (rev 0)
+++ branches/safari-537-branch/LayoutTests/fast/forms/select/listbox-click-on-scrollbar.html 2013-07-15 22:50:55 UTC (rev 152660)
@@ -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: branches/safari-537-branch/Source/WebCore/ChangeLog (152659 => 152660)
--- branches/safari-537-branch/Source/WebCore/ChangeLog 2013-07-15 22:42:26 UTC (rev 152659)
+++ branches/safari-537-branch/Source/WebCore/ChangeLog 2013-07-15 22:50:55 UTC (rev 152660)
@@ -1,5 +1,40 @@
2013-07-15 Lucas Forschler <[email protected]>
+ Merge r152330
+
+ 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-15 Lucas Forschler <[email protected]>
+
Merge r152320
2013-07-02 Radu Stavila <[email protected]>
Modified: branches/safari-537-branch/Source/WebCore/html/HTMLSelectElement.cpp (152659 => 152660)
--- branches/safari-537-branch/Source/WebCore/html/HTMLSelectElement.cpp 2013-07-15 22:42:26 UTC (rev 152659)
+++ branches/safari-537-branch/Source/WebCore/html/HTMLSelectElement.cpp 2013-07-15 22:50:55 UTC (rev 152660)
@@ -373,6 +373,7 @@
{
setRecalcListItems();
setNeedsValidityCheck();
+ m_lastOnChangeSelection.clear();
HTMLFormControlElementWithState::childrenChanged(changedByParser, beforeChange, afterChange, childCountDelta);
}
@@ -1346,6 +1347,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.