Bug 1683226 - part 15: Get rid of plugin specific members of `WidgetKeyboardEvent` r=m_kato,smaug

Depends on D100388

Differential Revision: https://phabricator.services.mozilla.com/D100389
This commit is contained in:
Masayuki Nakano 2020-12-29 21:16:48 +00:00
Родитель a63efd9519
Коммит 1b07095476
5 изменённых файлов: 20 добавлений и 110 удалений

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

@ -1829,38 +1829,8 @@ static NPCocoaEvent TranslateToNPCocoaEvent(WidgetGUIEvent* anEvent,
break;
}
case eKeyDown:
case eKeyUp: {
WidgetKeyboardEvent* keyEvent = anEvent->AsKeyboardEvent();
// That keyEvent->mPluginTextEventString is non-empty is a signal that we
// should create a text event for the plugin, instead of a key event.
if (anEvent->mMessage == eKeyDown &&
!keyEvent->mPluginTextEventString.IsEmpty()) {
cocoaEvent.type = NPCocoaEventTextInput;
const char16_t* pluginTextEventString =
keyEvent->mPluginTextEventString.get();
cocoaEvent.data.text.text = (NPNSString*)::CFStringCreateWithCharacters(
NULL, reinterpret_cast<const UniChar*>(pluginTextEventString),
keyEvent->mPluginTextEventString.Length());
} else {
cocoaEvent.data.key.keyCode = keyEvent->mNativeKeyCode;
cocoaEvent.data.key.isARepeat = keyEvent->mIsRepeat;
cocoaEvent.data.key.modifierFlags = keyEvent->mNativeModifierFlags;
const char16_t* nativeChars = keyEvent->mNativeCharacters.get();
cocoaEvent.data.key.characters =
(NPNSString*)::CFStringCreateWithCharacters(
NULL, reinterpret_cast<const UniChar*>(nativeChars),
keyEvent->mNativeCharacters.Length());
const char16_t* nativeCharsIgnoringModifiers =
keyEvent->mNativeCharactersIgnoringModifiers.get();
cocoaEvent.data.key.charactersIgnoringModifiers =
(NPNSString*)::CFStringCreateWithCharacters(
NULL,
reinterpret_cast<const UniChar*>(nativeCharsIgnoringModifiers),
keyEvent->mNativeCharactersIgnoringModifiers.Length());
}
case eKeyUp:
break;
}
case eFocus:
case eBlur:
cocoaEvent.data.focus.hasFocus = (anEvent->mMessage == eFocus);

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

@ -137,13 +137,7 @@ class WidgetKeyboardEvent : public WidgetInputEvent {
mCharCode(0),
mPseudoCharCode(0),
mLocation(eKeyLocationStandard),
mUniqueId(0)
#ifdef XP_MACOSX
,
mNativeModifierFlags(0),
mNativeKeyCode(0)
#endif // #ifdef XP_MACOSX
,
mUniqueId(0),
mKeyNameIndex(KEY_NAME_INDEX_Unidentified),
mCodeNameIndex(CODE_NAME_INDEX_UNKNOWN),
mIsRepeat(false),
@ -153,8 +147,7 @@ class WidgetKeyboardEvent : public WidgetInputEvent {
mUseLegacyKeyCodeAndCharCodeValues(false),
mEditCommandsForSingleLineEditorInitialized(false),
mEditCommandsForMultiLineEditorInitialized(false),
mEditCommandsForRichTextEditorInitialized(false) {
}
mEditCommandsForRichTextEditorInitialized(false) {}
public:
virtual WidgetKeyboardEvent* AsKeyboardEvent() override { return this; }
@ -168,13 +161,7 @@ class WidgetKeyboardEvent : public WidgetInputEvent {
mCharCode(0),
mPseudoCharCode(0),
mLocation(eKeyLocationStandard),
mUniqueId(0)
#ifdef XP_MACOSX
,
mNativeModifierFlags(0),
mNativeKeyCode(0)
#endif // #ifdef XP_MACOSX
,
mUniqueId(0),
mKeyNameIndex(KEY_NAME_INDEX_Unidentified),
mCodeNameIndex(CODE_NAME_INDEX_UNKNOWN),
mIsRepeat(false),
@ -385,16 +372,8 @@ class WidgetKeyboardEvent : public WidgetInputEvent {
// CODE_NAME_INDEX_USE_STRING.
nsString mCodeValue;
#ifdef XP_MACOSX
// Values given by a native NSEvent, for use with Cocoa NPAPI plugins.
nsString mNativeCharacters;
nsString mNativeCharactersIgnoringModifiers;
// If this is non-empty, create a text event for plugins instead of a
// keyboard event.
nsString mPluginTextEventString;
#endif // #ifdef XP_MACOSX
// OS-specific native event can optionally be preserved
// OS-specific native event can optionally be preserved.
// This is used to retrieve editing shortcut keys in the environment.
void* mNativeKeyEvent;
// A DOM keyCode value or 0. If a keypress event whose mCharCode is 0, this
// should be 0.
@ -414,12 +393,6 @@ class WidgetKeyboardEvent : public WidgetInputEvent {
// over long periods.
uint32_t mUniqueId;
#ifdef XP_MACOSX
// Values given by a native NSEvent, for use with Cocoa NPAPI plugins.
uint32_t mNativeModifierFlags;
uint16_t mNativeKeyCode;
#endif // #ifdef XP_MACOSX
// DOM KeyboardEvent.key
KeyNameIndex mKeyNameIndex;
// DOM KeyboardEvent.code
@ -703,14 +676,6 @@ class WidgetKeyboardEvent : public WidgetInputEvent {
// is destroyed.
mNativeKeyEvent = nullptr;
mUniqueId = aEvent.mUniqueId;
#ifdef XP_MACOSX
mNativeKeyCode = aEvent.mNativeKeyCode;
mNativeModifierFlags = aEvent.mNativeModifierFlags;
mNativeCharacters.Assign(aEvent.mNativeCharacters);
mNativeCharactersIgnoringModifiers.Assign(
aEvent.mNativeCharactersIgnoringModifiers);
mPluginTextEventString.Assign(aEvent.mPluginTextEventString);
#endif
mIsSynthesizedByTIP = aEvent.mIsSynthesizedByTIP;
mMaybeSkippableInRemoteProcess = aEvent.mMaybeSkippableInRemoteProcess;
mUseLegacyKeyCodeAndCharCodeValues =

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

@ -819,13 +819,13 @@ class TextInputHandlerBase : public TextEventDispatcherListener {
static bool IsPrintableChar(char16_t aChar);
/**
* IsNormalCharInputtingEvent() checks whether aKeyEvent causes text input.
* IsNormalCharInputtingEvent() checks whether aNativeEvent causes text input.
*
* @param aKeyEvent A key event.
* @param aNativeEvent A key event.
* @return TRUE if the key event causes text input.
* Otherwise, FALSE.
*/
static bool IsNormalCharInputtingEvent(const WidgetKeyboardEvent& aKeyEvent);
static bool IsNormalCharInputtingEvent(NSEvent* aNativeEvent);
/**
* IsModifierKey() checks whether the native keyCode is for a modifier key.

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

@ -1011,22 +1011,6 @@ void TISInputSourceWrapper::InitKeyEvent(NSEvent* aNativeKeyEvent, WidgetKeyboar
// call), so there is no need to retain and release this data.
aKeyEvent.mNativeKeyEvent = aNativeKeyEvent;
// Fill in fields used for Cocoa NPAPI plugins
if ([aNativeKeyEvent type] == NSKeyDown || [aNativeKeyEvent type] == NSKeyUp) {
aKeyEvent.mNativeKeyCode = [aNativeKeyEvent keyCode];
aKeyEvent.mNativeModifierFlags = [aNativeKeyEvent modifierFlags];
nsAutoString nativeChars;
nsCocoaUtils::GetStringForNSString([aNativeKeyEvent characters], nativeChars);
aKeyEvent.mNativeCharacters.Assign(nativeChars);
nsAutoString nativeCharsIgnoringModifiers;
nsCocoaUtils::GetStringForNSString([aNativeKeyEvent charactersIgnoringModifiers],
nativeCharsIgnoringModifiers);
aKeyEvent.mNativeCharactersIgnoringModifiers.Assign(nativeCharsIgnoringModifiers);
} else if ([aNativeKeyEvent type] == NSFlagsChanged) {
aKeyEvent.mNativeKeyCode = [aNativeKeyEvent keyCode];
aKeyEvent.mNativeModifierFlags = [aNativeKeyEvent modifierFlags];
}
aKeyEvent.mRefPoint = LayoutDeviceIntPoint(0, 0);
UInt32 kbType = GetKbdType();
@ -1838,7 +1822,7 @@ bool TextInputHandler::HandleKeyDownEvent(NSEvent* aNativeEvent, uint32_t aUniqu
// dispatch keypress event at that time. Note that the command may have
// been a converted or generated action by IME. Then, we shouldn't do
// our default action for this key.
if (!(interpretKeyEventsCalled && IsNormalCharInputtingEvent(keypressEvent))) {
if (!(interpretKeyEventsCalled && IsNormalCharInputtingEvent(aNativeEvent))) {
MOZ_LOG(gLog, LogLevel::Info,
("%p TextInputHandler::HandleKeyDownEvent, trying to dispatch "
"eKeyPress event since it's not yet dispatched",
@ -4928,13 +4912,18 @@ bool TextInputHandlerBase::SetSelection(NSRange& aRange) {
return false;
}
/* static */ bool TextInputHandlerBase::IsNormalCharInputtingEvent(
const WidgetKeyboardEvent& aKeyEvent) {
// this is not character inputting event, simply.
if (aKeyEvent.mNativeCharacters.IsEmpty() || aKeyEvent.IsMeta()) {
/* static */ bool TextInputHandlerBase::IsNormalCharInputtingEvent(NSEvent* aNativeEvent) {
if ([aNativeEvent type] != NSKeyDown && [aNativeEvent type] != NSKeyUp) {
return false;
}
return !IsControlChar(aKeyEvent.mNativeCharacters[0]);
nsAutoString nativeChars;
nsCocoaUtils::GetStringForNSString([aNativeEvent characters], nativeChars);
// this is not character inputting event, simply.
if (nativeChars.IsEmpty() || ([aNativeEvent modifierFlags] & NSCommandKeyMask)) {
return false;
}
return !IsControlChar(nativeChars[0]);
}
/* static */ bool TextInputHandlerBase::IsModifierKey(UInt32 aNativeKeyCode) {

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

@ -424,13 +424,6 @@ struct ParamTraits<mozilla::WidgetKeyboardEvent> {
WriteParam(aMsg, aParam.mUniqueId);
WriteParam(aMsg, aParam.mIsSynthesizedByTIP);
WriteParam(aMsg, aParam.mMaybeSkippableInRemoteProcess);
#ifdef XP_MACOSX
WriteParam(aMsg, aParam.mNativeKeyCode);
WriteParam(aMsg, aParam.mNativeModifierFlags);
WriteParam(aMsg, aParam.mNativeCharacters);
WriteParam(aMsg, aParam.mNativeCharactersIgnoringModifiers);
WriteParam(aMsg, aParam.mPluginTextEventString);
#endif
// An OS-specific native event might be attached in |mNativeKeyEvent|, but
// that cannot be copied across process boundaries.
@ -462,13 +455,6 @@ struct ParamTraits<mozilla::WidgetKeyboardEvent> {
ReadParam(aMsg, aIter, &aResult->mUniqueId) &&
ReadParam(aMsg, aIter, &aResult->mIsSynthesizedByTIP) &&
ReadParam(aMsg, aIter, &aResult->mMaybeSkippableInRemoteProcess) &&
#ifdef XP_MACOSX
ReadParam(aMsg, aIter, &aResult->mNativeKeyCode) &&
ReadParam(aMsg, aIter, &aResult->mNativeModifierFlags) &&
ReadParam(aMsg, aIter, &aResult->mNativeCharacters) &&
ReadParam(aMsg, aIter, &aResult->mNativeCharactersIgnoringModifiers) &&
ReadParam(aMsg, aIter, &aResult->mPluginTextEventString) &&
#endif
ReadParam(aMsg, aIter, &aResult->mEditCommandsForSingleLineEditor) &&
ReadParam(aMsg, aIter, &aResult->mEditCommandsForMultiLineEditor) &&
ReadParam(aMsg, aIter, &aResult->mEditCommandsForRichTextEditor) &&