| 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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 VisiblePosition visibleStart = endingSelection().visibleStart(); | 125 VisiblePosition visibleStart = endingSelection().visibleStart(); |
| 126 // When a selection ends at the start of a paragraph, we rarely paint | 126 // When a selection ends at the start of a paragraph, we rarely paint |
| 127 // the selection gap before that paragraph, because there often is no gap. | 127 // the selection gap before that paragraph, because there often is no gap. |
| 128 // In a case like this, it's not obvious to the user that the selection | 128 // In a case like this, it's not obvious to the user that the selection |
| 129 // ends "inside" that paragraph, so it would be confusing if InsertUn{Ordere
d}List | 129 // ends "inside" that paragraph, so it would be confusing if InsertUn{Ordere
d}List |
| 130 // operated on that paragraph. | 130 // operated on that paragraph. |
| 131 // FIXME: We paint the gap before some paragraphs that are indented with lef
t | 131 // FIXME: We paint the gap before some paragraphs that are indented with lef
t |
| 132 // margin/padding, but not others. We should make the gap painting more con
sistent and | 132 // margin/padding, but not others. We should make the gap painting more con
sistent and |
| 133 // then use a left margin/padding rule here. | 133 // then use a left margin/padding rule here. |
| 134 if (visibleEnd.deepEquivalent() != visibleStart.deepEquivalent() && isStartO
fParagraph(visibleEnd, CanSkipOverEditingBoundary)) { | 134 if (visibleEnd.deepEquivalent() != visibleStart.deepEquivalent() && isStartO
fParagraph(visibleEnd, CanSkipOverEditingBoundary)) { |
| 135 setEndingSelection(VisibleSelection(visibleStart, visibleEnd.previous(Ca
nnotCrossEditingBoundary), endingSelection().isDirectional())); | 135 setEndingSelection(VisibleSelection(visibleStart, previousPositionOf(vis
ibleEnd, CannotCrossEditingBoundary), endingSelection().isDirectional())); |
| 136 if (!endingSelection().rootEditableElement()) | 136 if (!endingSelection().rootEditableElement()) |
| 137 return; | 137 return; |
| 138 } | 138 } |
| 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(); |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 start = VisiblePosition(firstPositionInNode(listChildNode)); | 289 start = VisiblePosition(firstPositionInNode(listChildNode)); |
| 290 end = VisiblePosition(lastPositionInNode(listChildNode)); | 290 end = VisiblePosition(lastPositionInNode(listChildNode)); |
| 291 nextListChild = listChildNode->nextSibling(); | 291 nextListChild = listChildNode->nextSibling(); |
| 292 previousListChild = listChildNode->previousSibling(); | 292 previousListChild = listChildNode->previousSibling(); |
| 293 } else { | 293 } else { |
| 294 // A paragraph is visually a list item minus a list marker. The paragra
ph will be moved. | 294 // A paragraph is visually a list item minus a list marker. The paragra
ph will be moved. |
| 295 start = startOfParagraph(originalStart, CanSkipOverEditingBoundary); | 295 start = startOfParagraph(originalStart, CanSkipOverEditingBoundary); |
| 296 end = endOfParagraph(start, CanSkipOverEditingBoundary); | 296 end = endOfParagraph(start, CanSkipOverEditingBoundary); |
| 297 nextListChild = enclosingListChild(end.next().deepEquivalent().anchorNod
e(), listElement); | 297 nextListChild = enclosingListChild(end.next().deepEquivalent().anchorNod
e(), listElement); |
| 298 ASSERT(nextListChild != listChildNode); | 298 ASSERT(nextListChild != listChildNode); |
| 299 previousListChild = enclosingListChild(start.previous().deepEquivalent()
.anchorNode(), listElement); | 299 previousListChild = enclosingListChild(previousPositionOf(start).deepEqu
ivalent().anchorNode(), listElement); |
| 300 ASSERT(previousListChild != listChildNode); | 300 ASSERT(previousListChild != listChildNode); |
| 301 } | 301 } |
| 302 // When removing a list, we must always create a placeholder to act as a poi
nt of insertion | 302 // When removing a list, we must always create a placeholder to act as a poi
nt of insertion |
| 303 // for the list content being removed. | 303 // for the list content being removed. |
| 304 RefPtrWillBeRawPtr<HTMLBRElement> placeholder = createBreakElement(document(
)); | 304 RefPtrWillBeRawPtr<HTMLBRElement> placeholder = createBreakElement(document(
)); |
| 305 RefPtrWillBeRawPtr<HTMLElement> elementToInsert = placeholder; | 305 RefPtrWillBeRawPtr<HTMLElement> elementToInsert = placeholder; |
| 306 // If the content of the list item will be moved into another list, put it i
n a list item | 306 // If the content of the list item will be moved into another list, put it i
n a list item |
| 307 // so that we don't create an orphaned list child. | 307 // so that we don't create an orphaned list child. |
| 308 if (enclosingList(listElement)) { | 308 if (enclosingList(listElement)) { |
| 309 elementToInsert = createListItemElement(document()); | 309 elementToInsert = createListItemElement(document()); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 | 362 |
| 363 if (start.isNull() || end.isNull()) | 363 if (start.isNull() || end.isNull()) |
| 364 return nullptr; | 364 return nullptr; |
| 365 | 365 |
| 366 // Check for adjoining lists. | 366 // Check for adjoining lists. |
| 367 RefPtrWillBeRawPtr<HTMLElement> listItemElement = createListItemElement(docu
ment()); | 367 RefPtrWillBeRawPtr<HTMLElement> listItemElement = createListItemElement(docu
ment()); |
| 368 RefPtrWillBeRawPtr<HTMLBRElement> placeholder = createBreakElement(document(
)); | 368 RefPtrWillBeRawPtr<HTMLBRElement> placeholder = createBreakElement(document(
)); |
| 369 appendNode(placeholder, listItemElement); | 369 appendNode(placeholder, listItemElement); |
| 370 | 370 |
| 371 // Place list item into adjoining lists. | 371 // Place list item into adjoining lists. |
| 372 HTMLElement* previousList = adjacentEnclosingList(start, start.previous(Cann
otCrossEditingBoundary), listTag); | 372 HTMLElement* previousList = adjacentEnclosingList(start, previousPositionOf(
start, CannotCrossEditingBoundary), listTag); |
| 373 HTMLElement* nextList = adjacentEnclosingList(start, end.next(CannotCrossEdi
tingBoundary), listTag); | 373 HTMLElement* nextList = adjacentEnclosingList(start, end.next(CannotCrossEdi
tingBoundary), listTag); |
| 374 RefPtrWillBeRawPtr<HTMLElement> listElement = nullptr; | 374 RefPtrWillBeRawPtr<HTMLElement> listElement = nullptr; |
| 375 if (previousList) { | 375 if (previousList) { |
| 376 appendNode(listItemElement, previousList); | 376 appendNode(listItemElement, previousList); |
| 377 } else if (nextList) { | 377 } else if (nextList) { |
| 378 insertNodeAt(listItemElement, positionBeforeNode(nextList)); | 378 insertNodeAt(listItemElement, positionBeforeNode(nextList)); |
| 379 } else { | 379 } else { |
| 380 // Create the list. | 380 // Create the list. |
| 381 listElement = createHTMLElement(document(), listTag); | 381 listElement = createHTMLElement(document(), listTag); |
| 382 appendNode(listItemElement, listElement); | 382 appendNode(listItemElement, listElement); |
| (...skipping 44 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 |