| 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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 isLastVisiblePositionInNode(visiblePos, topBlockquote); | 114 isLastVisiblePositionInNode(visiblePos, topBlockquote); |
| 115 | 115 |
| 116 // If the position is at the beginning of the top quoted content, we don't | 116 // If the position is at the beginning of the top quoted content, we don't |
| 117 // need to break the quote. Instead, insert the break before the blockquote, | 117 // need to break the quote. Instead, insert the break before the blockquote, |
| 118 // unless the position is as the end of the the quoted content. | 118 // unless the position is as the end of the the quoted content. |
| 119 if (isFirstVisiblePositionInNode(visiblePos, topBlockquote) && | 119 if (isFirstVisiblePositionInNode(visiblePos, topBlockquote) && |
| 120 !isLastVisPosInNode) { | 120 !isLastVisPosInNode) { |
| 121 insertNodeBefore(breakElement, topBlockquote, editingState); | 121 insertNodeBefore(breakElement, topBlockquote, editingState); |
| 122 if (editingState->isAborted()) | 122 if (editingState->isAborted()) |
| 123 return; | 123 return; |
| 124 document().updateStyleAndLayoutIgnorePendingStylesheets(); | 124 setEndingSelection(SelectionInDOMTree::Builder() |
| 125 setEndingSelection(createVisibleSelection( | 125 .collapse(Position::beforeNode(breakElement)) |
| 126 SelectionInDOMTree::Builder() | 126 .setIsDirectional(endingSelection().isDirectional()) |
| 127 .collapse(Position::beforeNode(breakElement)) | 127 .build()); |
| 128 .setIsDirectional(endingSelection().isDirectional()) | |
| 129 .build())); | |
| 130 rebalanceWhitespace(); | 128 rebalanceWhitespace(); |
| 131 return; | 129 return; |
| 132 } | 130 } |
| 133 | 131 |
| 134 // Insert a break after the top blockquote. | 132 // Insert a break after the top blockquote. |
| 135 insertNodeAfter(breakElement, topBlockquote, editingState); | 133 insertNodeAfter(breakElement, topBlockquote, editingState); |
| 136 if (editingState->isAborted()) | 134 if (editingState->isAborted()) |
| 137 return; | 135 return; |
| 138 | 136 |
| 139 document().updateStyleAndLayoutIgnorePendingStylesheets(); | 137 document().updateStyleAndLayoutIgnorePendingStylesheets(); |
| 140 | 138 |
| 141 // If we're inserting the break at the end of the quoted content, we don't | 139 // If we're inserting the break at the end of the quoted content, we don't |
| 142 // need to break the quote. | 140 // need to break the quote. |
| 143 if (isLastVisPosInNode) { | 141 if (isLastVisPosInNode) { |
| 144 setEndingSelection(createVisibleSelection( | 142 setEndingSelection(SelectionInDOMTree::Builder() |
| 145 SelectionInDOMTree::Builder() | 143 .collapse(Position::beforeNode(breakElement)) |
| 146 .collapse(Position::beforeNode(breakElement)) | 144 .setIsDirectional(endingSelection().isDirectional()) |
| 147 .setIsDirectional(endingSelection().isDirectional()) | 145 .build()); |
| 148 .build())); | |
| 149 rebalanceWhitespace(); | 146 rebalanceWhitespace(); |
| 150 return; | 147 return; |
| 151 } | 148 } |
| 152 | 149 |
| 153 // Don't move a line break just after the caret. Doing so would create an | 150 // Don't move a line break just after the caret. Doing so would create an |
| 154 // extra, empty paragraph in the new blockquote. | 151 // extra, empty paragraph in the new blockquote. |
| 155 if (lineBreakExistsAtVisiblePosition(visiblePos)) { | 152 if (lineBreakExistsAtVisiblePosition(visiblePos)) { |
| 156 pos = nextPositionOf(pos, PositionMoveType::GraphemeCluster); | 153 pos = nextPositionOf(pos, PositionMoveType::GraphemeCluster); |
| 157 } | 154 } |
| 158 | 155 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 179 } | 176 } |
| 180 } else if (pos.computeEditingOffset() > 0) { | 177 } else if (pos.computeEditingOffset() > 0) { |
| 181 Node* childAtOffset = | 178 Node* childAtOffset = |
| 182 NodeTraversal::childAt(*startNode, pos.computeEditingOffset()); | 179 NodeTraversal::childAt(*startNode, pos.computeEditingOffset()); |
| 183 startNode = childAtOffset ? childAtOffset : NodeTraversal::next(*startNode); | 180 startNode = childAtOffset ? childAtOffset : NodeTraversal::next(*startNode); |
| 184 DCHECK(startNode); | 181 DCHECK(startNode); |
| 185 } | 182 } |
| 186 | 183 |
| 187 // If there's nothing inside topBlockquote to move, we're finished. | 184 // If there's nothing inside topBlockquote to move, we're finished. |
| 188 if (!startNode->isDescendantOf(topBlockquote)) { | 185 if (!startNode->isDescendantOf(topBlockquote)) { |
| 189 document().updateStyleAndLayoutIgnorePendingStylesheets(); | 186 setEndingSelection(SelectionInDOMTree::Builder() |
| 190 setEndingSelection(createVisibleSelection( | 187 .collapse(firstPositionInOrBeforeNode(startNode)) |
| 191 SelectionInDOMTree::Builder() | 188 .setIsDirectional(endingSelection().isDirectional()) |
| 192 .collapse(firstPositionInOrBeforeNode(startNode)) | 189 .build()); |
| 193 .setIsDirectional(endingSelection().isDirectional()) | |
| 194 .build())); | |
| 195 return; | 190 return; |
| 196 } | 191 } |
| 197 | 192 |
| 198 // Build up list of ancestors in between the start node and the top | 193 // Build up list of ancestors in between the start node and the top |
| 199 // blockquote. | 194 // blockquote. |
| 200 HeapVector<Member<Element>> ancestors; | 195 HeapVector<Member<Element>> ancestors; |
| 201 for (Element* node = startNode->parentElement(); | 196 for (Element* node = startNode->parentElement(); |
| 202 node && node != topBlockquote; node = node->parentElement()) | 197 node && node != topBlockquote; node = node->parentElement()) |
| 203 ancestors.append(node); | 198 ancestors.append(node); |
| 204 | 199 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 if (editingState->isAborted()) | 259 if (editingState->isAborted()) |
| 265 return; | 260 return; |
| 266 } | 261 } |
| 267 } | 262 } |
| 268 | 263 |
| 269 // Make sure the cloned block quote renders. | 264 // Make sure the cloned block quote renders. |
| 270 addBlockPlaceholderIfNeeded(clonedBlockquote, editingState); | 265 addBlockPlaceholderIfNeeded(clonedBlockquote, editingState); |
| 271 if (editingState->isAborted()) | 266 if (editingState->isAborted()) |
| 272 return; | 267 return; |
| 273 | 268 |
| 274 document().updateStyleAndLayoutIgnorePendingStylesheets(); | |
| 275 | |
| 276 // Put the selection right before the break. | 269 // Put the selection right before the break. |
| 277 setEndingSelection(createVisibleSelection( | 270 setEndingSelection(SelectionInDOMTree::Builder() |
| 278 SelectionInDOMTree::Builder() | 271 .collapse(Position::beforeNode(breakElement)) |
| 279 .collapse(Position::beforeNode(breakElement)) | 272 .setIsDirectional(endingSelection().isDirectional()) |
| 280 .setIsDirectional(endingSelection().isDirectional()) | 273 .build()); |
| 281 .build())); | |
| 282 rebalanceWhitespace(); | 274 rebalanceWhitespace(); |
| 283 } | 275 } |
| 284 | 276 |
| 285 } // namespace blink | 277 } // namespace blink |
| OLD | NEW |