Changeset 101575 in webkit
- Timestamp:
- Nov 30, 2011 5:16:13 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r101573 r101575 1 2011-11-30 Enrica Casucci <enrica@apple.com> 2 3 Copy/paste of the same content produces increasingly nested markup 4 https://bugs.webkit.org/show_bug.cgi?id=73497 5 <rdar://problem/10208605> 6 7 Reviewed by Darin Adler. 8 9 * editing/deleting/delete-and-cleanup-expected.txt: Added. 10 * editing/deleting/delete-and-cleanup.html: Added. 11 * editing/pasteboard/paste-without-nesting-expected.txt: Added. 12 * editing/pasteboard/paste-without-nesting.html: Added. 13 1 14 2011-11-30 Chris Fleizach <cfleizach@apple.com> 2 15 -
trunk/Source/WebCore/ChangeLog
r101574 r101575 1 2011-11-30 Enrica Casucci <enrica@apple.com> 2 3 Copy/paste of the same content produces increasingly nested markup 4 https://bugs.webkit.org/show_bug.cgi?id=73497 5 <rdar://problem/10208605> 6 7 When pasting a fragment over a selection, we perfom a DeleteSelection command 8 followed by a ReplaceSelection command. Delete selection preserves the style 9 of the selection start, leaving all the blocks containing the insertion point. 10 This patch eliminates all the nested divs that don't provide additional style, 11 avoiding the proliferation of nested divs. 12 13 Reviewed by Darin Adler. 14 15 Tests: editing/deleting/delete-and-cleanup.html 16 editing/pasteboard/paste-without-nesting.html 17 18 * editing/DeleteSelectionCommand.cpp: 19 (WebCore::DeleteSelectionCommand::removeRedundantBlocks): 20 (WebCore::DeleteSelectionCommand::doApply): 21 * editing/DeleteSelectionCommand.h: 22 1 23 2011-11-30 Dan Bernstein <mitz@apple.com> 2 24 -
trunk/Source/WebCore/editing/DeleteSelectionCommand.cpp
r97395 r101575 747 747 } 748 748 749 // This method removes div elements with no attributes that have only one child or no children at all. 750 void DeleteSelectionCommand::removeRedundantBlocks() 751 { 752 Node* node = m_endingPosition.deprecatedNode(); 753 Node* rootNode = node->rootEditableElement(); 754 755 while (node != rootNode) { 756 Node* parentNode = node->parentNode(); 757 if ((parentNode && parentNode->firstChild() != parentNode->lastChild()) || !node->hasTagName(divTag)) { 758 node = parentNode; 759 continue; 760 } 761 const NamedNodeMap* attributeMap = node->attributes(); 762 if (!attributeMap || attributeMap->isEmpty()) { 763 if (node == m_endingPosition.anchorNode()) 764 updatePositionForNodeRemoval(m_endingPosition, node); 765 766 CompositeEditCommand::removeNodePreservingChildren(node); 767 node = m_endingPosition.anchorNode(); 768 } else 769 node = parentNode; 770 } 771 } 772 749 773 void DeleteSelectionCommand::doApply() 750 774 { … … 811 835 RefPtr<Node> placeholder = m_needPlaceholder ? createBreakElement(document()).get() : 0; 812 836 813 if (placeholder) 837 if (placeholder) { 838 removeRedundantBlocks(); 814 839 insertNodeAt(placeholder.get(), m_endingPosition); 840 } 815 841 816 842 rebalanceWhitespaceAt(m_endingPosition); -
trunk/Source/WebCore/editing/DeleteSelectionCommand.h
r86295 r101575 68 68 virtual void removeNode(PassRefPtr<Node>); 69 69 virtual void deleteTextFromNode(PassRefPtr<Text>, unsigned, unsigned); 70 void removeRedundantBlocks(); 70 71 71 72 // This function provides access to original string after the correction has been deleted.
Note: See TracChangeset
for help on using the changeset viewer.