Chromium Code Reviews| 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 79d38cb36fe377f0d516a531a5b4fb95d4f2a6f6..1d6608c3f66698dc41aac0aa7e343a6e9ed1e501 100644 |
| --- a/third_party/WebKit/Source/core/editing/Editor.cpp |
| +++ b/third_party/WebKit/Source/core/editing/Editor.cpp |
| @@ -201,6 +201,18 @@ EditorClient& Editor::client() const { |
| return emptyEditorClient(); |
| } |
| +static bool isCaretAtTopOfWrappedLine(FrameSelection& selection) { |
| + if (!selection.isCaret()) |
| + return false; |
| + if (selection.affinity() != TextAffinity::Downstream) |
| + return false; |
| + // Enable this operation for plaintext only for now. |
| + if (selection.isContentRichlyEditable()) |
| + return false; |
| + // TODO(kojii): how to know if a Position is at the top of wrapped line? |
|
yosin_UTC9
2017/01/05 08:36:50
I think "start" is better than "top".
We can chec
|
| + return true; |
| +} |
| + |
| bool Editor::handleTextEvent(TextEvent* event) { |
| // Default event handling for Drag and Drop will be handled by DragController |
| // so we leave the event for it. |
| @@ -237,6 +249,9 @@ bool Editor::handleTextEvent(TextEvent* event) { |
| return insertParagraphSeparator(); |
| } |
| + if (data == " " && isCaretAtTopOfWrappedLine(frame().selection())) |
| + insertLineBreak(); |
| + |
| return insertTextWithoutSendingTextEvent(EditCommandSource::kMenuOrKeyBinding, |
| data, false, event); |
| } |