Commit 519a13df authored by Zhuoyu Qian's avatar Zhuoyu Qian Committed by Commit Bot

Change PasteMode to be an enum class.

This patch makes PasteMode to be an enum class for better type safety
and improving code health. Using forward declaratuion in other header
files instead of including |PasteMode.h|.
Signed-off-by: default avatarZhuoyu Qian <zhuoyu.qian@samsung.com>
Change-Id: I74ea67e08607779cb823cb379c415263d537303f
Reviewed-on: https://chromium-review.googlesource.com/954423Reviewed-by: default avatarKent Tamura <tkent@chromium.org>
Cr-Commit-Position: refs/heads/master@{#541724}
parent d1963901
......@@ -32,6 +32,7 @@
#include "core/clipboard/DraggedIsolatedFileSystem.h"
#include "core/clipboard/Pasteboard.h"
#include "platform/PasteMode.h"
#include "platform/clipboard/ClipboardMimeTypes.h"
#include "platform/clipboard/ClipboardUtilities.h"
#include "platform/wtf/HashSet.h"
......@@ -53,7 +54,7 @@ DataObject* DataObject::CreateFromPasteboard(PasteMode paste_mode) {
WebVector<WebString> web_types =
Platform::Current()->Clipboard()->ReadAvailableTypes(buffer, &ignored);
for (const WebString& type : web_types) {
if (paste_mode == kPlainTextOnly && type != kMimeTypeTextPlain)
if (paste_mode == PasteMode::kPlainTextOnly && type != kMimeTypeTextPlain)
continue;
data_object->item_list_.push_back(
DataObjectItem::CreateFromPasteboard(type, sequence_number));
......
......@@ -34,7 +34,6 @@
#include "base/memory/scoped_refptr.h"
#include "core/CoreExport.h"
#include "core/clipboard/DataObjectItem.h"
#include "platform/PasteMode.h"
#include "platform/Supplementable.h"
#include "platform/heap/Handle.h"
#include "platform/wtf/Vector.h"
......@@ -47,6 +46,8 @@ class KURL;
class SharedBuffer;
class WebDragData;
enum class PasteMode;
// A data object for holding data that would be in a clipboard or moved
// during a drag-n-drop operation. This is the data that WebCore is aware
// of and is not specific to a platform.
......
......@@ -38,7 +38,6 @@
#include "core/editing/WritingDirection.h"
#include "core/editing/finder/FindOptions.h"
#include "core/events/InputEvent.h"
#include "platform/PasteMode.h"
#include "platform/heap/Handle.h"
#include "platform/scroll/ScrollAlignment.h"
......
......@@ -78,6 +78,7 @@
#include "core/page/Page.h"
#include "platform/Histogram.h"
#include "platform/KillRing.h"
#include "platform/PasteMode.h"
#include "platform/loader/fetch/ResourceFetcher.h"
#include "platform/scroll/Scrollbar.h"
#include "platform/wtf/StringExtras.h"
......@@ -804,7 +805,7 @@ static bool DispatchCopyOrCutEvent(LocalFrame& frame,
return true;
return DispatchClipboardEvent(frame, event_type, kDataTransferWritable,
source, kAllMimeTypes);
source, PasteMode::kAllMimeTypes);
}
static bool CanSmartCopyOrDelete(LocalFrame& frame) {
......@@ -2121,7 +2122,7 @@ static void PasteWithPasteboard(LocalFrame& frame,
static void Paste(LocalFrame& frame, EditorCommandSource source) {
DCHECK(frame.GetDocument());
if (!DispatchPasteEvent(frame, kAllMimeTypes, source))
if (!DispatchPasteEvent(frame, PasteMode::kAllMimeTypes, source))
return;
if (!frame.GetEditor().CanPaste())
return;
......@@ -2139,8 +2140,9 @@ static void Paste(LocalFrame& frame, EditorCommandSource source) {
ResourceFetcher* const loader = frame.GetDocument()->Fetcher();
ResourceCacheValidationSuppressor validation_suppressor(loader);
const PasteMode paste_mode =
frame.GetEditor().CanEditRichly() ? kAllMimeTypes : kPlainTextOnly;
const PasteMode paste_mode = frame.GetEditor().CanEditRichly()
? PasteMode::kAllMimeTypes
: PasteMode::kPlainTextOnly;
if (source == EditorCommandSource::kMenuOrKeyBinding) {
DataTransfer* data_transfer =
......@@ -2157,7 +2159,7 @@ static void Paste(LocalFrame& frame, EditorCommandSource source) {
return;
}
if (paste_mode == kAllMimeTypes) {
if (paste_mode == PasteMode::kAllMimeTypes) {
PasteWithPasteboard(frame, Pasteboard::GeneralPasteboard(), source);
return;
}
......@@ -2206,7 +2208,7 @@ static bool ExecutePasteAndMatchStyle(LocalFrame& frame,
Event*,
EditorCommandSource source,
const String&) {
if (!DispatchPasteEvent(frame, kPlainTextOnly, source))
if (!DispatchPasteEvent(frame, PasteMode::kPlainTextOnly, source))
return false;
if (!frame.GetEditor().CanPaste())
return false;
......
......@@ -33,7 +33,7 @@
namespace blink {
enum PasteMode {
enum class PasteMode {
kAllMimeTypes,
kPlainTextOnly,
};
......
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