Title: [105692] branches/chromium/963
- Revision
- 105692
- Author
- [email protected]
- Date
- 2012-01-23 21:19:25 -0800 (Mon, 23 Jan 2012)
Log Message
Merge 105386 - REGRESSION(r100111): A 'change' event does not fire when a mouse drag
occurs to switch elements in a listbox <select>
https://bugs.webkit.org/show_bug.cgi?id=76244
Reviewed by Hajime Morita.
Source/WebCore:
Test: fast/forms/select/listbox-drag-in-non-multiple.html
* html/HTMLSelectElement.cpp:
(WebCore::HTMLSelectElement::updateSelectedState):
Do not update m_activeSelectionState for non-multiple <select>.
(WebCore::HTMLSelectElement::listBoxDefaultEventHandler):
Use setActiveSelection*Index() and updateListBoxSelection(true) instead
of updateSelectedState() because updateSelectedState() updates
m_lastOnChangeSelection and will prevent the mouseup handler from
dispatching 'change' event.
We should not call listBoxOnChange() in the mousemove handler in order
to align the behavior of IE and Firefox.
LayoutTests:
* fast/forms/resources/common.js:
(mouseMoveToIndexInListbox): Added.
* fast/forms/select/listbox-drag-in-non-multiple-expected.txt: Added.
* fast/forms/select/listbox-drag-in-non-multiple.html: Added.
[email protected]
BUG=crbug.com/110068
Review URL: https://chromiumcodereview.appspot.com/9285007
Modified Paths
Added Paths
Diff
Modified: branches/chromium/963/LayoutTests/fast/forms/resources/common.js (105691 => 105692)
--- branches/chromium/963/LayoutTests/fast/forms/resources/common.js 2012-01-24 05:08:14 UTC (rev 105691)
+++ branches/chromium/963/LayoutTests/fast/forms/resources/common.js 2012-01-24 05:19:25 UTC (rev 105692)
@@ -22,3 +22,12 @@
pos.y = element.offsetTop + element.offsetHeight / 2;
return pos;
}
+
+function mouseMoveToIndexInListbox(index, listboxId) {
+ var listbox = document.getElementById(listboxId);
+ var itemHeight = Math.floor(listbox.offsetHeight / listbox.size);
+ var border = 1;
+ var y = border + index * itemHeight;
+ if (window.eventSender)
+ eventSender.mouseMoveTo(listbox.offsetLeft + border, listbox.offsetTop + y - window.pageYOffset);
+}
Copied: branches/chromium/963/LayoutTests/fast/forms/select/listbox-drag-in-non-multiple-expected.txt (from rev 105386, trunk/LayoutTests/fast/forms/select/listbox-drag-in-non-multiple-expected.txt) (0 => 105692)
--- branches/chromium/963/LayoutTests/fast/forms/select/listbox-drag-in-non-multiple-expected.txt (rev 0)
+++ branches/chromium/963/LayoutTests/fast/forms/select/listbox-drag-in-non-multiple-expected.txt 2012-01-24 05:19:25 UTC (rev 105692)
@@ -0,0 +1,11 @@
+Test if 'change' event is dispatched when selecting an item by mouse dragging in a non-multiple listbox.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+
+PASS: A click event was dispatched.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Copied: branches/chromium/963/LayoutTests/fast/forms/select/listbox-drag-in-non-multiple.html (from rev 105386, trunk/LayoutTests/fast/forms/select/listbox-drag-in-non-multiple.html) (0 => 105692)
--- branches/chromium/963/LayoutTests/fast/forms/select/listbox-drag-in-non-multiple.html (rev 0)
+++ branches/chromium/963/LayoutTests/fast/forms/select/listbox-drag-in-non-multiple.html 2012-01-24 05:19:25 UTC (rev 105692)
@@ -0,0 +1,36 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src=""
+<script src=""
+
+<p id="description"></p>
+<select id="select1" size="4">
+<option>Option1</option>
+<option>Option2</option>
+<option>Option3</option>
+<option>Option4</option>
+</select>
+<div id="result">FAIL</div>
+<div id="console"></div>
+
+<script>
+description('Test if \'change\' event is dispatched when selecting an item by mouse dragging in a non-multiple listbox.');
+
+function handleChange() {
+ $('result').textContent = 'PASS: A click event was dispatched.';
+}
+$('select1').addEventListener('change', handleChange);
+
+if (!window.eventSender) {
+ debug('Press the left button on an item in the listbox, move the pointer to another item, and release the button. You\'ll see a "PASS" message.');
+} else {
+ mouseMoveToIndexInListbox(1, 'select1');
+ eventSender.mouseDown(0);
+ mouseMoveToIndexInListbox(2, 'select1');
+ eventSender.mouseUp(0);
+}
+</script>
+<script src=""
+</body>
+</html>
Modified: branches/chromium/963/Source/WebCore/html/HTMLSelectElement.cpp (105691 => 105692)
--- branches/chromium/963/Source/WebCore/html/HTMLSelectElement.cpp 2012-01-24 05:08:14 UTC (rev 105691)
+++ branches/chromium/963/Source/WebCore/html/HTMLSelectElement.cpp 2012-01-24 05:19:25 UTC (rev 105692)
@@ -1146,7 +1146,7 @@
if (clickedElement->hasTagName(optionTag)) {
// Keep track of whether an active selection (like during drag
// selection), should select or deselect.
- if (toHTMLOptionElement(clickedElement)->selected() && multi)
+ if (toHTMLOptionElement(clickedElement)->selected() && multiSelect)
m_activeSelectionState = false;
if (!m_activeSelectionState)
toHTMLOptionElement(clickedElement)->setSelectedState(false);
@@ -1214,8 +1214,11 @@
if (m_multiple) {
setActiveSelectionEndIndex(listIndex);
updateListBoxSelection(false);
- } else
- updateSelectedState(listIndex, false, false);
+ } else {
+ setActiveSelectionAnchorIndex(listIndex);
+ setActiveSelectionEndIndex(listIndex);
+ updateListBoxSelection(true);
+ }
event->setDefaultHandled();
}
} else if (event->type() == eventNames().mouseupEvent && event->isMouseEvent() && static_cast<MouseEvent*>(event)->button() == LeftButton && document()->frame()->eventHandler()->autoscrollRenderer() != renderer()) {
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes