OLD | NEW |
---|---|
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 1435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1446 } | 1446 } |
1447 | 1447 |
1448 // Splits the tree parent by parent until we reach the specified ancestor. We us e VisiblePositions | 1448 // Splits the tree parent by parent until we reach the specified ancestor. We us e VisiblePositions |
1449 // to determine if the split is necessary. Returns the last split node. | 1449 // to determine if the split is necessary. Returns the last split node. |
1450 PassRefPtr<Node> CompositeEditCommand::splitTreeToNode(Node* start, Node* end, b ool shouldSplitAncestor) | 1450 PassRefPtr<Node> CompositeEditCommand::splitTreeToNode(Node* start, Node* end, b ool shouldSplitAncestor) |
1451 { | 1451 { |
1452 ASSERT(start); | 1452 ASSERT(start); |
1453 ASSERT(end); | 1453 ASSERT(end); |
1454 ASSERT(start != end); | 1454 ASSERT(start != end); |
1455 | 1455 |
1456 RefPtr<Node> node; | |
1457 if (shouldSplitAncestor && end->parentNode()) | 1456 if (shouldSplitAncestor && end->parentNode()) |
1458 end = end->parentNode(); | 1457 end = end->parentNode(); |
1458 if (!start->isDescendantOf(end)) | |
1459 return end; | |
1459 | 1460 |
1460 RefPtr<Node> endNode = end; | 1461 RefPtr<Node> endNode = end; |
1461 for (node = start; node && node->parentNode() != endNode; node = node->paren tNode()) { | 1462 RefPtr<Node> node; |
1462 if (!node->parentNode()->isElementNode()) | 1463 for (node = start; node->parentNode() != endNode; node = node->parentNode()) { |
1463 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
| |
1464 // Do not split a node when doing so introduces an empty node. | 1464 // Do not split a node when doing so introduces an empty node. |
1465 VisiblePosition positionInParent(firstPositionInNode(node->parentNode()) ); | 1465 VisiblePosition positionInParent(firstPositionInNode(node->parentNode()) ); |
1466 VisiblePosition positionInNode(firstPositionInOrBeforeNode(node.get())); | 1466 VisiblePosition positionInNode(firstPositionInOrBeforeNode(node.get())); |
1467 if (positionInParent != positionInNode) | 1467 if (positionInParent != positionInNode) |
1468 splitElement(toElement(node->parentNode()), node); | 1468 splitElement(toElement(node->parentNode()), node); |
1469 } | 1469 } |
1470 | 1470 |
1471 return node.release(); | 1471 return node.release(); |
1472 } | 1472 } |
1473 | 1473 |
1474 PassRefPtrWillBeRawPtr<Element> createBlockPlaceholderElement(Document& document ) | 1474 PassRefPtrWillBeRawPtr<Element> createBlockPlaceholderElement(Document& document ) |
1475 { | 1475 { |
1476 return document.createElement(brTag, false); | 1476 return document.createElement(brTag, false); |
1477 } | 1477 } |
1478 | 1478 |
1479 } // namespace WebCore | 1479 } // namespace WebCore |
OLD | NEW |