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 6ac01cdf4159227f26899b2694297968b60a8101..72d484ede33cc09c89e368afb99c31af3d808e2d 100644 |
--- a/third_party/WebKit/Source/core/editing/Editor.cpp |
+++ b/third_party/WebKit/Source/core/editing/Editor.cpp |
@@ -49,6 +49,7 @@ |
#include "core/editing/commands/DeleteSelectionCommand.h" |
#include "core/editing/commands/IndentOutdentCommand.h" |
#include "core/editing/commands/InsertListCommand.h" |
+#include "core/editing/commands/MoveSelectionCommand.h" |
#include "core/editing/commands/RemoveFormatCommand.h" |
#include "core/editing/commands/ReplaceSelectionCommand.h" |
#include "core/editing/commands/SimplifyMarkupCommand.h" |
@@ -524,6 +525,23 @@ void Editor::replaceSelectionWithText(const String& text, bool selectReplacement |
replaceSelectionWithFragment(createFragmentFromText(selectedRange(), text), selectReplacement, smartReplace, true); |
} |
+// TODO(xiaochengh): Merge it with |replaceSelectionWithFragment()|. |
+void Editor::replaceSelectionAfterDragging(PassRefPtrWillBeRawPtr<DocumentFragment> fragment, bool smartReplace, bool plainText) |
+{ |
+ ReplaceSelectionCommand::CommandOptions options = ReplaceSelectionCommand::SelectReplacement | ReplaceSelectionCommand::PreventNesting; |
+ if (smartReplace) |
+ options |= ReplaceSelectionCommand::SmartReplace; |
+ if (plainText) |
+ options |= ReplaceSelectionCommand::MatchStyle; |
+ ASSERT(frame().document()); |
+ ReplaceSelectionCommand::create(*frame().document(), fragment, options, EditActionDrag)->apply(); |
+} |
+ |
+void Editor::moveSelectionAfterDragging(PassRefPtrWillBeRawPtr<DocumentFragment> fragment, const Position& pos, bool smartInsert, bool smartDelete) |
+{ |
+ MoveSelectionCommand::create(fragment, pos, smartInsert, smartDelete)->apply(); |
+} |
+ |
EphemeralRange Editor::selectedRange() |
{ |
return frame().selection().selection().toNormalizedEphemeralRange(); |