Changeset 54413 in webkit
- Timestamp:
- Feb 5, 2010 1:23:06 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r54406 r54413 1 2010-02-05 Tony Chang <tony@chromium.org> 2 3 Reviewed by Eric Seidel. 4 5 https://bugs.webkit.org/show_bug.cgi?id=24872 6 Add a test to make sure copying from a list and pasting into a list 7 keeps the list at the same indention level rather than nesting. 8 9 * editing/pasteboard/paste-list-002-expected.txt: Added. 10 * editing/pasteboard/paste-list-002.html: Added. 11 1 12 2010-02-04 Fumitoshi Ukai <ukai@chromium.org> 2 13 -
trunk/WebCore/ChangeLog
r54405 r54413 1 2010-02-05 Tony Chang <tony@chromium.org> 2 3 Reviewed by Eric Seidel. 4 5 https://bugs.webkit.org/show_bug.cgi?id=24872 6 When pasting a list into another list should not indent another level. 7 If the cursor is at the beginning of the line, it should insert the 8 list items before the current list item. If the cursor is at the end 9 of the line, it should insert the list items after the current list item. 10 11 This matches Firefox and IE and makes the common activity of reordering a list 12 work as expected. 13 14 This also adds a small helper method (isListItem) to htmlediting.h. 15 16 Test: editing/pasteboard/paste-list-002.html 17 18 * editing/ReplaceSelectionCommand.cpp: 19 (WebCore::ReplaceSelectionCommand::doApply): 20 (WebCore::ReplaceSelectionCommand::insertAsListItems): 21 * editing/ReplaceSelectionCommand.h: 22 * editing/htmlediting.cpp: 23 (WebCore::isListItem): 24 (WebCore::appendedSublist): 25 * editing/htmlediting.h: 26 1 27 2010-02-04 Mark Rowe <mrowe@apple.com> 2 28 -
trunk/WebCore/editing/ReplaceSelectionCommand.cpp
r54036 r54413 753 753 754 754 if ((selectionStartWasStartOfParagraph && selectionEndWasEndOfParagraph && !startIsInsideMailBlockquote) || 755 startBlock == currentRoot || 756 (startBlock && startBlock->renderer() && startBlock->renderer()->isListItem()) || 757 selectionIsPlainText) 755 startBlock == currentRoot || isListItem(startBlock) || selectionIsPlainText) 758 756 m_preventNesting = false; 759 757 … … 872 870 873 871 fragment.removeNode(refNode); 874 insertNodeAtAndUpdateNodesInserted(refNode, insertionPos); 872 873 Node* blockStart = enclosingBlock(insertionPos.node()); 874 if (isListElement(refNode.get()) && blockStart->renderer()->isListItem()) 875 refNode = insertAsListItems(refNode, blockStart, insertionPos); 876 else 877 insertNodeAtAndUpdateNodesInserted(refNode, insertionPos); 875 878 876 879 // Mutation events (bug 22634) may have already removed the inserted content … … 961 964 if (!isStartOfParagraph(endOfInsertedContent)) { 962 965 setEndingSelection(endOfInsertedContent); 963 // Use a default paragraph element (a plain div) for the empty paragraph, using the last paragraph 964 // block's style seems to annoy users. 965 insertParagraphSeparator(true); 966 Node* enclosingNode = enclosingBlock(endOfInsertedContent.deepEquivalent().node()); 967 if (isListItem(enclosingNode)) { 968 RefPtr<Node> newListItem = createListItemElement(document()); 969 insertNodeAfter(newListItem, enclosingNode); 970 setEndingSelection(VisiblePosition(Position(newListItem, 0))); 971 } else 972 // Use a default paragraph element (a plain div) for the empty paragraph, using the last paragraph 973 // block's style seems to annoy users. 974 insertParagraphSeparator(true); 966 975 967 976 // Select up to the paragraph separator that was added. … … 1112 1121 } 1113 1122 1123 // If the user is inserting a list into an existing list, instead of nesting the list, 1124 // we put the list items into the existing list. 1125 Node* ReplaceSelectionCommand::insertAsListItems(PassRefPtr<Node> listElement, Node* insertionNode, const Position& p) 1126 { 1127 while (listElement->hasChildNodes() && isListElement(listElement->firstChild()) && listElement->childNodeCount() == 1) 1128 listElement = listElement->firstChild(); 1129 1130 bool isStart = isStartOfParagraph(p); 1131 bool isEnd = isEndOfParagraph(p); 1132 1133 Node* lastNode = insertionNode; 1134 while (RefPtr<Node> listItem = listElement->firstChild()) { 1135 ExceptionCode ec = 0; 1136 listElement->removeChild(listItem.get(), ec); 1137 ASSERT(!ec); 1138 if (isStart) 1139 insertNodeBefore(listItem, lastNode); 1140 else if (isEnd) { 1141 insertNodeAfter(listItem, lastNode); 1142 lastNode = listItem.get(); 1143 } else { 1144 // FIXME: If we're in the middle of a list item, we should split it into two separate 1145 // list items and insert these nodes between them. For now, just append the nodes. 1146 insertNodeAfter(listItem, lastNode); 1147 lastNode = listItem.get(); 1148 } 1149 } 1150 if (isStart) 1151 lastNode = lastNode->previousSibling(); 1152 updateNodesInserted(lastNode); 1153 return lastNode; 1154 } 1155 1114 1156 void ReplaceSelectionCommand::updateNodesInserted(Node *node) 1115 1157 { -
trunk/WebCore/editing/ReplaceSelectionCommand.h
r42821 r54413 55 55 void insertNodeAtAndUpdateNodesInserted(PassRefPtr<Node>, const Position&); 56 56 void insertNodeBeforeAndUpdateNodesInserted(PassRefPtr<Node> insertChild, Node* refChild); 57 Node* insertAsListItems(PassRefPtr<Node>, Node* insertionNode, const Position&); 57 58 58 59 void updateNodesInserted(Node*); -
trunk/WebCore/editing/htmlediting.cpp
r54368 r54413 659 659 } 660 660 661 bool isListItem(Node *n) 662 { 663 return n && n->renderer() && n->renderer()->isListItem(); 664 } 665 661 666 Node* enclosingNodeWithTag(const Position& p, const QualifiedName& tagName) 662 667 { … … 780 785 if (isListElement(n)) 781 786 return static_cast<HTMLElement*>(n); 782 if ( n->renderer() && n->renderer()->isListItem())787 if (isListItem(listItem)) 783 788 return 0; 784 789 } -
trunk/WebCore/editing/htmlediting.h
r54368 r54413 91 91 bool isTableStructureNode(const Node*); 92 92 bool isListElement(Node*); 93 bool isListItem(Node*); 93 94 bool isNodeRendered(const Node*); 94 95 bool isNodeVisiblyContainedWithin(Node*, const Range*);
Note: See TracChangeset
for help on using the changeset viewer.