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

Unified Diff: Source/core/editing/DeleteSelectionCommand.cpp

Issue 14969020: Avoid adding placeholder when deleting last text in root (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fixed bad TestExpectations behavior and unnecessary results churn. Created 7 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: Source/core/editing/DeleteSelectionCommand.cpp
diff --git a/Source/core/editing/DeleteSelectionCommand.cpp b/Source/core/editing/DeleteSelectionCommand.cpp
index 868e60ab2be2dd28f78665b3d234ddd0f667b503..fa303858b9b3b910e1f84db6ea3b8ca81a70a27e 100644
--- a/Source/core/editing/DeleteSelectionCommand.cpp
+++ b/Source/core/editing/DeleteSelectionCommand.cpp
@@ -766,9 +766,12 @@ void DeleteSelectionCommand::doApply()
EAffinity affinity = m_selectionToDelete.affinity();
Position downstreamEnd = m_selectionToDelete.end().downstream();
- m_needPlaceholder = isStartOfParagraph(m_selectionToDelete.visibleStart(), CanCrossEditingBoundary)
- && isEndOfParagraph(m_selectionToDelete.visibleEnd(), CanCrossEditingBoundary)
- && !lineBreakExistsAtVisiblePosition(m_selectionToDelete.visibleEnd());
+ bool rootWillStayOpenWithoutPlaceholder = downstreamEnd.containerNode() == downstreamEnd.containerNode()->rootEditableElement()
+ || (downstreamEnd.containerNode()->isTextNode() && downstreamEnd.containerNode()->parentNode() == downstreamEnd.containerNode()->rootEditableElement());
+ m_needPlaceholder = !rootWillStayOpenWithoutPlaceholder
+ && isStartOfParagraph(m_selectionToDelete.visibleStart(), CanCrossEditingBoundary)
+ && isEndOfParagraph(m_selectionToDelete.visibleEnd(), CanCrossEditingBoundary)
+ && !lineBreakExistsAtVisiblePosition(m_selectionToDelete.visibleEnd());
if (m_needPlaceholder) {
// Don't need a placeholder when deleting a selection that starts just before a table
// and ends inside it (we do need placeholders to hold open empty cells, but that's

Powered by Google App Engine
This is Rietveld 408576698