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

Side by Side 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-28T05:18:57 Created 6 years, 6 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 unified diff | Download patch
« no previous file with comments | « LayoutTests/editing/execCommand/indent-table-cell-crash-expected.txt ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 1438 matching lines...) Expand 10 before | Expand all | Expand 10 after
1449 } 1449 }
1450 1450
1451 // Splits the tree parent by parent until we reach the specified ancestor. We us e VisiblePositions 1451 // Splits the tree parent by parent until we reach the specified ancestor. We us e VisiblePositions
1452 // to determine if the split is necessary. Returns the last split node. 1452 // to determine if the split is necessary. Returns the last split node.
1453 PassRefPtr<Node> CompositeEditCommand::splitTreeToNode(Node* start, Node* end, b ool shouldSplitAncestor) 1453 PassRefPtr<Node> CompositeEditCommand::splitTreeToNode(Node* start, Node* end, b ool shouldSplitAncestor)
1454 { 1454 {
1455 ASSERT(start); 1455 ASSERT(start);
1456 ASSERT(end); 1456 ASSERT(end);
1457 ASSERT(start != end); 1457 ASSERT(start != end);
1458 1458
1459 RefPtr<Node> node;
1460 if (shouldSplitAncestor && end->parentNode()) 1459 if (shouldSplitAncestor && end->parentNode())
1461 end = end->parentNode(); 1460 end = end->parentNode();
1461 if (!start->isDescendantOf(end))
1462 return end;
1462 1463
1463 RefPtr<Node> endNode = end; 1464 RefPtr<Node> endNode = end;
1464 for (node = start; node && node->parentNode() != endNode; node = node->paren tNode()) { 1465 RefPtr<Node> node;
1466 for (node = start; node->parentNode() != endNode; node = node->parentNode()) {
1465 if (!node->parentNode()->isElementNode()) 1467 if (!node->parentNode()->isElementNode())
1466 break; 1468 break;
1467 // Do not split a node when doing so introduces an empty node. 1469 // Do not split a node when doing so introduces an empty node.
1468 VisiblePosition positionInParent(firstPositionInNode(node->parentNode()) ); 1470 VisiblePosition positionInParent(firstPositionInNode(node->parentNode()) );
1469 VisiblePosition positionInNode(firstPositionInOrBeforeNode(node.get())); 1471 VisiblePosition positionInNode(firstPositionInOrBeforeNode(node.get()));
1470 if (positionInParent != positionInNode) 1472 if (positionInParent != positionInNode)
1471 splitElement(toElement(node->parentNode()), node); 1473 splitElement(toElement(node->parentNode()), node);
1472 } 1474 }
1473 1475
1474 return node.release(); 1476 return node.release();
1475 } 1477 }
1476 1478
1477 PassRefPtrWillBeRawPtr<Element> createBlockPlaceholderElement(Document& document ) 1479 PassRefPtrWillBeRawPtr<Element> createBlockPlaceholderElement(Document& document )
1478 { 1480 {
1479 return document.createElement(brTag, false); 1481 return document.createElement(brTag, false);
1480 } 1482 }
1481 1483
1482 } // namespace WebCore 1484 } // namespace WebCore
OLDNEW
« no previous file with comments | « LayoutTests/editing/execCommand/indent-table-cell-crash-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698