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

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

Issue 2350323003: Merge can/shouldDeleteRange in Editor (Closed)
Patch Set: 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 | « third_party/WebKit/Source/core/editing/Editor.h ('k') | 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 da461c3d567635c84749f2fbd001275764291806..6a66aa9d0db49ff014f509bfa78e2cf6c5cc1c1c 100644
--- a/third_party/WebKit/Source/core/editing/Editor.cpp
+++ b/third_party/WebKit/Source/core/editing/Editor.cpp
@@ -282,19 +282,6 @@ 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;
-
- return hasEditableStyle(*startContainer) && hasEditableStyle(*endContainer);
-}
-
bool Editor::smartInsertDeleteEnabled() const
{
if (Settings* settings = frame().settings())
@@ -577,12 +564,17 @@ EphemeralRange Editor::selectedRange()
return frame().selection().selection().toNormalizedEphemeralRange();
}
-bool Editor::shouldDeleteRange(const EphemeralRange& range) const
+bool Editor::canDeleteRange(const EphemeralRange& range) const
{
if (range.isCollapsed())
return false;
- return canDeleteRange(range);
+ Node* startContainer = range.startPosition().computeContainerNode();
+ Node* endContainer = range.endPosition().computeContainerNode();
+ if (!startContainer || !endContainer)
+ return false;
+
+ return hasEditableStyle(*startContainer) && hasEditableStyle(*endContainer);
}
void Editor::notifyComponentsOnChangedSelection()
@@ -886,7 +878,7 @@ void Editor::cut(EditorCommandSource source)
if (!canCut())
return;
// TODO(yosin) We should use early return style here.
- if (shouldDeleteRange(selectedRange())) {
+ if (canDeleteRange(selectedRange())) {
spellChecker().updateMarkersForWordsAffectedByEditing(true);
if (enclosingTextFormControl(frame().selection().start())) {
String plainText = frame().selectedTextForClipboard();
« no previous file with comments | « third_party/WebKit/Source/core/editing/Editor.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698