-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix keyboard selection of RenderListBox in vertical writing mode
https://bugs.webkit.org/show_bug.cgi?id=261804 rdar://115766451 Reviewed by Wenson Hsieh. In horizontal writing mode, the down and up arrow keys can be used to select the next and previous option respectively. Adjust the arrow keys used for vertical writing mode. The added test will pass once <select> is enabled under the vertical form controls feature. * LayoutTests/imported/w3c/web-platform-tests/css/css-writing-modes/forms/select-multiple-keyboard-selection.optional-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/css/css-writing-modes/forms/select-multiple-keyboard-selection.optional.html: Added. * LayoutTests/platform/ios/TestExpectations: `RenderListBox` is not used on iOS. * Source/WebCore/html/HTMLSelectElement.cpp: (WebCore::HTMLSelectElement::listBoxDefaultEventHandler): `vertical-lr`: Right and left arrow keys can be used for next and previous respectively. `vertical-rl`: Left and right arrow keys can be used for next and previous respectively. Canonical link: https://commits.webkit.org/268926@main
- Loading branch information
Showing
4 changed files
with
112 additions
and
7 deletions.
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
...ests/css/css-writing-modes/forms/select-multiple-keyboard-selection.optional-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
|
||
|
||
PASS select[multiple][style="writing-mode: horizontal-tb"] supports keyboard navigation | ||
FAIL select[multiple][style="writing-mode: vertical-lr"] supports keyboard navigation assert_equals: expected "Option 2" but got "Option 1" | ||
FAIL select[multiple][style="writing-mode: vertical-rl"] supports keyboard navigation assert_equals: expected "Option 2" but got "Option 1" | ||
FAIL select[multiple][style="writing-mode: sideways-lr"] supports keyboard navigation assert_equals: expected "Option 2" but got "Option 1" | ||
FAIL select[multiple][style="writing-mode: sideways-rl"] supports keyboard navigation assert_equals: expected "Option 2" but got "Option 1" | ||
|
87 changes: 87 additions & 0 deletions
87
...atform-tests/css/css-writing-modes/forms/select-multiple-keyboard-selection.optional.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
<!doctype html> | ||
<link rel="author" title="Aditya Keerthi" href="https://github.com/pxlcoder"> | ||
<link rel="help" href="https://html.spec.whatwg.org/#the-select-element"> | ||
<link rel="help" href="https://drafts.csswg.org/css-writing-modes-4/#block-flow"> | ||
<title>Test <select> multiple keyboard selection</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="/resources/testdriver.js"></script> | ||
<script src="/resources/testdriver-actions.js"></script> | ||
<script src="/resources/testdriver-vendor.js"></script> | ||
|
||
<select multiple size="4"></select> | ||
<script> | ||
const select = document.querySelector("select"); | ||
for (let i = 0; i < 5; i++) { | ||
const option = document.createElement("option"); | ||
option.textContent = `Option ${i + 1}`; | ||
select.appendChild(option); | ||
} | ||
|
||
const arrow_left = "\uE012"; | ||
const arrow_up = "\uE013"; | ||
const arrow_right = "\uE014"; | ||
const arrow_down = "\uE015"; | ||
|
||
for (const writingMode of ["horizontal-tb", "vertical-lr", "vertical-rl", "sideways-lr", "sideways-rl"]) { | ||
if (!CSS.supports(`writing-mode: ${writingMode}`)) | ||
continue; | ||
|
||
const isHorizontal = writingMode === "horizontal-tb"; | ||
const isReversedBlockFlowDirection = writingMode.endsWith("-rl"); | ||
const scrollBlockAxis = isHorizontal ? "scrollTop" : "scrollLeft"; | ||
|
||
let nextKey = isHorizontal ? arrow_down : arrow_right; | ||
let previousKey = isHorizontal ? arrow_up : arrow_left; | ||
|
||
if (isReversedBlockFlowDirection) { | ||
[nextKey, previousKey] = [previousKey, nextKey]; | ||
} | ||
|
||
promise_test(async function() { | ||
select.selectedIndex = 0; | ||
select.style.writingMode = writingMode; | ||
this.add_cleanup(() => { | ||
select.scrollTop = 0; | ||
select.scrollLeft = 0; | ||
select.removeAttribute("style"); | ||
}); | ||
|
||
assert_equals(select.value, "Option 1"); | ||
assert_equals(select[scrollBlockAxis], 0); | ||
|
||
select.focus(); | ||
|
||
assert_equals(document.activeElement, select); | ||
|
||
await test_driver.send_keys(document.activeElement, previousKey); | ||
assert_equals(select.value, "Option 1"); | ||
assert_equals(select[scrollBlockAxis], 0); | ||
|
||
await test_driver.send_keys(document.activeElement, nextKey); | ||
assert_equals(select.value, "Option 2"); | ||
assert_equals(select[scrollBlockAxis], 0); | ||
|
||
for (let i = 0; i < select.size - 1; i++) { | ||
await test_driver.send_keys(document.activeElement, nextKey); | ||
} | ||
|
||
assert_equals(select.value, "Option 5"); | ||
|
||
if (!isReversedBlockFlowDirection) { | ||
assert_true(select[scrollBlockAxis] > 0); | ||
} else { | ||
assert_true(select[scrollBlockAxis] < 0); | ||
} | ||
|
||
await test_driver.send_keys(document.activeElement, previousKey); | ||
assert_equals(select.value, "Option 4"); | ||
|
||
if (!isReversedBlockFlowDirection) { | ||
assert_true(select[scrollBlockAxis] > 0); | ||
} else { | ||
assert_true(select[scrollBlockAxis] < 0); | ||
} | ||
}, `select[multiple][style="writing-mode: ${writingMode}"] supports keyboard navigation`); | ||
}; | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters