Commit 64c6dc07 authored by Zhuoyu Qian's avatar Zhuoyu Qian Committed by Commit Bot

Introduce ClipboardCommands to split EditorCommand.cpp

This Cl introduces "ClipboardCommands.h", move the declarations of some
static functions related to clipboard to the header file. Make
EditorCommand simpler for improving code health.

Bug: 818552
Signed-off-by: default avatarZhuoyu Qian <zhuoyu.qian@samsung.com>
Change-Id: I2ebbd4ebb6a0ee3cc13f3a928c786a8d6e285bf4
Reviewed-on: https://chromium-review.googlesource.com/952744Reviewed-by: default avatarYoshifumi Inoue <yosin@chromium.org>
Commit-Queue: Yoshifumi Inoue <yosin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#542052}
parent 045cdc93
......@@ -101,6 +101,7 @@ blink_core_sources("editing") {
"commands/ApplyStyleCommand.h",
"commands/BreakBlockquoteCommand.cpp",
"commands/BreakBlockquoteCommand.h",
"commands/ClipboardCommands.h",
"commands/CompositeEditCommand.cpp",
"commands/CompositeEditCommand.h",
"commands/CreateLinkCommand.cpp",
......
/*
* Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
* Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
* Copyright (C) 2009 Igalia S.L.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ClipboardCommands_h
#define ClipboardCommands_h
#include "core/clipboard/DataTransferAccessPolicy.h"
#include "core/editing/Forward.h"
#include "platform/wtf/Allocator.h"
#include "platform/wtf/text/WTFString.h"
namespace blink {
class DocumentFragment;
class Element;
class Event;
class LocalFrame;
class Pasteboard;
enum class EditorCommandSource;
enum class PasteMode;
// This class provides static functions about commands related to clipboard.
class ClipboardCommands {
STATIC_ONLY(ClipboardCommands);
public:
static bool EnabledCopy(LocalFrame&, Event*, EditorCommandSource);
static bool EnabledCut(LocalFrame&, Event*, EditorCommandSource);
static bool EnabledPaste(LocalFrame&, Event*, EditorCommandSource);
// Returns |bool| value for Document#execCommand().
static bool ExecuteCopy(LocalFrame&,
Event*,
EditorCommandSource,
const String&);
static bool ExecuteCut(LocalFrame&,
Event*,
EditorCommandSource,
const String&);
static bool ExecutePaste(LocalFrame&,
Event*,
EditorCommandSource,
const String&);
static bool ExecutePasteGlobalSelection(LocalFrame&,
Event*,
EditorCommandSource,
const String&);
static bool ExecutePasteAndMatchStyle(LocalFrame&,
Event*,
EditorCommandSource,
const String&);
static bool PasteSupported(LocalFrame*);
private:
static bool CanReadClipboard(LocalFrame&, EditorCommandSource);
static bool CanWriteClipboard(LocalFrame&, EditorCommandSource);
static bool CanSmartReplaceWithPasteboard(LocalFrame&, Pasteboard*);
static bool CanDeleteRange(const EphemeralRange&);
static Element* FindEventTargetForClipboardEvent(LocalFrame&,
EditorCommandSource);
// Returns true if Editor should continue with default processing.
static bool DispatchClipboardEvent(LocalFrame&,
const AtomicString&,
DataTransferAccessPolicy,
EditorCommandSource,
PasteMode);
static bool DispatchCopyOrCutEvent(LocalFrame&,
EditorCommandSource,
const AtomicString&);
static bool DispatchPasteEvent(LocalFrame&, PasteMode, EditorCommandSource);
static void WriteSelectionToPasteboard(LocalFrame&);
static void Paste(LocalFrame&, EditorCommandSource);
static void PasteAsFragment(LocalFrame&,
DocumentFragment*,
bool smart_replace,
bool match_style,
EditorCommandSource);
static void PasteAsPlainTextWithPasteboard(LocalFrame&,
Pasteboard*,
EditorCommandSource);
static void PasteWithPasteboard(LocalFrame&,
Pasteboard*,
EditorCommandSource);
};
} // namespace blink
#endif
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