Chromium Code Reviews| Index: third_party/WebKit/Source/core/editing/commands/EditorCommand.cpp |
| diff --git a/third_party/WebKit/Source/core/editing/commands/EditorCommand.cpp b/third_party/WebKit/Source/core/editing/commands/EditorCommand.cpp |
| index e564b7c0d884b6ea903d2627b38ece6a15b724e2..fea344e7e9936f2ea519143231bf2009061605c5 100644 |
| --- a/third_party/WebKit/Source/core/editing/commands/EditorCommand.cpp |
| +++ b/third_party/WebKit/Source/core/editing/commands/EditorCommand.cpp |
| @@ -109,105 +109,6 @@ WebEditingCommandType WebEditingCommandTypeFromCommandName( |
| return WebEditingCommandType::Invalid; |
| } |
| -// |frame| is only used for |InsertNewline| due to how |executeInsertNewline()| |
| -// works. |
| -InputEvent::InputType InputTypeFromCommandType( |
|
chongz
2016/12/20 04:48:58
Distributed to the ctor of each |CompositeEditComm
|
| - WebEditingCommandType commandType, |
| - LocalFrame& frame) { |
| - // We only handle InputType on spec for 'beforeinput'. |
| - // http://w3c.github.io/editing/input-events.html |
| - using CommandType = WebEditingCommandType; |
| - using InputType = InputEvent::InputType; |
| - |
| - // |executeInsertNewline()| could do two things but we have no other ways to |
| - // predict. |
| - if (commandType == CommandType::InsertNewline) |
| - return frame.editor().canEditRichly() ? InputType::InsertParagraph |
| - : InputType::InsertLineBreak; |
| - |
| - switch (commandType) { |
| - // Insertion. |
| - case CommandType::InsertBacktab: |
| - case CommandType::InsertText: |
| - return InputType::InsertText; |
| - case CommandType::InsertLineBreak: |
| - return InputType::InsertLineBreak; |
| - case CommandType::InsertParagraph: |
| - case CommandType::InsertNewlineInQuotedContent: |
| - return InputType::InsertParagraph; |
| - case CommandType::InsertHorizontalRule: |
| - return InputType::InsertHorizontalRule; |
| - case CommandType::InsertOrderedList: |
| - return InputType::InsertOrderedList; |
| - case CommandType::InsertUnorderedList: |
| - return InputType::InsertUnorderedList; |
| - |
| - // Deletion. |
| - case CommandType::Delete: |
| - case CommandType::DeleteBackward: |
| - case CommandType::DeleteBackwardByDecomposingPreviousCharacter: |
| - return InputType::DeleteContentBackward; |
| - case CommandType::DeleteForward: |
| - return InputType::DeleteContentForward; |
| - case CommandType::DeleteToBeginningOfLine: |
| - return InputType::DeleteLineBackward; |
| - case CommandType::DeleteToEndOfLine: |
| - return InputType::DeleteLineForward; |
| - case CommandType::DeleteWordBackward: |
| - return InputType::DeleteWordBackward; |
| - case CommandType::DeleteWordForward: |
| - return InputType::DeleteWordForward; |
| - // TODO(chongz): Find appreciate InputType for following commands. |
| - case CommandType::DeleteToBeginningOfParagraph: |
| - case CommandType::DeleteToEndOfParagraph: |
| - case CommandType::DeleteToMark: |
| - return InputType::None; |
| - |
| - // Command. |
| - case CommandType::Undo: |
| - return InputType::HistoryUndo; |
| - case CommandType::Redo: |
| - return InputType::HistoryRedo; |
| - // Cut and Paste will be handled in |Editor::dispatchCPPEvent()|. |
| - |
| - // Styling. |
| - case CommandType::Bold: |
| - case CommandType::ToggleBold: |
| - return InputType::FormatBold; |
| - case CommandType::Italic: |
| - case CommandType::ToggleItalic: |
| - return InputType::FormatItalic; |
| - case CommandType::Underline: |
| - case CommandType::ToggleUnderline: |
| - return InputType::FormatUnderline; |
| - case CommandType::Strikethrough: |
| - return InputType::FormatStrikeThrough; |
| - case CommandType::Superscript: |
| - return InputType::FormatSuperscript; |
| - case CommandType::Subscript: |
| - return InputType::FormatSubscript; |
| - default: |
| - return InputType::None; |
| - } |
| -} |
| - |
| -RangeVector* RangesFromCurrentSelectionOrExtendCaret( |
|
chongz
2016/12/20 04:48:58
Moved into "TypingCommand.cpp".
|
| - const LocalFrame& frame, |
| - SelectionDirection direction, |
| - TextGranularity granularity) { |
| - frame.document()->updateStyleAndLayoutIgnorePendingStylesheets(); |
| - SelectionModifier selectionModifier(frame, frame.selection().selection()); |
| - if (selectionModifier.selection().isCaret()) |
| - selectionModifier.modify(FrameSelection::AlterationExtend, direction, |
| - granularity); |
| - RangeVector* ranges = new RangeVector; |
| - // We only supports single selections. |
| - if (selectionModifier.selection().isNone()) |
| - return ranges; |
| - ranges->push_back(firstRangeOf(selectionModifier.selection())); |
| - return ranges; |
| -} |
| - |
| } // anonymous namespace |
| class EditorInternalCommand { |
| @@ -2648,21 +2549,6 @@ bool Editor::Command::execute(const String& parameter, |
| return false; |
| } |
| - if (m_source == EditCommandSource::kMenuOrKeyBinding) { |
| - InputEvent::InputType inputType = |
| - InputTypeFromCommandType(m_command->commandType, *m_frame); |
| - if (inputType != InputEvent::InputType::None) { |
| - if (dispatchBeforeInputEditorCommand( |
| - eventTargetNodeForDocument(m_frame->document()), inputType, |
| - getTargetRanges()) != DispatchEventResult::NotCanceled) |
| - return true; |
| - } |
| - } |
| - |
| - // 'beforeinput' event handler may destroy target frame. |
| - if (m_frame->document()->frame() != m_frame) |
| - return false; |
| - |
| frame().document()->updateStyleAndLayoutIgnorePendingStylesheets(); |
| DEFINE_STATIC_LOCAL(SparseHistogram, commandHistogram, |
| ("WebCore.Editing.Commands")); |
| @@ -2717,39 +2603,4 @@ int Editor::Command::idForHistogram() const { |
| return isSupported() ? static_cast<int>(m_command->commandType) : 0; |
| } |
| -RangeVector* Editor::Command::getTargetRanges() const { |
|
chongz
2016/12/20 04:48:58
Moved to |TypingCommand::targetRangesForInputEvent
|
| - if (!isSupported() || !m_frame) |
| - return nullptr; |
| - |
| - switch (m_command->commandType) { |
| - case WebEditingCommandType::Delete: |
| - case WebEditingCommandType::DeleteBackward: |
| - return RangesFromCurrentSelectionOrExtendCaret( |
| - *m_frame, DirectionBackward, CharacterGranularity); |
| - case WebEditingCommandType::DeleteForward: |
| - return RangesFromCurrentSelectionOrExtendCaret(*m_frame, DirectionForward, |
| - CharacterGranularity); |
| - case WebEditingCommandType::DeleteToBeginningOfLine: |
| - return RangesFromCurrentSelectionOrExtendCaret( |
| - *m_frame, DirectionBackward, LineGranularity); |
| - case WebEditingCommandType::DeleteToBeginningOfParagraph: |
| - return RangesFromCurrentSelectionOrExtendCaret( |
| - *m_frame, DirectionBackward, ParagraphGranularity); |
| - case WebEditingCommandType::DeleteToEndOfLine: |
| - return RangesFromCurrentSelectionOrExtendCaret(*m_frame, DirectionForward, |
| - LineGranularity); |
| - case WebEditingCommandType::DeleteToEndOfParagraph: |
| - return RangesFromCurrentSelectionOrExtendCaret(*m_frame, DirectionForward, |
| - ParagraphGranularity); |
| - case WebEditingCommandType::DeleteWordBackward: |
| - return RangesFromCurrentSelectionOrExtendCaret( |
| - *m_frame, DirectionBackward, WordGranularity); |
| - case WebEditingCommandType::DeleteWordForward: |
| - return RangesFromCurrentSelectionOrExtendCaret(*m_frame, DirectionForward, |
| - WordGranularity); |
| - default: |
| - return nullptr; |
| - } |
| -} |
| - |
| } // namespace blink |