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

Unified Diff: sky/engine/core/dom/Node.cpp

Issue 855733005: Simplify Node::textContent(). (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 11 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 | « sky/engine/core/dom/Node.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/engine/core/dom/Node.cpp
diff --git a/sky/engine/core/dom/Node.cpp b/sky/engine/core/dom/Node.cpp
index ff75c2de139219cda67a0027696cecb83a8b8f9b..2944c93a46fd6c2008664efc8d1bb60a5c60f75f 100644
--- a/sky/engine/core/dom/Node.cpp
+++ b/sky/engine/core/dom/Node.cpp
@@ -906,22 +906,13 @@ ContainerNode* Node::ownerScope() const
return 0;
}
-static void appendTextContent(const Node* node, bool convertBRsToNewlines, StringBuilder& content)
-{
- if (node->nodeType() == Node::TEXT_NODE) {
- content.append(toCharacterData(node)->data());
- return;
- }
-
- for (Node* child = toContainerNode(node)->firstChild(); child; child = child->nextSibling()) {
- appendTextContent(child, convertBRsToNewlines, content);
- }
-}
-
-String Node::textContent(bool convertBRsToNewlines) const
+String Node::textContent() const
{
StringBuilder content;
- appendTextContent(this, convertBRsToNewlines, content);
+ for (const Node* node = this; node; node = NodeTraversal::next(*node, this)) {
+ if (node->isTextNode())
+ content.append(toText(node)->data());
+ }
return content.toString();
}
« no previous file with comments | « sky/engine/core/dom/Node.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698