haikuwebkit/LayoutTests/fast/forms/placeholder-show-and-hide-v...

17 lines
604 B
Plaintext
Raw Permalink Normal View History

Add Legacy WebKit SPI and WebKit IPI to show and hide placeholder https://bugs.webkit.org/show_bug.cgi?id=206459 <rdar://problem/58700534> Reviewed by Wenson Hsieh. Source/WebCore: Adds setter and getter to update whether the placeholder can be shown. Test: fast/forms/placeholder-show-and-hide-via-setCanShowPlaceholder.html * html/HTMLTextFormControlElement.cpp: (WebCore::HTMLTextFormControlElement::HTMLTextFormControlElement): Initialize state. Default to can show the placeholder to keep the behavior we have currently. (WebCore::HTMLTextFormControlElement::placeholderShouldBeVisible const): Modified to account for m_canShowPlaceholder. (WebCore::HTMLTextFormControlElement::setCanShowPlaceholder): Added. Update state and invalidate style. * html/HTMLTextFormControlElement.h: (WebCore::HTMLTextFormControlElement::canShowPlaceholder const): Added. * testing/Internals.cpp: (WebCore::Internals::setCanShowPlaceholder): Added. For testing purposes. * testing/Internals.h: * testing/Internals.idl: Source/WebKit: Add Modern WebKit IPI to control whether the placeholder can be shown or not when a form control is empty. This is for aesthetics. * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::setCanShowPlaceholder): Added. * UIProcess/WebPageProxy.h: * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::setCanShowPlaceholder): Added. Maps the input text to its element. If it's a HTML text form control element then calls through to HTMLTextFormControlElement::setCanShowPlaceholder(). * WebProcess/WebPage/WebPage.h: * WebProcess/WebPage/WebPage.messages.in: Added new message. Source/WebKitLegacy/mac: Add Legacy WebKit SPI to allow a client to control whether the placeholder can be shown or not when a form control is empty. This is for aesthetics. * DOM/DOMHTMLInputElement.mm: (-[DOMHTMLInputElement canShowPlaceholder]): Added. (-[DOMHTMLInputElement setCanShowPlaceholder:]): Added. * DOM/DOMHTMLInputElementPrivate.h: * DOM/DOMHTMLTextAreaElement.mm: (-[DOMHTMLTextAreaElement canShowPlaceholder]): Added. (-[DOMHTMLTextAreaElement setCanShowPlaceholder:]): Added. * DOM/DOMHTMLTextAreaElementPrivate.h: LayoutTests: Adds a new test to ensure that HTMLTextFormControlElement::setCanShowPlaceholder() works. * fast/forms/placeholder-show-and-hide-via-setCanShowPlaceholder-expected.txt: Added. * fast/forms/placeholder-show-and-hide-via-setCanShowPlaceholder.html: Added. Canonical link: https://commits.webkit.org/219621@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@254886 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-01-21 23:10:27 +00:00
Tests that the placeholder can be hidden and shown for empty fields via setCanShowPlaceholder().
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
Disallow showing of placeholder:
PASS internals.visiblePlaceholder(document.querySelector("input")) is ""
PASS internals.visiblePlaceholder(document.querySelector("textarea")) is ""
Allow showing of placeholder:
PASS internals.visiblePlaceholder(document.querySelector("input")) is "first"
PASS internals.visiblePlaceholder(document.querySelector("textarea")) is "second"
PASS successfullyParsed is true
TEST COMPLETE