| 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 917 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 928 | 928 |
| 929 Position upstreamStart = mostBackwardCaretPosition(visibleParagraphStart.dee
pEquivalent()); | 929 Position upstreamStart = mostBackwardCaretPosition(visibleParagraphStart.dee
pEquivalent()); |
| 930 Position upstreamEnd = mostBackwardCaretPosition(visibleEnd.deepEquivalent()
); | 930 Position upstreamEnd = mostBackwardCaretPosition(visibleEnd.deepEquivalent()
); |
| 931 | 931 |
| 932 // If there are no VisiblePositions in the same block as pos then | 932 // If there are no VisiblePositions in the same block as pos then |
| 933 // upstreamStart will be outside the paragraph | 933 // upstreamStart will be outside the paragraph |
| 934 if (comparePositions(pos, upstreamStart) < 0) | 934 if (comparePositions(pos, upstreamStart) < 0) |
| 935 return nullptr; | 935 return nullptr; |
| 936 | 936 |
| 937 // Perform some checks to see if we need to perform work in this function. | 937 // Perform some checks to see if we need to perform work in this function. |
| 938 if (isBlock(upstreamStart.anchorNode())) { | 938 if (isEnclosingBlock(upstreamStart.anchorNode())) { |
| 939 // If the block is the root editable element, always move content to a n
ew block, | 939 // If the block is the root editable element, always move content to a n
ew block, |
| 940 // since it is illegal to modify attributes on the root editable element
for editing. | 940 // since it is illegal to modify attributes on the root editable element
for editing. |
| 941 if (upstreamStart.anchorNode() == editableRootForPosition(upstreamStart)
) { | 941 if (upstreamStart.anchorNode() == editableRootForPosition(upstreamStart)
) { |
| 942 // If the block is the root editable element and it contains no visi
ble content, create a new | 942 // If the block is the root editable element and it contains no visi
ble content, create a new |
| 943 // block but don't try and move content into it, since there's nothi
ng for moveParagraphs to move. | 943 // block but don't try and move content into it, since there's nothi
ng for moveParagraphs to move. |
| 944 if (!hasRenderedNonAnonymousDescendantsWithHeight(upstreamStart.anch
orNode()->layoutObject())) | 944 if (!hasRenderedNonAnonymousDescendantsWithHeight(upstreamStart.anch
orNode()->layoutObject())) |
| 945 return insertNewDefaultParagraphElementAt(upstreamStart); | 945 return insertNewDefaultParagraphElementAt(upstreamStart); |
| 946 } else if (isBlock(upstreamEnd.anchorNode())) { | 946 } else if (isEnclosingBlock(upstreamEnd.anchorNode())) { |
| 947 if (!upstreamEnd.anchorNode()->isDescendantOf(upstreamStart.anchorNo
de())) { | 947 if (!upstreamEnd.anchorNode()->isDescendantOf(upstreamStart.anchorNo
de())) { |
| 948 // If the paragraph end is a descendant of paragraph start, then
we need to run | 948 // If the paragraph end is a descendant of paragraph start, then
we need to run |
| 949 // the rest of this function. If not, we can bail here. | 949 // the rest of this function. If not, we can bail here. |
| 950 return nullptr; | 950 return nullptr; |
| 951 } | 951 } |
| 952 } else if (enclosingBlock(upstreamEnd.anchorNode()) != upstreamStart.anc
horNode()) { | 952 } else if (enclosingBlock(upstreamEnd.anchorNode()) != upstreamStart.anc
horNode()) { |
| 953 // It should be an ancestor of the paragraph start. | 953 // It should be an ancestor of the paragraph start. |
| 954 // We can bail as we have a full block to work with. | 954 // We can bail as we have a full block to work with. |
| 955 return nullptr; | 955 return nullptr; |
| 956 } else if (isEndOfEditableOrNonEditableContent(visibleEnd)) { | 956 } else if (isEndOfEditableOrNonEditableContent(visibleEnd)) { |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1092 return; | 1092 return; |
| 1093 | 1093 |
| 1094 // Normally deletion will leave a br as a placeholder. | 1094 // Normally deletion will leave a br as a placeholder. |
| 1095 if (isHTMLBRElement(*node)) { | 1095 if (isHTMLBRElement(*node)) { |
| 1096 removeNodeAndPruneAncestors(node, destinationNode); | 1096 removeNodeAndPruneAncestors(node, destinationNode); |
| 1097 | 1097 |
| 1098 // If the selection to move was empty and in an empty block that | 1098 // If the selection to move was empty and in an empty block that |
| 1099 // doesn't require a placeholder to prop itself open (like a bordere
d | 1099 // doesn't require a placeholder to prop itself open (like a bordere
d |
| 1100 // div or an li), remove it during the move (the list removal code | 1100 // div or an li), remove it during the move (the list removal code |
| 1101 // expects this behavior). | 1101 // expects this behavior). |
| 1102 } else if (isBlock(node)) { | 1102 } else if (isEnclosingBlock(node)) { |
| 1103 // If caret position after deletion and destination position coincid
es, | 1103 // If caret position after deletion and destination position coincid
es, |
| 1104 // node should not be removed. | 1104 // node should not be removed. |
| 1105 if (!rendersInDifferentPosition(position, destination.deepEquivalent
())) { | 1105 if (!rendersInDifferentPosition(position, destination.deepEquivalent
())) { |
| 1106 prune(node, destinationNode); | 1106 prune(node, destinationNode); |
| 1107 return; | 1107 return; |
| 1108 } | 1108 } |
| 1109 removeNodeAndPruneAncestors(node, destinationNode); | 1109 removeNodeAndPruneAncestors(node, destinationNode); |
| 1110 } else if (lineBreakExistsAtPosition(position)) { | 1110 } else if (lineBreakExistsAtPosition(position)) { |
| 1111 // There is a preserved '\n' at caretAfterDelete. | 1111 // There is a preserved '\n' at caretAfterDelete. |
| 1112 // We can safely assume this is a text node. | 1112 // We can safely assume this is a text node. |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1421 return original; | 1421 return original; |
| 1422 | 1422 |
| 1423 VisiblePosition visiblePos(original); | 1423 VisiblePosition visiblePos(original); |
| 1424 Element* enclosingAnchor = enclosingAnchorElement(original); | 1424 Element* enclosingAnchor = enclosingAnchorElement(original); |
| 1425 Position result = original; | 1425 Position result = original; |
| 1426 | 1426 |
| 1427 if (!enclosingAnchor) | 1427 if (!enclosingAnchor) |
| 1428 return result; | 1428 return result; |
| 1429 | 1429 |
| 1430 // Don't avoid block level anchors, because that would insert content into t
he wrong paragraph. | 1430 // Don't avoid block level anchors, because that would insert content into t
he wrong paragraph. |
| 1431 if (enclosingAnchor && !isBlock(enclosingAnchor)) { | 1431 if (enclosingAnchor && !isEnclosingBlock(enclosingAnchor)) { |
| 1432 VisiblePosition firstInAnchor(firstPositionInNode(enclosingAnchor)); | 1432 VisiblePosition firstInAnchor(firstPositionInNode(enclosingAnchor)); |
| 1433 VisiblePosition lastInAnchor(lastPositionInNode(enclosingAnchor)); | 1433 VisiblePosition lastInAnchor(lastPositionInNode(enclosingAnchor)); |
| 1434 // If visually just after the anchor, insert *inside* the anchor unless
it's the last | 1434 // If visually just after the anchor, insert *inside* the anchor unless
it's the last |
| 1435 // VisiblePosition in the document, to match NSTextView. | 1435 // VisiblePosition in the document, to match NSTextView. |
| 1436 if (visiblePos.deepEquivalent() == lastInAnchor.deepEquivalent()) { | 1436 if (visiblePos.deepEquivalent() == lastInAnchor.deepEquivalent()) { |
| 1437 // Make sure anchors are pushed down before avoiding them so that we
don't | 1437 // Make sure anchors are pushed down before avoiding them so that we
don't |
| 1438 // also avoid structural elements like lists and blocks (5142012). | 1438 // also avoid structural elements like lists and blocks (5142012). |
| 1439 if (original.anchorNode() != enclosingAnchor && original.anchorNode(
)->parentNode() != enclosingAnchor) { | 1439 if (original.anchorNode() != enclosingAnchor && original.anchorNode(
)->parentNode() != enclosingAnchor) { |
| 1440 pushAnchorElementDown(enclosingAnchor); | 1440 pushAnchorElementDown(enclosingAnchor); |
| 1441 enclosingAnchor = enclosingAnchorElement(original); | 1441 enclosingAnchor = enclosingAnchorElement(original); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1502 } | 1502 } |
| 1503 | 1503 |
| 1504 DEFINE_TRACE(CompositeEditCommand) | 1504 DEFINE_TRACE(CompositeEditCommand) |
| 1505 { | 1505 { |
| 1506 visitor->trace(m_commands); | 1506 visitor->trace(m_commands); |
| 1507 visitor->trace(m_composition); | 1507 visitor->trace(m_composition); |
| 1508 EditCommand::trace(visitor); | 1508 EditCommand::trace(visitor); |
| 1509 } | 1509 } |
| 1510 | 1510 |
| 1511 } // namespace blink | 1511 } // namespace blink |
| OLD | NEW |