Chromium Code Reviews| Index: Source/core/editing/markup.cpp |
| diff --git a/Source/core/editing/markup.cpp b/Source/core/editing/markup.cpp |
| index ce7484641725632a31205dbabf8cb6e86c49a584..b2b6522670ac9cfcf47fb4acd05db38a83f5a83d 100644 |
| --- a/Source/core/editing/markup.cpp |
| +++ b/Source/core/editing/markup.cpp |
| @@ -369,7 +369,7 @@ Node* StyledMarkupAccumulator::traverseNodesForSerialization(Node* startNode, No |
| appendStartTag(*n); |
| // If node has no children, close the tag now. |
| - if (!n->childNodeCount()) { |
| + if (!n->hasChildNodes()) { |
| if (shouldEmit) |
| appendEndTag(*n); |
| lastClosed = n; |
| @@ -782,15 +782,20 @@ static void fillContainerFromString(ContainerNode* paragraph, const String& stri |
| } |
| } |
| -bool isPlainTextMarkup(Node *node) |
| +bool isPlainTextMarkup(Node* node) |
| { |
| - if (!node->isElementNode() || !node->hasTagName(divTag) || toElement(node)->hasAttributes()) |
| + if (!node->isElementNode()) |
| return false; |
| - if (node->childNodeCount() == 1 && (node->firstChild()->isTextNode() || (node->firstChild()->firstChild()))) |
| + Element* element = toElement(node); |
| + if (!element->hasTagName(divTag) || !element->hasAttributes()) |
| + return false; |
| + |
| + if (element->hasOneChild() && (element->firstChild()->isTextNode() || (element->firstChild()->firstChild()))) |
| return true; |
| - return (node->childNodeCount() == 2 && isTabSpanTextNode(node->firstChild()->firstChild()) && node->firstChild()->nextSibling()->isTextNode()); |
| + bool elementHasTwoChildren = (element->firstChild() && element->firstChild()->nextSibling() && !element->firstChild()->nextSibling()->nextSibling()); |
|
eseidel
2014/02/19 05:39:54
I wonder if a generic hasChildCount(unsigned) is u
Inactive
2014/02/19 14:28:15
This is likely the only place where we would need
|
| + return (elementHasTwoChildren && isTabSpanTextNode(element->firstChild()->firstChild()) && element->firstChild()->nextSibling()->isTextNode()); |
| } |
| static bool shouldPreserveNewline(const Range& range) |