| 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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 | 139 |
| 140 const HTMLQualifiedName& listTag = (m_type == OrderedList) ? olTag : ulTag; | 140 const HTMLQualifiedName& listTag = (m_type == OrderedList) ? olTag : ulTag; |
| 141 if (endingSelection().isRange()) { | 141 if (endingSelection().isRange()) { |
| 142 bool forceListCreation = false; | 142 bool forceListCreation = false; |
| 143 VisibleSelection selection = selectionForParagraphIteration(endingSelect
ion()); | 143 VisibleSelection selection = selectionForParagraphIteration(endingSelect
ion()); |
| 144 ASSERT(selection.isRange()); | 144 ASSERT(selection.isRange()); |
| 145 VisiblePosition startOfSelection = selection.visibleStart(); | 145 VisiblePosition startOfSelection = selection.visibleStart(); |
| 146 VisiblePosition endOfSelection = selection.visibleEnd(); | 146 VisiblePosition endOfSelection = selection.visibleEnd(); |
| 147 VisiblePosition startOfLastParagraph = startOfParagraph(endOfSelection,
CanSkipOverEditingBoundary); | 147 VisiblePosition startOfLastParagraph = startOfParagraph(endOfSelection,
CanSkipOverEditingBoundary); |
| 148 | 148 |
| 149 RefPtrWillBeRawPtr<Range> currentSelection = endingSelection().firstRang
e(); | 149 RefPtrWillBeRawPtr<Range> currentSelection = firstRangeOf(endingSelectio
n()); |
| 150 RefPtrWillBeRawPtr<ContainerNode> scopeForStartOfSelection = nullptr; | 150 RefPtrWillBeRawPtr<ContainerNode> scopeForStartOfSelection = nullptr; |
| 151 RefPtrWillBeRawPtr<ContainerNode> scopeForEndOfSelection = nullptr; | 151 RefPtrWillBeRawPtr<ContainerNode> scopeForEndOfSelection = nullptr; |
| 152 // FIXME: This is an inefficient way to keep selection alive because | 152 // FIXME: This is an inefficient way to keep selection alive because |
| 153 // indexForVisiblePosition walks from the beginning of the document to t
he | 153 // indexForVisiblePosition walks from the beginning of the document to t
he |
| 154 // endOfSelection everytime this code is executed. But not using index i
s hard | 154 // endOfSelection everytime this code is executed. But not using index i
s hard |
| 155 // because there are so many ways we can los eselection inside doApplyFo
rSingleParagraph. | 155 // because there are so many ways we can los eselection inside doApplyFo
rSingleParagraph. |
| 156 int indexForStartOfSelection = indexForVisiblePosition(startOfSelection,
scopeForStartOfSelection); | 156 int indexForStartOfSelection = indexForVisiblePosition(startOfSelection,
scopeForStartOfSelection); |
| 157 int indexForEndOfSelection = indexForVisiblePosition(endOfSelection, sco
peForEndOfSelection); | 157 int indexForEndOfSelection = indexForVisiblePosition(endOfSelection, sco
peForEndOfSelection); |
| 158 | 158 |
| 159 if (startOfParagraph(startOfSelection, CanSkipOverEditingBoundary).deepE
quivalent() != startOfLastParagraph.deepEquivalent()) { | 159 if (startOfParagraph(startOfSelection, CanSkipOverEditingBoundary).deepE
quivalent() != startOfLastParagraph.deepEquivalent()) { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 } | 197 } |
| 198 if (startOfSelection.isNull() || startOfSelection.isOrphan()) { | 198 if (startOfSelection.isNull() || startOfSelection.isOrphan()) { |
| 199 startOfSelection = visiblePositionForIndex(indexForStartOfSelection,
scopeForStartOfSelection.get()); | 199 startOfSelection = visiblePositionForIndex(indexForStartOfSelection,
scopeForStartOfSelection.get()); |
| 200 if (startOfSelection.isNull()) | 200 if (startOfSelection.isNull()) |
| 201 return; | 201 return; |
| 202 } | 202 } |
| 203 setEndingSelection(VisibleSelection(startOfSelection, endOfSelection, en
dingSelection().isDirectional())); | 203 setEndingSelection(VisibleSelection(startOfSelection, endOfSelection, en
dingSelection().isDirectional())); |
| 204 return; | 204 return; |
| 205 } | 205 } |
| 206 | 206 |
| 207 ASSERT(endingSelection().firstRange()); | 207 ASSERT(firstRangeOf(endingSelection())); |
| 208 doApplyForSingleParagraph(false, listTag, *endingSelection().firstRange()); | 208 doApplyForSingleParagraph(false, listTag, *firstRangeOf(endingSelection())); |
| 209 } | 209 } |
| 210 | 210 |
| 211 bool InsertListCommand::doApplyForSingleParagraph(bool forceCreateList, const HT
MLQualifiedName& listTag, Range& currentSelection) | 211 bool InsertListCommand::doApplyForSingleParagraph(bool forceCreateList, const HT
MLQualifiedName& listTag, Range& currentSelection) |
| 212 { | 212 { |
| 213 // FIXME: This will produce unexpected results for a selection that starts j
ust before a | 213 // FIXME: This will produce unexpected results for a selection that starts j
ust before a |
| 214 // table and ends inside the first cell, selectionForParagraphIteration shou
ld probably | 214 // table and ends inside the first cell, selectionForParagraphIteration shou
ld probably |
| 215 // be renamed and deployed inside setEndingSelection(). | 215 // be renamed and deployed inside setEndingSelection(). |
| 216 Node* selectionNode = endingSelection().start().anchorNode(); | 216 Node* selectionNode = endingSelection().start().anchorNode(); |
| 217 Node* listChildNode = enclosingListChild(selectionNode); | 217 Node* listChildNode = enclosingListChild(selectionNode); |
| 218 bool switchListType = false; | 218 bool switchListType = false; |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 return listElement; | 427 return listElement; |
| 428 } | 428 } |
| 429 | 429 |
| 430 DEFINE_TRACE(InsertListCommand) | 430 DEFINE_TRACE(InsertListCommand) |
| 431 { | 431 { |
| 432 visitor->trace(m_listElement); | 432 visitor->trace(m_listElement); |
| 433 CompositeEditCommand::trace(visitor); | 433 CompositeEditCommand::trace(visitor); |
| 434 } | 434 } |
| 435 | 435 |
| 436 } | 436 } |
| OLD | NEW |