Commit 26a3c373 authored by Zhuoyu Qian's avatar Zhuoyu Qian Committed by Commit Bot

Move PasteAsFragment() to EditorCommand.cpp.

Editor::PasteAsFragment() is called by PasteWithPasteboard() in
EditorCommand.cpp. Move it to make |Editor| class simpler for improving
code health.

BUG=672405
Signed-off-by: default avatarZhuoyu Qian <zhuoyu.qian@samsung.com>
Change-Id: Ia6c2d5f4ecb936e9fade8437fb8db1ebae508ded
Reviewed-on: https://chromium-review.googlesource.com/933683
Commit-Queue: Yoshifumi Inoue <yosin@chromium.org>
Reviewed-by: default avatarYoshifumi Inoue <yosin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#539077}
parent 004ef605
...@@ -411,17 +411,6 @@ void Editor::PasteAsPlainText(const String& pasting_text, ...@@ -411,17 +411,6 @@ void Editor::PasteAsPlainText(const String& pasting_text,
GetFrame().DomWindow(), pasting_text, smart_replace)); GetFrame().DomWindow(), pasting_text, smart_replace));
} }
void Editor::PasteAsFragment(DocumentFragment* pasting_fragment,
bool smart_replace,
bool match_style,
EditorCommandSource source) {
Element* target = FindEventTargetForClipboardEvent(source);
if (!target)
return;
target->DispatchEvent(TextEvent::CreateForFragmentPaste(
GetFrame().DomWindow(), pasting_fragment, smart_replace, match_style));
}
bool Editor::DispatchCopyEvent(EditorCommandSource source) { bool Editor::DispatchCopyEvent(EditorCommandSource source) {
// TODO(editing-dev): The use of UpdateStyleAndLayoutIgnorePendingStylesheets // TODO(editing-dev): The use of UpdateStyleAndLayoutIgnorePendingStylesheets
// needs to be audited. See http://crbug.com/590369 for more details. // needs to be audited. See http://crbug.com/590369 for more details.
......
...@@ -210,10 +210,6 @@ class CORE_EXPORT Editor final : public GarbageCollectedFinalized<Editor> { ...@@ -210,10 +210,6 @@ class CORE_EXPORT Editor final : public GarbageCollectedFinalized<Editor> {
void AddToKillRing(const EphemeralRange&); void AddToKillRing(const EphemeralRange&);
void PasteAsFragment(DocumentFragment*,
bool smart_replace,
bool match_style,
EditorCommandSource);
void PasteAsPlainText(const String&, bool smart_replace, EditorCommandSource); void PasteAsPlainText(const String&, bool smart_replace, EditorCommandSource);
Element* FindEventTargetFrom(const VisibleSelection&) const; Element* FindEventTargetFrom(const VisibleSelection&) const;
......
...@@ -60,6 +60,7 @@ ...@@ -60,6 +60,7 @@
#include "core/editing/iterators/TextIterator.h" #include "core/editing/iterators/TextIterator.h"
#include "core/editing/serializers/Serialization.h" #include "core/editing/serializers/Serialization.h"
#include "core/editing/spellcheck/SpellChecker.h" #include "core/editing/spellcheck/SpellChecker.h"
#include "core/events/TextEvent.h"
#include "core/frame/ContentSettingsClient.h" #include "core/frame/ContentSettingsClient.h"
#include "core/frame/LocalFrame.h" #include "core/frame/LocalFrame.h"
#include "core/frame/LocalFrameView.h" #include "core/frame/LocalFrameView.h"
...@@ -1840,6 +1841,19 @@ static bool DispatchPasteEvent(LocalFrame& frame, ...@@ -1840,6 +1841,19 @@ static bool DispatchPasteEvent(LocalFrame& frame,
EventTypeNames::paste, kDataTransferReadable, source, paste_mode); EventTypeNames::paste, kDataTransferReadable, source, paste_mode);
} }
static void PasteAsFragment(LocalFrame& frame,
DocumentFragment* pasting_fragment,
bool smart_replace,
bool match_style,
EditorCommandSource source) {
Element* const target =
frame.GetEditor().FindEventTargetForClipboardEvent(source);
if (!target)
return;
target->DispatchEvent(TextEvent::CreateForFragmentPaste(
frame.DomWindow(), pasting_fragment, smart_replace, match_style));
}
static void PasteWithPasteboard(LocalFrame& frame, static void PasteWithPasteboard(LocalFrame& frame,
Pasteboard* pasteboard, Pasteboard* pasteboard,
EditorCommandSource source) { EditorCommandSource source) {
...@@ -1879,9 +1893,9 @@ static void PasteWithPasteboard(LocalFrame& frame, ...@@ -1879,9 +1893,9 @@ static void PasteWithPasteboard(LocalFrame& frame,
if (!fragment) if (!fragment)
return; return;
frame.GetEditor().PasteAsFragment( PasteAsFragment(frame, fragment,
fragment, CanSmartReplaceWithPasteboard(frame, pasteboard), CanSmartReplaceWithPasteboard(frame, pasteboard),
chose_plain_text, source); chose_plain_text, source);
} }
static void Paste(LocalFrame& frame, EditorCommandSource source) { static void Paste(LocalFrame& frame, EditorCommandSource source) {
......
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