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

Side by Side Diff: Source/core/editing/ReplaceSelectionCommand.cpp

Issue 23450030: Introduce Position::inDocument() (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/editing/MoveSelectionCommand.cpp ('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, 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 1146 matching lines...) Expand 10 before | Expand all | Expand 10 after
1157 // before the selection that was pasted into would also move content aft er 1157 // before the selection that was pasted into would also move content aft er
1158 // the selection that was pasted into if: only one paragraph was being p asted, 1158 // the selection that was pasted into if: only one paragraph was being p asted,
1159 // and it was not wrapped in a block, the selection that was pasted into ended 1159 // and it was not wrapped in a block, the selection that was pasted into ended
1160 // at the end of a block and the next paragraph didn't start at the star t of a block. 1160 // at the end of a block and the next paragraph didn't start at the star t of a block.
1161 // Insert a line break just after the inserted content to separate it fr om what 1161 // Insert a line break just after the inserted content to separate it fr om what
1162 // comes after and prevent that from happening. 1162 // comes after and prevent that from happening.
1163 VisiblePosition endOfInsertedContent = positionAtEndOfInsertedContent(); 1163 VisiblePosition endOfInsertedContent = positionAtEndOfInsertedContent();
1164 if (startOfParagraph(endOfInsertedContent) == startOfParagraphToMove) { 1164 if (startOfParagraph(endOfInsertedContent) == startOfParagraphToMove) {
1165 insertNodeAt(createBreakElement(document()).get(), endOfInsertedCont ent.deepEquivalent()); 1165 insertNodeAt(createBreakElement(document()).get(), endOfInsertedCont ent.deepEquivalent());
1166 // Mutation events (bug 22634) triggered by inserting the <br> might have removed the content we're about to move 1166 // Mutation events (bug 22634) triggered by inserting the <br> might have removed the content we're about to move
1167 if (!startOfParagraphToMove.deepEquivalent().anchorNode()->inDocumen t()) 1167 if (!startOfParagraphToMove.deepEquivalent().inDocument())
1168 return; 1168 return;
1169 } 1169 }
1170 1170
1171 // FIXME: Maintain positions for the start and end of inserted content i nstead of keeping nodes. The nodes are 1171 // FIXME: Maintain positions for the start and end of inserted content i nstead of keeping nodes. The nodes are
1172 // only ever used to create positions where inserted content starts/ends . 1172 // only ever used to create positions where inserted content starts/ends .
1173 moveParagraph(startOfParagraphToMove, endOfParagraph(startOfParagraphToM ove), destination); 1173 moveParagraph(startOfParagraphToMove, endOfParagraph(startOfParagraphToM ove), destination);
1174 m_startOfInsertedContent = endingSelection().visibleStart().deepEquivale nt().downstream(); 1174 m_startOfInsertedContent = endingSelection().visibleStart().deepEquivale nt().downstream();
1175 if (m_endOfInsertedContent.isOrphan()) 1175 if (m_endOfInsertedContent.isOrphan())
1176 m_endOfInsertedContent = endingSelection().visibleEnd().deepEquivale nt().upstream(); 1176 m_endOfInsertedContent = endingSelection().visibleEnd().deepEquivale nt().upstream();
1177 } 1177 }
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
1487 removeNodeAndPruneAncestors(nodeAfterInsertionPos.get()); 1487 removeNodeAndPruneAncestors(nodeAfterInsertionPos.get());
1488 1488
1489 VisibleSelection selectionAfterReplace(m_selectReplacement ? start : end, en d); 1489 VisibleSelection selectionAfterReplace(m_selectReplacement ? start : end, en d);
1490 1490
1491 setEndingSelection(selectionAfterReplace); 1491 setEndingSelection(selectionAfterReplace);
1492 1492
1493 return true; 1493 return true;
1494 } 1494 }
1495 1495
1496 } // namespace WebCore 1496 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/editing/MoveSelectionCommand.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698