diff options
author | Steve Block <steveblock@google.com> | 2011-05-25 19:08:45 +0100 |
---|---|---|
committer | Steve Block <steveblock@google.com> | 2011-06-08 13:51:31 +0100 |
commit | 2bde8e466a4451c7319e3a072d118917957d6554 (patch) | |
tree | 28f4a1b869a513e565c7760d0e6a06e7cf1fe95a /Source/WebCore/editing/InsertListCommand.cpp | |
parent | 6939c99b71d9372d14a0c74a772108052e8c48c8 (diff) | |
download | external_webkit-2bde8e466a4451c7319e3a072d118917957d6554.zip external_webkit-2bde8e466a4451c7319e3a072d118917957d6554.tar.gz external_webkit-2bde8e466a4451c7319e3a072d118917957d6554.tar.bz2 |
Merge WebKit at r82507: Initial merge by git
Change-Id: I60ce9d780725b58b45e54165733a8ffee23b683e
Diffstat (limited to 'Source/WebCore/editing/InsertListCommand.cpp')
-rw-r--r-- | Source/WebCore/editing/InsertListCommand.cpp | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/Source/WebCore/editing/InsertListCommand.cpp b/Source/WebCore/editing/InsertListCommand.cpp index 68661b4..4585b2e 100644 --- a/Source/WebCore/editing/InsertListCommand.cpp +++ b/Source/WebCore/editing/InsertListCommand.cpp @@ -121,8 +121,8 @@ void InsertListCommand::doApply() // FIXME: We paint the gap before some paragraphs that are indented with left // margin/padding, but not others. We should make the gap painting more consistent and // then use a left margin/padding rule here. - if (visibleEnd != visibleStart && isStartOfParagraph(visibleEnd)) - setEndingSelection(VisibleSelection(visibleStart, visibleEnd.previous(true))); + if (visibleEnd != visibleStart && isStartOfParagraph(visibleEnd, CanSkipOverEditingBoundary)) + setEndingSelection(VisibleSelection(visibleStart, visibleEnd.previous(CannotCrossEditingBoundary))); const QualifiedName& listTag = (m_type == OrderedList) ? olTag : ulTag; if (endingSelection().isRange()) { @@ -130,14 +130,14 @@ void InsertListCommand::doApply() ASSERT(selection.isRange()); VisiblePosition startOfSelection = selection.visibleStart(); VisiblePosition endOfSelection = selection.visibleEnd(); - VisiblePosition startOfLastParagraph = startOfParagraph(endOfSelection); + VisiblePosition startOfLastParagraph = startOfParagraph(endOfSelection, CanSkipOverEditingBoundary); - if (startOfParagraph(startOfSelection) != startOfLastParagraph) { + if (startOfParagraph(startOfSelection, CanSkipOverEditingBoundary) != startOfLastParagraph) { bool forceCreateList = !selectionHasListOfType(selection, listTag); RefPtr<Range> currentSelection = endingSelection().firstRange(); VisiblePosition startOfCurrentParagraph = startOfSelection; - while (startOfCurrentParagraph != startOfLastParagraph) { + while (!inSameParagraph(startOfCurrentParagraph, startOfLastParagraph, CanCrossEditingBoundary)) { // doApply() may operate on and remove the last paragraph of the selection from the document // if it's in the same list item as startOfCurrentParagraph. Return early to avoid an // infinite loop and because there is no more work to be done. @@ -162,7 +162,7 @@ void InsertListCommand::doApply() if (!lastSelectionRange) return; endOfSelection = lastSelectionRange->startPosition(); - startOfLastParagraph = startOfParagraph(endOfSelection); + startOfLastParagraph = startOfParagraph(endOfSelection, CanSkipOverEditingBoundary); } // Fetch the start of the selection after moving the first paragraph, @@ -257,14 +257,14 @@ void InsertListCommand::unlistifyParagraph(const VisiblePosition& originalStart, VisiblePosition start; VisiblePosition end; if (listChildNode->hasTagName(liTag)) { - start = firstDeepEditingPositionForNode(listChildNode); - end = lastDeepEditingPositionForNode(listChildNode); + start = firstPositionInNode(listChildNode); + end = lastPositionInNode(listChildNode); nextListChild = listChildNode->nextSibling(); previousListChild = listChildNode->previousSibling(); } else { // A paragraph is visually a list item minus a list marker. The paragraph will be moved. - start = startOfParagraph(originalStart); - end = endOfParagraph(start); + start = startOfParagraph(originalStart, CanSkipOverEditingBoundary); + end = endOfParagraph(start, CanSkipOverEditingBoundary); nextListChild = enclosingListChild(end.next().deepEquivalent().deprecatedNode(), listNode); ASSERT(nextListChild != listChildNode); previousListChild = enclosingListChild(start.previous().deepEquivalent().deprecatedNode(), listNode); @@ -327,8 +327,8 @@ static Element* adjacentEnclosingList(const VisiblePosition& pos, const VisibleP PassRefPtr<HTMLElement> InsertListCommand::listifyParagraph(const VisiblePosition& originalStart, const QualifiedName& listTag) { - VisiblePosition start = startOfParagraph(originalStart); - VisiblePosition end = endOfParagraph(start); + VisiblePosition start = startOfParagraph(originalStart, CanSkipOverEditingBoundary); + VisiblePosition end = endOfParagraph(start, CanSkipOverEditingBoundary); if (start.isNull() || end.isNull()) return 0; @@ -339,8 +339,8 @@ PassRefPtr<HTMLElement> InsertListCommand::listifyParagraph(const VisiblePositio appendNode(placeholder, listItemElement); // Place list item into adjoining lists. - Element* previousList = adjacentEnclosingList(start.deepEquivalent(), start.previous(true), listTag); - Element* nextList = adjacentEnclosingList(start.deepEquivalent(), end.next(true), listTag); + Element* previousList = adjacentEnclosingList(start.deepEquivalent(), start.previous(CannotCrossEditingBoundary), listTag); + Element* nextList = adjacentEnclosingList(start.deepEquivalent(), end.next(CannotCrossEditingBoundary), listTag); RefPtr<HTMLElement> listElement; if (previousList) appendNode(listItemElement, previousList); @@ -375,8 +375,11 @@ PassRefPtr<HTMLElement> InsertListCommand::listifyParagraph(const VisiblePositio // We inserted the list at the start of the content we're about to move // Update the start of content, so we don't try to move the list into itself. bug 19066 - if (insertionPos == start.deepEquivalent()) - start = startOfParagraph(originalStart); + // Layout is necessary since start's node's inline renderers may have been destroyed by the insertion + if (insertionPos == start.deepEquivalent()) { + listElement->document()->updateLayoutIgnorePendingStylesheets(); + start = startOfParagraph(originalStart, CanSkipOverEditingBoundary); + } } moveParagraph(start, end, positionBeforeNode(placeholder.get()), true); |