Bug 1546839 - part 1: Change `enum Command` to `enum class Command` and drop "Command" prefix from each item r=smaug

If I remember correctly, `enum class` was not allowed when I added
`enum Command`.  Now, we can make it `enum class` for better type check at
compile time.

Differential Revision: https://phabricator.services.mozilla.com/D29169

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Masayuki Nakano 2019-04-30 04:23:24 +00:00
Родитель cd530d2abf
Коммит 6c0c323d6f
8 изменённых файлов: 311 добавлений и 301 удалений

Просмотреть файл

@ -202,12 +202,12 @@ inline bool IsDataTransferAvailableOnHTMLEditor(EditorInputType aInputType) {
}
}
#define NS_DEFINE_COMMAND(aName, aCommandStr) , Command##aName
#define NS_DEFINE_COMMAND_NO_EXEC_COMMAND(aName) , Command##aName
#define NS_DEFINE_COMMAND(aName, aCommandStr) , aName
#define NS_DEFINE_COMMAND_NO_EXEC_COMMAND(aName) , aName
typedef int8_t CommandInt;
enum Command : CommandInt {
CommandDoNothing
enum class Command : CommandInt {
DoNothing
#include "mozilla/CommandList.h"
};

Просмотреть файл

@ -76,17 +76,17 @@ const nsCString ToString(CodeNameIndex aCodeNameIndex) {
}
const char* ToChar(Command aCommand) {
if (aCommand == CommandDoNothing) {
if (aCommand == Command::DoNothing) {
return "CommandDoNothing";
}
switch (aCommand) {
#define NS_DEFINE_COMMAND(aName, aCommandStr) \
case Command##aName: \
return "Command" #aName;
case Command::aName: \
return "Command::" #aName;
#define NS_DEFINE_COMMAND_NO_EXEC_COMMAND(aName) \
case Command##aName: \
return "Command" #aName;
case Command::aName: \
return "Command::" #aName;
#include "mozilla/CommandList.h"
@ -1100,7 +1100,7 @@ uint32_t WidgetKeyboardEvent::GetFallbackKeyCodeOfPunctuationKey(
#define NS_DEFINE_COMMAND(aName, aCommandStr) , #aCommandStr
#define NS_DEFINE_COMMAND_NO_EXEC_COMMAND(aName)
static const char* const kCommands[] = {
"" // CommandDoNothing
"" // DoNothing
#include "mozilla/CommandList.h"
};
#undef NS_DEFINE_COMMAND
@ -1108,7 +1108,7 @@ uint32_t WidgetKeyboardEvent::GetFallbackKeyCodeOfPunctuationKey(
MOZ_RELEASE_ASSERT(static_cast<size_t>(aCommand) < ArrayLength(kCommands),
"Illegal command enumeration value");
return kCommands[aCommand];
return kCommands[static_cast<CommandInt>(aCommand)];
}
/* static */

Просмотреть файл

@ -15,7 +15,7 @@
namespace mozilla {
namespace widget {
typedef nsDataHashtable<nsPtrHashKey<struct objc_selector>, CommandInt>
typedef nsDataHashtable<nsPtrHashKey<struct objc_selector>, Command>
SelectorCommandHashtable;
class NativeKeyBindings final {

Просмотреть файл

@ -70,24 +70,24 @@ void NativeKeyBindings::Init(NativeKeyBindingsType aType) {
// SEL_TO_COMMAND(centerSelectionInVisibleArea:, );
// SEL_TO_COMMAND(changeCaseOfLetter:, );
// SEL_TO_COMMAND(complete:, );
SEL_TO_COMMAND(copy:, CommandCopy);
SEL_TO_COMMAND(copy:, Command::Copy);
// SEL_TO_COMMAND(copyFont:, );
// SEL_TO_COMMAND(copyRuler:, );
SEL_TO_COMMAND(cut:, CommandCut);
SEL_TO_COMMAND(delete:, CommandDelete);
SEL_TO_COMMAND(deleteBackward:, CommandDeleteCharBackward);
SEL_TO_COMMAND(cut:, Command::Cut);
SEL_TO_COMMAND(delete:, Command::Delete);
SEL_TO_COMMAND(deleteBackward:, Command::DeleteCharBackward);
// SEL_TO_COMMAND(deleteBackwardByDecomposingPreviousCharacter:, );
SEL_TO_COMMAND(deleteForward:, CommandDeleteCharForward);
SEL_TO_COMMAND(deleteForward:, Command::DeleteCharForward);
// TODO: deleteTo* selectors are also supposed to add text to a kill buffer
SEL_TO_COMMAND(deleteToBeginningOfLine:, CommandDeleteToBeginningOfLine);
SEL_TO_COMMAND(deleteToBeginningOfParagraph:, CommandDeleteToBeginningOfLine);
SEL_TO_COMMAND(deleteToEndOfLine:, CommandDeleteToEndOfLine);
SEL_TO_COMMAND(deleteToEndOfParagraph:, CommandDeleteToEndOfLine);
SEL_TO_COMMAND(deleteToBeginningOfLine:, Command::DeleteToBeginningOfLine);
SEL_TO_COMMAND(deleteToBeginningOfParagraph:, Command::DeleteToBeginningOfLine);
SEL_TO_COMMAND(deleteToEndOfLine:, Command::DeleteToEndOfLine);
SEL_TO_COMMAND(deleteToEndOfParagraph:, Command::DeleteToEndOfLine);
// SEL_TO_COMMAND(deleteToMark:, );
SEL_TO_COMMAND(deleteWordBackward:, CommandDeleteWordBackward);
SEL_TO_COMMAND(deleteWordForward:, CommandDeleteWordForward);
SEL_TO_COMMAND(deleteWordBackward:, Command::DeleteWordBackward);
SEL_TO_COMMAND(deleteWordForward:, Command::DeleteWordForward);
// SEL_TO_COMMAND(indent:, );
// SEL_TO_COMMAND(insertBacktab:, );
// SEL_TO_COMMAND(insertContainerBreak:, );
@ -100,69 +100,69 @@ void NativeKeyBindings::Init(NativeKeyBindingsType aType) {
// SEL_TO_COMMAND(insertDoubleQuoteIgnoringSubstitution:, );
// SEL_TO_COMMAND(insertSingleQuoteIgnoringSubstitution:, );
// SEL_TO_COMMAND(lowercaseWord:, );
SEL_TO_COMMAND(moveBackward:, CommandCharPrevious);
SEL_TO_COMMAND(moveBackwardAndModifySelection:, CommandSelectCharPrevious);
SEL_TO_COMMAND(moveBackward:, Command::CharPrevious);
SEL_TO_COMMAND(moveBackwardAndModifySelection:, Command::SelectCharPrevious);
if (aType == nsIWidget::NativeKeyBindingsForSingleLineEditor) {
SEL_TO_COMMAND(moveDown:, CommandEndLine);
SEL_TO_COMMAND(moveDown:, Command::EndLine);
} else {
SEL_TO_COMMAND(moveDown:, CommandLineNext);
SEL_TO_COMMAND(moveDown:, Command::LineNext);
}
SEL_TO_COMMAND(moveDownAndModifySelection:, CommandSelectLineNext);
SEL_TO_COMMAND(moveForward:, CommandCharNext);
SEL_TO_COMMAND(moveForwardAndModifySelection:, CommandSelectCharNext);
SEL_TO_COMMAND(moveLeft:, CommandCharPrevious);
SEL_TO_COMMAND(moveLeftAndModifySelection:, CommandSelectCharPrevious);
SEL_TO_COMMAND(moveParagraphBackwardAndModifySelection:, CommandSelectBeginLine);
SEL_TO_COMMAND(moveParagraphForwardAndModifySelection:, CommandSelectEndLine);
SEL_TO_COMMAND(moveRight:, CommandCharNext);
SEL_TO_COMMAND(moveRightAndModifySelection:, CommandSelectCharNext);
SEL_TO_COMMAND(moveToBeginningOfDocument:, CommandMoveTop);
SEL_TO_COMMAND(moveToBeginningOfDocumentAndModifySelection:, CommandSelectTop);
SEL_TO_COMMAND(moveToBeginningOfLine:, CommandBeginLine);
SEL_TO_COMMAND(moveToBeginningOfLineAndModifySelection:, CommandSelectBeginLine);
SEL_TO_COMMAND(moveToBeginningOfParagraph:, CommandBeginLine);
SEL_TO_COMMAND(moveToBeginningOfParagraphAndModifySelection:, CommandSelectBeginLine);
SEL_TO_COMMAND(moveToEndOfDocument:, CommandMoveBottom);
SEL_TO_COMMAND(moveToEndOfDocumentAndModifySelection:, CommandSelectBottom);
SEL_TO_COMMAND(moveToEndOfLine:, CommandEndLine);
SEL_TO_COMMAND(moveToEndOfLineAndModifySelection:, CommandSelectEndLine);
SEL_TO_COMMAND(moveToEndOfParagraph:, CommandEndLine);
SEL_TO_COMMAND(moveToEndOfParagraphAndModifySelection:, CommandSelectEndLine);
SEL_TO_COMMAND(moveToLeftEndOfLine:, CommandBeginLine);
SEL_TO_COMMAND(moveToLeftEndOfLineAndModifySelection:, CommandSelectBeginLine);
SEL_TO_COMMAND(moveToRightEndOfLine:, CommandEndLine);
SEL_TO_COMMAND(moveToRightEndOfLineAndModifySelection:, CommandSelectEndLine);
SEL_TO_COMMAND(moveDownAndModifySelection:, Command::SelectLineNext);
SEL_TO_COMMAND(moveForward:, Command::CharNext);
SEL_TO_COMMAND(moveForwardAndModifySelection:, Command::SelectCharNext);
SEL_TO_COMMAND(moveLeft:, Command::CharPrevious);
SEL_TO_COMMAND(moveLeftAndModifySelection:, Command::SelectCharPrevious);
SEL_TO_COMMAND(moveParagraphBackwardAndModifySelection:, Command::SelectBeginLine);
SEL_TO_COMMAND(moveParagraphForwardAndModifySelection:, Command::SelectEndLine);
SEL_TO_COMMAND(moveRight:, Command::CharNext);
SEL_TO_COMMAND(moveRightAndModifySelection:, Command::SelectCharNext);
SEL_TO_COMMAND(moveToBeginningOfDocument:, Command::MoveTop);
SEL_TO_COMMAND(moveToBeginningOfDocumentAndModifySelection:, Command::SelectTop);
SEL_TO_COMMAND(moveToBeginningOfLine:, Command::BeginLine);
SEL_TO_COMMAND(moveToBeginningOfLineAndModifySelection:, Command::SelectBeginLine);
SEL_TO_COMMAND(moveToBeginningOfParagraph:, Command::BeginLine);
SEL_TO_COMMAND(moveToBeginningOfParagraphAndModifySelection:, Command::SelectBeginLine);
SEL_TO_COMMAND(moveToEndOfDocument:, Command::MoveBottom);
SEL_TO_COMMAND(moveToEndOfDocumentAndModifySelection:, Command::SelectBottom);
SEL_TO_COMMAND(moveToEndOfLine:, Command::EndLine);
SEL_TO_COMMAND(moveToEndOfLineAndModifySelection:, Command::SelectEndLine);
SEL_TO_COMMAND(moveToEndOfParagraph:, Command::EndLine);
SEL_TO_COMMAND(moveToEndOfParagraphAndModifySelection:, Command::SelectEndLine);
SEL_TO_COMMAND(moveToLeftEndOfLine:, Command::BeginLine);
SEL_TO_COMMAND(moveToLeftEndOfLineAndModifySelection:, Command::SelectBeginLine);
SEL_TO_COMMAND(moveToRightEndOfLine:, Command::EndLine);
SEL_TO_COMMAND(moveToRightEndOfLineAndModifySelection:, Command::SelectEndLine);
if (aType == nsIWidget::NativeKeyBindingsForSingleLineEditor) {
SEL_TO_COMMAND(moveUp:, CommandBeginLine);
SEL_TO_COMMAND(moveUp:, Command::BeginLine);
} else {
SEL_TO_COMMAND(moveUp:, CommandLinePrevious);
SEL_TO_COMMAND(moveUp:, Command::LinePrevious);
}
SEL_TO_COMMAND(moveUpAndModifySelection:, CommandSelectLinePrevious);
SEL_TO_COMMAND(moveWordBackward:, CommandWordPrevious);
SEL_TO_COMMAND(moveWordBackwardAndModifySelection:, CommandSelectWordPrevious);
SEL_TO_COMMAND(moveWordForward:, CommandWordNext);
SEL_TO_COMMAND(moveWordForwardAndModifySelection:, CommandSelectWordNext);
SEL_TO_COMMAND(moveWordLeft:, CommandWordPrevious);
SEL_TO_COMMAND(moveWordLeftAndModifySelection:, CommandSelectWordPrevious);
SEL_TO_COMMAND(moveWordRight:, CommandWordNext);
SEL_TO_COMMAND(moveWordRightAndModifySelection:, CommandSelectWordNext);
SEL_TO_COMMAND(pageDown:, CommandMovePageDown);
SEL_TO_COMMAND(pageDownAndModifySelection:, CommandSelectPageDown);
SEL_TO_COMMAND(pageUp:, CommandMovePageUp);
SEL_TO_COMMAND(pageUpAndModifySelection:, CommandSelectPageUp);
SEL_TO_COMMAND(paste:, CommandPaste);
SEL_TO_COMMAND(moveUpAndModifySelection:, Command::SelectLinePrevious);
SEL_TO_COMMAND(moveWordBackward:, Command::WordPrevious);
SEL_TO_COMMAND(moveWordBackwardAndModifySelection:, Command::SelectWordPrevious);
SEL_TO_COMMAND(moveWordForward:, Command::WordNext);
SEL_TO_COMMAND(moveWordForwardAndModifySelection:, Command::SelectWordNext);
SEL_TO_COMMAND(moveWordLeft:, Command::WordPrevious);
SEL_TO_COMMAND(moveWordLeftAndModifySelection:, Command::SelectWordPrevious);
SEL_TO_COMMAND(moveWordRight:, Command::WordNext);
SEL_TO_COMMAND(moveWordRightAndModifySelection:, Command::SelectWordNext);
SEL_TO_COMMAND(pageDown:, Command::MovePageDown);
SEL_TO_COMMAND(pageDownAndModifySelection:, Command::SelectPageDown);
SEL_TO_COMMAND(pageUp:, Command::MovePageUp);
SEL_TO_COMMAND(pageUpAndModifySelection:, Command::SelectPageUp);
SEL_TO_COMMAND(paste:, Command::Paste);
// SEL_TO_COMMAND(pasteFont:, );
// SEL_TO_COMMAND(pasteRuler:, );
SEL_TO_COMMAND(scrollLineDown:, CommandScrollLineDown);
SEL_TO_COMMAND(scrollLineUp:, CommandScrollLineUp);
SEL_TO_COMMAND(scrollPageDown:, CommandScrollPageDown);
SEL_TO_COMMAND(scrollPageUp:, CommandScrollPageUp);
SEL_TO_COMMAND(scrollToBeginningOfDocument:, CommandScrollTop);
SEL_TO_COMMAND(scrollToEndOfDocument:, CommandScrollBottom);
SEL_TO_COMMAND(selectAll:, CommandSelectAll);
SEL_TO_COMMAND(scrollLineDown:, Command::ScrollLineDown);
SEL_TO_COMMAND(scrollLineUp:, Command::ScrollLineUp);
SEL_TO_COMMAND(scrollPageDown:, Command::ScrollPageDown);
SEL_TO_COMMAND(scrollPageUp:, Command::ScrollPageUp);
SEL_TO_COMMAND(scrollToBeginningOfDocument:, Command::ScrollTop);
SEL_TO_COMMAND(scrollToEndOfDocument:, Command::ScrollBottom);
SEL_TO_COMMAND(selectAll:, Command::SelectAll);
// selectLine: is complex, see KeyDown
if (aType == nsIWidget::NativeKeyBindingsForSingleLineEditor) {
SEL_TO_COMMAND(selectParagraph:, CommandSelectAll);
SEL_TO_COMMAND(selectParagraph:, Command::SelectAll);
}
// SEL_TO_COMMAND(selectToMark:, );
// selectWord: is complex, see KeyDown
@ -220,23 +220,22 @@ void NativeKeyBindings::GetEditCommands(const WidgetKeyboardEvent& aEvent,
}
// Try to find a simple mapping in the hashtable
CommandInt geckoCommand =
mSelectorToCommand.Get(reinterpret_cast<struct objc_selector*>(selector));
if (geckoCommand) {
aCommands.AppendElement(geckoCommand);
Command geckoCommand = Command::DoNothing;
if (mSelectorToCommand.Get(reinterpret_cast<struct objc_selector*>(selector), &geckoCommand) &&
geckoCommand != Command::DoNothing) {
aCommands.AppendElement(static_cast<CommandInt>(geckoCommand));
} else if (selector == @selector(selectLine:)) {
// This is functional, but Cocoa's version is direction-less in that
// selection direction is not determined until some future directed action
// is taken. See bug 282097, comment 79 for more details.
aCommands.AppendElement(CommandBeginLine);
aCommands.AppendElement(CommandSelectEndLine);
aCommands.AppendElement(static_cast<CommandInt>(Command::BeginLine));
aCommands.AppendElement(static_cast<CommandInt>(Command::SelectEndLine));
} else if (selector == @selector(selectWord:)) {
// This is functional, but Cocoa's version is direction-less in that
// selection direction is not determined until some future directed action
// is taken. See bug 282097, comment 79 for more details.
aCommands.AppendElement(CommandWordPrevious);
aCommands.AppendElement(CommandSelectWordNext);
aCommands.AppendElement(static_cast<CommandInt>(Command::WordPrevious));
aCommands.AppendElement(static_cast<CommandInt>(Command::SelectWordNext));
}
}

Просмотреть файл

@ -612,89 +612,89 @@ class TextInputHandlerBase : public TextEventDispatcherListener {
Modifiers modifiers = nsCocoaUtils::ModifiersForEvent(mKeyEvent) &
(MODIFIER_SHIFT | MODIFIER_CONTROL | MODIFIER_ALT | MODIFIER_META);
switch (aCommand) {
case CommandInsertLineBreak:
case Command::InsertLineBreak:
return keyNameIndex == KEY_NAME_INDEX_Enter && modifiers == MODIFIER_CONTROL;
case CommandInsertParagraph:
case Command::InsertParagraph:
return keyNameIndex == KEY_NAME_INDEX_Enter && modifiers == MODIFIER_NONE;
case CommandDeleteCharBackward:
case Command::DeleteCharBackward:
return keyNameIndex == KEY_NAME_INDEX_Backspace && modifiers == MODIFIER_NONE;
case CommandDeleteToBeginningOfLine:
case Command::DeleteToBeginningOfLine:
return keyNameIndex == KEY_NAME_INDEX_Backspace && modifiers == MODIFIER_META;
case CommandDeleteWordBackward:
case Command::DeleteWordBackward:
return keyNameIndex == KEY_NAME_INDEX_Backspace && modifiers == MODIFIER_ALT;
case CommandDeleteCharForward:
case Command::DeleteCharForward:
return keyNameIndex == KEY_NAME_INDEX_Delete && modifiers == MODIFIER_NONE;
case CommandDeleteWordForward:
case Command::DeleteWordForward:
return keyNameIndex == KEY_NAME_INDEX_Delete && modifiers == MODIFIER_ALT;
case CommandInsertTab:
case Command::InsertTab:
return keyNameIndex == KEY_NAME_INDEX_Tab && modifiers == MODIFIER_NONE;
case CommandInsertBacktab:
case Command::InsertBacktab:
return keyNameIndex == KEY_NAME_INDEX_Tab && modifiers == MODIFIER_SHIFT;
case CommandCharNext:
case Command::CharNext:
return keyNameIndex == KEY_NAME_INDEX_ArrowRight && modifiers == MODIFIER_NONE;
case CommandSelectCharNext:
case Command::SelectCharNext:
return keyNameIndex == KEY_NAME_INDEX_ArrowRight && modifiers == MODIFIER_SHIFT;
case CommandWordNext:
case Command::WordNext:
return keyNameIndex == KEY_NAME_INDEX_ArrowRight && modifiers == MODIFIER_ALT;
case CommandSelectWordNext:
case Command::SelectWordNext:
return keyNameIndex == KEY_NAME_INDEX_ArrowRight &&
modifiers == (MODIFIER_ALT | MODIFIER_SHIFT);
case CommandEndLine:
case Command::EndLine:
return keyNameIndex == KEY_NAME_INDEX_ArrowRight && modifiers == MODIFIER_META;
case CommandSelectEndLine:
case Command::SelectEndLine:
return keyNameIndex == KEY_NAME_INDEX_ArrowRight &&
modifiers == (MODIFIER_META | MODIFIER_SHIFT);
case CommandCharPrevious:
case Command::CharPrevious:
return keyNameIndex == KEY_NAME_INDEX_ArrowLeft && modifiers == MODIFIER_NONE;
case CommandSelectCharPrevious:
case Command::SelectCharPrevious:
return keyNameIndex == KEY_NAME_INDEX_ArrowLeft && modifiers == MODIFIER_SHIFT;
case CommandWordPrevious:
case Command::WordPrevious:
return keyNameIndex == KEY_NAME_INDEX_ArrowLeft && modifiers == MODIFIER_ALT;
case CommandSelectWordPrevious:
case Command::SelectWordPrevious:
return keyNameIndex == KEY_NAME_INDEX_ArrowLeft &&
modifiers == (MODIFIER_ALT | MODIFIER_SHIFT);
case CommandBeginLine:
case Command::BeginLine:
return keyNameIndex == KEY_NAME_INDEX_ArrowLeft && modifiers == MODIFIER_META;
case CommandSelectBeginLine:
case Command::SelectBeginLine:
return keyNameIndex == KEY_NAME_INDEX_ArrowLeft &&
modifiers == (MODIFIER_META | MODIFIER_SHIFT);
case CommandLinePrevious:
case Command::LinePrevious:
return keyNameIndex == KEY_NAME_INDEX_ArrowUp && modifiers == MODIFIER_NONE;
case CommandSelectLinePrevious:
case Command::SelectLinePrevious:
return keyNameIndex == KEY_NAME_INDEX_ArrowUp && modifiers == MODIFIER_SHIFT;
case CommandMoveTop:
case Command::MoveTop:
return keyNameIndex == KEY_NAME_INDEX_ArrowUp && modifiers == MODIFIER_META;
case CommandSelectTop:
case Command::SelectTop:
return (keyNameIndex == KEY_NAME_INDEX_ArrowUp &&
modifiers == (MODIFIER_META | MODIFIER_SHIFT)) ||
(keyNameIndex == KEY_NAME_INDEX_Home && modifiers == MODIFIER_SHIFT);
case CommandLineNext:
case Command::LineNext:
return keyNameIndex == KEY_NAME_INDEX_ArrowDown && modifiers == MODIFIER_NONE;
case CommandSelectLineNext:
case Command::SelectLineNext:
return keyNameIndex == KEY_NAME_INDEX_ArrowDown && modifiers == MODIFIER_SHIFT;
case CommandMoveBottom:
case Command::MoveBottom:
return keyNameIndex == KEY_NAME_INDEX_ArrowDown && modifiers == MODIFIER_META;
case CommandSelectBottom:
case Command::SelectBottom:
return (keyNameIndex == KEY_NAME_INDEX_ArrowDown &&
modifiers == (MODIFIER_META | MODIFIER_SHIFT)) ||
(keyNameIndex == KEY_NAME_INDEX_End && modifiers == MODIFIER_SHIFT);
case CommandScrollPageUp:
case Command::ScrollPageUp:
return keyNameIndex == KEY_NAME_INDEX_PageUp && modifiers == MODIFIER_NONE;
case CommandSelectPageUp:
case Command::SelectPageUp:
return keyNameIndex == KEY_NAME_INDEX_PageUp && modifiers == MODIFIER_SHIFT;
case CommandScrollPageDown:
case Command::ScrollPageDown:
return keyNameIndex == KEY_NAME_INDEX_PageDown && modifiers == MODIFIER_NONE;
case CommandSelectPageDown:
case Command::SelectPageDown:
return keyNameIndex == KEY_NAME_INDEX_PageDown && modifiers == MODIFIER_SHIFT;
case CommandScrollBottom:
case Command::ScrollBottom:
return keyNameIndex == KEY_NAME_INDEX_End && modifiers == MODIFIER_NONE;
case CommandScrollTop:
case Command::ScrollTop:
return keyNameIndex == KEY_NAME_INDEX_Home && modifiers == MODIFIER_NONE;
case CommandCancelOperation:
case Command::CancelOperation:
return (keyNameIndex == KEY_NAME_INDEX_Escape &&
(modifiers == MODIFIER_NONE || modifiers == MODIFIER_SHIFT)) ||
([mKeyEvent keyCode] == kVK_ANSI_Period && modifiers == MODIFIER_META);
case CommandComplete:
case Command::Complete:
return keyNameIndex == KEY_NAME_INDEX_Escape &&
(modifiers == MODIFIER_ALT || modifiers == (MODIFIER_ALT | MODIFIER_SHIFT));
default:

Просмотреть файл

@ -2517,8 +2517,8 @@ bool TextInputHandler::HandleCommand(Command aCommand) {
// the command.
if (IsIMEComposing()) {
switch (aCommand) {
case CommandInsertLineBreak:
case CommandInsertParagraph: {
case Command::InsertLineBreak:
case Command::InsertParagraph: {
// Insert '\n' as committing composition.
// Otherwise, we need to dispatch keypress event because HTMLEditor
// doesn't treat "\n" in composition string as a line break unless
@ -2533,48 +2533,48 @@ bool TextInputHandler::HandleCommand(Command aCommand) {
[lineBreaker release];
return true;
}
case CommandDeleteCharBackward:
case CommandDeleteCharForward:
case CommandDeleteToBeginningOfLine:
case CommandDeleteWordBackward:
case CommandDeleteWordForward:
case Command::DeleteCharBackward:
case Command::DeleteCharForward:
case Command::DeleteToBeginningOfLine:
case Command::DeleteWordBackward:
case Command::DeleteWordForward:
// Don't remove any contents during composition.
return false;
case CommandInsertTab:
case CommandInsertBacktab:
case Command::InsertTab:
case Command::InsertBacktab:
// Don't move focus during composition.
return false;
case CommandCharNext:
case CommandSelectCharNext:
case CommandWordNext:
case CommandSelectWordNext:
case CommandEndLine:
case CommandSelectEndLine:
case CommandCharPrevious:
case CommandSelectCharPrevious:
case CommandWordPrevious:
case CommandSelectWordPrevious:
case CommandBeginLine:
case CommandSelectBeginLine:
case CommandLinePrevious:
case CommandSelectLinePrevious:
case CommandMoveTop:
case CommandLineNext:
case CommandSelectLineNext:
case CommandMoveBottom:
case CommandSelectBottom:
case CommandSelectPageUp:
case CommandSelectPageDown:
case CommandScrollBottom:
case CommandScrollTop:
case Command::CharNext:
case Command::SelectCharNext:
case Command::WordNext:
case Command::SelectWordNext:
case Command::EndLine:
case Command::SelectEndLine:
case Command::CharPrevious:
case Command::SelectCharPrevious:
case Command::WordPrevious:
case Command::SelectWordPrevious:
case Command::BeginLine:
case Command::SelectBeginLine:
case Command::LinePrevious:
case Command::SelectLinePrevious:
case Command::MoveTop:
case Command::LineNext:
case Command::SelectLineNext:
case Command::MoveBottom:
case Command::SelectBottom:
case Command::SelectPageUp:
case Command::SelectPageDown:
case Command::ScrollBottom:
case Command::ScrollTop:
// Don't move selection during composition.
return false;
case CommandCancelOperation:
case CommandComplete:
case Command::CancelOperation:
case Command::Complete:
// Don't handle Escape key by ourselves during composition.
return false;
case CommandScrollPageUp:
case CommandScrollPageDown:
case Command::ScrollPageUp:
case Command::ScrollPageDown:
// Allow to scroll.
break;
default:
@ -2621,8 +2621,8 @@ bool TextInputHandler::HandleCommand(Command aCommand) {
NS_WARNING_ASSERTION(keypressEvent.mNativeKeyEvent,
"Without native key event, NativeKeyBindings cannot compute aCommand");
switch (aCommand) {
case CommandInsertLineBreak:
case CommandInsertParagraph: {
case Command::InsertLineBreak:
case Command::InsertParagraph: {
// Although, Shift+Enter and Enter are work differently in HTML
// editor, we should expose actual Shift state if it's caused by
// Enter key for compatibility with Chromium. Chromium breaks
@ -2635,150 +2635,150 @@ bool TextInputHandler::HandleCommand(Command aCommand) {
keypressEvent.mKeyCode = NS_VK_RETURN;
keypressEvent.mKeyNameIndex = KEY_NAME_INDEX_Enter;
keypressEvent.mModifiers &= ~(MODIFIER_CONTROL | MODIFIER_ALT | MODIFIER_META);
if (aCommand == CommandInsertLineBreak) {
if (aCommand == Command::InsertLineBreak) {
// In default settings, Ctrl + Enter causes insertLineBreak command.
// So, let's make Ctrl state active of the keypress event.
keypressEvent.mModifiers |= MODIFIER_CONTROL;
}
break;
}
case CommandInsertTab:
case CommandInsertBacktab:
case Command::InsertTab:
case Command::InsertBacktab:
nsCocoaUtils::InitInputEvent(keypressEvent, keyEvent);
keypressEvent.mKeyCode = NS_VK_TAB;
keypressEvent.mKeyNameIndex = KEY_NAME_INDEX_Tab;
keypressEvent.mModifiers &= ~(MODIFIER_CONTROL | MODIFIER_ALT | MODIFIER_META);
if (aCommand == CommandInsertBacktab) {
if (aCommand == Command::InsertBacktab) {
keypressEvent.mModifiers |= MODIFIER_SHIFT;
}
break;
case CommandDeleteCharBackward:
case CommandDeleteToBeginningOfLine:
case CommandDeleteWordBackward: {
case Command::DeleteCharBackward:
case Command::DeleteToBeginningOfLine:
case Command::DeleteWordBackward: {
nsCocoaUtils::InitInputEvent(keypressEvent, keyEvent);
keypressEvent.mKeyCode = NS_VK_BACK;
keypressEvent.mKeyNameIndex = KEY_NAME_INDEX_Backspace;
keypressEvent.mModifiers &= ~(MODIFIER_CONTROL | MODIFIER_ALT | MODIFIER_META);
if (aCommand == CommandDeleteToBeginningOfLine) {
if (aCommand == Command::DeleteToBeginningOfLine) {
keypressEvent.mModifiers |= MODIFIER_META;
} else if (aCommand == CommandDeleteWordBackward) {
} else if (aCommand == Command::DeleteWordBackward) {
keypressEvent.mModifiers |= MODIFIER_ALT;
}
break;
}
case CommandDeleteCharForward:
case CommandDeleteWordForward: {
case Command::DeleteCharForward:
case Command::DeleteWordForward: {
nsCocoaUtils::InitInputEvent(keypressEvent, keyEvent);
keypressEvent.mKeyCode = NS_VK_DELETE;
keypressEvent.mKeyNameIndex = KEY_NAME_INDEX_Delete;
keypressEvent.mModifiers &= ~(MODIFIER_CONTROL | MODIFIER_ALT | MODIFIER_META);
if (aCommand == CommandDeleteWordForward) {
if (aCommand == Command::DeleteWordForward) {
keypressEvent.mModifiers |= MODIFIER_ALT;
}
break;
}
case CommandCharNext:
case CommandSelectCharNext:
case CommandWordNext:
case CommandSelectWordNext:
case CommandEndLine:
case CommandSelectEndLine: {
case Command::CharNext:
case Command::SelectCharNext:
case Command::WordNext:
case Command::SelectWordNext:
case Command::EndLine:
case Command::SelectEndLine: {
nsCocoaUtils::InitInputEvent(keypressEvent, keyEvent);
keypressEvent.mKeyCode = NS_VK_RIGHT;
keypressEvent.mKeyNameIndex = KEY_NAME_INDEX_ArrowRight;
keypressEvent.mModifiers &= ~(MODIFIER_CONTROL | MODIFIER_ALT | MODIFIER_META);
if (aCommand == CommandSelectCharNext || aCommand == CommandSelectWordNext ||
aCommand == CommandSelectEndLine) {
if (aCommand == Command::SelectCharNext || aCommand == Command::SelectWordNext ||
aCommand == Command::SelectEndLine) {
keypressEvent.mModifiers |= MODIFIER_SHIFT;
}
if (aCommand == CommandWordNext || aCommand == CommandSelectWordNext) {
if (aCommand == Command::WordNext || aCommand == Command::SelectWordNext) {
keypressEvent.mModifiers |= MODIFIER_ALT;
}
if (aCommand == CommandEndLine || aCommand == CommandSelectEndLine) {
if (aCommand == Command::EndLine || aCommand == Command::SelectEndLine) {
keypressEvent.mModifiers |= MODIFIER_META;
}
break;
}
case CommandCharPrevious:
case CommandSelectCharPrevious:
case CommandWordPrevious:
case CommandSelectWordPrevious:
case CommandBeginLine:
case CommandSelectBeginLine: {
case Command::CharPrevious:
case Command::SelectCharPrevious:
case Command::WordPrevious:
case Command::SelectWordPrevious:
case Command::BeginLine:
case Command::SelectBeginLine: {
nsCocoaUtils::InitInputEvent(keypressEvent, keyEvent);
keypressEvent.mKeyCode = NS_VK_LEFT;
keypressEvent.mKeyNameIndex = KEY_NAME_INDEX_ArrowLeft;
keypressEvent.mModifiers &= ~(MODIFIER_CONTROL | MODIFIER_ALT | MODIFIER_META);
if (aCommand == CommandSelectCharPrevious || aCommand == CommandSelectWordPrevious ||
aCommand == CommandSelectBeginLine) {
if (aCommand == Command::SelectCharPrevious || aCommand == Command::SelectWordPrevious ||
aCommand == Command::SelectBeginLine) {
keypressEvent.mModifiers |= MODIFIER_SHIFT;
}
if (aCommand == CommandWordPrevious || aCommand == CommandSelectWordPrevious) {
if (aCommand == Command::WordPrevious || aCommand == Command::SelectWordPrevious) {
keypressEvent.mModifiers |= MODIFIER_ALT;
}
if (aCommand == CommandBeginLine || aCommand == CommandSelectBeginLine) {
if (aCommand == Command::BeginLine || aCommand == Command::SelectBeginLine) {
keypressEvent.mModifiers |= MODIFIER_META;
}
break;
}
case CommandLinePrevious:
case CommandSelectLinePrevious:
case CommandMoveTop:
case CommandSelectTop: {
case Command::LinePrevious:
case Command::SelectLinePrevious:
case Command::MoveTop:
case Command::SelectTop: {
nsCocoaUtils::InitInputEvent(keypressEvent, keyEvent);
keypressEvent.mKeyCode = NS_VK_UP;
keypressEvent.mKeyNameIndex = KEY_NAME_INDEX_ArrowUp;
keypressEvent.mModifiers &= ~(MODIFIER_CONTROL | MODIFIER_ALT | MODIFIER_META);
if (aCommand == CommandSelectLinePrevious || aCommand == CommandSelectTop) {
if (aCommand == Command::SelectLinePrevious || aCommand == Command::SelectTop) {
keypressEvent.mModifiers |= MODIFIER_SHIFT;
}
if (aCommand == CommandMoveTop || aCommand == CommandSelectTop) {
if (aCommand == Command::MoveTop || aCommand == Command::SelectTop) {
keypressEvent.mModifiers |= MODIFIER_META;
}
break;
}
case CommandLineNext:
case CommandSelectLineNext:
case CommandMoveBottom:
case CommandSelectBottom: {
case Command::LineNext:
case Command::SelectLineNext:
case Command::MoveBottom:
case Command::SelectBottom: {
nsCocoaUtils::InitInputEvent(keypressEvent, keyEvent);
keypressEvent.mKeyCode = NS_VK_DOWN;
keypressEvent.mKeyNameIndex = KEY_NAME_INDEX_ArrowDown;
keypressEvent.mModifiers &= ~(MODIFIER_CONTROL | MODIFIER_ALT | MODIFIER_META);
if (aCommand == CommandSelectLineNext || aCommand == CommandSelectBottom) {
if (aCommand == Command::SelectLineNext || aCommand == Command::SelectBottom) {
keypressEvent.mModifiers |= MODIFIER_SHIFT;
}
if (aCommand == CommandMoveBottom || aCommand == CommandSelectBottom) {
if (aCommand == Command::MoveBottom || aCommand == Command::SelectBottom) {
keypressEvent.mModifiers |= MODIFIER_META;
}
break;
}
case CommandScrollPageUp:
case CommandSelectPageUp: {
case Command::ScrollPageUp:
case Command::SelectPageUp: {
nsCocoaUtils::InitInputEvent(keypressEvent, keyEvent);
keypressEvent.mKeyCode = NS_VK_PAGE_UP;
keypressEvent.mKeyNameIndex = KEY_NAME_INDEX_PageUp;
keypressEvent.mModifiers &= ~(MODIFIER_CONTROL | MODIFIER_ALT | MODIFIER_META);
if (aCommand == CommandSelectPageUp) {
if (aCommand == Command::SelectPageUp) {
keypressEvent.mModifiers |= MODIFIER_SHIFT;
}
break;
}
case CommandScrollPageDown:
case CommandSelectPageDown: {
case Command::ScrollPageDown:
case Command::SelectPageDown: {
nsCocoaUtils::InitInputEvent(keypressEvent, keyEvent);
keypressEvent.mKeyCode = NS_VK_PAGE_DOWN;
keypressEvent.mKeyNameIndex = KEY_NAME_INDEX_PageDown;
keypressEvent.mModifiers &= ~(MODIFIER_CONTROL | MODIFIER_ALT | MODIFIER_META);
if (aCommand == CommandSelectPageDown) {
if (aCommand == Command::SelectPageDown) {
keypressEvent.mModifiers |= MODIFIER_SHIFT;
}
break;
}
case CommandScrollBottom:
case CommandScrollTop: {
case Command::ScrollBottom:
case Command::ScrollTop: {
nsCocoaUtils::InitInputEvent(keypressEvent, keyEvent);
if (aCommand == CommandScrollBottom) {
if (aCommand == Command::ScrollBottom) {
keypressEvent.mKeyCode = NS_VK_END;
keypressEvent.mKeyNameIndex = KEY_NAME_INDEX_End;
} else {
@ -2788,13 +2788,13 @@ bool TextInputHandler::HandleCommand(Command aCommand) {
keypressEvent.mModifiers &= ~(MODIFIER_CONTROL | MODIFIER_ALT | MODIFIER_META);
break;
}
case CommandCancelOperation:
case CommandComplete: {
case Command::CancelOperation:
case Command::Complete: {
nsCocoaUtils::InitInputEvent(keypressEvent, keyEvent);
keypressEvent.mKeyCode = NS_VK_ESCAPE;
keypressEvent.mKeyNameIndex = KEY_NAME_INDEX_Escape;
keypressEvent.mModifiers &= ~(MODIFIER_CONTROL | MODIFIER_ALT | MODIFIER_META);
if (aCommand == CommandComplete) {
if (aCommand == Command::Complete) {
keypressEvent.mModifiers |= MODIFIER_ALT;
}
break;
@ -2852,7 +2852,7 @@ bool TextInputHandler::HandleCommand(Command aCommand) {
// If keypress event isn't dispatched as expected, we should fallback to
// using composition events.
if (aCommand == CommandInsertLineBreak || aCommand == CommandInsertParagraph) {
if (aCommand == Command::InsertLineBreak || aCommand == Command::InsertParagraph) {
NSAttributedString* lineBreaker = [[NSAttributedString alloc] initWithString:@"\n"];
InsertTextAsCommittingComposition(lineBreaker, nullptr);
if (currentKeyEvent) {
@ -2953,8 +2953,8 @@ bool TextInputHandler::DoCommandBySelector(const char* aSelector) {
// ChildView only when current key event is proper event to fire Escape
// keypress event.
if (!strcmp(aSelector, "cancelOperatiorn:") && currentKeyEvent &&
currentKeyEvent->IsProperKeyEvent(CommandCancelOperation)) {
return HandleCommand(CommandCancelOperation);
currentKeyEvent->IsProperKeyEvent(Command::CancelOperation)) {
return HandleCommand(Command::CancelOperation);
}
// Otherwise, we've not handled the command yet. Propagate the command

Просмотреть файл

@ -4908,252 +4908,252 @@ static gfx::IntPoint GetIntegerDeltaForEvent(NSEvent* aEvent) {
- (void)insertNewline:(id)sender {
if (mTextInputHandler) {
mTextInputHandler->HandleCommand(CommandInsertParagraph);
mTextInputHandler->HandleCommand(Command::InsertParagraph);
}
}
- (void)insertLineBreak:(id)sender {
// Ctrl + Enter in the default settings.
if (mTextInputHandler) {
mTextInputHandler->HandleCommand(CommandInsertLineBreak);
mTextInputHandler->HandleCommand(Command::InsertLineBreak);
}
}
- (void)deleteBackward:(id)sender {
// Backspace in the default settings.
if (mTextInputHandler) {
mTextInputHandler->HandleCommand(CommandDeleteCharBackward);
mTextInputHandler->HandleCommand(Command::DeleteCharBackward);
}
}
- (void)deleteBackwardByDecomposingPreviousCharacter:(id)sender {
// Ctrl + Backspace in the default settings.
if (mTextInputHandler) {
mTextInputHandler->HandleCommand(CommandDeleteCharBackward);
mTextInputHandler->HandleCommand(Command::DeleteCharBackward);
}
}
- (void)deleteWordBackward:(id)sender {
// Alt + Backspace in the default settings.
if (mTextInputHandler) {
mTextInputHandler->HandleCommand(CommandDeleteWordBackward);
mTextInputHandler->HandleCommand(Command::DeleteWordBackward);
}
}
- (void)deleteToBeginningOfBackward:(id)sender {
// Command + Backspace in the default settings.
if (mTextInputHandler) {
mTextInputHandler->HandleCommand(CommandDeleteToBeginningOfLine);
mTextInputHandler->HandleCommand(Command::DeleteToBeginningOfLine);
}
}
- (void)deleteForward:(id)sender {
// Delete in the default settings.
if (mTextInputHandler) {
mTextInputHandler->HandleCommand(CommandDeleteCharForward);
mTextInputHandler->HandleCommand(Command::DeleteCharForward);
}
}
- (void)deleteWordForward:(id)sender {
// Alt + Delete in the default settings.
if (mTextInputHandler) {
mTextInputHandler->HandleCommand(CommandDeleteWordForward);
mTextInputHandler->HandleCommand(Command::DeleteWordForward);
}
}
- (void)insertTab:(id)sender {
// Tab in the default settings.
if (mTextInputHandler) {
mTextInputHandler->HandleCommand(CommandInsertTab);
mTextInputHandler->HandleCommand(Command::InsertTab);
}
}
- (void)insertBacktab:(id)sender {
// Shift + Tab in the default settings.
if (mTextInputHandler) {
mTextInputHandler->HandleCommand(CommandInsertBacktab);
mTextInputHandler->HandleCommand(Command::InsertBacktab);
}
}
- (void)moveRight:(id)sender {
// RightArrow in the default settings.
if (mTextInputHandler) {
mTextInputHandler->HandleCommand(CommandCharNext);
mTextInputHandler->HandleCommand(Command::CharNext);
}
}
- (void)moveRightAndModifySelection:(id)sender {
// Shift + RightArrow in the default settings.
if (mTextInputHandler) {
mTextInputHandler->HandleCommand(CommandSelectCharNext);
mTextInputHandler->HandleCommand(Command::SelectCharNext);
}
}
- (void)moveWordRight:(id)sender {
// Alt + RightArrow in the default settings.
if (mTextInputHandler) {
mTextInputHandler->HandleCommand(CommandWordNext);
mTextInputHandler->HandleCommand(Command::WordNext);
}
}
- (void)moveWordRightAndModifySelection:(id)sender {
// Alt + Shift + RightArrow in the default settings.
if (mTextInputHandler) {
mTextInputHandler->HandleCommand(CommandSelectWordNext);
mTextInputHandler->HandleCommand(Command::SelectWordNext);
}
}
- (void)moveToRightEndOfLine:(id)sender {
// Command + RightArrow in the default settings.
if (mTextInputHandler) {
mTextInputHandler->HandleCommand(CommandEndLine);
mTextInputHandler->HandleCommand(Command::EndLine);
}
}
- (void)moveToRightEndOfLineAndModifySelection:(id)sender {
// Command + Shift + RightArrow in the default settings.
if (mTextInputHandler) {
mTextInputHandler->HandleCommand(CommandSelectEndLine);
mTextInputHandler->HandleCommand(Command::SelectEndLine);
}
}
- (void)moveLeft:(id)sender {
// LeftArrow in the default settings.
if (mTextInputHandler) {
mTextInputHandler->HandleCommand(CommandCharPrevious);
mTextInputHandler->HandleCommand(Command::CharPrevious);
}
}
- (void)moveLeftAndModifySelection:(id)sender {
// Shift + LeftArrow in the default settings.
if (mTextInputHandler) {
mTextInputHandler->HandleCommand(CommandSelectCharPrevious);
mTextInputHandler->HandleCommand(Command::SelectCharPrevious);
}
}
- (void)moveWordLeft:(id)sender {
// Alt + LeftArrow in the default settings.
if (mTextInputHandler) {
mTextInputHandler->HandleCommand(CommandWordPrevious);
mTextInputHandler->HandleCommand(Command::WordPrevious);
}
}
- (void)moveWordLeftAndModifySelection:(id)sender {
// Alt + Shift + LeftArrow in the default settings.
if (mTextInputHandler) {
mTextInputHandler->HandleCommand(CommandSelectWordPrevious);
mTextInputHandler->HandleCommand(Command::SelectWordPrevious);
}
}
- (void)moveToLeftEndOfLine:(id)sender {
// Command + LeftArrow in the default settings.
if (mTextInputHandler) {
mTextInputHandler->HandleCommand(CommandBeginLine);
mTextInputHandler->HandleCommand(Command::BeginLine);
}
}
- (void)moveToLeftEndOfLineAndModifySelection:(id)sender {
// Command + Shift + LeftArrow in the default settings.
if (mTextInputHandler) {
mTextInputHandler->HandleCommand(CommandSelectBeginLine);
mTextInputHandler->HandleCommand(Command::SelectBeginLine);
}
}
- (void)moveUp:(id)sender {
// ArrowUp in the default settings.
if (mTextInputHandler) {
mTextInputHandler->HandleCommand(CommandLinePrevious);
mTextInputHandler->HandleCommand(Command::LinePrevious);
}
}
- (void)moveUpAndModifySelection:(id)sender {
// Shift + ArrowUp in the default settings.
if (mTextInputHandler) {
mTextInputHandler->HandleCommand(CommandSelectLinePrevious);
mTextInputHandler->HandleCommand(Command::SelectLinePrevious);
}
}
- (void)moveToBeginningOfDocument:(id)sender {
// Command + ArrowUp in the default settings.
if (mTextInputHandler) {
mTextInputHandler->HandleCommand(CommandMoveTop);
mTextInputHandler->HandleCommand(Command::MoveTop);
}
}
- (void)moveToBeginningOfDocumentAndModifySelection:(id)sender {
// Command + Shift + ArrowUp or Shift + Home in the default settings.
if (mTextInputHandler) {
mTextInputHandler->HandleCommand(CommandSelectTop);
mTextInputHandler->HandleCommand(Command::SelectTop);
}
}
- (void)moveDown:(id)sender {
// ArrowDown in the default settings.
if (mTextInputHandler) {
mTextInputHandler->HandleCommand(CommandLineNext);
mTextInputHandler->HandleCommand(Command::LineNext);
}
}
- (void)moveDownAndModifySelection:(id)sender {
// Shift + ArrowDown in the default settings.
if (mTextInputHandler) {
mTextInputHandler->HandleCommand(CommandSelectLineNext);
mTextInputHandler->HandleCommand(Command::SelectLineNext);
}
}
- (void)moveToEndOfDocument:(id)sender {
// Command + ArrowDown in the default settings.
if (mTextInputHandler) {
mTextInputHandler->HandleCommand(CommandMoveBottom);
mTextInputHandler->HandleCommand(Command::MoveBottom);
}
}
- (void)moveToEndOfDocumentAndModifySelection:(id)sender {
// Command + Shift + ArrowDown or Shift + End in the default settings.
if (mTextInputHandler) {
mTextInputHandler->HandleCommand(CommandSelectBottom);
mTextInputHandler->HandleCommand(Command::SelectBottom);
}
}
- (void)scrollPageUp:(id)sender {
// PageUp in the default settings.
if (mTextInputHandler) {
mTextInputHandler->HandleCommand(CommandScrollPageUp);
mTextInputHandler->HandleCommand(Command::ScrollPageUp);
}
}
- (void)pageUpAndModifySelection:(id)sender {
// Shift + PageUp in the default settings.
if (mTextInputHandler) {
mTextInputHandler->HandleCommand(CommandSelectPageUp);
mTextInputHandler->HandleCommand(Command::SelectPageUp);
}
}
- (void)scrollPageDown:(id)sender {
// PageDown in the default settings.
if (mTextInputHandler) {
mTextInputHandler->HandleCommand(CommandScrollPageDown);
mTextInputHandler->HandleCommand(Command::ScrollPageDown);
}
}
- (void)pageDownAndModifySelection:(id)sender {
// Shift + PageDown in the default settings.
if (mTextInputHandler) {
mTextInputHandler->HandleCommand(CommandSelectPageDown);
mTextInputHandler->HandleCommand(Command::SelectPageDown);
}
}
- (void)scrollToEndOfDocument:(id)sender {
// End in the default settings.
if (mTextInputHandler) {
mTextInputHandler->HandleCommand(CommandScrollBottom);
mTextInputHandler->HandleCommand(Command::ScrollBottom);
}
}
- (void)scrollToBeginningOfDocument:(id)sender {
// Home in the default settings.
if (mTextInputHandler) {
mTextInputHandler->HandleCommand(CommandScrollTop);
mTextInputHandler->HandleCommand(Command::ScrollTop);
}
}
@ -5164,7 +5164,7 @@ static gfx::IntPoint GetIntegerDeltaForEvent(NSEvent* aEvent) {
- (void)complete:(id)sender {
// Alt + Escape or Alt + Shift + Escape in the default settings.
if (mTextInputHandler) {
mTextInputHandler->HandleCommand(CommandComplete);
mTextInputHandler->HandleCommand(Command::Complete);
}
}

Просмотреть файл

@ -22,15 +22,20 @@ namespace widget {
static nsTArray<CommandInt>* gCurrentCommands = nullptr;
static bool gHandled = false;
inline void AddCommand(Command aCommand) {
MOZ_ASSERT(gCurrentCommands);
gCurrentCommands->AppendElement(static_cast<CommandInt>(aCommand));
}
// Common GtkEntry and GtkTextView signals
static void copy_clipboard_cb(GtkWidget* w, gpointer user_data) {
gCurrentCommands->AppendElement(CommandCopy);
AddCommand(Command::Copy);
g_signal_stop_emission_by_name(w, "copy_clipboard");
gHandled = true;
}
static void cut_clipboard_cb(GtkWidget* w, gpointer user_data) {
gCurrentCommands->AppendElement(CommandCut);
AddCommand(Command::Cut);
g_signal_stop_emission_by_name(w, "cut_clipboard");
gHandled = true;
}
@ -42,18 +47,24 @@ static void cut_clipboard_cb(GtkWidget* w, gpointer user_data) {
static const Command sDeleteCommands[][2] = {
// backward, forward
{CommandDeleteCharBackward, CommandDeleteCharForward}, // CHARS
{CommandDeleteWordBackward, CommandDeleteWordForward}, // WORD_ENDS
{CommandDeleteWordBackward, CommandDeleteWordForward}, // WORDS
{CommandDeleteToBeginningOfLine, CommandDeleteToEndOfLine}, // LINES
{CommandDeleteToBeginningOfLine, CommandDeleteToEndOfLine}, // LINE_ENDS
{CommandDeleteToBeginningOfLine,
CommandDeleteToEndOfLine}, // PARAGRAPH_ENDS
{CommandDeleteToBeginningOfLine, CommandDeleteToEndOfLine}, // PARAGRAPHS
// CHARS
{Command::DeleteCharBackward, Command::DeleteCharForward},
// WORD_ENDS
{Command::DeleteWordBackward, Command::DeleteWordForward},
// WORDS
{Command::DeleteWordBackward, Command::DeleteWordForward},
// LINES
{Command::DeleteToBeginningOfLine, Command::DeleteToEndOfLine},
// LINE_ENDS
{Command::DeleteToBeginningOfLine, Command::DeleteToEndOfLine},
// PARAGRAPH_ENDS
{Command::DeleteToBeginningOfLine, Command::DeleteToEndOfLine},
// PARAGRAPHS
{Command::DeleteToBeginningOfLine, Command::DeleteToEndOfLine},
// This deletes from the end of the previous word to the beginning of the
// next word, but only if the caret is not in a word.
// XXX need to implement in editor
{CommandDoNothing, CommandDoNothing} // WHITESPACE
{Command::DoNothing, Command::DoNothing} // WHITESPACE
};
static void delete_from_cursor_cb(GtkWidget* w, GtkDeleteType del_type,
@ -91,31 +102,31 @@ static void delete_from_cursor_cb(GtkWidget* w, GtkDeleteType del_type,
// This works like word_ends, except we first move the caret to the
// beginning/end of the current word.
if (forward) {
gCurrentCommands->AppendElement(CommandWordNext);
gCurrentCommands->AppendElement(CommandWordPrevious);
AddCommand(Command::WordNext);
AddCommand(Command::WordPrevious);
} else {
gCurrentCommands->AppendElement(CommandWordPrevious);
gCurrentCommands->AppendElement(CommandWordNext);
AddCommand(Command::WordPrevious);
AddCommand(Command::WordNext);
}
} else if (del_type == GTK_DELETE_DISPLAY_LINES ||
del_type == GTK_DELETE_PARAGRAPHS) {
// This works like display_line_ends, except we first move the caret to the
// beginning/end of the current line.
if (forward) {
gCurrentCommands->AppendElement(CommandBeginLine);
AddCommand(Command::BeginLine);
} else {
gCurrentCommands->AppendElement(CommandEndLine);
AddCommand(Command::EndLine);
}
}
Command command = sDeleteCommands[del_type][forward];
if (!command) {
return; // unsupported command
if (command == Command::DoNothing) {
return;
}
unsigned int absCount = Abs(count);
for (unsigned int i = 0; i < absCount; ++i) {
gCurrentCommands->AppendElement(command);
AddCommand(command);
}
}
@ -125,35 +136,35 @@ static const Command sMoveCommands[][2][2] = {
// and visual position, which is always left/right.
// We should fix this to work the same way for RTL text input.
{// LOGICAL_POSITIONS
{CommandCharPrevious, CommandCharNext},
{CommandSelectCharPrevious, CommandSelectCharNext}},
{Command::CharPrevious, Command::CharNext},
{Command::SelectCharPrevious, Command::SelectCharNext}},
{// VISUAL_POSITIONS
{CommandCharPrevious, CommandCharNext},
{CommandSelectCharPrevious, CommandSelectCharNext}},
{Command::CharPrevious, Command::CharNext},
{Command::SelectCharPrevious, Command::SelectCharNext}},
{// WORDS
{CommandWordPrevious, CommandWordNext},
{CommandSelectWordPrevious, CommandSelectWordNext}},
{Command::WordPrevious, Command::WordNext},
{Command::SelectWordPrevious, Command::SelectWordNext}},
{// DISPLAY_LINES
{CommandLinePrevious, CommandLineNext},
{CommandSelectLinePrevious, CommandSelectLineNext}},
{Command::LinePrevious, Command::LineNext},
{Command::SelectLinePrevious, Command::SelectLineNext}},
{// DISPLAY_LINE_ENDS
{CommandBeginLine, CommandEndLine},
{CommandSelectBeginLine, CommandSelectEndLine}},
{Command::BeginLine, Command::EndLine},
{Command::SelectBeginLine, Command::SelectEndLine}},
{// PARAGRAPHS
{CommandLinePrevious, CommandLineNext},
{CommandSelectLinePrevious, CommandSelectLineNext}},
{Command::LinePrevious, Command::LineNext},
{Command::SelectLinePrevious, Command::SelectLineNext}},
{// PARAGRAPH_ENDS
{CommandBeginLine, CommandEndLine},
{CommandSelectBeginLine, CommandSelectEndLine}},
{Command::BeginLine, Command::EndLine},
{Command::SelectBeginLine, Command::SelectEndLine}},
{// PAGES
{CommandMovePageUp, CommandMovePageDown},
{CommandSelectPageUp, CommandSelectPageDown}},
{Command::MovePageUp, Command::MovePageDown},
{Command::SelectPageUp, Command::SelectPageDown}},
{// BUFFER_ENDS
{CommandMoveTop, CommandMoveBottom},
{CommandSelectTop, CommandSelectBottom}},
{Command::MoveTop, Command::MoveBottom},
{Command::SelectTop, Command::SelectBottom}},
{// HORIZONTAL_PAGES (unsupported)
{CommandDoNothing, CommandDoNothing},
{CommandDoNothing, CommandDoNothing}}};
{Command::DoNothing, Command::DoNothing},
{Command::DoNothing, Command::DoNothing}}};
static void move_cursor_cb(GtkWidget* w, GtkMovementStep step, gint count,
gboolean extend_selection, gpointer user_data) {
@ -171,25 +182,25 @@ static void move_cursor_cb(GtkWidget* w, GtkMovementStep step, gint count,
}
Command command = sMoveCommands[step][extend_selection][forward];
if (!command) {
return; // unsupported command
if (command == Command::DoNothing) {
return;
}
unsigned int absCount = Abs(count);
for (unsigned int i = 0; i < absCount; ++i) {
gCurrentCommands->AppendElement(command);
AddCommand(command);
}
}
static void paste_clipboard_cb(GtkWidget* w, gpointer user_data) {
gCurrentCommands->AppendElement(CommandPaste);
AddCommand(Command::Paste);
g_signal_stop_emission_by_name(w, "paste_clipboard");
gHandled = true;
}
// GtkTextView-only signals
static void select_all_cb(GtkWidget* w, gboolean select, gpointer user_data) {
gCurrentCommands->AppendElement(CommandSelectAll);
AddCommand(Command::SelectAll);
g_signal_stop_emission_by_name(w, "select_all");
gHandled = true;
}