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

Side by Side Diff: Source/core/editing/InsertListCommand.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/IndentOutdentCommand.cpp ('k') | Source/core/editing/InsertTextCommand.cpp » ('j') | 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) 2006, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2010 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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 bool forceCreateList = !selectionHasListOfType(selection, listTag); 137 bool forceCreateList = !selectionHasListOfType(selection, listTag);
138 138
139 RefPtr<Range> currentSelection = endingSelection().firstRange(); 139 RefPtr<Range> currentSelection = endingSelection().firstRange();
140 VisiblePosition startOfCurrentParagraph = startOfSelection; 140 VisiblePosition startOfCurrentParagraph = startOfSelection;
141 while (!inSameParagraph(startOfCurrentParagraph, startOfLastParagrap h, CanCrossEditingBoundary)) { 141 while (!inSameParagraph(startOfCurrentParagraph, startOfLastParagrap h, CanCrossEditingBoundary)) {
142 // doApply() may operate on and remove the last paragraph of the selection from the document 142 // doApply() may operate on and remove the last paragraph of the selection from the document
143 // if it's in the same list item as startOfCurrentParagraph. Re turn early to avoid an 143 // if it's in the same list item as startOfCurrentParagraph. Re turn early to avoid an
144 // infinite loop and because there is no more work to be done. 144 // infinite loop and because there is no more work to be done.
145 // FIXME(<rdar://problem/5983974>): The endingSelection() may be incorrect here. Compute 145 // FIXME(<rdar://problem/5983974>): The endingSelection() may be incorrect here. Compute
146 // the new location of endOfSelection and use it as the end of t he new selection. 146 // the new location of endOfSelection and use it as the end of t he new selection.
147 if (!startOfLastParagraph.deepEquivalent().anchorNode()->inDocum ent()) 147 if (!startOfLastParagraph.deepEquivalent().inDocument())
148 return; 148 return;
149 setEndingSelection(startOfCurrentParagraph); 149 setEndingSelection(startOfCurrentParagraph);
150 150
151 // Save and restore endOfSelection and startOfLastParagraph when necessary 151 // Save and restore endOfSelection and startOfLastParagraph when necessary
152 // since moveParagraph and movePragraphWithClones can remove nod es. 152 // since moveParagraph and movePragraphWithClones can remove nod es.
153 // FIXME: This is an inefficient way to keep selection alive bec ause indexForVisiblePosition walks from 153 // FIXME: This is an inefficient way to keep selection alive bec ause indexForVisiblePosition walks from
154 // the beginning of the document to the endOfSelection everytime this code is executed. 154 // the beginning of the document to the endOfSelection everytime this code is executed.
155 // But not using index is hard because there are so many ways we can lose selection inside doApplyForSingleParagraph. 155 // But not using index is hard because there are so many ways we can lose selection inside doApplyForSingleParagraph.
156 RefPtr<ContainerNode> scope; 156 RefPtr<ContainerNode> scope;
157 int indexForEndOfSelection = indexForVisiblePosition(endOfSelect ion, scope); 157 int indexForEndOfSelection = indexForVisiblePosition(endOfSelect ion, scope);
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 if (listElement) 389 if (listElement)
390 return mergeWithNeighboringLists(listElement); 390 return mergeWithNeighboringLists(listElement);
391 391
392 if (canMergeLists(previousList, nextList)) 392 if (canMergeLists(previousList, nextList))
393 mergeIdenticalElements(previousList, nextList); 393 mergeIdenticalElements(previousList, nextList);
394 394
395 return listElement; 395 return listElement;
396 } 396 }
397 397
398 } 398 }
OLDNEW
« no previous file with comments | « Source/core/editing/IndentOutdentCommand.cpp ('k') | Source/core/editing/InsertTextCommand.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698