Bug 238551 - [css-ui] alias appearance <compat-auto> keywords to 'auto' for textfield
Summary: [css-ui] alias appearance <compat-auto> keywords to 'auto' for textfield
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: zsun
URL:
Keywords: InRadar
Depends on:
Blocks: 238751
  Show dependency treegraph
 
Reported: 2022-03-30 07:08 PDT by zsun
Modified: 2022-05-16 12:01 PDT (History)
10 users (show)

See Also:


Attachments
Patch (4.68 KB, patch)
2022-03-30 07:18 PDT, zsun
no flags Details | Formatted Diff | Diff
Patch (3.02 KB, patch)
2022-04-01 05:16 PDT, zsun
no flags Details | Formatted Diff | Diff
Patch (1.55 KB, patch)
2022-05-16 03:10 PDT, zsun
no flags Details | Formatted Diff | Diff
Patch (3.51 KB, patch)
2022-05-16 03:29 PDT, zsun
no flags Details | Formatted Diff | Diff
[fast-cq] Patch (3.74 KB, patch)
2022-05-16 05:40 PDT, zsun
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description zsun 2022-03-30 07:08:14 PDT
Add support for alias appearance <compat-auto> keywords to 'auto' for textfield
Comment 1 zsun 2022-03-30 07:18:43 PDT
Created attachment 456118 [details]
Patch
Comment 2 zsun 2022-04-01 05:16:17 PDT
Created attachment 456350 [details]
Patch
Comment 3 Tim Nguyen (:ntim) 2022-04-02 19:01:15 PDT
Comment on attachment 456350 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=456350&action=review

> Source/WebCore/ChangeLog:15
> +        The test failures though, are not fully fixed. The issue left is that the search cancel button
> +        for input type="search" still present while it is expected to disappear.

Can we try to get the 2 tests passing? Just to match WebKit's policy of having tests that start passing for every patch.

Maybe this is a good place to start looking: https://webkit-search.igalia.com/webkit/source/Source/WebCore/html/shadow/TextControlInnerElements.cpp#290-315
Comment 4 Radar WebKit Bug Importer 2022-04-04 11:39:06 PDT
<rdar://problem/91252542>
Comment 5 Tim Nguyen (:ntim) 2022-04-04 11:55:07 PDT
I filed bug 238751 for input[type=search]
Comment 6 Tim Nguyen (:ntim) 2022-04-04 13:46:32 PDT
This is a good starting point:

diff --git a/Source/WebCore/html/shadow/TextControlInnerElements.cpp b/Source/WebCore/html/shadow/TextControlInnerElements.cpp
index c0e8fee503fe..0098997ddc63 100644
--- a/Source/WebCore/html/shadow/TextControlInnerElements.cpp
+++ b/Source/WebCore/html/shadow/TextControlInnerElements.cpp
@@ -306,11 +306,13 @@ Ref<SearchFieldCancelButtonElement> SearchFieldCancelButtonElement::create(Docum
     return element;
 }
 
-std::optional<Style::ElementStyle> SearchFieldCancelButtonElement::resolveCustomStyle(const Style::ResolutionContext& resolutionContext, const RenderStyle*)
+std::optional<Style::ElementStyle> SearchFieldCancelButtonElement::resolveCustomStyle(const Style::ResolutionContext& resolutionContext, const RenderStyle* shadowHostStyle)
 {
     auto elementStyle = resolveStyle(resolutionContext);
     auto& inputElement = downcast<HTMLInputElement>(*shadowHost());
     elementStyle.renderStyle->setVisibility(elementStyle.renderStyle->visibility() == Visibility::Hidden || inputElement.value().isEmpty() ? Visibility::Hidden : Visibility::Visible);
+    if (shadowHostStyle->effectiveAppearance() == TextFieldPart)
+        elementStyle.renderStyle->setEffectiveDisplay(DisplayType::None);
     return elementStyle;
 }



Remaining issues are:
- width is too large compared to <input type="text"> (not quite sure why)
- focusring offset is too large compared to <input type="text"> (html.css sets input[type=text] outline-offset to -2px, but [type=search] to 0, outline-offset needs to be tied to appearance: textfield instead of input[type])

It would be good to fix this first in bug 238751
Comment 7 Tim Nguyen (:ntim) 2022-05-13 23:07:49 PDT
Comment on attachment 456350 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=456350&action=review

> Source/WebCore/rendering/RenderTheme.cpp:98
> +    if (part == AutoPart || part == SearchFieldPart || part == SearchFieldCancelButtonPart || part == TextAreaPart || part == CheckboxPart || part == RadioPart || part == ListboxPart || part == MeterPart || part == ProgressBarPart

I unexposed SearchFieldCancelButtonPart in bug 240384, this isn't needed

> Source/WebCore/rendering/RenderTheme.cpp:128
> +#if ENABLE(INPUT_TYPE_COLOR)
> +        // Add restriction of using appearances of `textfield` for color element. See 
> +        // https://bugs.webkit.org/show_bug.cgi?id=191279
> +        if (is<HTMLInputElement>(*element) && downcast<HTMLInputElement>(*element).isColorControl())
> +            return part;
> +#endif

I'm not really sure this behavior is worth preserving. It doesn't match the spec and I don't see the point of setting appearance: textfield on <input type=color>.

data:text/html,<input%20type=color%20style="appearance:textfield">

Aditya/Wenson, what do you think?
Comment 8 Tim Nguyen (:ntim) 2022-05-13 23:11:59 PDT
> > Source/WebCore/rendering/RenderTheme.cpp:128
> > +#if ENABLE(INPUT_TYPE_COLOR)
> > +        // Add restriction of using appearances of `textfield` for color element. See 
> > +        // https://bugs.webkit.org/show_bug.cgi?id=191279
> > +        if (is<HTMLInputElement>(*element) && downcast<HTMLInputElement>(*element).isColorControl())
> > +            return part;
> > +#endif
> 
> I'm not really sure this behavior is worth preserving. It doesn't match the
> spec and I don't see the point of setting appearance: textfield on <input
> type=color>.
> 
> data:text/html,<input%20type=color%20style="appearance:textfield">
> 
> Aditya/Wenson, what do you think?

Fwiw, the relevant test (fast/forms/color/color-input-uses-color-well-appearance.html) argues that <input type=color> and <input type=color style="appearance:textfield"> should look different. The spec argues for otherwise.

Looking at the original bug (bug 191279), I don't think testing this was necessarily the intent.
Comment 9 Aditya Keerthi 2022-05-13 23:36:14 PDT
(In reply to Tim Nguyen (:ntim) from comment #7)
> Comment on attachment 456350 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=456350&action=review
> 
> > Source/WebCore/rendering/RenderTheme.cpp:98
> > +    if (part == AutoPart || part == SearchFieldPart || part == SearchFieldCancelButtonPart || part == TextAreaPart || part == CheckboxPart || part == RadioPart || part == ListboxPart || part == MeterPart || part == ProgressBarPart
> 
> I unexposed SearchFieldCancelButtonPart in bug 240384, this isn't needed
> 
> > Source/WebCore/rendering/RenderTheme.cpp:128
> > +#if ENABLE(INPUT_TYPE_COLOR)
> > +        // Add restriction of using appearances of `textfield` for color element. See 
> > +        // https://bugs.webkit.org/show_bug.cgi?id=191279
> > +        if (is<HTMLInputElement>(*element) && downcast<HTMLInputElement>(*element).isColorControl())
> > +            return part;
> > +#endif
> 
> I'm not really sure this behavior is worth preserving. It doesn't match the
> spec and I don't see the point of setting appearance: textfield on <input
> type=color>.
> 
> data:text/html,<input%20type=color%20style="appearance:textfield">
> 
> Aditya/Wenson, what do you think?

Agreed. This appears to be an artifact of the time when <input type=color> was just a text box with a hex color code.

We can remove the test, or change '-expected-mismatch.html' to '-expected.html', if this is not already covered by a WPT.
Comment 10 Tim Nguyen (:ntim) 2022-05-16 00:27:09 PDT
(In reply to Aditya Keerthi from comment #9)
> (In reply to Tim Nguyen (:ntim) from comment #7)
> > Comment on attachment 456350 [details]
> > Patch
> > 
> > View in context:
> > https://bugs.webkit.org/attachment.cgi?id=456350&action=review
> > 
> > > Source/WebCore/rendering/RenderTheme.cpp:98
> > > +    if (part == AutoPart || part == SearchFieldPart || part == SearchFieldCancelButtonPart || part == TextAreaPart || part == CheckboxPart || part == RadioPart || part == ListboxPart || part == MeterPart || part == ProgressBarPart
> > 
> > I unexposed SearchFieldCancelButtonPart in bug 240384, this isn't needed
> > 
> > > Source/WebCore/rendering/RenderTheme.cpp:128
> > > +#if ENABLE(INPUT_TYPE_COLOR)
> > > +        // Add restriction of using appearances of `textfield` for color element. See 
> > > +        // https://bugs.webkit.org/show_bug.cgi?id=191279
> > > +        if (is<HTMLInputElement>(*element) && downcast<HTMLInputElement>(*element).isColorControl())
> > > +            return part;
> > > +#endif
> > 
> > I'm not really sure this behavior is worth preserving. It doesn't match the
> > spec and I don't see the point of setting appearance: textfield on <input
> > type=color>.
> > 
> > data:text/html,<input%20type=color%20style="appearance:textfield">
> > 
> > Aditya/Wenson, what do you think?
> 
> Agreed. This appears to be an artifact of the time when <input type=color>
> was just a text box with a hex color code.
> 
> We can remove the test, or change '-expected-mismatch.html' to
> '-expected.html', if this is not already covered by a WPT.

I'd be ok with the renaming option, given we don't fully pass the corresponding WPT for other reasons (bug 238751), and that would allow us to have a test for this change.

Ziran, does that plan sound ok to you?
Comment 11 zsun 2022-05-16 03:10:36 PDT
Created attachment 459411 [details]
Patch
Comment 12 zsun 2022-05-16 03:29:28 PDT
Created attachment 459412 [details]
Patch
Comment 13 Tim Nguyen (:ntim) 2022-05-16 03:31:27 PDT
Comment on attachment 459412 [details]
Patch

r=me if EWS is green
Comment 14 zsun 2022-05-16 05:40:51 PDT
Created attachment 459418 [details]
[fast-cq] Patch
Comment 15 EWS 2022-05-16 12:01:22 PDT
Committed r294249 (250605@main): <https://commits.webkit.org/250605@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 459418 [details].