Skip to content
Permalink
Browse files
Cannot select multiple non-adjacent items in a multiple select contro…
…l with the keyboard only

https://bugs.webkit.org/show_bug.cgi?id=15816

Patch by Pascal Jacquemart <p.jacquemart@samsung.com> on 2014-01-09
Reviewed by Chris Fleizach.

Source/WebCore:

Test: fast/forms/listbox-non-contiguous-keyboard-selection.html

* html/HTMLSelectElement.cpp:
(WebCore::HTMLSelectElement::HTMLSelectElement):
New member m_allowsNonContiguousSelection defaults to false
(WebCore::HTMLSelectElement::listBoxDefaultEventHandler):
Tracking CTRL modifier to start multiple non contiguous selection
* html/HTMLSelectElement.h: New member m_allowsNonContiguousSelection
(WebCore::HTMLSelectElement::allowsNonContiguousSelection): New getter
* rendering/RenderListBox.cpp:
(WebCore::RenderListBox::addFocusRingRects):
Following implementation made for spatial navigation

LayoutTests:

* fast/forms/listbox-non-contiguous-keyboard-selection-expected.txt: Added.
* fast/forms/listbox-non-contiguous-keyboard-selection.html: Added.
* platform/mac/TestExpectations:
Multiple non contiguous selection with keyboard not enabled on Mac

Canonical link: https://commits.webkit.org/144580@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@161558 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Pascal Jacquemart authored and webkit-commit-queue committed Jan 9, 2014
1 parent 3c54d38 commit a7231d79b025807f673868003da931d13b349309
Showing 8 changed files with 123 additions and 3 deletions.
@@ -1,3 +1,15 @@
2014-01-09 Pascal Jacquemart <p.jacquemart@samsung.com>

Cannot select multiple non-adjacent items in a multiple select control with the keyboard only
https://bugs.webkit.org/show_bug.cgi?id=15816

Reviewed by Chris Fleizach.

* fast/forms/listbox-non-contiguous-keyboard-selection-expected.txt: Added.
* fast/forms/listbox-non-contiguous-keyboard-selection.html: Added.
* platform/mac/TestExpectations:
Multiple non contiguous selection with keyboard not enabled on Mac

2014-01-09 Seokju Kwon <seokju@webkit.org>

Web Inspector: Remove unused overriding protocols.
@@ -0,0 +1,11 @@
<select> selection test for multiple but non contiguous selection with keyboard.

On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".


1) Select multiple non-adjacent items with the keyboard
PASS selectionPattern("sl1") is "01010"
PASS successfullyParsed is true

TEST COMPLETE

@@ -0,0 +1,65 @@
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../../resources/js-test-pre.js"></script>
</head>
<body>
<p id="description"></p>
<div id="console"></div>
<script>
description('&lt;select&gt; selection test for multiple but non contiguous selection with keyboard.');

function keyDownOnSelect(selId, identifier, modifier) {
document.getElementById(selId).focus();
if (window.eventSender)
eventSender.keyDown(identifier, [modifier]);
}

function createSelect(idName, sz, mlt, selIndex) {
var sl = document.createElement("select");
var i = 0;
sl.size = sz;
while (i < sz) {
var opt = document.createElement("option");
if (i == selIndex)
opt.selected = true;
opt.textContent = "item " + i;
sl.appendChild(opt);
i++;
}
sl.multiple = mlt;
sl.id = idName;
var parent = document.getElementById("parent");
parent.appendChild(sl);
}

function selectionPattern(selId) {
var sl = document.getElementById(selId);
var result = '';
for (var i = 0; i < sl.options.length; i++)
result += sl.options[i].selected ? '1' : '0';
return result;
}

var parent = document.createElement('div');
parent.id = "parent";
document.body.appendChild(parent);

createSelect("sl1", 5, true, -1);

debug("1) Select multiple non-adjacent items with the keyboard");
// Move to second item.
keyDownOnSelect("sl1", "downArrow", "addSelectionKey");
keyDownOnSelect("sl1", "downArrow", "addSelectionKey");
// Select it.
keyDownOnSelect("sl1", " ");
// Move to fourth item.
keyDownOnSelect("sl1", "downArrow", "addSelectionKey");
keyDownOnSelect("sl1", "downArrow", "addSelectionKey");
// Select it.
keyDownOnSelect("sl1", " ");
shouldBe('selectionPattern("sl1")', '"01010"');
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>
@@ -565,6 +565,9 @@ webkit.org/b/92352 css3/flexbox/flex-rounding.html
fast/events/show-modal-dialog-onblur-onfocus.html
platform/mac/fast/forms/listbox-scrollbar-hit-test.html

# Multiple non contiguous selection with keyboard not enabled on mac
webkit.org/b/15816 fast/forms/listbox-non-contiguous-keyboard-selection.html [ Skip ]

# <rdar://problem/11224894> Several Japanese vertical text tests failing on Mountain Lion
fast/dynamic/text-combine.html
fast/repaint/japanese-rl-selection-clear.html
@@ -1,3 +1,23 @@
2014-01-09 Pascal Jacquemart <p.jacquemart@samsung.com>

Cannot select multiple non-adjacent items in a multiple select control with the keyboard only
https://bugs.webkit.org/show_bug.cgi?id=15816

Reviewed by Chris Fleizach.

Test: fast/forms/listbox-non-contiguous-keyboard-selection.html

* html/HTMLSelectElement.cpp:
(WebCore::HTMLSelectElement::HTMLSelectElement):
New member m_allowsNonContiguousSelection defaults to false
(WebCore::HTMLSelectElement::listBoxDefaultEventHandler):
Tracking CTRL modifier to start multiple non contiguous selection
* html/HTMLSelectElement.h: New member m_allowsNonContiguousSelection
(WebCore::HTMLSelectElement::allowsNonContiguousSelection): New getter
* rendering/RenderListBox.cpp:
(WebCore::RenderListBox::addFocusRingRects):
Following implementation made for spatial navigation

2014-01-09 Seokju Kwon <seokju@webkit.org>

Web Inspector: Remove unused overriding protocols.
@@ -74,6 +74,7 @@ HTMLSelectElement::HTMLSelectElement(const QualifiedName& tagName, Document& doc
, m_isProcessingUserDrivenChange(false)
, m_multiple(false)
, m_activeSelectionState(false)
, m_allowsNonContiguousSelection(false)
, m_shouldRecalcListItems(false)
{
ASSERT(hasTagName(selectTag));
@@ -1457,7 +1458,13 @@ void HTMLSelectElement::listBoxDefaultEventHandler(Event* event)
ASSERT_UNUSED(listItems, !listItems.size() || static_cast<size_t>(endIndex) < listItems.size());
setActiveSelectionEndIndex(endIndex);

bool selectNewItem = !m_multiple || static_cast<KeyboardEvent*>(event)->shiftKey() || !isSpatialNavigationEnabled(document().frame());
#if PLATFORM(MAC)
m_allowsNonContiguousSelection = m_multiple && isSpatialNavigationEnabled(document().frame());
#else
m_allowsNonContiguousSelection = m_multiple && (isSpatialNavigationEnabled(document().frame()) || static_cast<KeyboardEvent*>(event)->ctrlKey());
#endif
bool selectNewItem = static_cast<KeyboardEvent*>(event)->shiftKey() || !m_allowsNonContiguousSelection;

if (selectNewItem)
m_activeSelectionState = true;
// If the anchor is unitialized, or if we're going to deselect all
@@ -1487,7 +1494,7 @@ void HTMLSelectElement::listBoxDefaultEventHandler(Event* event)
if (form())
form()->submitImplicitly(event, false);
event->setDefaultHandled();
} else if (m_multiple && keyCode == ' ' && isSpatialNavigationEnabled(document().frame())) {
} else if (m_multiple && keyCode == ' ' && m_allowsNonContiguousSelection) {
// Use space to toggle selection change.
m_activeSelectionState = !m_activeSelectionState;
ASSERT(m_activeSelectionEndIndex >= 0
@@ -111,6 +111,7 @@ class HTMLSelectElement : public HTMLFormControlElementWithState, public TypeAhe

// For use in the implementation of HTMLOptionElement.
void optionSelectionStateChanged(HTMLOptionElement*, bool optionIsSelected);
bool allowsNonContiguousSelection() const { return m_allowsNonContiguousSelection; };

protected:
HTMLSelectElement(const QualifiedName&, Document&, HTMLFormElement*);
@@ -208,6 +209,7 @@ class HTMLSelectElement : public HTMLFormControlElementWithState, public TypeAhe
bool m_isProcessingUserDrivenChange;
bool m_multiple;
bool m_activeSelectionState;
bool m_allowsNonContiguousSelection;
mutable bool m_shouldRecalcListItems;
};

@@ -319,7 +319,7 @@ void RenderListBox::paintObject(PaintInfo& paintInfo, const LayoutPoint& paintOf

void RenderListBox::addFocusRingRects(Vector<IntRect>& rects, const LayoutPoint& additionalOffset, const RenderLayerModelObject* paintContainer)
{
if (!isSpatialNavigationEnabled(&frame()))
if (!selectElement().allowsNonContiguousSelection())
return RenderBlockFlow::addFocusRingRects(rects, additionalOffset, paintContainer);

// Focus the last selected item.

0 comments on commit a7231d7

Please sign in to comment.