Commit 7966ad31 authored by xiaochengh's avatar xiaochengh Committed by Commit bot

Move logic of WebLocalFrameImpl::replaceSelection to Editor

This patch moves the main logic of WebLocalFrameImpl::replaceSelection to Editor,
so that the web/ layer becomes thinner, and less details of editing are exposed.
No behavior is changed.

This patch is also a preparation for https://codereview.chromium.org/2576903002.

BUG=673789

Review-Url: https://codereview.chromium.org/2575343002
Cr-Commit-Position: refs/heads/master@{#438757}
parent 09721f55
...@@ -1665,6 +1665,14 @@ void Editor::tidyUpHTMLStructure(Document& document) { ...@@ -1665,6 +1665,14 @@ void Editor::tidyUpHTMLStructure(Document& document) {
// TODO(tkent): Should we check and move Text node children of <html>? // TODO(tkent): Should we check and move Text node children of <html>?
} }
void Editor::replaceSelection(const String& text) {
DCHECK(!frame().document()->needsLayoutTreeUpdate());
bool selectReplacement = behavior().shouldSelectReplacement();
bool smartReplace = true;
replaceSelectionWithText(text, selectReplacement, smartReplace,
InputEvent::InputType::InsertReplacementText);
}
DEFINE_TRACE(Editor) { DEFINE_TRACE(Editor) {
visitor->trace(m_frame); visitor->trace(m_frame);
visitor->trace(m_lastEditCommand); visitor->trace(m_lastEditCommand);
......
...@@ -261,7 +261,9 @@ class CORE_EXPORT Editor final : public GarbageCollectedFinalized<Editor> { ...@@ -261,7 +261,9 @@ class CORE_EXPORT Editor final : public GarbageCollectedFinalized<Editor> {
bool smartReplace, bool smartReplace,
InputEvent::InputType); InputEvent::InputType);
// TODO(xiaochengh): Replace |bool| parameters by |enum|. // Implementation of WebLocalFrameImpl::replaceSelection.
void replaceSelection(const String&);
void replaceSelectionAfterDragging(DocumentFragment*, void replaceSelectionAfterDragging(DocumentFragment*,
InsertMode, InsertMode,
DragSourceType); DragSourceType);
......
...@@ -949,12 +949,7 @@ void WebLocalFrameImpl::replaceSelection(const WebString& text) { ...@@ -949,12 +949,7 @@ void WebLocalFrameImpl::replaceSelection(const WebString& text) {
// needs to be audited. See http://crbug.com/590369 for more details. // needs to be audited. See http://crbug.com/590369 for more details.
frame()->document()->updateStyleAndLayoutIgnorePendingStylesheets(); frame()->document()->updateStyleAndLayoutIgnorePendingStylesheets();
bool selectReplacement = frame()->editor().replaceSelection(text);
frame()->editor().behavior().shouldSelectReplacement();
bool smartReplace = true;
frame()->editor().replaceSelectionWithText(
text, selectReplacement, smartReplace,
InputEvent::InputType::InsertReplacementText);
} }
void WebLocalFrameImpl::setMarkedText(const WebString& text, void WebLocalFrameImpl::setMarkedText(const WebString& text,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment