Support single-value <select> elements (#35684)

https://github.com/user-attachments/assets/9aba75ff-4190-4a85-89ed-d3f3aa53d3b0



Among other things this adds a new `EmbedderMsg::ShowSelectElementMenu`
to tell the embedder to display a select popup at the given location.

This is a draft because some small style adjustments need to be made:
* the select element should always have the width of the largest option
* the border should be part of the shadow tree

Apart from that, it's mostly ready for review.

<details><summary>HTML for demo video</summary>

```html
<html>

<body>
<select id="c" name="choice">
  <option value="first">First Value</option>
  <option value="second">Second Value</option>
  <option value="third">Third Value</option>
</select>
</body>
</html>
```
</details>

---

<!-- Thank you for contributing to Servo! Please replace each `[ ]` by
`[X]` when the step is complete, and replace `___` with appropriate
data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] Part of https://github.com/servo/servo/issues/3551
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because ___

<!-- Also, please make sure that "Allow edits from maintainers" checkbox
is checked, so that we can help you if you get stuck somewhere along the
way.-->

<!-- Pull requests that do not address these steps are welcome, but they
will require additional verification as part of the review process. -->

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
This commit is contained in:
Simon Wülker 2025-04-03 14:11:55 +02:00 committed by GitHub
parent 6e9d01b908
commit 0e99539dab
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
32 changed files with 633 additions and 151 deletions

View file

@ -349238,7 +349238,7 @@
],
"the-select-element": {
"option-add-label-quirks.html": [
"2c3c8093e253250f11a7e84a7ba89f3535d2eb20",
"f91609afc506b7530c6106bd047eab93b8645aa7",
[
null,
[

View file

@ -0,0 +1,2 @@
[content-none-option.html]
expected: FAIL

View file

@ -0,0 +1,2 @@
[content-none-select-1.html]
expected: FAIL

View file

@ -0,0 +1,2 @@
[content-none-select-2.html]
expected: FAIL

View file

@ -28,3 +28,24 @@
[opened <details> content shown ("<div><details open><summary>abc</summary>123")]
expected: FAIL
[<select size='1'> contents of options preserved ("<select size='1'><option>abc</option><option>def")]
expected: FAIL
[<select size='2'> contents of options preserved ("<select size='2'><option>abc</option><option>def")]
expected: FAIL
[empty <optgroup> in <select> ("<div>a<select><optgroup></select>bc")]
expected: FAIL
[empty <option> in <select> ("<div>a<select><option></select>bc")]
expected: FAIL
[<optgroup> containing <option> ("<select><optgroup><option>abc</select>")]
expected: FAIL
[<select size='1'> contents of options preserved ("<div><select size='1'><option>abc</option><option>def")]
expected: FAIL
[<select size='2'> contents of options preserved ("<div><select size='2'><option>abc</option><option>def")]
expected: FAIL

View file

@ -1,2 +0,0 @@
[option-label-whitespace.html]
expected: FAIL

View file

@ -1,2 +0,0 @@
[option-with-br.html]
expected: FAIL

View file

@ -0,0 +1,2 @@
[select-1-block-size-001.html]
expected: FAIL

View file

@ -0,0 +1,2 @@
[select-button-min-height-001.html]
expected: FAIL

View file

@ -0,0 +1,2 @@
[select-empty.html]
expected: FAIL

View file

@ -0,0 +1,2 @@
[select-multiple-re-add-option-via-document-fragment.html]
expected: FAIL

View file

@ -1,4 +0,0 @@
[select-wrap-no-spill.optional.html]
[Selected OPTION label with white-space:pre-wrap should not spill out.]
expected: FAIL

View file

@ -1,2 +0,0 @@
[option-add-label-quirks.html]
expected: FAIL

View file

@ -1,2 +0,0 @@
[option-checked-styling.html]
expected: FAIL

View file

@ -5,15 +5,9 @@
[interactive content <input> as first child of <label>]
expected: FAIL
[interactive content <select></select> as second child under <label>]
expected: FAIL
[interactive content <iframe></iframe> as second child under <label>]
expected: FAIL
[interactive content <select></select> as first child of <label>]
expected: FAIL
[interactive content <video tabindex=""></video> as second child under <label>]
expected: FAIL
@ -32,9 +26,6 @@
[interactive content <object usemap=""></object> as second child under <label>]
expected: FAIL
[interactive content <select></select> deeply nested under <label>]
expected: FAIL
[interactive content <textarea></textarea> as first child of <label>]
expected: FAIL
@ -67,4 +58,3 @@
[interactive content <textarea></textarea> as second child under <label>]
expected: FAIL

View file

@ -1,2 +0,0 @@
[closed-listbox-rendering.tentative.html]
expected: FAIL

View file

@ -1,2 +0,0 @@
[select-marker-end-aligned.tentative.html]
expected: FAIL

View file

@ -2,7 +2,7 @@
<title>OPTION's label attribute in SELECT -- Adding a label (quirks)</title>
<link rel="help" href="https://html.spec.whatwg.org/multipage/rendering.html#the-select-element-2">
<link rel="match" href="option-label-ref.html">
<meta name="assert" content="An option element is expected to be rendered by displaying the element's label.">
<meta name="assert" content="An option element is expected to be rendered by displaying the element's label when the document is in quirks mode">
<select>
<option>Element Text</option>