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

Unified Diff: Source/core/editing/CompositeEditCommand.cpp

Issue 306473003: Don't over split DOM tree in CompositeEditCommand::splitTreeToNode (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 2014-05-27T01:56:21 Created 6 years, 7 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
Index: Source/core/editing/CompositeEditCommand.cpp
diff --git a/Source/core/editing/CompositeEditCommand.cpp b/Source/core/editing/CompositeEditCommand.cpp
index b208a812a939821643de0d856ac23f6fe6332393..cb15b9cf0eaac31c5f1c190197011428a63b9a03 100644
--- a/Source/core/editing/CompositeEditCommand.cpp
+++ b/Source/core/editing/CompositeEditCommand.cpp
@@ -1453,14 +1453,14 @@ PassRefPtr<Node> CompositeEditCommand::splitTreeToNode(Node* start, Node* end, b
ASSERT(end);
ASSERT(start != end);
- RefPtr<Node> node;
if (shouldSplitAncestor && end->parentNode())
end = end->parentNode();
+ if (!start->isDescendantOf(end))
+ return end;
RefPtr<Node> endNode = end;
- for (node = start; node && node->parentNode() != endNode; node = node->parentNode()) {
- if (!node->parentNode()->isElementNode())
- break;
Yuta Kitamura 2014/05/27 07:41:27 I think the removal of these lines would make Blin
yosin_UTC9 2014/05/27 09:30:06 Only nodes can have Document as parent are BODY an
Yuta Kitamura 2014/05/28 07:44:17 Well, actually |node| could be <HTML>. Or it could
+ RefPtr<Node> node;
+ for (node = start; node->parentNode() != endNode; node = node->parentNode()) {
// Do not split a node when doing so introduces an empty node.
VisiblePosition positionInParent(firstPositionInNode(node->parentNode()));
VisiblePosition positionInNode(firstPositionInOrBeforeNode(node.get()));

Powered by Google App Engine
This is Rietveld 408576698