Index: third_party/WebKit/Source/core/editing/InputMethodController.cpp |
diff --git a/third_party/WebKit/Source/core/editing/InputMethodController.cpp b/third_party/WebKit/Source/core/editing/InputMethodController.cpp |
index e1d2f0fe18572803afa15c40bfe7af59a60e36ee..a5c08174873a4bac26db07ebf95a96528d0f4743 100644 |
--- a/third_party/WebKit/Source/core/editing/InputMethodController.cpp |
+++ b/third_party/WebKit/Source/core/editing/InputMethodController.cpp |
@@ -456,6 +456,40 @@ void InputMethodController::extendSelectionAndDelete(int before, int after) |
TypingCommand::deleteSelection(*frame().document()); |
} |
+void InputMethodController::deleteSurroundingText(int before, int after) |
+{ |
+ if (!editor().canEdit()) |
+ return; |
+ PlainTextRange selectionOffsets(getSelectionOffsets()); |
+ if (selectionOffsets.isNull()) |
+ return; |
+ |
+ int selectionStart = static_cast<int>(selectionOffsets.start()); |
+ int selectionEnd = static_cast<int>(selectionOffsets.end()); |
+ |
+ if (before > 0) { |
+ int deleteLength = std::min(selectionStart, before); |
+ int leftStart = selectionStart - deleteLength; |
+ int leftEnd = selectionStart; |
+ if (!setSelectionOffsets(PlainTextRange(leftStart, leftEnd))) |
+ return; |
+ TypingCommand::deleteSelection(*frame().document()); |
+ |
+ selectionStart = leftStart; |
+ selectionEnd = selectionEnd - deleteLength; |
+ } |
+ |
+ if (after > 0) { |
+ int rightStart = selectionEnd; |
+ int rightEnd = selectionEnd + after; |
+ if (!setSelectionOffsets(PlainTextRange(rightStart, rightEnd))) |
+ return; |
+ TypingCommand::deleteSelection(*frame().document()); |
+ } |
+ |
+ setSelectionOffsets(PlainTextRange(selectionStart, selectionEnd)); |
+} |
+ |
DEFINE_TRACE(InputMethodController) |
{ |
visitor->trace(m_frame); |