OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2005, 2006, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2005, 2006, 2008 Apple Inc. All rights reserved. |
3 * Copyright (C) 2009, 2010, 2011 Google Inc. All rights reserved. | 3 * Copyright (C) 2009, 2010, 2011 Google Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 1108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1119 insertionBlock = 0; | 1119 insertionBlock = 0; |
1120 | 1120 |
1121 VisiblePosition startOfInsertedContent = firstPositionInOrBeforeNode(inserte dNodes.firstNodeInserted()); | 1121 VisiblePosition startOfInsertedContent = firstPositionInOrBeforeNode(inserte dNodes.firstNodeInserted()); |
1122 | 1122 |
1123 // We inserted before the insertionBlock to prevent nesting, and the content before the insertionBlock wasn't in its own block and | 1123 // We inserted before the insertionBlock to prevent nesting, and the content before the insertionBlock wasn't in its own block and |
1124 // didn't have a br after it, so the inserted content ended up in the same p aragraph. | 1124 // didn't have a br after it, so the inserted content ended up in the same p aragraph. |
1125 if (insertionBlock && insertionPos.deprecatedNode() == insertionBlock->paren tNode() && (unsigned)insertionPos.deprecatedEditingOffset() < insertionBlock->no deIndex() && !isStartOfParagraph(startOfInsertedContent)) | 1125 if (insertionBlock && insertionPos.deprecatedNode() == insertionBlock->paren tNode() && (unsigned)insertionPos.deprecatedEditingOffset() < insertionBlock->no deIndex() && !isStartOfParagraph(startOfInsertedContent)) |
1126 insertNodeAt(createBreakElement(document()).get(), startOfInsertedConten t.deepEquivalent()); | 1126 insertNodeAt(createBreakElement(document()).get(), startOfInsertedConten t.deepEquivalent()); |
1127 | 1127 |
1128 if (endBR && (plainTextFragment || shouldRemoveEndBR(endBR, originalVisPosBe foreEndBR))) { | 1128 if (endBR && (plainTextFragment || shouldRemoveEndBR(endBR, originalVisPosBe foreEndBR))) { |
1129 RefPtr<Node> parent = endBR->parentNode(); | 1129 // Don't remove br if we are replacing plain texts with content ending w ith newline |
1130 insertedNodes.willRemoveNode(*endBR); | 1130 if (!(fragment.hasInterchangeNewlineAtEnd() && selectionIsPlainText)) { |
yosin_UTC9
2013/12/20 01:23:06
nit: Please merge L1130 condition into L1129.
| |
1131 removeNode(endBR); | 1131 RefPtr<Node> parent = endBR->parentNode(); |
1132 if (Node* nodeToRemove = highestNodeToRemoveInPruning(parent.get())) { | 1132 insertedNodes.willRemoveNode(*endBR); |
1133 insertedNodes.willRemoveNode(*nodeToRemove); | 1133 removeNode(endBR); |
1134 removeNode(nodeToRemove); | 1134 if (Node* nodeToRemove = highestNodeToRemoveInPruning(parent.get())) { |
1135 insertedNodes.willRemoveNode(*nodeToRemove); | |
1136 removeNode(nodeToRemove); | |
1137 } | |
1135 } | 1138 } |
1136 } | 1139 } |
1137 | 1140 |
1138 makeInsertedContentRoundTrippableWithHTMLTreeBuilder(insertedNodes); | 1141 makeInsertedContentRoundTrippableWithHTMLTreeBuilder(insertedNodes); |
1139 | 1142 |
1140 removeRedundantStylesAndKeepStyleSpanInline(insertedNodes); | 1143 removeRedundantStylesAndKeepStyleSpanInline(insertedNodes); |
1141 | 1144 |
1142 if (m_sanitizeFragment) | 1145 if (m_sanitizeFragment) |
1143 applyCommandToComposite(SimplifyMarkupCommand::create(document(), insert edNodes.firstNodeInserted(), insertedNodes.pastLastLeaf())); | 1146 applyCommandToComposite(SimplifyMarkupCommand::create(document(), insert edNodes.firstNodeInserted(), insertedNodes.pastLastLeaf())); |
1144 | 1147 |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1494 removeNodeAndPruneAncestors(nodeAfterInsertionPos.get()); | 1497 removeNodeAndPruneAncestors(nodeAfterInsertionPos.get()); |
1495 | 1498 |
1496 VisibleSelection selectionAfterReplace(m_selectReplacement ? start : end, en d); | 1499 VisibleSelection selectionAfterReplace(m_selectReplacement ? start : end, en d); |
1497 | 1500 |
1498 setEndingSelection(selectionAfterReplace); | 1501 setEndingSelection(selectionAfterReplace); |
1499 | 1502 |
1500 return true; | 1503 return true; |
1501 } | 1504 } |
1502 | 1505 |
1503 } // namespace WebCore | 1506 } // namespace WebCore |
OLD | NEW |