OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2005 Apple Computer, Inc. All rights reserved. | 2 * Copyright (C) 2005 Apple Computer, 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 return next.isNull() || !next.deepEquivalent().anchorNode()->isDescendantOf(
node); | 65 return next.isNull() || !next.deepEquivalent().anchorNode()->isDescendantOf(
node); |
66 } | 66 } |
67 | 67 |
68 } // namespace | 68 } // namespace |
69 | 69 |
70 BreakBlockquoteCommand::BreakBlockquoteCommand(Document& document) | 70 BreakBlockquoteCommand::BreakBlockquoteCommand(Document& document) |
71 : CompositeEditCommand(document) | 71 : CompositeEditCommand(document) |
72 { | 72 { |
73 } | 73 } |
74 | 74 |
75 void BreakBlockquoteCommand::doApply(EditingState*) | 75 void BreakBlockquoteCommand::doApply(EditingState* editingState) |
76 { | 76 { |
77 if (endingSelection().isNone()) | 77 if (endingSelection().isNone()) |
78 return; | 78 return; |
79 | 79 |
80 // Delete the current selection. | 80 // Delete the current selection. |
81 if (endingSelection().isRange()) | 81 if (endingSelection().isRange()) { |
82 deleteSelection(ASSERT_NO_EDITING_ABORT, false, false); | 82 deleteSelection(editingState, false, false); |
| 83 if (editingState->isAborted()) |
| 84 return; |
| 85 } |
83 | 86 |
84 // This is a scenario that should never happen, but we want to | 87 // This is a scenario that should never happen, but we want to |
85 // make sure we don't dereference a null pointer below. | 88 // make sure we don't dereference a null pointer below. |
86 | 89 |
87 ASSERT(!endingSelection().isNone()); | 90 ASSERT(!endingSelection().isNone()); |
88 | 91 |
89 if (endingSelection().isNone()) | 92 if (endingSelection().isNone()) |
90 return; | 93 return; |
91 | 94 |
92 VisiblePosition visiblePos = endingSelection().visibleStart(); | 95 VisiblePosition visiblePos = endingSelection().visibleStart(); |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 if (isHTMLOListElement(*clonedChild)) { | 187 if (isHTMLOListElement(*clonedChild)) { |
185 Node* listChildNode = i > 1 ? ancestors[i - 2].get() : startNode; | 188 Node* listChildNode = i > 1 ? ancestors[i - 2].get() : startNode; |
186 // The first child of the cloned list might not be a list item eleme
nt, | 189 // The first child of the cloned list might not be a list item eleme
nt, |
187 // find the first one so that we know where to start numbering. | 190 // find the first one so that we know where to start numbering. |
188 while (listChildNode && !isHTMLLIElement(*listChildNode)) | 191 while (listChildNode && !isHTMLLIElement(*listChildNode)) |
189 listChildNode = listChildNode->nextSibling(); | 192 listChildNode = listChildNode->nextSibling(); |
190 if (isListItem(listChildNode)) | 193 if (isListItem(listChildNode)) |
191 setNodeAttribute(clonedChild, startAttr, AtomicString::number(to
LayoutListItem(listChildNode->layoutObject())->value())); | 194 setNodeAttribute(clonedChild, startAttr, AtomicString::number(to
LayoutListItem(listChildNode->layoutObject())->value())); |
192 } | 195 } |
193 | 196 |
194 appendNode(clonedChild.get(), clonedAncestor.get()); | 197 appendNode(clonedChild.get(), clonedAncestor.get(), editingState); |
| 198 if (editingState->isAborted()) |
| 199 return; |
195 clonedAncestor = clonedChild; | 200 clonedAncestor = clonedChild; |
196 } | 201 } |
197 | 202 |
198 moveRemainingSiblingsToNewParent(startNode, 0, clonedAncestor); | 203 moveRemainingSiblingsToNewParent(startNode, 0, clonedAncestor, editingState)
; |
| 204 if (editingState->isAborted()) |
| 205 return; |
199 | 206 |
200 if (!ancestors.isEmpty()) { | 207 if (!ancestors.isEmpty()) { |
201 // Split the tree up the ancestor chain until the topBlockquote | 208 // Split the tree up the ancestor chain until the topBlockquote |
202 // Throughout this loop, clonedParent is the clone of ancestor's parent. | 209 // Throughout this loop, clonedParent is the clone of ancestor's parent. |
203 // This is so we can clone ancestor's siblings and place the clones | 210 // This is so we can clone ancestor's siblings and place the clones |
204 // into the clone corresponding to the ancestor's parent. | 211 // into the clone corresponding to the ancestor's parent. |
205 RefPtrWillBeRawPtr<Element> ancestor = nullptr; | 212 RefPtrWillBeRawPtr<Element> ancestor = nullptr; |
206 RefPtrWillBeRawPtr<Element> clonedParent = nullptr; | 213 RefPtrWillBeRawPtr<Element> clonedParent = nullptr; |
207 for (ancestor = ancestors.first(), clonedParent = clonedAncestor->parent
Element(); | 214 for (ancestor = ancestors.first(), clonedParent = clonedAncestor->parent
Element(); |
208 ancestor && ancestor != topBlockquote; | 215 ancestor && ancestor != topBlockquote; |
209 ancestor = ancestor->parentElement(), clonedParent = clonedParent->p
arentElement()) | 216 ancestor = ancestor->parentElement(), clonedParent = clonedParent->p
arentElement()) { |
210 moveRemainingSiblingsToNewParent(ancestor->nextSibling(), 0, clonedP
arent); | 217 moveRemainingSiblingsToNewParent(ancestor->nextSibling(), 0, clonedP
arent, editingState); |
| 218 if (editingState->isAborted()) |
| 219 return; |
| 220 } |
211 | 221 |
212 // If the startNode's original parent is now empty, remove it | 222 // If the startNode's original parent is now empty, remove it |
213 Element* originalParent = ancestors.first().get(); | 223 Element* originalParent = ancestors.first().get(); |
214 if (!originalParent->hasChildren()) | 224 if (!originalParent->hasChildren()) { |
215 removeNode(originalParent); | 225 removeNode(originalParent, editingState); |
| 226 if (editingState->isAborted()) |
| 227 return; |
| 228 } |
216 } | 229 } |
217 | 230 |
218 // Make sure the cloned block quote renders. | 231 // Make sure the cloned block quote renders. |
219 addBlockPlaceholderIfNeeded(clonedBlockquote.get()); | 232 addBlockPlaceholderIfNeeded(clonedBlockquote.get()); |
220 | 233 |
221 // Put the selection right before the break. | 234 // Put the selection right before the break. |
222 setEndingSelection(VisibleSelection(positionBeforeNode(breakElement.get()),
TextAffinity::Downstream, endingSelection().isDirectional())); | 235 setEndingSelection(VisibleSelection(positionBeforeNode(breakElement.get()),
TextAffinity::Downstream, endingSelection().isDirectional())); |
223 rebalanceWhitespace(); | 236 rebalanceWhitespace(); |
224 } | 237 } |
225 | 238 |
226 } // namespace blink | 239 } // namespace blink |
OLD | NEW |