OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2005, 2006, 2007, 2008 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 1421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1432 ? start | 1432 ? start |
1433 : mostBackwardCaretPosition(endOfParagraphToMove.deepEquivalent()); | 1433 : mostBackwardCaretPosition(endOfParagraphToMove.deepEquivalent()); |
1434 if (comparePositions(start, end) > 0) | 1434 if (comparePositions(start, end) > 0) |
1435 end = start; | 1435 end = start; |
1436 | 1436 |
1437 cloneParagraphUnderNewElement(start, end, outerNode, blockElement, | 1437 cloneParagraphUnderNewElement(start, end, outerNode, blockElement, |
1438 editingState); | 1438 editingState); |
1439 | 1439 |
1440 document().updateStyleAndLayoutIgnorePendingStylesheets(); | 1440 document().updateStyleAndLayoutIgnorePendingStylesheets(); |
1441 | 1441 |
1442 setEndingSelection(createVisibleSelection(start, end)); | 1442 setEndingSelection(createVisibleSelection( |
1443 SelectionInDOMTree::Builder().collapse(start).extend(end).build())); | |
1443 deleteSelection(editingState, false, false, false); | 1444 deleteSelection(editingState, false, false, false); |
1444 if (editingState->isAborted()) | 1445 if (editingState->isAborted()) |
1445 return; | 1446 return; |
1446 | 1447 |
1447 // There are bugs in deletion when it removes a fully selected table/list. | 1448 // There are bugs in deletion when it removes a fully selected table/list. |
1448 // It expands and removes the entire table/list, but will let content | 1449 // It expands and removes the entire table/list, but will let content |
1449 // before and after the table/list collapse onto one line. | 1450 // before and after the table/list collapse onto one line. |
1450 | 1451 |
1451 cleanupAfterDeletion(editingState); | 1452 cleanupAfterDeletion(editingState); |
1452 if (editingState->isAborted()) | 1453 if (editingState->isAborted()) |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1591 styleInEmptyParagraph->mergeTypingStyle(&document()); | 1592 styleInEmptyParagraph->mergeTypingStyle(&document()); |
1592 // The moved paragraph should assume the block style of the destination. | 1593 // The moved paragraph should assume the block style of the destination. |
1593 styleInEmptyParagraph->removeBlockProperties(); | 1594 styleInEmptyParagraph->removeBlockProperties(); |
1594 } | 1595 } |
1595 | 1596 |
1596 // FIXME (5098931): We should add a new insert action | 1597 // FIXME (5098931): We should add a new insert action |
1597 // "WebViewInsertActionMoved" and call shouldInsertFragment here. | 1598 // "WebViewInsertActionMoved" and call shouldInsertFragment here. |
1598 | 1599 |
1599 DCHECK(!document().needsLayoutTreeUpdate()); | 1600 DCHECK(!document().needsLayoutTreeUpdate()); |
1600 | 1601 |
1601 setEndingSelection(createVisibleSelection(start, end)); | 1602 setEndingSelection(createVisibleSelection( |
1603 SelectionInDOMTree::Builder().collapse(start).extend(end).build())); | |
Xiaocheng
2016/10/26 05:49:18
Do we have non-null start and end here?
yosin_UTC9
2016/10/26 07:43:07
I would like to know the case which makes start| o
| |
1602 document() | 1604 document() |
1603 .frame() | 1605 .frame() |
1604 ->spellChecker() | 1606 ->spellChecker() |
1605 .clearMisspellingsAndBadGrammarForMovingParagraphs(endingSelection()); | 1607 .clearMisspellingsAndBadGrammarForMovingParagraphs(endingSelection()); |
1606 deleteSelection(editingState, false, false, false); | 1608 deleteSelection(editingState, false, false, false); |
1607 if (editingState->isAborted()) | 1609 if (editingState->isAborted()) |
1608 return; | 1610 return; |
1609 | 1611 |
1610 DCHECK(destination.deepEquivalent().isConnected()) << destination; | 1612 DCHECK(destination.deepEquivalent().isConnected()) << destination; |
1611 cleanupAfterDeletion(editingState, destination); | 1613 cleanupAfterDeletion(editingState, destination); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1702 // to rangeFromLocationAndLength with a location past the end of the | 1704 // to rangeFromLocationAndLength with a location past the end of the |
1703 // document (which will return null). | 1705 // document (which will return null). |
1704 EphemeralRange startRange = PlainTextRange(destinationIndex + startIndex) | 1706 EphemeralRange startRange = PlainTextRange(destinationIndex + startIndex) |
1705 .createRangeForSelection(*documentElement); | 1707 .createRangeForSelection(*documentElement); |
1706 if (startRange.isNull()) | 1708 if (startRange.isNull()) |
1707 return; | 1709 return; |
1708 EphemeralRange endRange = PlainTextRange(destinationIndex + endIndex) | 1710 EphemeralRange endRange = PlainTextRange(destinationIndex + endIndex) |
1709 .createRangeForSelection(*documentElement); | 1711 .createRangeForSelection(*documentElement); |
1710 if (endRange.isNull()) | 1712 if (endRange.isNull()) |
1711 return; | 1713 return; |
1712 setEndingSelection(createVisibleSelection( | 1714 setEndingSelection( |
1713 startRange.startPosition(), endRange.startPosition(), | 1715 createVisibleSelection(SelectionInDOMTree::Builder() |
1714 TextAffinity::Downstream, originalIsDirectional)); | 1716 .collapse(startRange.startPosition()) |
1717 .extend(endRange.startPosition()) | |
1718 .setIsDirectional(originalIsDirectional) | |
1719 .build())); | |
1715 } | 1720 } |
1716 | 1721 |
1717 // FIXME: Send an appropriate shouldDeleteRange call. | 1722 // FIXME: Send an appropriate shouldDeleteRange call. |
1718 bool CompositeEditCommand::breakOutOfEmptyListItem(EditingState* editingState) { | 1723 bool CompositeEditCommand::breakOutOfEmptyListItem(EditingState* editingState) { |
1719 DCHECK(!document().needsLayoutTreeUpdate()); | 1724 DCHECK(!document().needsLayoutTreeUpdate()); |
1720 Node* emptyListItem = | 1725 Node* emptyListItem = |
1721 enclosingEmptyListItem(endingSelection().visibleStart()); | 1726 enclosingEmptyListItem(endingSelection().visibleStart()); |
1722 if (!emptyListItem) | 1727 if (!emptyListItem) |
1723 return false; | 1728 return false; |
1724 | 1729 |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2027 return node; | 2032 return node; |
2028 } | 2033 } |
2029 | 2034 |
2030 DEFINE_TRACE(CompositeEditCommand) { | 2035 DEFINE_TRACE(CompositeEditCommand) { |
2031 visitor->trace(m_commands); | 2036 visitor->trace(m_commands); |
2032 visitor->trace(m_composition); | 2037 visitor->trace(m_composition); |
2033 EditCommand::trace(visitor); | 2038 EditCommand::trace(visitor); |
2034 } | 2039 } |
2035 | 2040 |
2036 } // namespace blink | 2041 } // namespace blink |
OLD | NEW |