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 ca051a0c662ea21fe8e1dd82ca3db819b1c1d4e9..1edbc2c0fbc8ea335473ab90a585deda277ae298 100644 |
--- a/third_party/WebKit/Source/core/editing/InputMethodController.cpp |
+++ b/third_party/WebKit/Source/core/editing/InputMethodController.cpp |
@@ -472,6 +472,43 @@ void InputMethodController::extendSelectionAndDelete(int before, int after) |
TypingCommand::deleteSelection(*frame().document()); |
} |
+void InputMethodController::deleteSurroundingText(size_t before, size_t after) |
+{ |
+ if (!editor().canEdit()) |
+ return; |
+ PlainTextRange selectionOffsets(getSelectionOffsets()); |
+ if (selectionOffsets.isNull()) |
+ return; |
+ |
+ size_t selectionStart = selectionOffsets.start(); |
+ size_t selectionEnd = selectionOffsets.end(); |
+ |
+ if (before != 0) { |
Changwan Ryu
2016/04/26 05:36:30
before > 0u
|
+ before = std::min(selectionStart, before); |
+ |
+ // Select the text to be deleted before selectionStart, |
+ // and adjust the start of selection in case of multi-code text. |
+ Position basePosition(frame().selection().start().anchorNode(), selectionStart - before + 1); |
+ Position adjustedPosition = previousPositionOf(basePosition, PositionMoveType::GraphemeCluster); |
+ int adjustedStart = adjustedPosition.computeOffsetInContainerNode(); |
+ |
+ if (!setSelectionOffsets(PlainTextRange(adjustedStart, static_cast<int>(selectionStart)))) |
+ return; |
+ TypingCommand::deleteSelection(*frame().document()); |
+ |
+ selectionEnd = selectionEnd - (selectionStart - adjustedStart); |
+ selectionStart = adjustedStart; |
+ } |
+ |
+ if (after != 0) { |
Changwan Ryu
2016/04/26 05:36:30
after > 0u
Comment still missing: why do you need
|
+ if (!setSelectionOffsets(PlainTextRange(static_cast<int>(selectionEnd), static_cast<int>(selectionEnd + after)))) |
+ return; |
+ TypingCommand::deleteSelection(*frame().document()); |
+ } |
+ |
+ setSelectionOffsets(PlainTextRange(selectionStart, selectionEnd)); |
+} |
+ |
DEFINE_TRACE(InputMethodController) |
{ |
visitor->trace(m_frame); |