Index: Source/core/dom/Node.cpp |
diff --git a/Source/core/dom/Node.cpp b/Source/core/dom/Node.cpp |
index e624958e979a1d3d7237763ceed9b682bf9554dd..c45ddb541b7f1c5edf74ee4b89516de96193234a 100644 |
--- a/Source/core/dom/Node.cpp |
+++ b/Source/core/dom/Node.cpp |
@@ -953,16 +953,15 @@ void Node::detach(const AttachContext& context) |
#endif |
} |
-void Node::reattachWhitespaceSiblings(Text* start) |
+void Node::reattachWhitespaceSiblingsIfNeeded(Text* start) |
{ |
for (Node* sibling = start; sibling; sibling = sibling->nextSibling()) { |
if (sibling->isTextNode() && toText(sibling)->containsOnlyWhitespace()) { |
bool hadRenderer = !!sibling->renderer(); |
- sibling->reattach(); |
- // If the reattach didn't toggle the visibility of the whitespace we don't |
- // need to continue reattaching siblings since they won't toggle visibility |
- // either. |
- if (hadRenderer == !!sibling->renderer()) |
+ toText(sibling)->reattachIfNeeded(); |
+ // If sibling's renderer status didn't change we don't need to continue checking |
+ // other siblings since their renderer status won't change either. |
+ if (!!sibling->renderer() == hadRenderer) |
return; |
} else if (sibling->renderer()) { |
return; |