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

Unified Diff: third_party/WebKit/Source/core/editing/Editor.cpp

Issue 2351103002: Prune CreateVisiblePositionDeprecated from Editor::canDeleteRange (Closed)
Patch Set: Address comments Created 4 years, 3 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/editing/Editor.cpp
diff --git a/third_party/WebKit/Source/core/editing/Editor.cpp b/third_party/WebKit/Source/core/editing/Editor.cpp
index 953b683cc0b668b60db066f6bcafa80938b9961c..da461c3d567635c84749f2fbd001275764291806 100644
--- a/third_party/WebKit/Source/core/editing/Editor.cpp
+++ b/third_party/WebKit/Source/core/editing/Editor.cpp
@@ -282,24 +282,17 @@ bool Editor::canDelete() const
return selection.isRange() && selection.rootEditableElement();
}
+// TODO(xiaochengh): Merge it with |shouldDeleteRange|.
bool Editor::canDeleteRange(const EphemeralRange& range) const
{
+ DCHECK(!range.isCollapsed()) << range.startPosition();
+
Node* startContainer = range.startPosition().computeContainerNode();
Node* endContainer = range.endPosition().computeContainerNode();
if (!startContainer || !endContainer)
return false;
- if (!hasEditableStyle(*startContainer) || !hasEditableStyle(*endContainer))
- return false;
-
- if (range.isCollapsed()) {
- VisiblePosition start = createVisiblePositionDeprecated(range.startPosition());
- VisiblePosition previous = previousPositionOf(start);
- // FIXME: We sometimes allow deletions at the start of editable roots, like when the caret is in an empty list item.
- if (previous.isNull() || rootEditableElement(*previous.deepEquivalent().anchorNode()) != rootEditableElement(*startContainer))
- return false;
- }
- return true;
+ return hasEditableStyle(*startContainer) && hasEditableStyle(*endContainer);
}
bool Editor::smartInsertDeleteEnabled() const
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698