Commit a62b4777 authored by Zhuoyu Qian's avatar Zhuoyu Qian Committed by Commit Bot

Introduce StyleCommands to split EditorCommand.cpp

This CL introduces "StyleCommands.h" to move the declarations of some
static functions related to style commands to the header file to make
EditorCommand simpler for improving code health.

Bug: 818552
Signed-off-by: default avatarZhuoyu Qian <zhuoyu.qian@samsung.com>
Change-Id: Ic30cfa48855dbb482a92d2d2e2d657a9cdfb7ae7
Reviewed-on: https://chromium-review.googlesource.com/985596Reviewed-by: default avatarYoshifumi Inoue <yosin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#546779}
parent bd784801
...@@ -177,6 +177,7 @@ blink_core_sources("editing") { ...@@ -177,6 +177,7 @@ blink_core_sources("editing") {
"commands/SplitTextNodeCommand.h", "commands/SplitTextNodeCommand.h",
"commands/SplitTextNodeContainingElementCommand.cpp", "commands/SplitTextNodeContainingElementCommand.cpp",
"commands/SplitTextNodeContainingElementCommand.h", "commands/SplitTextNodeContainingElementCommand.h",
"commands/StyleCommands.h",
"commands/TypingCommand.cpp", "commands/TypingCommand.cpp",
"commands/TypingCommand.h", "commands/TypingCommand.h",
"commands/UndoStack.cpp", "commands/UndoStack.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 StyleCommands_h
#define StyleCommands_h
#include "core/editing/WritingDirection.h"
#include "core/events/InputEvent.h"
#include "platform/wtf/Allocator.h"
#include "platform/wtf/Forward.h"
namespace blink {
class CSSPropertyValueSet;
class EditingStyle;
class EditorInternalCommand;
class Event;
class LocalFrame;
enum class EditingTriState;
enum class EditorCommandSource;
// This class provides static functions about commands related to style.
class StyleCommands {
STATIC_ONLY(StyleCommands);
public:
// Returns |bool| value for Document#execCommand().
static bool ExecuteBackColor(LocalFrame&,
Event*,
EditorCommandSource,
const String&);
static bool ExecuteForeColor(LocalFrame&,
Event*,
EditorCommandSource,
const String&);
static bool ExecuteFontName(LocalFrame&,
Event*,
EditorCommandSource,
const String&);
static bool ExecuteFontSize(LocalFrame&,
Event*,
EditorCommandSource,
const String&);
static bool ExecuteFontSizeDelta(LocalFrame&,
Event*,
EditorCommandSource,
const String&);
static bool ExecuteToggleBold(LocalFrame&,
Event*,
EditorCommandSource,
const String&);
static bool ExecuteToggleItalic(LocalFrame&,
Event*,
EditorCommandSource,
const String&);
static bool ExecuteSubscript(LocalFrame&,
Event*,
EditorCommandSource,
const String&);
static bool ExecuteSuperscript(LocalFrame&,
Event*,
EditorCommandSource,
const String&);
static bool ExecuteUnscript(LocalFrame&,
Event*,
EditorCommandSource,
const String&);
static bool ExecuteStrikethrough(LocalFrame&,
Event*,
EditorCommandSource,
const String&);
static bool ExecuteUnderline(LocalFrame&,
Event*,
EditorCommandSource,
const String&);
static bool ExecuteMakeTextWritingDirectionLeftToRight(LocalFrame&,
Event*,
EditorCommandSource,
const String&);
static bool ExecuteMakeTextWritingDirectionNatural(LocalFrame&,
Event*,
EditorCommandSource,
const String&);
static bool ExecuteMakeTextWritingDirectionRightToLeft(LocalFrame&,
Event*,
EditorCommandSource,
const String&);
static bool ExecuteStyleWithCSS(LocalFrame&,
Event*,
EditorCommandSource,
const String&);
static bool ExecuteUseCSS(LocalFrame&,
Event*,
EditorCommandSource,
const String&);
// State functions
static EditingTriState StateStyle(LocalFrame&, CSSPropertyID, const char*);
static EditingTriState StateBold(LocalFrame&, Event*);
static EditingTriState StateItalic(LocalFrame&, Event*);
static EditingTriState StateStrikethrough(LocalFrame&, Event*);
static EditingTriState StateStyleWithCSS(LocalFrame&, Event*);
static EditingTriState StateSubscript(LocalFrame&, Event*);
static EditingTriState StateSuperscript(LocalFrame&, Event*);
static EditingTriState StateTextWritingDirectionLeftToRight(LocalFrame&,
Event*);
static EditingTriState StateTextWritingDirectionNatural(LocalFrame&, Event*);
static EditingTriState StateTextWritingDirectionRightToLeft(LocalFrame&,
Event*);
static EditingTriState StateUnderline(LocalFrame&, Event*);
// Value functions
static String ValueBackColor(const EditorInternalCommand&,
LocalFrame&,
Event*);
static String ValueForeColor(const EditorInternalCommand&,
LocalFrame&,
Event*);
static String ValueFontName(const EditorInternalCommand&,
LocalFrame&,
Event*);
static String ValueFontSize(const EditorInternalCommand&,
LocalFrame&,
Event*);
static String ValueFontSizeDelta(const EditorInternalCommand&,
LocalFrame&,
Event*);
private:
static void ApplyStyle(LocalFrame&,
CSSPropertyValueSet*,
InputEvent::InputType);
static void ApplyStyleToSelection(LocalFrame&,
CSSPropertyValueSet*,
InputEvent::InputType);
static bool ApplyCommandToFrame(LocalFrame&,
EditorCommandSource,
InputEvent::InputType,
CSSPropertyValueSet*);
static bool ExecuteApplyStyle(LocalFrame&,
EditorCommandSource,
InputEvent::InputType,
CSSPropertyID,
const String&);
static bool ExecuteApplyStyle(LocalFrame&,
EditorCommandSource,
InputEvent::InputType,
CSSPropertyID,
CSSValueID);
static bool ExecuteToggleStyle(LocalFrame&,
EditorCommandSource,
InputEvent::InputType,
CSSPropertyID,
const char* off_value,
const char* on_value);
// FIXME: executeToggleStyleInList does not handle complicated cases such as
// <b><u>hello</u>world</b> properly. This function must use
// EditingStyle::SelectionHasStyle to determine the current style but we
// cannot fix this until https://bugs.webkit.org/show_bug.cgi?id=27818 is
// resolved.
static bool ExecuteToggleStyleInList(LocalFrame&,
EditorCommandSource,
InputEvent::InputType,
CSSPropertyID,
CSSValue*);
static bool SelectionStartHasStyle(LocalFrame&, CSSPropertyID, const String&);
static String SelectionStartCSSPropertyValue(LocalFrame&, CSSPropertyID);
static String ValueStyle(LocalFrame&, CSSPropertyID);
static bool IsUnicodeBidiNestedOrMultipleEmbeddings(CSSValueID);
// TODO(editing-dev): We should make |textDirectionForSelection()| to take
// |selectionInDOMTree|.
static WritingDirection TextDirectionForSelection(const VisibleSelection&,
EditingStyle*,
bool&);
static EditingTriState StateTextWritingDirection(LocalFrame&,
WritingDirection);
};
} // 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