Diff
Modified: trunk/LayoutTests/ChangeLog (254885 => 254886)
--- trunk/LayoutTests/ChangeLog 2020-01-21 22:57:01 UTC (rev 254885)
+++ trunk/LayoutTests/ChangeLog 2020-01-21 23:10:27 UTC (rev 254886)
@@ -1,3 +1,16 @@
+2020-01-21 Daniel Bates <[email protected]>
+
+ 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.
+
+ 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.
+
2020-01-21 Justin Fan <[email protected]>
[WebGL2] Sampler objects
Added: trunk/LayoutTests/fast/forms/placeholder-show-and-hide-via-setCanShowPlaceholder-expected.txt (0 => 254886)
--- trunk/LayoutTests/fast/forms/placeholder-show-and-hide-via-setCanShowPlaceholder-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/forms/placeholder-show-and-hide-via-setCanShowPlaceholder-expected.txt 2020-01-21 23:10:27 UTC (rev 254886)
@@ -0,0 +1,16 @@
+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
+
Added: trunk/LayoutTests/fast/forms/placeholder-show-and-hide-via-setCanShowPlaceholder.html (0 => 254886)
--- trunk/LayoutTests/fast/forms/placeholder-show-and-hide-via-setCanShowPlaceholder.html (rev 0)
+++ trunk/LayoutTests/fast/forms/placeholder-show-and-hide-via-setCanShowPlaceholder.html 2020-01-21 23:10:27 UTC (rev 254886)
@@ -0,0 +1,45 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<input type="text" placeholder="first">
+<textarea placeholder="second"></textarea>
+<script>
+description("Tests that the placeholder can be hidden and shown for empty fields via setCanShowPlaceholder().");
+
+function testThatPlaceholderIsHidden(tagName)
+{
+ let element = document.querySelector(tagName);
+ internals.setCanShowPlaceholder(element, false);
+ shouldBeEqualToString(`internals.visiblePlaceholder(document.querySelector("${tagName}"))`, "");
+}
+
+function testThatPlaceholderIsEqualToString(tagName, expectedText)
+{
+ let element = document.querySelector(tagName);
+ internals.setCanShowPlaceholder(element, true);
+ shouldBeEqualToString(`internals.visiblePlaceholder(document.querySelector("${tagName}"))`, expectedText);
+}
+
+function runTest()
+{
+ if (!window.internals) {
+ testFailed("Must have window.internals.");
+ return;
+ }
+
+ debug("Disallow showing of placeholder:");
+ testThatPlaceholderIsHidden("input");
+ testThatPlaceholderIsHidden("textarea");
+
+ debug("<br>Allow showing of placeholder:");
+ testThatPlaceholderIsEqualToString("input", "first");
+ testThatPlaceholderIsEqualToString("textarea", "second");
+}
+
+runTest();
+</script>
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (254885 => 254886)
--- trunk/Source/WebCore/ChangeLog 2020-01-21 22:57:01 UTC (rev 254885)
+++ trunk/Source/WebCore/ChangeLog 2020-01-21 23:10:27 UTC (rev 254886)
@@ -1,3 +1,27 @@
+2020-01-21 Daniel Bates <[email protected]>
+
+ 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.
+
+ 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:
+
2020-01-21 Rob Buis <[email protected]>
Add build flag for stale-while-revalidate
Modified: trunk/Source/WebCore/html/HTMLTextFormControlElement.cpp (254885 => 254886)
--- trunk/Source/WebCore/html/HTMLTextFormControlElement.cpp 2020-01-21 22:57:01 UTC (rev 254885)
+++ trunk/Source/WebCore/html/HTMLTextFormControlElement.cpp 2020-01-21 23:10:27 UTC (rev 254886)
@@ -65,6 +65,7 @@
, m_cachedSelectionDirection(SelectionHasNoDirection)
, m_lastChangeWasUserEdit(false)
, m_isPlaceholderVisible(false)
+ , m_canShowPlaceholder(true)
, m_cachedSelectionStart(-1)
, m_cachedSelectionEnd(-1)
{
@@ -158,7 +159,7 @@
{
// This function is used by the style resolver to match the :placeholder-shown pseudo class.
// Since it is used for styling, it must not use any value depending on the style.
- return supportsPlaceholder() && isEmptyValue() && !isPlaceholderEmpty();
+ return supportsPlaceholder() && isEmptyValue() && !isPlaceholderEmpty() && m_canShowPlaceholder;
}
void HTMLTextFormControlElement::updatePlaceholderVisibility()
@@ -172,6 +173,12 @@
invalidateStyleForSubtree();
}
+void HTMLTextFormControlElement::setCanShowPlaceholder(bool canShowPlaceholder)
+{
+ m_canShowPlaceholder = canShowPlaceholder;
+ updatePlaceholderVisibility();
+}
+
void HTMLTextFormControlElement::setSelectionStart(int start)
{
setSelectionRange(start, std::max(start, selectionEnd()), selectionDirection());
Modified: trunk/Source/WebCore/html/HTMLTextFormControlElement.h (254885 => 254886)
--- trunk/Source/WebCore/html/HTMLTextFormControlElement.h 2020-01-21 22:57:01 UTC (rev 254885)
+++ trunk/Source/WebCore/html/HTMLTextFormControlElement.h 2020-01-21 23:10:27 UTC (rev 254886)
@@ -62,6 +62,9 @@
virtual HTMLElement* placeholderElement() const = 0;
void updatePlaceholderVisibility();
+ WEBCORE_EXPORT void setCanShowPlaceholder(bool);
+ bool canShowPlaceholder() const { return m_canShowPlaceholder; }
+
int indexForVisiblePosition(const VisiblePosition&) const;
WEBCORE_EXPORT VisiblePosition visiblePositionForIndex(int index) const;
WEBCORE_EXPORT int selectionStart() const;
@@ -160,6 +163,7 @@
unsigned m_cachedSelectionDirection : 2;
unsigned m_lastChangeWasUserEdit : 1;
unsigned m_isPlaceholderVisible : 1;
+ unsigned m_canShowPlaceholder : 1;
String m_textAsOfLastFormControlChangeEvent;
Modified: trunk/Source/WebCore/testing/Internals.cpp (254885 => 254886)
--- trunk/Source/WebCore/testing/Internals.cpp 2020-01-21 22:57:01 UTC (rev 254885)
+++ trunk/Source/WebCore/testing/Internals.cpp 2020-01-21 23:10:27 UTC (rev 254886)
@@ -1420,6 +1420,12 @@
return String();
}
+void Internals::setCanShowPlaceholder(Element& element, bool canShowPlaceholder)
+{
+ if (is<HTMLTextFormControlElement>(element))
+ downcast<HTMLTextFormControlElement>(element).setCanShowPlaceholder(canShowPlaceholder);
+}
+
void Internals::selectColorInColorChooser(HTMLInputElement& element, const String& colorValue)
{
element.selectColor(colorValue);
Modified: trunk/Source/WebCore/testing/Internals.h (254885 => 254886)
--- trunk/Source/WebCore/testing/Internals.h 2020-01-21 22:57:01 UTC (rev 254885)
+++ trunk/Source/WebCore/testing/Internals.h 2020-01-21 23:10:27 UTC (rev 254886)
@@ -236,6 +236,8 @@
Node* parentTreeScope(Node&);
String visiblePlaceholder(Element&);
+ void setCanShowPlaceholder(Element&, bool);
+
void selectColorInColorChooser(HTMLInputElement&, const String& colorValue);
ExceptionOr<Vector<String>> formControlStateOfPreviousHistoryItem();
ExceptionOr<void> setFormControlStateOfPreviousHistoryItem(const Vector<String>&);
Modified: trunk/Source/WebCore/testing/Internals.idl (254885 => 254886)
--- trunk/Source/WebCore/testing/Internals.idl 2020-01-21 22:57:01 UTC (rev 254885)
+++ trunk/Source/WebCore/testing/Internals.idl 2020-01-21 23:10:27 UTC (rev 254886)
@@ -307,6 +307,8 @@
AutoFillButtonType autoFillButtonType(HTMLInputElement inputElement);
AutoFillButtonType lastAutoFillButtonType(HTMLInputElement inputElement);
+ void setCanShowPlaceholder(Element element, boolean canShowPlaceholder);
+
[MayThrowException] Range? rangeOfString(DOMString text, Range? referenceRange, sequence<DOMString> findOptions);
[MayThrowException] unsigned long countMatchesForText(DOMString text, sequence<DOMString> findOptions, DOMString markMatches);
[MayThrowException] unsigned long countFindMatches(DOMString text, sequence<DOMString> findOptions);
Modified: trunk/Source/WebKit/ChangeLog (254885 => 254886)
--- trunk/Source/WebKit/ChangeLog 2020-01-21 22:57:01 UTC (rev 254885)
+++ trunk/Source/WebKit/ChangeLog 2020-01-21 23:10:27 UTC (rev 254886)
@@ -1,3 +1,24 @@
+2020-01-21 Daniel Bates <[email protected]>
+
+ 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.
+
+ 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.
+
2020-01-21 Jiewen Tan <[email protected]>
ProvisionalPageProxy::loadData should pass last navigation's shouldOpenExternalURLsPolicy flag to WebPageProxy
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (254885 => 254886)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2020-01-21 22:57:01 UTC (rev 254885)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2020-01-21 23:10:27 UTC (rev 254886)
@@ -9664,6 +9664,12 @@
sendWithAsyncReply(Messages::WebPage::FocusTextInputContext(context), WTFMove(completionHandler));
}
+void WebPageProxy::setCanShowPlaceholder(const WebCore::ElementContext& context, bool canShowPlaceholder)
+{
+ if (hasRunningProcess())
+ send(Messages::WebPage::SetCanShowPlaceholder(context, canShowPlaceholder));
+}
+
Logger& WebPageProxy::logger()
{
if (!m_logger) {
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (254885 => 254886)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.h 2020-01-21 22:57:01 UTC (rev 254885)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h 2020-01-21 23:10:27 UTC (rev 254886)
@@ -687,6 +687,7 @@
void textInputContextsInRect(WebCore::FloatRect, CompletionHandler<void(const Vector<WebCore::ElementContext>&)>&&);
void focusTextInputContext(const WebCore::ElementContext&, CompletionHandler<void(bool)>&&);
+ void setCanShowPlaceholder(const WebCore::ElementContext&, bool);
#if ENABLE(UI_SIDE_COMPOSITING)
void updateVisibleContentRects(const VisibleContentRectUpdateInfo&);
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (254885 => 254886)
--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2020-01-21 22:57:01 UTC (rev 254885)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2020-01-21 23:10:27 UTC (rev 254886)
@@ -6827,6 +6827,13 @@
completionHandler(element);
}
+void WebPage::setCanShowPlaceholder(const WebCore::ElementContext& elementContext, bool canShowPlaceholder)
+{
+ RefPtr<Element> element = elementForContext(elementContext);
+ if (is<HTMLTextFormControlElement>(element))
+ downcast<HTMLTextFormControlElement>(*element).setCanShowPlaceholder(canShowPlaceholder);
+}
+
Element* WebPage::elementForContext(const WebCore::ElementContext& elementContext) const
{
if (elementContext.webPageIdentifier != m_identifier)
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.h (254885 => 254886)
--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.h 2020-01-21 22:57:01 UTC (rev 254885)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.h 2020-01-21 23:10:27 UTC (rev 254886)
@@ -631,6 +631,7 @@
void textInputContextsInRect(WebCore::FloatRect, CompletionHandler<void(const Vector<WebCore::ElementContext>&)>&&);
void focusTextInputContext(const WebCore::ElementContext&, CompletionHandler<void(bool)>&&);
+ void setCanShowPlaceholder(const WebCore::ElementContext&, bool);
#if PLATFORM(IOS_FAMILY)
WebCore::FloatSize screenSize() const;
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in (254885 => 254886)
--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in 2020-01-21 22:57:01 UTC (rev 254885)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in 2020-01-21 23:10:27 UTC (rev 254886)
@@ -574,6 +574,7 @@
TextInputContextsInRect(WebCore::FloatRect rect) -> (Vector<struct WebCore::ElementContext> contexts) Async
FocusTextInputContext(struct WebCore::ElementContext context) -> (bool success) Async
+ SetCanShowPlaceholder(struct WebCore::ElementContext context, bool canShowPlaceholder)
#if ENABLE(RESOURCE_LOAD_STATISTICS)
WasLoadedWithDataTransferFromPrevalentResource()
Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (254885 => 254886)
--- trunk/Source/WebKitLegacy/mac/ChangeLog 2020-01-21 22:57:01 UTC (rev 254885)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog 2020-01-21 23:10:27 UTC (rev 254886)
@@ -1,3 +1,23 @@
+2020-01-21 Daniel Bates <[email protected]>
+
+ 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.
+
+ 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:
+
2020-01-21 Rob Buis <[email protected]>
Add build flag for stale-while-revalidate
Modified: trunk/Source/WebKitLegacy/mac/DOM/DOMHTMLInputElement.mm (254885 => 254886)
--- trunk/Source/WebKitLegacy/mac/DOM/DOMHTMLInputElement.mm 2020-01-21 22:57:01 UTC (rev 254885)
+++ trunk/Source/WebKitLegacy/mac/DOM/DOMHTMLInputElement.mm 2020-01-21 23:10:27 UTC (rev 254886)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2004-2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2004-2020 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -710,6 +710,18 @@
}
#endif // TARGET_OS_IPHONE
+- (BOOL)canShowPlaceholder
+{
+ WebCore::JSMainThreadNullState state;
+ return IMPL->canShowPlaceholder();
+}
+
+- (void)setCanShowPlaceholder:(BOOL)canShowPlaceholder
+{
+ WebCore::JSMainThreadNullState state;
+ IMPL->setCanShowPlaceholder(canShowPlaceholder);
+}
+
@end
WebCore::HTMLInputElement* core(DOMHTMLInputElement *wrapper)
Modified: trunk/Source/WebKitLegacy/mac/DOM/DOMHTMLInputElementPrivate.h (254885 => 254886)
--- trunk/Source/WebKitLegacy/mac/DOM/DOMHTMLInputElementPrivate.h 2020-01-21 22:57:01 UTC (rev 254885)
+++ trunk/Source/WebKitLegacy/mac/DOM/DOMHTMLInputElementPrivate.h 2020-01-21 23:10:27 UTC (rev 254886)
@@ -53,6 +53,7 @@
@property (copy) NSString *selectionDirection;
@property BOOL incremental;
@property BOOL capture;
+@property (nonatomic) BOOL canShowPlaceholder;
- (void)stepUp:(int)n;
- (void)stepDown:(int)n;
Modified: trunk/Source/WebKitLegacy/mac/DOM/DOMHTMLTextAreaElement.mm (254885 => 254886)
--- trunk/Source/WebKitLegacy/mac/DOM/DOMHTMLTextAreaElement.mm 2020-01-21 22:57:01 UTC (rev 254885)
+++ trunk/Source/WebKitLegacy/mac/DOM/DOMHTMLTextAreaElement.mm 2020-01-21 23:10:27 UTC (rev 254886)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2004-2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2004-2016, 2020 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -323,4 +323,16 @@
unwrap(*self).setSelectionRange(start, end);
}
+- (BOOL)canShowPlaceholder
+{
+ WebCore::JSMainThreadNullState state;
+ return unwrap(*self).canShowPlaceholder();
+}
+
+- (void)setCanShowPlaceholder:(BOOL)canShowPlaceholder
+{
+ WebCore::JSMainThreadNullState state;
+ unwrap(*self).setCanShowPlaceholder(canShowPlaceholder);
+}
+
@end
Modified: trunk/Source/WebKitLegacy/mac/DOM/DOMHTMLTextAreaElementPrivate.h (254885 => 254886)
--- trunk/Source/WebKitLegacy/mac/DOM/DOMHTMLTextAreaElementPrivate.h 2020-01-21 22:57:01 UTC (rev 254885)
+++ trunk/Source/WebKitLegacy/mac/DOM/DOMHTMLTextAreaElementPrivate.h 2020-01-21 23:10:27 UTC (rev 254886)
@@ -39,6 +39,7 @@
@property (readonly, strong) DOMNodeList *labels;
@property (copy) NSString *selectionDirection;
@property (copy) NSString *autocomplete;
+@property (nonatomic) BOOL canShowPlaceholder;
- (void)setRangeText:(NSString *)replacement;
- (void)setRangeText:(NSString *)replacement start:(unsigned)start end:(unsigned)end selectionMode:(NSString *)selectionMode;
@end