| 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 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 // A paragraph is visually a list item minus a list marker. The paragra
ph will be moved. | 272 // A paragraph is visually a list item minus a list marker. The paragra
ph will be moved. |
| 273 start = startOfParagraph(originalStart, CanSkipOverEditingBoundary); | 273 start = startOfParagraph(originalStart, CanSkipOverEditingBoundary); |
| 274 end = endOfParagraph(start, CanSkipOverEditingBoundary); | 274 end = endOfParagraph(start, CanSkipOverEditingBoundary); |
| 275 nextListChild = enclosingListChild(end.next().deepEquivalent().deprecate
dNode(), listNode); | 275 nextListChild = enclosingListChild(end.next().deepEquivalent().deprecate
dNode(), listNode); |
| 276 ASSERT(nextListChild != listChildNode); | 276 ASSERT(nextListChild != listChildNode); |
| 277 previousListChild = enclosingListChild(start.previous().deepEquivalent()
.deprecatedNode(), listNode); | 277 previousListChild = enclosingListChild(start.previous().deepEquivalent()
.deprecatedNode(), listNode); |
| 278 ASSERT(previousListChild != listChildNode); | 278 ASSERT(previousListChild != listChildNode); |
| 279 } | 279 } |
| 280 // When removing a list, we must always create a placeholder to act as a poi
nt of insertion | 280 // When removing a list, we must always create a placeholder to act as a poi
nt of insertion |
| 281 // for the list content being removed. | 281 // for the list content being removed. |
| 282 RefPtr<Element> placeholder = createBreakElement(document()); | 282 RefPtrWillBeRawPtr<Element> placeholder = createBreakElement(document()); |
| 283 RefPtr<Element> nodeToInsert = placeholder; | 283 RefPtrWillBeRawPtr<Element> nodeToInsert = placeholder; |
| 284 // If the content of the list item will be moved into another list, put it i
n a list item | 284 // If the content of the list item will be moved into another list, put it i
n a list item |
| 285 // so that we don't create an orphaned list child. | 285 // so that we don't create an orphaned list child. |
| 286 if (enclosingList(listNode)) { | 286 if (enclosingList(listNode)) { |
| 287 nodeToInsert = createListItemElement(document()); | 287 nodeToInsert = createListItemElement(document()); |
| 288 appendNode(placeholder, nodeToInsert); | 288 appendNode(placeholder, nodeToInsert); |
| 289 } | 289 } |
| 290 | 290 |
| 291 if (nextListChild && previousListChild) { | 291 if (nextListChild && previousListChild) { |
| 292 // We want to pull listChildNode out of listNode, and place it before ne
xtListChild | 292 // We want to pull listChildNode out of listNode, and place it before ne
xtListChild |
| 293 // and after previousListChild, so we split listNode and insert it betwe
en the two lists. | 293 // and after previousListChild, so we split listNode and insert it betwe
en the two lists. |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 insertNodeAt(listItemElement, positionBeforeNode(nextList)); | 355 insertNodeAt(listItemElement, positionBeforeNode(nextList)); |
| 356 else { | 356 else { |
| 357 // Create the list. | 357 // Create the list. |
| 358 listElement = createHTMLElement(document(), listTag); | 358 listElement = createHTMLElement(document(), listTag); |
| 359 appendNode(listItemElement, listElement); | 359 appendNode(listItemElement, listElement); |
| 360 | 360 |
| 361 if (start == end && isBlock(start.deepEquivalent().deprecatedNode())) { | 361 if (start == end && isBlock(start.deepEquivalent().deprecatedNode())) { |
| 362 // Inserting the list into an empty paragraph that isn't held open | 362 // Inserting the list into an empty paragraph that isn't held open |
| 363 // by a br or a '\n', will invalidate start and end. Insert | 363 // by a br or a '\n', will invalidate start and end. Insert |
| 364 // a placeholder and then recompute start and end. | 364 // a placeholder and then recompute start and end. |
| 365 RefPtr<Node> placeholder = insertBlockPlaceholder(start.deepEquivale
nt()); | 365 RefPtrWillBeRawPtr<Node> placeholder = insertBlockPlaceholder(start.
deepEquivalent()); |
| 366 start = VisiblePosition(positionBeforeNode(placeholder.get())); | 366 start = VisiblePosition(positionBeforeNode(placeholder.get())); |
| 367 end = start; | 367 end = start; |
| 368 } | 368 } |
| 369 | 369 |
| 370 // Insert the list at a position visually equivalent to start of the | 370 // Insert the list at a position visually equivalent to start of the |
| 371 // paragraph that is being moved into the list. | 371 // paragraph that is being moved into the list. |
| 372 // Try to avoid inserting it somewhere where it will be surrounded by | 372 // Try to avoid inserting it somewhere where it will be surrounded by |
| 373 // inline ancestors of start, since it is easier for editing to produce | 373 // inline ancestors of start, since it is easier for editing to produce |
| 374 // clean markup when inline elements are pushed down as far as possible. | 374 // clean markup when inline elements are pushed down as far as possible. |
| 375 Position insertionPos(start.deepEquivalent().upstream()); | 375 Position insertionPos(start.deepEquivalent().upstream()); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 395 | 395 |
| 396 if (listElement) | 396 if (listElement) |
| 397 return mergeWithNeighboringLists(listElement); | 397 return mergeWithNeighboringLists(listElement); |
| 398 | 398 |
| 399 if (canMergeLists(previousList, nextList)) | 399 if (canMergeLists(previousList, nextList)) |
| 400 mergeIdenticalElements(previousList, nextList); | 400 mergeIdenticalElements(previousList, nextList); |
| 401 | 401 |
| 402 return listElement; | 402 return listElement; |
| 403 } | 403 } |
| 404 | 404 |
| 405 void InsertListCommand::trace(Visitor* visitor) |
| 406 { |
| 407 visitor->trace(m_listElement); |
| 408 CompositeEditCommand::trace(visitor); |
| 405 } | 409 } |
| 410 |
| 411 } |
| OLD | NEW |