-
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.
[iOS] <option> elements outside of an <optgroup> are added to the pre…
…ceding group https://bugs.webkit.org/show_bug.cgi?id=264192 rdar://117930480 Reviewed by Wenson Hsieh. <option> elements are displayed in the UI process by sending over a vector of options that includes a minimal data representation of <optgroup> and <option> elements. Currently, <options> are associated with an <optgroup> by incrementing a counter whenever an <optgroup> is encountered, and then storing the current counter value on the <option> representation. The current approach is flawed when an <optgroup> terminates, and is followed by <option> elements outside of a group. In this case, the counter is not incremented, and the options are associated with the preceding group. To fix, keep track of the current <optgroup> element, and when an option that no longer belongs to the current <optgroup> is encountered, insert a "fake" group and increment the counter. This approach ensures that trailing <options> do not appear as part of the preceding group. This fix is not applied for the picker wheel UI used in bincompat scenarios, as the UI does not allow for ungrouped options to be distinguished. Additionally, fix the appearance of groups with no items and groups missing a title, to exclude a disclosure button, and remove padding, respectively. * LayoutTests/fast/forms/ios/select-multiple-options-after-optgroup-expected.txt: Added. * LayoutTests/fast/forms/ios/select-multiple-options-after-optgroup.html: Added. * LayoutTests/fast/forms/ios/select-options-after-optgroup-expected.txt: Added. * LayoutTests/fast/forms/ios/select-options-after-optgroup.html: Added. * Source/WebKit/UIProcess/ios/forms/WKFormSelectPicker.mm: (-[WKSelectPicker createMenu]): (-[WKSelectPickerGroupHeaderView initWithGroupName:section:isCollapsible:]): (-[WKSelectPickerGroupHeaderView setCollapsed:animated:]): (-[WKSelectPickerTableViewController tableView:heightForHeaderInSection:]): Groups without a title should appear as a smaller amount of padding, rather than a full size header. (-[WKSelectPickerTableViewController tableView:viewForHeaderInSection:]): Empty groups are not collapsible, and should not show a disclosure button. (-[WKSelectPickerTableViewController didTapSelectPickerGroupHeaderView:]): (-[WKSelectPickerGroupHeaderView initWithGroupName:section:]): Deleted. * Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm: (WebKit::WebPage::focusedElementInformation): Keep track of the current <optgroup> element when one is encountered. If the next <option> does not belong to the same group, make it part of a new group with an empty title. Canonical link: https://commits.webkit.org/270235@main
- Loading branch information
Showing
6 changed files
with
197 additions
and
29 deletions.
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
LayoutTests/fast/forms/ios/select-multiple-options-after-optgroup-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,14 @@ | ||
This test verifies that choosing multiple options which have preceding optgroup siblings works as expected. | ||
|
||
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". | ||
|
||
|
||
PASS selectValues is "" | ||
PASS selectValues is "B" | ||
PASS selectValues is "B,2" | ||
PASS selectValues is "B,2,D" | ||
PASS selectValues is "B,2,D,E" | ||
PASS successfullyParsed is true | ||
|
||
TEST COMPLETE | ||
|
55 changes: 55 additions & 0 deletions
55
LayoutTests/fast/forms/ios/select-multiple-options-after-optgroup.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,55 @@ | ||
<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true ] --> | ||
<html> | ||
<head> | ||
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no"> | ||
<script src="../../../resources/js-test.js"></script> | ||
<script src="../../../resources/ui-helper.js"></script> | ||
</head> | ||
<body> | ||
<select multiple id="select"> | ||
<option>A</option> | ||
<option>B</option> | ||
<option>C</option> | ||
<optgroup label="Numbers"> | ||
<option>1</option> | ||
<option>2</option> | ||
<option>3</option> | ||
</optgroup> | ||
<option>D</option> | ||
<option>E</option> | ||
</select> | ||
</body> | ||
<script> | ||
jsTestIsAsync = true; | ||
|
||
function valuesForSelectElement(element) | ||
{ | ||
return Array.from(element.selectedOptions).map(o => o.value).toString(); | ||
} | ||
|
||
async function selectRowAndAssertValues(row, values) | ||
{ | ||
await UIHelper.ensurePresentationUpdate(); | ||
await UIHelper.selectFormAccessoryPickerRow(row); | ||
await UIHelper.ensurePresentationUpdate(); | ||
|
||
selectValues = valuesForSelectElement(select); | ||
shouldBeEqualToString("selectValues", values); | ||
} | ||
|
||
addEventListener("load", async () => { | ||
description("This test verifies that choosing multiple options which have preceding optgroup siblings works as expected."); | ||
|
||
selectValues = valuesForSelectElement(select); | ||
shouldBeEqualToString("selectValues", ""); | ||
|
||
await UIHelper.activateElement(select); | ||
await selectRowAndAssertValues(1, "B"); | ||
await selectRowAndAssertValues(4, "B,2"); | ||
await selectRowAndAssertValues(6, "B,2,D"); | ||
await selectRowAndAssertValues(7, "B,2,D,E"); | ||
|
||
finishJSTest(); | ||
}); | ||
</script> | ||
</html> |
13 changes: 13 additions & 0 deletions
13
LayoutTests/fast/forms/ios/select-options-after-optgroup-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,13 @@ | ||
This test verifies that choosing options which have preceding optgroup siblings works as expected. | ||
|
||
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". | ||
|
||
|
||
PASS select.value is "A" | ||
PASS select.value is "B" | ||
PASS select.value is "2" | ||
PASS select.value is "D" | ||
PASS successfullyParsed is true | ||
|
||
TEST COMPLETE | ||
|
51 changes: 51 additions & 0 deletions
51
LayoutTests/fast/forms/ios/select-options-after-optgroup.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,51 @@ | ||
<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true ] --> | ||
<html> | ||
<head> | ||
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no"> | ||
<script src="../../../resources/js-test.js"></script> | ||
<script src="../../../resources/ui-helper.js"></script> | ||
</head> | ||
<body> | ||
<select id="select"> | ||
<option>A</option> | ||
<option>B</option> | ||
<option>C</option> | ||
<optgroup label="Numbers"> | ||
<option>1</option> | ||
<option>2</option> | ||
<option>3</option> | ||
</optgroup> | ||
<option>D</option> | ||
<option>E</option> | ||
</select> | ||
</body> | ||
<script> | ||
jsTestIsAsync = true; | ||
|
||
addEventListener("load", async () => { | ||
description("This test verifies that choosing options which have preceding optgroup siblings works as expected."); | ||
|
||
shouldBeEqualToString("select.value", "A"); | ||
|
||
await UIHelper.activateElement(select); | ||
await UIHelper.waitForContextMenuToShow(); | ||
await UIHelper.selectFormAccessoryPickerRow(1); | ||
await UIHelper.waitForContextMenuToHide(); | ||
shouldBeEqualToString("select.value", "B"); | ||
|
||
await UIHelper.activateElement(select); | ||
await UIHelper.waitForContextMenuToShow(); | ||
await UIHelper.selectFormAccessoryPickerRow(4); | ||
await UIHelper.waitForContextMenuToHide(); | ||
shouldBeEqualToString("select.value", "2"); | ||
|
||
await UIHelper.activateElement(select); | ||
await UIHelper.waitForContextMenuToShow(); | ||
await UIHelper.selectFormAccessoryPickerRow(6); | ||
await UIHelper.waitForContextMenuToHide(); | ||
shouldBeEqualToString("select.value", "D"); | ||
|
||
finishJSTest(); | ||
}); | ||
</script> | ||
</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
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