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

Side by Side Diff: Source/WebCore/editing/InsertListCommand.cpp

Issue 9567015: Merge 108009 (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/963/
Patch Set: Created 8 years, 9 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
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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 // the new location of endOfSelection and use it as the end of t he new selection. 145 // the new location of endOfSelection and use it as the end of t he new selection.
146 if (!startOfLastParagraph.deepEquivalent().anchorNode()->inDocum ent()) 146 if (!startOfLastParagraph.deepEquivalent().anchorNode()->inDocum ent())
147 return; 147 return;
148 setEndingSelection(startOfCurrentParagraph); 148 setEndingSelection(startOfCurrentParagraph);
149 149
150 // Save and restore endOfSelection and startOfLastParagraph when necessary 150 // Save and restore endOfSelection and startOfLastParagraph when necessary
151 // since moveParagraph and movePragraphWithClones can remove nod es. 151 // since moveParagraph and movePragraphWithClones can remove nod es.
152 // FIXME: This is an inefficient way to keep selection alive bec ause indexForVisiblePosition walks from 152 // FIXME: This is an inefficient way to keep selection alive bec ause indexForVisiblePosition walks from
153 // the beginning of the document to the endOfSelection everytime this code is executed. 153 // the beginning of the document to the endOfSelection everytime this code is executed.
154 // But not using index is hard because there are so many ways we can lose selection inside doApplyForSingleParagraph. 154 // But not using index is hard because there are so many ways we can lose selection inside doApplyForSingleParagraph.
155 Element* scope = 0; 155 RefPtr<Element> scope;
156 int indexForEndOfSelection = indexForVisiblePosition(endOfSelect ion, &scope); 156 int indexForEndOfSelection = indexForVisiblePosition(endOfSelect ion, scope);
157 doApplyForSingleParagraph(forceCreateList, listTag, currentSelec tion.get()); 157 doApplyForSingleParagraph(forceCreateList, listTag, currentSelec tion.get());
158 if (endOfSelection.isNull() || endOfSelection.isOrphan() || star tOfLastParagraph.isNull() || startOfLastParagraph.isOrphan()) { 158 if (endOfSelection.isNull() || endOfSelection.isOrphan() || star tOfLastParagraph.isNull() || startOfLastParagraph.isOrphan()) {
159 endOfSelection = visiblePositionForIndex(indexForEndOfSelect ion, scope); 159 endOfSelection = visiblePositionForIndex(indexForEndOfSelect ion, scope.get());
160 // If endOfSelection is null, then some contents have been d eleted from the document. 160 // If endOfSelection is null, then some contents have been d eleted from the document.
161 // This should never happen and if it did, exit early immedi ately because we've lost the loop invariant. 161 // This should never happen and if it did, exit early immedi ately because we've lost the loop invariant.
162 ASSERT(endOfSelection.isNotNull()); 162 ASSERT(endOfSelection.isNotNull());
163 if (endOfSelection.isNull()) 163 if (endOfSelection.isNull())
164 return; 164 return;
165 startOfLastParagraph = startOfParagraph(endOfSelection, CanS kipOverEditingBoundary); 165 startOfLastParagraph = startOfParagraph(endOfSelection, CanS kipOverEditingBoundary);
166 } 166 }
167 167
168 // Fetch the start of the selection after moving the first parag raph, 168 // Fetch the start of the selection after moving the first parag raph,
169 // because moving the paragraph will invalidate the original sta rt. 169 // because moving the paragraph will invalidate the original sta rt.
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 if (listElement) 387 if (listElement)
388 return mergeWithNeighboringLists(listElement); 388 return mergeWithNeighboringLists(listElement);
389 389
390 if (canMergeLists(previousList, nextList)) 390 if (canMergeLists(previousList, nextList))
391 mergeIdenticalElements(previousList, nextList); 391 mergeIdenticalElements(previousList, nextList);
392 392
393 return listElement; 393 return listElement;
394 } 394 }
395 395
396 } 396 }
OLDNEW
« no previous file with comments | « Source/WebCore/editing/ApplyBlockElementCommand.cpp ('k') | Source/WebCore/editing/htmlediting.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698