Make <option> and <optgroup> share a text content algorithm - #12232
Conversation
The content model of the optgroup element only allows a legend if it is the first child though, right? Otherwise this change looks ok to me |
|
The content model has no bearing on browsers. However, it seems that in #12199 we are thinking of changing the standard to require that only the first element child is checked for being a So I guess I'll wait with this to see how your experiment pans out and if it pans out favorably I will update the text. |
2bae032 to
a5c2ef8
Compare
|
Now that #12199 is fixed I've rebased this. @josepharhar @keithamus could you please review? |
josepharhar
left a comment
There was a problem hiding this comment.
This looks good but does web-platform-tests/wpt#61109 cover all of the changes here?
|
I'm not entirely sure how we can test some of the behavior that's mostly still implementation-defined. Any ideas? |
|
I see, yeah this just changes how the legend element in an optgroup is converted into a text representation for appearance:auto, which we can't test because of the native picker, right? The appearance:auto listbox select elements in chromium are actually rendering the legend element instead of a text representation of them, so I wouldn't be able to test it that way either. |
This also fixes several other issues: 1. Be more specific about which legend element we care about. 2. Address the label attribute being missing. 3. <img alt> offers replacement text and as such adding spaces on both sides is wrong. 4. When includeAltText is false we still want to skip the descendants of img elements. This does not fix an existing issue which is that user agents should be allowed to render the img elements as well if they want to.
a5c2ef8 to
624fefe
Compare
https://bugs.webkit.org/show_bug.cgi?id=324223 Reviewed by NOBODY (OOPS!). Implements whatwg/html#12232, which replaces "collect option text" with "get HTML-aware text content", now shared between <option> and <optgroup>. Getting an <optgroup>'s label now only considers a <legend> that is the optgroup's first element child, falling back to the label attribute and then the empty string. The label element has to look like a <legend>, which is the entire reason it exists, so it now shares their user agent style rule through an -internal-optgroup-label user agent part rather than carrying two inline padding properties that had drifted from that rule. fast/forms/select/optgroup-option-shadow-tree.html expected the label element to exist only for a label attribute, so update it, and cover a <legend> that is not the first element child while there. The reference tests are not always passing due to the slight shift of the picker icon as noted in TestExpectations. Test: imported/w3c/web-platform-tests/html/semantics/forms/the-select-element/customizable-select/select-appearance-optgroup-legend-not-first.html Upstream: web-platform-tests/wpt#61109
https://bugs.webkit.org/show_bug.cgi?id=324223 Reviewed by Tim Nguyen. Implements whatwg/html#12232, which replaces "collect option text" with "get HTML-aware text content", now shared between <option> and <optgroup>. Getting an <optgroup>'s label now only considers a <legend> that is the optgroup's first element child, falling back to the label attribute and then the empty string. The label element has to look like a <legend>, which is the entire reason it exists, so it now shares their user agent style rule through an -internal-optgroup-label user agent part rather than carrying two inline padding properties that had drifted from that rule. fast/forms/select/optgroup-option-shadow-tree.html expected the label element to exist only for a label attribute, so update it, and cover a <legend> that is not the first element child while there. The reference tests are not always passing due to the slight shift of the picker icon as noted in TestExpectations. Test: imported/w3c/web-platform-tests/html/semantics/forms/the-select-element/customizable-select/select-appearance-optgroup-legend-not-first.html Upstream: web-platform-tests/wpt#61109 Canonical link: https://commits.webkit.org/321227@main
This also fixes several other issues:
<img alt>offers replacement text and as such adding spaces on both sides is wrong.This does not fix an existing issue which is that user agents should be allowed to render the img elements as well if they want to.
(See WHATWG Working Mode: Changes for more details.)
/form-elements.html ( diff )
/rendering.html ( diff )