[Webkit-unassigned] [Bug 238751] [css-ui] Hide input[type=search] results and clear buttons with appearance: textfield

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Mon Apr 4 13:47:40 PDT 2022


https://bugs.webkit.org/show_bug.cgi?id=238751

--- Comment #2 from Tim Nguyen (:ntim) <ntim at apple.com> ---
This is a good starting point to hide the clear button:

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])

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20220404/a0d383bf/attachment.htm>


More information about the webkit-unassigned mailing list