void HTMLTextAreaElement::setDefaultValue(const String& defaultValue) { // To preserve comments, remove only the text nodes, then add a single text node. Vector<RefPtr<Node> > textNodes; for (Node* n = firstChild(); n; n = n->nextSibling()) { if (n->isTextNode()) textNodes.append(n); } ExceptionCode ec; size_t size = textNodes.size(); for (size_t i = 0; i < size; ++i) removeChild(textNodes[i].get(), ec); // Normalize line endings. // Add an extra line break if the string starts with one, since // the code to read default values from the DOM strips the leading one. String value = defaultValue; value.replace("\r\n", "\n"); value.replace('\r', '\n'); if (value[0] == '\n') value = "\n" + value; insertBefore(document()->createTextNode(value), firstChild(), ec); setNonDirtyValue(value); }
void HTMLTextAreaElement::setDefaultValue(const String& defaultValue) { RefPtr<Node> protectFromMutationEvents(this); // To preserve comments, remove only the text nodes, then add a single text node. Vector<RefPtr<Node> > textNodes; for (Node* n = firstChild(); n; n = n->nextSibling()) { if (n->isTextNode()) textNodes.append(n); } ExceptionCode ec; size_t size = textNodes.size(); for (size_t i = 0; i < size; ++i) removeChild(textNodes[i].get(), ec); // Normalize line endings. String value = defaultValue; value.replace("\r\n", "\n"); value.replace('\r', '\n'); insertBefore(document()->createTextNode(value), firstChild(), ec); if (!m_isDirty) setNonDirtyValue(value); }
void HTMLTextAreaElement::childrenChanged(const ChildrenChange& change) { HTMLElement::childrenChanged(change); setLastChangeWasNotUserEdit(); if (m_isDirty) setInnerEditorValue(value()); else setNonDirtyValue(defaultValue()); }
void HTMLTextAreaElement::childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta) { setLastChangeWasNotUserEdit(); if (!m_isDirty) setNonDirtyValue(defaultValue()); setInnerTextValue(value()); HTMLElement::childrenChanged(changedByParser, beforeChange, afterChange, childCountDelta); }
void HTMLTextAreaElement::setDefaultValue(const String& defaultValue) { // To preserve comments, remove only the text nodes, then add a single text // node. HeapVector<Member<Node>> textNodes; for (Node* n = firstChild(); n; n = n->nextSibling()) { if (n->isTextNode()) textNodes.append(n); } for (const auto& text : textNodes) removeChild(text.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); if (!m_isDirty) setNonDirtyValue(value); }
void HTMLTextAreaElement::setDefaultValue(const String& defaultValue) { Ref<HTMLTextAreaElement> protectFromMutationEvents(*this); // To preserve comments, remove only the text nodes, then add a single text node. Vector<RefPtr<Text>> textNodes; for (Text* textNode = TextNodeTraversal::firstChild(this); textNode; textNode = TextNodeTraversal::nextSibling(textNode)) textNodes.append(textNode); 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); if (!m_isDirty) setNonDirtyValue(value); }
void HTMLTextAreaElement::reset() { setNonDirtyValue(defaultValue()); }
void HTMLTextAreaElement::childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta) { setNonDirtyValue(defaultValue()); HTMLElement::childrenChanged(changedByParser, beforeChange, afterChange, childCountDelta); }
void HTMLTextAreaElement::setValue(const String& value) { setNonDirtyValue(value); m_isDirty = true; }