Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(444)

Unified Diff: Source/core/html/HTMLTextAreaElement.cpp

Issue 1221233003: HTMLTextAreaElement.defaultValue is not implemented as per spec Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix test failures Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « LayoutTests/fast/dom/HTMLTextAreaElement/get-default-value-expected.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/HTMLTextAreaElement.cpp
diff --git a/Source/core/html/HTMLTextAreaElement.cpp b/Source/core/html/HTMLTextAreaElement.cpp
index cdf5e58ea41f9c85ccf238c1dedf433dc899722b..8234ff202da06b6a2eecc5a6856784af6ad0fd56 100644
--- a/Source/core/html/HTMLTextAreaElement.cpp
+++ b/Source/core/html/HTMLTextAreaElement.cpp
@@ -413,40 +413,14 @@ void HTMLTextAreaElement::setInnerEditorValue(const String& value)
String HTMLTextAreaElement::defaultValue() const
{
- StringBuilder value;
-
- // Since there may be comments, ignore nodes other than text nodes.
- for (Node* n = firstChild(); n; n = n->nextSibling()) {
- if (n->isTextNode())
- value.append(toText(n)->data());
- }
-
- return value.toString();
+ return textContent();
}
void HTMLTextAreaElement::setDefaultValue(const String& defaultValue)
{
- RefPtrWillBeRawPtr<Node> protectFromMutationEvents(this);
-
- // To preserve comments, remove only the text nodes, then add a single text node.
- WillBeHeapVector<RefPtrWillBeMember<Node>> textNodes;
- for (Node* n = firstChild(); n; n = n->nextSibling()) {
- if (n->isTextNode())
- textNodes.append(n);
- }
- size_t size = textNodes.size();
- for (size_t i = 0; i < size; ++i)
- removeChild(textNodes[i].get(), IGNORE_EXCEPTION);
-
- // Normalize line endings.
- String value = defaultValue;
- value.replace("\r\n", "\n");
- value.replace('\r', '\n');
-
- insertBefore(document().createTextNode(value), firstChild(), IGNORE_EXCEPTION);
-
+ setTextContent(defaultValue);
if (!m_isDirty)
Sunil Ratnu 2015/07/10 07:47:26 I tried using ImplementedAs=textContent in the idl
tkent 2015/07/10 07:59:40 Can you add test cases of ta.textContent = '...' t
- setNonDirtyValue(value);
+ setNonDirtyValue(defaultValue);
}
int HTMLTextAreaElement::maxLength() const
« no previous file with comments | « LayoutTests/fast/dom/HTMLTextAreaElement/get-default-value-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698