- Revision
- 288005
- Author
- cdu...@apple.com
- Date
- 2022-01-13 19:14:33 -0800 (Thu, 13 Jan 2022)
Log Message
Unable to have new lines in HTMLTextArea's placeholder text
https://bugs.webkit.org/show_bug.cgi?id=235205
Reviewed by Wenson Hsieh.
Source/WebCore:
Unlike the placeholder for HTMLInputElement, the placeholder for HTMLTextAreaElement needs
to allow new lines as per:
- https://html.spec.whatwg.org/multipage/form-elements.html#attr-textarea-placeholder
This aligns our behavior with Blink and Gecko.
No new tests, unskipped existing WPT tests.
* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::placeholder const):
* html/HTMLInputElement.h:
* html/HTMLTextAreaElement.cpp:
(WebCore::HTMLTextAreaElement::updatePlaceholderText):
* html/HTMLTextFormControlElement.cpp:
(WebCore::HTMLTextFormControlElement::strippedPlaceholder const): Deleted.
* html/HTMLTextFormControlElement.h:
* html/TextFieldInputType.cpp:
(WebCore::TextFieldInputType::updatePlaceholderText):
LayoutTests:
Unskip WPT tests that are no longer failing.
* TestExpectations:
Modified Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (288004 => 288005)
--- trunk/LayoutTests/ChangeLog 2022-01-14 03:06:53 UTC (rev 288004)
+++ trunk/LayoutTests/ChangeLog 2022-01-14 03:14:33 UTC (rev 288005)
@@ -1,3 +1,14 @@
+2022-01-13 Chris Dumez <cdu...@apple.com>
+
+ Unable to have new lines in HTMLTextArea's placeholder text
+ https://bugs.webkit.org/show_bug.cgi?id=235205
+
+ Reviewed by Wenson Hsieh.
+
+ Unskip WPT tests that are no longer failing.
+
+ * TestExpectations:
+
2022-01-13 Cameron McCormack <hey...@apple.com>
Only apply automatic minimum block-size aspect-ratio rules to non-replaced elements
Modified: trunk/LayoutTests/TestExpectations (288004 => 288005)
--- trunk/LayoutTests/TestExpectations 2022-01-14 03:06:53 UTC (rev 288004)
+++ trunk/LayoutTests/TestExpectations 2022-01-14 03:14:33 UTC (rev 288005)
@@ -751,9 +751,6 @@
imported/w3c/web-platform-tests/html/semantics/forms/the-option-element/dynamic-content-change-rendering.html [ ImageOnlyFailure ]
imported/w3c/web-platform-tests/html/semantics/forms/the-select-element/reset-algorithm-rendering.html [ ImageOnlyFailure ]
imported/w3c/web-platform-tests/html/semantics/forms/the-selectmenu-element/selectmenu-option-arbitrary-content-displayed.tentative.html [ ImageOnlyFailure ]
-imported/w3c/web-platform-tests/html/semantics/forms/the-textarea-element/multiline-placeholder-cr.html [ ImageOnlyFailure ]
-imported/w3c/web-platform-tests/html/semantics/forms/the-textarea-element/multiline-placeholder-crlf.html [ ImageOnlyFailure ]
-imported/w3c/web-platform-tests/html/semantics/forms/the-textarea-element/multiline-placeholder.html [ ImageOnlyFailure ]
imported/w3c/web-platform-tests/html/semantics/interactive-elements/the-popup-element/popup-hidden-display.tentative.html [ ImageOnlyFailure ]
imported/w3c/web-platform-tests/html/semantics/interactive-elements/the-popup-element/popup-initiallyopen-display.tentative.html [ ImageOnlyFailure ]
imported/w3c/web-platform-tests/html/semantics/interactive-elements/the-popup-element/popup-open-display.tentative.html [ ImageOnlyFailure ]
Modified: trunk/Source/WebCore/ChangeLog (288004 => 288005)
--- trunk/Source/WebCore/ChangeLog 2022-01-14 03:06:53 UTC (rev 288004)
+++ trunk/Source/WebCore/ChangeLog 2022-01-14 03:14:33 UTC (rev 288005)
@@ -1,5 +1,31 @@
2022-01-13 Chris Dumez <cdu...@apple.com>
+ Unable to have new lines in HTMLTextArea's placeholder text
+ https://bugs.webkit.org/show_bug.cgi?id=235205
+
+ Reviewed by Wenson Hsieh.
+
+ Unlike the placeholder for HTMLInputElement, the placeholder for HTMLTextAreaElement needs
+ to allow new lines as per:
+ - https://html.spec.whatwg.org/multipage/form-elements.html#attr-textarea-placeholder
+
+ This aligns our behavior with Blink and Gecko.
+
+ No new tests, unskipped existing WPT tests.
+
+ * html/HTMLInputElement.cpp:
+ (WebCore::HTMLInputElement::placeholder const):
+ * html/HTMLInputElement.h:
+ * html/HTMLTextAreaElement.cpp:
+ (WebCore::HTMLTextAreaElement::updatePlaceholderText):
+ * html/HTMLTextFormControlElement.cpp:
+ (WebCore::HTMLTextFormControlElement::strippedPlaceholder const): Deleted.
+ * html/HTMLTextFormControlElement.h:
+ * html/TextFieldInputType.cpp:
+ (WebCore::TextFieldInputType::updatePlaceholderText):
+
+2022-01-13 Chris Dumez <cdu...@apple.com>
+
html/semantics/scripting-1/the-script-element/script-type-and-language-empty.html WPT test is failing
https://bugs.webkit.org/show_bug.cgi?id=235202
Modified: trunk/Source/WebCore/html/HTMLInputElement.cpp (288004 => 288005)
--- trunk/Source/WebCore/html/HTMLInputElement.cpp 2022-01-14 03:06:53 UTC (rev 288004)
+++ trunk/Source/WebCore/html/HTMLInputElement.cpp 2022-01-14 03:14:33 UTC (rev 288005)
@@ -2189,4 +2189,14 @@
return m_inputType->resultForDialogSubmit();
}
+String HTMLInputElement::placeholder() const
+{
+ // According to the HTML5 specification, we need to remove CR and LF from
+ // the attribute value.
+ String attributeValue = attributeWithoutSynchronization(placeholderAttr);
+ return attributeValue.removeCharacters([](UChar c) {
+ return c == newlineCharacter || c == carriageReturn;
+ });
+}
+
} // namespace
Modified: trunk/Source/WebCore/html/HTMLInputElement.h (288004 => 288005)
--- trunk/Source/WebCore/html/HTMLInputElement.h 2022-01-14 03:06:53 UTC (rev 288004)
+++ trunk/Source/WebCore/html/HTMLInputElement.h 2022-01-14 03:14:33 UTC (rev 288005)
@@ -177,6 +177,8 @@
bool isValidValue(const String&) const;
bool hasDirtyValue() const { return !m_valueIfDirty.isNull(); };
+ String placeholder() const;
+
String sanitizeValue(const String&) const;
String localizeValue(const String&) const;
Modified: trunk/Source/WebCore/html/HTMLTextAreaElement.cpp (288004 => 288005)
--- trunk/Source/WebCore/html/HTMLTextAreaElement.cpp 2022-01-14 03:06:53 UTC (rev 288004)
+++ trunk/Source/WebCore/html/HTMLTextAreaElement.cpp 2022-01-14 03:14:33 UTC (rev 288005)
@@ -538,7 +538,7 @@
void HTMLTextAreaElement::updatePlaceholderText()
{
- String placeholderText = strippedPlaceholder();
+ auto& placeholderText = attributeWithoutSynchronization(placeholderAttr);
if (placeholderText.isEmpty()) {
if (m_placeholder) {
userAgentShadowRoot()->removeChild(*m_placeholder);
Modified: trunk/Source/WebCore/html/HTMLTextFormControlElement.cpp (288004 => 288005)
--- trunk/Source/WebCore/html/HTMLTextFormControlElement.cpp 2022-01-14 03:06:53 UTC (rev 288004)
+++ trunk/Source/WebCore/html/HTMLTextFormControlElement.cpp 2022-01-14 03:14:33 UTC (rev 288005)
@@ -131,26 +131,6 @@
innerTextElement()->defaultEventHandler(event);
}
-String HTMLTextFormControlElement::strippedPlaceholder() const
-{
- // According to the HTML5 specification, we need to remove CR and LF from
- // the attribute value.
- const AtomString& attributeValue = attributeWithoutSynchronization(placeholderAttr);
- if (!attributeValue.contains(newlineCharacter) && !attributeValue.contains(carriageReturn))
- return attributeValue;
-
- StringBuilder stripped;
- unsigned length = attributeValue.length();
- stripped.reserveCapacity(length);
- for (unsigned i = 0; i < length; ++i) {
- UChar character = attributeValue[i];
- if (character == newlineCharacter || character == carriageReturn)
- continue;
- stripped.append(character);
- }
- return stripped.toString();
-}
-
static bool isNotLineBreak(UChar ch) { return ch != newlineCharacter && ch != carriageReturn; }
bool HTMLTextFormControlElement::isPlaceholderEmpty() const
Modified: trunk/Source/WebCore/html/HTMLTextFormControlElement.h (288004 => 288005)
--- trunk/Source/WebCore/html/HTMLTextFormControlElement.h 2022-01-14 03:06:53 UTC (rev 288004)
+++ trunk/Source/WebCore/html/HTMLTextFormControlElement.h 2022-01-14 03:14:33 UTC (rev 288005)
@@ -60,7 +60,6 @@
// The derived class should return true if placeholder processing is needed.
bool isPlaceholderVisible() const { return m_isPlaceholderVisible; }
virtual bool supportsPlaceholder() const = 0;
- String strippedPlaceholder() const;
virtual HTMLElement* placeholderElement() const = 0;
void updatePlaceholderVisibility();
Modified: trunk/Source/WebCore/html/TextFieldInputType.cpp (288004 => 288005)
--- trunk/Source/WebCore/html/TextFieldInputType.cpp 2022-01-14 03:06:53 UTC (rev 288004)
+++ trunk/Source/WebCore/html/TextFieldInputType.cpp 2022-01-14 03:14:33 UTC (rev 288005)
@@ -619,7 +619,7 @@
if (!supportsPlaceholder())
return;
ASSERT(element());
- String placeholderText = element()->strippedPlaceholder();
+ String placeholderText = element()->placeholder();
if (placeholderText.isEmpty()) {
if (m_placeholder) {
m_placeholder->parentNode()->removeChild(*m_placeholder);