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

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: 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
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 745 matching lines...) Expand 10 before | Expand all | Expand 10 after
756 if (!m_hasSelectionToDelete) 756 if (!m_hasSelectionToDelete)
757 m_selectionToDelete = endingSelection(); 757 m_selectionToDelete = endingSelection();
758 758
759 if (!m_selectionToDelete.isNonOrphanedRange()) 759 if (!m_selectionToDelete.isNonOrphanedRange())
760 return; 760 return;
761 761
762 // save this to later make the selection with 762 // save this to later make the selection with
763 EAffinity affinity = m_selectionToDelete.affinity(); 763 EAffinity affinity = m_selectionToDelete.affinity();
764 764
765 Position downstreamEnd = m_selectionToDelete.end().downstream(); 765 Position downstreamEnd = m_selectionToDelete.end().downstream();
766 m_needPlaceholder = isStartOfParagraph(m_selectionToDelete.visibleStart(), C anCrossEditingBoundary) 766 bool rootWillStayOpenWithoutPlaceholder = downstreamEnd.containerNode() == d ownstreamEnd.containerNode()->rootEditableElement()
767 && isEndOfParagraph(m_selectionToDelete.visibleEnd(), CanCrossEditin gBoundary) 767 || (downstreamEnd.containerNode()->isTextNode() && downstreamEnd.contain erNode()->parentNode() == downstreamEnd.containerNode()->rootEditableElement());
768 && !lineBreakExistsAtVisiblePosition(m_selectionToDelete.visibleEnd( )); 768 m_needPlaceholder = !rootWillStayOpenWithoutPlaceholder
769 && isStartOfParagraph(m_selectionToDelete.visibleStart(), CanCrossEditin gBoundary)
770 && isEndOfParagraph(m_selectionToDelete.visibleEnd(), CanCrossEditingBou ndary)
771 && !lineBreakExistsAtVisiblePosition(m_selectionToDelete.visibleEnd());
769 if (m_needPlaceholder) { 772 if (m_needPlaceholder) {
770 // Don't need a placeholder when deleting a selection that starts just b efore a table 773 // Don't need a placeholder when deleting a selection that starts just b efore a table
771 // and ends inside it (we do need placeholders to hold open empty cells, but that's 774 // and ends inside it (we do need placeholders to hold open empty cells, but that's
772 // handled elsewhere). 775 // handled elsewhere).
773 if (Node* table = isLastPositionBeforeTable(m_selectionToDelete.visibleS tart())) 776 if (Node* table = isLastPositionBeforeTable(m_selectionToDelete.visibleS tart()))
774 if (m_selectionToDelete.end().deprecatedNode()->isDescendantOf(table )) 777 if (m_selectionToDelete.end().deprecatedNode()->isDescendantOf(table ))
775 m_needPlaceholder = false; 778 m_needPlaceholder = false;
776 } 779 }
777 780
778 781
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
828 831
829 // Normally deletion doesn't preserve the typing style that was present before i t. For example, 832 // Normally deletion doesn't preserve the typing style that was present before i t. For example,
830 // type a character, Bold, then delete the character and start typing. The Bold typing style shouldn't 833 // type a character, Bold, then delete the character and start typing. The Bold typing style shouldn't
831 // stick around. Deletion should preserve a typing style that *it* sets, howeve r. 834 // stick around. Deletion should preserve a typing style that *it* sets, howeve r.
832 bool DeleteSelectionCommand::preservesTypingStyle() const 835 bool DeleteSelectionCommand::preservesTypingStyle() const
833 { 836 {
834 return m_typingStyle; 837 return m_typingStyle;
835 } 838 }
836 839
837 } // namespace WebCore 840 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698