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 @@ ...@@ -32,6 +32,7 @@
#include "core/clipboard/DraggedIsolatedFileSystem.h" #include "core/clipboard/DraggedIsolatedFileSystem.h"
#include "core/clipboard/Pasteboard.h" #include "core/clipboard/Pasteboard.h"
#include "platform/PasteMode.h"
#include "platform/clipboard/ClipboardMimeTypes.h" #include "platform/clipboard/ClipboardMimeTypes.h"
#include "platform/clipboard/ClipboardUtilities.h" #include "platform/clipboard/ClipboardUtilities.h"
#include "platform/wtf/HashSet.h" #include "platform/wtf/HashSet.h"
...@@ -53,7 +54,7 @@ DataObject* DataObject::CreateFromPasteboard(PasteMode paste_mode) { ...@@ -53,7 +54,7 @@ DataObject* DataObject::CreateFromPasteboard(PasteMode paste_mode) {
WebVector<WebString> web_types = WebVector<WebString> web_types =
Platform::Current()->Clipboard()->ReadAvailableTypes(buffer, &ignored); Platform::Current()->Clipboard()->ReadAvailableTypes(buffer, &ignored);
for (const WebString& type : web_types) { for (const WebString& type : web_types) {
if (paste_mode == kPlainTextOnly && type != kMimeTypeTextPlain) if (paste_mode == PasteMode::kPlainTextOnly && type != kMimeTypeTextPlain)
continue; continue;
data_object->item_list_.push_back( data_object->item_list_.push_back(
DataObjectItem::CreateFromPasteboard(type, sequence_number)); DataObjectItem::CreateFromPasteboard(type, sequence_number));
......
...@@ -34,7 +34,6 @@ ...@@ -34,7 +34,6 @@
#include "base/memory/scoped_refptr.h" #include "base/memory/scoped_refptr.h"
#include "core/CoreExport.h" #include "core/CoreExport.h"
#include "core/clipboard/DataObjectItem.h" #include "core/clipboard/DataObjectItem.h"
#include "platform/PasteMode.h"
#include "platform/Supplementable.h" #include "platform/Supplementable.h"
#include "platform/heap/Handle.h" #include "platform/heap/Handle.h"
#include "platform/wtf/Vector.h" #include "platform/wtf/Vector.h"
...@@ -47,6 +46,8 @@ class KURL; ...@@ -47,6 +46,8 @@ class KURL;
class SharedBuffer; class SharedBuffer;
class WebDragData; class WebDragData;
enum class PasteMode;
// A data object for holding data that would be in a clipboard or moved // 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 // during a drag-n-drop operation. This is the data that WebCore is aware
// of and is not specific to a platform. // of and is not specific to a platform.
......
...@@ -38,7 +38,6 @@ ...@@ -38,7 +38,6 @@
#include "core/editing/WritingDirection.h" #include "core/editing/WritingDirection.h"
#include "core/editing/finder/FindOptions.h" #include "core/editing/finder/FindOptions.h"
#include "core/events/InputEvent.h" #include "core/events/InputEvent.h"
#include "platform/PasteMode.h"
#include "platform/heap/Handle.h" #include "platform/heap/Handle.h"
#include "platform/scroll/ScrollAlignment.h" #include "platform/scroll/ScrollAlignment.h"
......
...@@ -78,6 +78,7 @@ ...@@ -78,6 +78,7 @@
#include "core/page/Page.h" #include "core/page/Page.h"
#include "platform/Histogram.h" #include "platform/Histogram.h"
#include "platform/KillRing.h" #include "platform/KillRing.h"
#include "platform/PasteMode.h"
#include "platform/loader/fetch/ResourceFetcher.h" #include "platform/loader/fetch/ResourceFetcher.h"
#include "platform/scroll/Scrollbar.h" #include "platform/scroll/Scrollbar.h"
#include "platform/wtf/StringExtras.h" #include "platform/wtf/StringExtras.h"
...@@ -804,7 +805,7 @@ static bool DispatchCopyOrCutEvent(LocalFrame& frame, ...@@ -804,7 +805,7 @@ static bool DispatchCopyOrCutEvent(LocalFrame& frame,
return true; return true;
return DispatchClipboardEvent(frame, event_type, kDataTransferWritable, return DispatchClipboardEvent(frame, event_type, kDataTransferWritable,
source, kAllMimeTypes); source, PasteMode::kAllMimeTypes);
} }
static bool CanSmartCopyOrDelete(LocalFrame& frame) { static bool CanSmartCopyOrDelete(LocalFrame& frame) {
...@@ -2121,7 +2122,7 @@ static void PasteWithPasteboard(LocalFrame& frame, ...@@ -2121,7 +2122,7 @@ static void PasteWithPasteboard(LocalFrame& frame,
static void Paste(LocalFrame& frame, EditorCommandSource source) { static void Paste(LocalFrame& frame, EditorCommandSource source) {
DCHECK(frame.GetDocument()); DCHECK(frame.GetDocument());
if (!DispatchPasteEvent(frame, kAllMimeTypes, source)) if (!DispatchPasteEvent(frame, PasteMode::kAllMimeTypes, source))
return; return;
if (!frame.GetEditor().CanPaste()) if (!frame.GetEditor().CanPaste())
return; return;
...@@ -2139,8 +2140,9 @@ static void Paste(LocalFrame& frame, EditorCommandSource source) { ...@@ -2139,8 +2140,9 @@ static void Paste(LocalFrame& frame, EditorCommandSource source) {
ResourceFetcher* const loader = frame.GetDocument()->Fetcher(); ResourceFetcher* const loader = frame.GetDocument()->Fetcher();
ResourceCacheValidationSuppressor validation_suppressor(loader); ResourceCacheValidationSuppressor validation_suppressor(loader);
const PasteMode paste_mode = const PasteMode paste_mode = frame.GetEditor().CanEditRichly()
frame.GetEditor().CanEditRichly() ? kAllMimeTypes : kPlainTextOnly; ? PasteMode::kAllMimeTypes
: PasteMode::kPlainTextOnly;
if (source == EditorCommandSource::kMenuOrKeyBinding) { if (source == EditorCommandSource::kMenuOrKeyBinding) {
DataTransfer* data_transfer = DataTransfer* data_transfer =
...@@ -2157,7 +2159,7 @@ static void Paste(LocalFrame& frame, EditorCommandSource source) { ...@@ -2157,7 +2159,7 @@ static void Paste(LocalFrame& frame, EditorCommandSource source) {
return; return;
} }
if (paste_mode == kAllMimeTypes) { if (paste_mode == PasteMode::kAllMimeTypes) {
PasteWithPasteboard(frame, Pasteboard::GeneralPasteboard(), source); PasteWithPasteboard(frame, Pasteboard::GeneralPasteboard(), source);
return; return;
} }
...@@ -2206,7 +2208,7 @@ static bool ExecutePasteAndMatchStyle(LocalFrame& frame, ...@@ -2206,7 +2208,7 @@ static bool ExecutePasteAndMatchStyle(LocalFrame& frame,
Event*, Event*,
EditorCommandSource source, EditorCommandSource source,
const String&) { const String&) {
if (!DispatchPasteEvent(frame, kPlainTextOnly, source)) if (!DispatchPasteEvent(frame, PasteMode::kPlainTextOnly, source))
return false; return false;
if (!frame.GetEditor().CanPaste()) if (!frame.GetEditor().CanPaste())
return false; return false;
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
namespace blink { namespace blink {
enum PasteMode { enum class PasteMode {
kAllMimeTypes, kAllMimeTypes,
kPlainTextOnly, 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