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 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 if (editingState->isAborted()) | 234 if (editingState->isAborted()) |
235 return; | 235 return; |
236 | 236 |
237 if (!ancestors.isEmpty()) { | 237 if (!ancestors.isEmpty()) { |
238 // Split the tree up the ancestor chain until the topBlockquote | 238 // Split the tree up the ancestor chain until the topBlockquote |
239 // Throughout this loop, clonedParent is the clone of ancestor's parent. | 239 // Throughout this loop, clonedParent is the clone of ancestor's parent. |
240 // This is so we can clone ancestor's siblings and place the clones | 240 // This is so we can clone ancestor's siblings and place the clones |
241 // into the clone corresponding to the ancestor's parent. | 241 // into the clone corresponding to the ancestor's parent. |
242 Element* ancestor = nullptr; | 242 Element* ancestor = nullptr; |
243 Element* clonedParent = nullptr; | 243 Element* clonedParent = nullptr; |
244 for (ancestor = ancestors.first(), | 244 for (ancestor = ancestors.front(), |
245 clonedParent = clonedAncestor->parentElement(); | 245 clonedParent = clonedAncestor->parentElement(); |
246 ancestor && ancestor != topBlockquote; | 246 ancestor && ancestor != topBlockquote; |
247 ancestor = ancestor->parentElement(), | 247 ancestor = ancestor->parentElement(), |
248 clonedParent = clonedParent->parentElement()) { | 248 clonedParent = clonedParent->parentElement()) { |
249 moveRemainingSiblingsToNewParent(ancestor->nextSibling(), 0, clonedParent, | 249 moveRemainingSiblingsToNewParent(ancestor->nextSibling(), 0, clonedParent, |
250 editingState); | 250 editingState); |
251 if (editingState->isAborted()) | 251 if (editingState->isAborted()) |
252 return; | 252 return; |
253 } | 253 } |
254 | 254 |
255 // If the startNode's original parent is now empty, remove it | 255 // If the startNode's original parent is now empty, remove it |
256 Element* originalParent = ancestors.first().get(); | 256 Element* originalParent = ancestors.front().get(); |
257 if (!originalParent->hasChildren()) { | 257 if (!originalParent->hasChildren()) { |
258 removeNode(originalParent, editingState); | 258 removeNode(originalParent, editingState); |
259 if (editingState->isAborted()) | 259 if (editingState->isAborted()) |
260 return; | 260 return; |
261 } | 261 } |
262 } | 262 } |
263 | 263 |
264 // Make sure the cloned block quote renders. | 264 // Make sure the cloned block quote renders. |
265 addBlockPlaceholderIfNeeded(clonedBlockquote, editingState); | 265 addBlockPlaceholderIfNeeded(clonedBlockquote, editingState); |
266 if (editingState->isAborted()) | 266 if (editingState->isAborted()) |
267 return; | 267 return; |
268 | 268 |
269 // Put the selection right before the break. | 269 // Put the selection right before the break. |
270 setEndingSelection(SelectionInDOMTree::Builder() | 270 setEndingSelection(SelectionInDOMTree::Builder() |
271 .collapse(Position::beforeNode(breakElement)) | 271 .collapse(Position::beforeNode(breakElement)) |
272 .setIsDirectional(endingSelection().isDirectional()) | 272 .setIsDirectional(endingSelection().isDirectional()) |
273 .build()); | 273 .build()); |
274 rebalanceWhitespace(); | 274 rebalanceWhitespace(); |
275 } | 275 } |
276 | 276 |
277 } // namespace blink | 277 } // namespace blink |
OLD | NEW |