| OLD | NEW |
| 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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 // Fetch the start of the selection after moving the first parag
raph, | 167 // Fetch the start of the selection after moving the first parag
raph, |
| 168 // because moving the paragraph will invalidate the original sta
rt. | 168 // because moving the paragraph will invalidate the original sta
rt. |
| 169 // We'll use the new start to restore the original selection aft
er | 169 // We'll use the new start to restore the original selection aft
er |
| 170 // we modified all selected paragraphs. | 170 // we modified all selected paragraphs. |
| 171 if (startOfCurrentParagraph == startOfSelection) | 171 if (startOfCurrentParagraph == startOfSelection) |
| 172 startOfSelection = endingSelection().visibleStart(); | 172 startOfSelection = endingSelection().visibleStart(); |
| 173 | 173 |
| 174 startOfCurrentParagraph = startOfNextParagraph(endingSelection()
.visibleStart()); | 174 startOfCurrentParagraph = startOfNextParagraph(endingSelection()
.visibleStart()); |
| 175 } | 175 } |
| 176 setEndingSelection(endOfSelection); | 176 setEndingSelection(endOfSelection); |
| 177 currentSelection = endingSelection().firstRange(); |
| 177 doApplyForSingleParagraph(forceCreateList, listTag, currentSelection
.get()); | 178 doApplyForSingleParagraph(forceCreateList, listTag, currentSelection
.get()); |
| 178 // Fetch the end of the selection, for the reason mentioned above. | 179 // Fetch the end of the selection, for the reason mentioned above. |
| 179 if (endOfSelection.isNull() || endOfSelection.isOrphan()) { | 180 endOfSelection = endingSelection().visibleEnd(); |
| 180 endOfSelection = visiblePositionForIndex(indexForEndOfSelection,
scope.get()); | |
| 181 if (endOfSelection.isNull()) | |
| 182 return; | |
| 183 } | |
| 184 setEndingSelection(VisibleSelection(startOfSelection, endOfSelection
, endingSelection().isDirectional())); | 181 setEndingSelection(VisibleSelection(startOfSelection, endOfSelection
, endingSelection().isDirectional())); |
| 185 return; | 182 return; |
| 186 } | 183 } |
| 187 } | 184 } |
| 188 | 185 |
| 189 doApplyForSingleParagraph(false, listTag, endingSelection().firstRange().get
()); | 186 doApplyForSingleParagraph(false, listTag, endingSelection().firstRange().get
()); |
| 190 } | 187 } |
| 191 | 188 |
| 192 void InsertListCommand::doApplyForSingleParagraph(bool forceCreateList, const Qu
alifiedName& listTag, Range* currentSelection) | 189 void InsertListCommand::doApplyForSingleParagraph(bool forceCreateList, const Qu
alifiedName& listTag, Range* currentSelection) |
| 193 { | 190 { |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 if (listElement) | 388 if (listElement) |
| 392 return mergeWithNeighboringLists(listElement); | 389 return mergeWithNeighboringLists(listElement); |
| 393 | 390 |
| 394 if (canMergeLists(previousList, nextList)) | 391 if (canMergeLists(previousList, nextList)) |
| 395 mergeIdenticalElements(previousList, nextList); | 392 mergeIdenticalElements(previousList, nextList); |
| 396 | 393 |
| 397 return listElement; | 394 return listElement; |
| 398 } | 395 } |
| 399 | 396 |
| 400 } | 397 } |
| OLD | NEW |