Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(245)

Side by Side Diff: Source/core/editing/DeleteSelectionCommand.cpp

Issue 18644008: Avoid adding placeholder when deleting last text in root (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Add additional tests that need rebaselines Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/editing/CompositeEditCommand.cpp ('k') | Source/core/html/HTMLInputElement.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2005 Apple Computer, Inc. All rights reserved. 2 * Copyright (C) 2005 Apple Computer, 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 754 matching lines...) Expand 10 before | Expand all | Expand 10 after
765 if (!m_hasSelectionToDelete) 765 if (!m_hasSelectionToDelete)
766 m_selectionToDelete = endingSelection(); 766 m_selectionToDelete = endingSelection();
767 767
768 if (!m_selectionToDelete.isNonOrphanedRange()) 768 if (!m_selectionToDelete.isNonOrphanedRange())
769 return; 769 return;
770 770
771 // save this to later make the selection with 771 // save this to later make the selection with
772 EAffinity affinity = m_selectionToDelete.affinity(); 772 EAffinity affinity = m_selectionToDelete.affinity();
773 773
774 Position downstreamEnd = m_selectionToDelete.end().downstream(); 774 Position downstreamEnd = m_selectionToDelete.end().downstream();
775 m_needPlaceholder = isStartOfParagraph(m_selectionToDelete.visibleStart(), C anCrossEditingBoundary) 775 bool rootWillStayOpenWithoutPlaceholder = downstreamEnd.containerNode() == d ownstreamEnd.containerNode()->rootEditableElement()
776 && isEndOfParagraph(m_selectionToDelete.visibleEnd(), CanCrossEditin gBoundary) 776 || (downstreamEnd.containerNode()->isTextNode() && downstreamEnd.contain erNode()->parentNode() == downstreamEnd.containerNode()->rootEditableElement());
777 && !lineBreakExistsAtVisiblePosition(m_selectionToDelete.visibleEnd( )); 777 m_needPlaceholder = !rootWillStayOpenWithoutPlaceholder
778 && isStartOfParagraph(m_selectionToDelete.visibleStart(), CanCrossEditin gBoundary)
779 && isEndOfParagraph(m_selectionToDelete.visibleEnd(), CanCrossEditingBou ndary)
780 && !lineBreakExistsAtVisiblePosition(m_selectionToDelete.visibleEnd());
778 if (m_needPlaceholder) { 781 if (m_needPlaceholder) {
779 // Don't need a placeholder when deleting a selection that starts just b efore a table 782 // Don't need a placeholder when deleting a selection that starts just b efore a table
780 // and ends inside it (we do need placeholders to hold open empty cells, but that's 783 // and ends inside it (we do need placeholders to hold open empty cells, but that's
781 // handled elsewhere). 784 // handled elsewhere).
782 if (Node* table = isLastPositionBeforeTable(m_selectionToDelete.visibleS tart())) 785 if (Node* table = isLastPositionBeforeTable(m_selectionToDelete.visibleS tart()))
783 if (m_selectionToDelete.end().deprecatedNode()->isDescendantOf(table )) 786 if (m_selectionToDelete.end().deprecatedNode()->isDescendantOf(table ))
784 m_needPlaceholder = false; 787 m_needPlaceholder = false;
785 } 788 }
786 789
787 790
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
837 840
838 // Normally deletion doesn't preserve the typing style that was present before i t. For example, 841 // Normally deletion doesn't preserve the typing style that was present before i t. For example,
839 // type a character, Bold, then delete the character and start typing. The Bold typing style shouldn't 842 // type a character, Bold, then delete the character and start typing. The Bold typing style shouldn't
840 // stick around. Deletion should preserve a typing style that *it* sets, howeve r. 843 // stick around. Deletion should preserve a typing style that *it* sets, howeve r.
841 bool DeleteSelectionCommand::preservesTypingStyle() const 844 bool DeleteSelectionCommand::preservesTypingStyle() const
842 { 845 {
843 return m_typingStyle; 846 return m_typingStyle;
844 } 847 }
845 848
846 } // namespace WebCore 849 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/editing/CompositeEditCommand.cpp ('k') | Source/core/html/HTMLInputElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698