mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-27 14:52:16 +00:00
Bug 1683226 - part 11: Get rid of IMEEnabled::Plugin
r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D100123
This commit is contained in:
parent
07ec351c5b
commit
9e229babfa
@ -1887,7 +1887,7 @@ nsINode* IMEStateManager::GetRootEditableNode(nsPresContext* aPresContext,
|
||||
|
||||
// static
|
||||
bool IMEStateManager::IsIMEObserverNeeded(const IMEState& aState) {
|
||||
return aState.MaybeEditable();
|
||||
return aState.IsEditable();
|
||||
}
|
||||
|
||||
// static
|
||||
|
@ -172,8 +172,6 @@ std::ostream& operator<<(std::ostream& aStream, const IMEEnabled& aEnabled) {
|
||||
return aStream << "ENABLED";
|
||||
case IMEEnabled::Password:
|
||||
return aStream << "PASSWORD";
|
||||
case IMEEnabled::Plugin:
|
||||
return aStream << "PLUGIN";
|
||||
case IMEEnabled::Unknown:
|
||||
return aStream << "illegal value";
|
||||
}
|
||||
|
@ -279,13 +279,6 @@ enum class IMEEnabled {
|
||||
* special rules on some platforms.
|
||||
*/
|
||||
Password,
|
||||
/**
|
||||
* This state is used when a plugin is focused.
|
||||
* When a plug-in is focused content, we should send native events
|
||||
* directly. Because we don't process some native events, but they may
|
||||
* be needed by the plug-in.
|
||||
*/
|
||||
Plugin,
|
||||
/**
|
||||
* 'Unknown' is useful when you cache this enum. So, this shouldn't be
|
||||
* used with nsIWidget::SetInputContext().
|
||||
@ -345,13 +338,6 @@ struct IMEState final {
|
||||
bool IsEditable() const {
|
||||
return mEnabled == IMEEnabled::Enabled || mEnabled == IMEEnabled::Password;
|
||||
}
|
||||
// Returns true if the user might be able to input characters.
|
||||
// This means that a plain text editor, an HTML editor, a password editor,
|
||||
// a plain text editor whose ime-mode is "disabled" or a windowless plugin
|
||||
// has focus.
|
||||
bool MaybeEditable() const {
|
||||
return IsEditable() || mEnabled == IMEEnabled::Plugin;
|
||||
}
|
||||
};
|
||||
|
||||
// NS_ONLY_ONE_NATIVE_IME_CONTEXT is a special value of native IME context.
|
||||
|
@ -754,18 +754,10 @@ nsresult PuppetWidget::NotifyIMEOfFocusChange(
|
||||
|
||||
bool gotFocus = aIMENotification.mMessage == NOTIFY_IME_OF_FOCUS;
|
||||
if (gotFocus) {
|
||||
if (mInputContext.mIMEState.mEnabled != IMEEnabled::Plugin) {
|
||||
// When IME gets focus, we should initalize all information of the
|
||||
// content.
|
||||
if (NS_WARN_IF(!mContentCache.CacheAll(this, &aIMENotification))) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
} else {
|
||||
// However, if a plugin has focus, only the editor rect information is
|
||||
// available.
|
||||
if (NS_WARN_IF(!mContentCache.CacheEditorRect(this, &aIMENotification))) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
// When IME gets focus, we should initialize all information of the
|
||||
// content.
|
||||
if (NS_WARN_IF(!mContentCache.CacheAll(this, &aIMENotification))) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
} else {
|
||||
// When IME loses focus, we don't need to store anything.
|
||||
@ -800,8 +792,7 @@ nsresult PuppetWidget::NotifyIMEOfCompositionUpdate(
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (mInputContext.mIMEState.mEnabled != IMEEnabled::Plugin &&
|
||||
NS_WARN_IF(!mContentCache.CacheSelection(this, &aIMENotification))) {
|
||||
if (NS_WARN_IF(!mContentCache.CacheSelection(this, &aIMENotification))) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
mBrowserChild->SendNotifyIMECompositionUpdate(mContentCache,
|
||||
@ -819,11 +810,6 @@ nsresult PuppetWidget::NotifyIMEOfTextChange(
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// While a plugin has focus, text change notification shouldn't be available.
|
||||
if (NS_WARN_IF(mInputContext.mIMEState.mEnabled == IMEEnabled::Plugin)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// FYI: text change notification is the first notification after
|
||||
// a user operation changes the content. So, we need to modify
|
||||
// the cache as far as possible here.
|
||||
@ -851,12 +837,6 @@ nsresult PuppetWidget::NotifyIMEOfSelectionChange(
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// While a plugin has focus, selection change notification shouldn't be
|
||||
// available.
|
||||
if (NS_WARN_IF(mInputContext.mIMEState.mEnabled == IMEEnabled::Plugin)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// Note that selection change must be notified after text change if it occurs.
|
||||
// Therefore, we don't need to query text content again here.
|
||||
mContentCache.SetSelection(
|
||||
@ -877,12 +857,6 @@ nsresult PuppetWidget::NotifyIMEOfMouseButtonEvent(
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// While a plugin has focus, mouse button event notification shouldn't be
|
||||
// available.
|
||||
if (NS_WARN_IF(mInputContext.mIMEState.mEnabled == IMEEnabled::Plugin)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
bool consumedByIME = false;
|
||||
if (!mBrowserChild->SendNotifyIMEMouseButtonEvent(aIMENotification,
|
||||
&consumedByIME)) {
|
||||
@ -902,10 +876,7 @@ nsresult PuppetWidget::NotifyIMEOfPositionChange(
|
||||
if (NS_WARN_IF(!mContentCache.CacheEditorRect(this, &aIMENotification))) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
// While a plugin has focus, selection range isn't available. So, we don't
|
||||
// need to cache it at that time.
|
||||
if (mInputContext.mIMEState.mEnabled != IMEEnabled::Plugin &&
|
||||
NS_WARN_IF(!mContentCache.CacheSelection(this, &aIMENotification))) {
|
||||
if (NS_WARN_IF(!mContentCache.CacheSelection(this, &aIMENotification))) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
if (mIMENotificationRequestsOfParent.WantPositionChanged()) {
|
||||
@ -1317,14 +1288,6 @@ PuppetWidget::NotifyIME(TextEventDispatcher* aTextEventDispatcher,
|
||||
|
||||
NS_IMETHODIMP_(IMENotificationRequests)
|
||||
PuppetWidget::GetIMENotificationRequests() {
|
||||
if (mInputContext.mIMEState.mEnabled == IMEEnabled::Plugin) {
|
||||
// If a plugin has focus, we cannot receive text nor selection change
|
||||
// in the plugin. Therefore, PuppetWidget needs to receive only position
|
||||
// change event for updating the editor rect cache.
|
||||
return IMENotificationRequests(
|
||||
mIMENotificationRequestsOfParent.mWantUpdates |
|
||||
IMENotificationRequests::NOTIFY_POSITION_CHANGE);
|
||||
}
|
||||
return IMENotificationRequests(
|
||||
mIMENotificationRequestsOfParent.mWantUpdates |
|
||||
IMENotificationRequests::NOTIFY_TEXT_CHANGE |
|
||||
|
@ -1526,7 +1526,6 @@ void nsChildView::SetInputContext(const InputContext& aContext, const InputConte
|
||||
mInputContext = aContext;
|
||||
switch (aContext.mIMEState.mEnabled) {
|
||||
case IMEEnabled::Enabled:
|
||||
case IMEEnabled::Plugin:
|
||||
mTextInputHandler->SetASCIICapableOnly(false);
|
||||
mTextInputHandler->EnableIME(true);
|
||||
if (mInputContext.mIMEState.mOpen != IMEState::DONT_CHANGE_OPEN_STATE) {
|
||||
@ -1549,7 +1548,6 @@ void nsChildView::SetInputContext(const InputContext& aContext, const InputConte
|
||||
InputContext nsChildView::GetInputContext() {
|
||||
switch (mInputContext.mIMEState.mEnabled) {
|
||||
case IMEEnabled::Enabled:
|
||||
case IMEEnabled::Plugin:
|
||||
if (mTextInputHandler) {
|
||||
mInputContext.mIMEState.mOpen =
|
||||
mTextInputHandler->IsIMEOpened() ? IMEState::OPEN : IMEState::CLOSED;
|
||||
|
@ -615,12 +615,6 @@ TextEventDispatcher* IMContextWrapper::GetTextEventDispatcher() {
|
||||
|
||||
NS_IMETHODIMP_(IMENotificationRequests)
|
||||
IMContextWrapper::GetIMENotificationRequests() {
|
||||
// While a plugin has focus, IMContextWrapper doesn't need any
|
||||
// notifications.
|
||||
if (mInputContext.mIMEState.mEnabled == IMEEnabled::Plugin) {
|
||||
return IMENotificationRequests();
|
||||
}
|
||||
|
||||
IMENotificationRequests::Notifications notifications =
|
||||
IMENotificationRequests::NOTIFY_NOTHING;
|
||||
// If it's not enabled, we don't need position change notification.
|
||||
@ -766,7 +760,7 @@ KeyHandlingState IMContextWrapper::OnKeyEvent(
|
||||
bool aKeyboardEventWasDispatched /* = false */) {
|
||||
MOZ_ASSERT(aEvent, "aEvent must be non-null");
|
||||
|
||||
if (!mInputContext.mIMEState.MaybeEditable() || MOZ_UNLIKELY(IsDestroyed())) {
|
||||
if (!mInputContext.mIMEState.IsEditable() || MOZ_UNLIKELY(IsDestroyed())) {
|
||||
return KeyHandlingState::eNotHandled;
|
||||
}
|
||||
|
||||
@ -1284,7 +1278,7 @@ void IMContextWrapper::SetInputContext(nsWindow* aCaller,
|
||||
aContext->mHTMLInputType != mInputContext.mHTMLInputType;
|
||||
|
||||
// Release current IME focus if IME is enabled.
|
||||
if (changingEnabledState && mInputContext.mIMEState.MaybeEditable()) {
|
||||
if (changingEnabledState && mInputContext.mIMEState.IsEditable()) {
|
||||
EndIMEComposition(mLastFocusedWindow);
|
||||
Blur();
|
||||
}
|
||||
@ -1292,7 +1286,7 @@ void IMContextWrapper::SetInputContext(nsWindow* aCaller,
|
||||
mInputContext = *aContext;
|
||||
|
||||
if (changingEnabledState) {
|
||||
if (mInputContext.mIMEState.MaybeEditable()) {
|
||||
if (mInputContext.mIMEState.IsEditable()) {
|
||||
GtkIMContext* currentContext = GetCurrentContext();
|
||||
if (currentContext) {
|
||||
GtkInputPurpose purpose = GTK_INPUT_PURPOSE_FREE_FORM;
|
||||
@ -1394,7 +1388,6 @@ bool IMContextWrapper::IsValidContext(GtkIMContext* aContext) const {
|
||||
|
||||
bool IMContextWrapper::IsEnabled() const {
|
||||
return mInputContext.mIMEState.mEnabled == IMEEnabled::Enabled ||
|
||||
mInputContext.mIMEState.mEnabled == IMEEnabled::Plugin ||
|
||||
(!sUseSimpleContext &&
|
||||
mInputContext.mIMEState.mEnabled == IMEEnabled::Password);
|
||||
}
|
||||
|
@ -2005,14 +2005,13 @@ char16_t NativeKey::ComputeUnicharFromScanCode() const {
|
||||
ComputeVirtualKeyCodeFromScanCode(), MAPVK_VK_TO_CHAR, mKeyboardLayout));
|
||||
}
|
||||
|
||||
nsEventStatus NativeKey::InitKeyEvent(WidgetKeyboardEvent& aKeyEvent,
|
||||
const MSG* aMsgSentToPlugin) const {
|
||||
return InitKeyEvent(aKeyEvent, mModKeyState, aMsgSentToPlugin);
|
||||
nsEventStatus NativeKey::InitKeyEvent(WidgetKeyboardEvent& aKeyEvent) const {
|
||||
return InitKeyEvent(aKeyEvent, mModKeyState);
|
||||
}
|
||||
|
||||
nsEventStatus NativeKey::InitKeyEvent(WidgetKeyboardEvent& aKeyEvent,
|
||||
const ModifierKeyState& aModKeyState,
|
||||
const MSG* aMsgSentToPlugin) const {
|
||||
nsEventStatus NativeKey::InitKeyEvent(
|
||||
WidgetKeyboardEvent& aKeyEvent,
|
||||
const ModifierKeyState& aModKeyState) const {
|
||||
if (mWidget->Destroyed()) {
|
||||
MOZ_CRASH("NativeKey tries to dispatch a key event on destroyed widget");
|
||||
}
|
||||
@ -2072,10 +2071,6 @@ nsEventStatus NativeKey::InitKeyEvent(WidgetKeyboardEvent& aKeyEvent,
|
||||
aKeyEvent.mLocation = GetKeyLocation();
|
||||
aModKeyState.InitInputEvent(aKeyEvent);
|
||||
|
||||
if (aMsgSentToPlugin) {
|
||||
MaybeInitPluginEventOfKeyEvent(aKeyEvent, *aMsgSentToPlugin);
|
||||
}
|
||||
|
||||
KeyboardLayout::NotifyIdleServiceOfUserActivity();
|
||||
|
||||
MOZ_LOG(
|
||||
@ -2096,18 +2091,6 @@ nsEventStatus NativeKey::InitKeyEvent(WidgetKeyboardEvent& aKeyEvent,
|
||||
: nsEventStatus_eIgnore;
|
||||
}
|
||||
|
||||
void NativeKey::MaybeInitPluginEventOfKeyEvent(
|
||||
WidgetKeyboardEvent& aKeyEvent, const MSG& aMsgSentToPlugin) const {
|
||||
if (mWidget->GetInputContext().mIMEState.mEnabled != IMEEnabled::Plugin) {
|
||||
return;
|
||||
}
|
||||
NPEvent pluginEvent;
|
||||
pluginEvent.event = aMsgSentToPlugin.message;
|
||||
pluginEvent.wParam = aMsgSentToPlugin.wParam;
|
||||
pluginEvent.lParam = aMsgSentToPlugin.lParam;
|
||||
aKeyEvent.mPluginEvent.Copy(pluginEvent);
|
||||
}
|
||||
|
||||
bool NativeKey::DispatchCommandEvent(uint32_t aEventCommand) const {
|
||||
RefPtr<nsAtom> command;
|
||||
switch (aEventCommand) {
|
||||
@ -2250,7 +2233,7 @@ bool NativeKey::HandleAppCommandMessage() const {
|
||||
"event...",
|
||||
this));
|
||||
WidgetKeyboardEvent keydownEvent(true, eKeyDown, mWidget);
|
||||
nsEventStatus status = InitKeyEvent(keydownEvent, mModKeyState, &mMsg);
|
||||
nsEventStatus status = InitKeyEvent(keydownEvent, mModKeyState);
|
||||
MOZ_LOG(sNativeKeyLogger, LogLevel::Info,
|
||||
("%p NativeKey::HandleAppCommandMessage(), tries to dispatch "
|
||||
"keydown event...",
|
||||
@ -2381,7 +2364,7 @@ bool NativeKey::HandleAppCommandMessage() const {
|
||||
"event...",
|
||||
this));
|
||||
WidgetKeyboardEvent keyupEvent(true, eKeyUp, mWidget);
|
||||
nsEventStatus status = InitKeyEvent(keyupEvent, mModKeyState, &mMsg);
|
||||
nsEventStatus status = InitKeyEvent(keyupEvent, mModKeyState);
|
||||
MOZ_LOG(sNativeKeyLogger, LogLevel::Info,
|
||||
("%p NativeKey::HandleAppCommandMessage(), dispatching keyup "
|
||||
"event...",
|
||||
@ -2474,7 +2457,7 @@ bool NativeKey::HandleKeyDownMessage(bool* aEventDispatched) const {
|
||||
EventMessage keyDownMessage =
|
||||
IsKeyMessageOnPlugin() ? eKeyDownOnPlugin : eKeyDown;
|
||||
WidgetKeyboardEvent keydownEvent(true, keyDownMessage, mWidget);
|
||||
nsEventStatus status = InitKeyEvent(keydownEvent, mModKeyState, &mMsg);
|
||||
nsEventStatus status = InitKeyEvent(keydownEvent, mModKeyState);
|
||||
MOZ_LOG(
|
||||
sNativeKeyLogger, LogLevel::Info,
|
||||
("%p NativeKey::HandleKeyDownMessage(), dispatching keydown event...",
|
||||
@ -2773,7 +2756,7 @@ bool NativeKey::HandleCharMessage(const MSG& aCharMsg,
|
||||
IsPrintableCharMessage(aCharMsg)) {
|
||||
modKeyState.Unset(MODIFIER_ALT | MODIFIER_CONTROL);
|
||||
}
|
||||
nsEventStatus status = InitKeyEvent(keypressEvent, modKeyState, &aCharMsg);
|
||||
nsEventStatus status = InitKeyEvent(keypressEvent, modKeyState);
|
||||
MOZ_LOG(sNativeKeyLogger, LogLevel::Info,
|
||||
("%p NativeKey::HandleCharMessage(), dispatching keypress event...",
|
||||
this));
|
||||
@ -2838,7 +2821,7 @@ bool NativeKey::HandleKeyUpMessage(bool* aEventDispatched) const {
|
||||
this));
|
||||
EventMessage keyUpMessage = IsKeyMessageOnPlugin() ? eKeyUpOnPlugin : eKeyUp;
|
||||
WidgetKeyboardEvent keyupEvent(true, keyUpMessage, mWidget);
|
||||
nsEventStatus status = InitKeyEvent(keyupEvent, mModKeyState, &mMsg);
|
||||
nsEventStatus status = InitKeyEvent(keyupEvent, mModKeyState);
|
||||
MOZ_LOG(sNativeKeyLogger, LogLevel::Info,
|
||||
("%p NativeKey::HandleKeyUpMessage(), dispatching keyup event...",
|
||||
this));
|
||||
@ -3530,9 +3513,7 @@ bool NativeKey::DispatchKeyPressEventsWithRetrievedCharMessages() const {
|
||||
// We don't need to send char message here if there are two or more retrieved
|
||||
// messages because we need to set each message to each eKeyPress event.
|
||||
bool needsCallback = mFollowingCharMsgs.Length() > 1;
|
||||
nsEventStatus status =
|
||||
InitKeyEvent(keypressEvent, modKeyState,
|
||||
!needsCallback ? &mFollowingCharMsgs[0] : nullptr);
|
||||
nsEventStatus status = InitKeyEvent(keypressEvent, modKeyState);
|
||||
MOZ_LOG(sNativeKeyLogger, LogLevel::Info,
|
||||
("%p NativeKey::DispatchKeyPressEventsWithRetrievedCharMessages(), "
|
||||
"dispatching keypress event(s)...",
|
||||
@ -3629,7 +3610,6 @@ void NativeKey::WillDispatchKeyboardEvent(WidgetKeyboardEvent& aKeyboardEvent,
|
||||
if (foundPrintableCharMessages++ == aIndex) {
|
||||
// Found message which caused the eKeyPress event. Let's set the
|
||||
// message for plugin if it's necessary.
|
||||
MaybeInitPluginEventOfKeyEvent(aKeyboardEvent, mFollowingCharMsgs[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -722,17 +722,8 @@ class MOZ_STACK_CLASS NativeKey final {
|
||||
* Initializes the aKeyEvent with the information stored in the instance.
|
||||
*/
|
||||
nsEventStatus InitKeyEvent(WidgetKeyboardEvent& aKeyEvent,
|
||||
const ModifierKeyState& aModKeyState,
|
||||
const MSG* aMsgSentToPlugin = nullptr) const;
|
||||
nsEventStatus InitKeyEvent(WidgetKeyboardEvent& aKeyEvent,
|
||||
const MSG* aMsgSentToPlugin = nullptr) const;
|
||||
|
||||
/**
|
||||
* MaybeInitPluginEventOfKeyEvent() may initialize aKeyEvent::mPluginEvent
|
||||
* with aMsgSentToPlugin if it's necessary.
|
||||
*/
|
||||
void MaybeInitPluginEventOfKeyEvent(WidgetKeyboardEvent& aKeyEvent,
|
||||
const MSG& aMsgSentToPlugin) const;
|
||||
const ModifierKeyState& aModKeyState) const;
|
||||
nsEventStatus InitKeyEvent(WidgetKeyboardEvent& aKeyEvent) const;
|
||||
|
||||
/**
|
||||
* Dispatches a command event for aEventCommand.
|
||||
|
@ -425,8 +425,6 @@ void IMEHandler::SetInputContext(nsWindow* aWindow, InputContext& aInputContext,
|
||||
// FYI: If there is no composition, this call will do nothing.
|
||||
NotifyIME(aWindow, IMENotification(REQUEST_TO_COMMIT_COMPOSITION));
|
||||
|
||||
const InputContext& oldInputContext = aWindow->GetInputContext();
|
||||
|
||||
if (aInputContext.mHTMLInputInputmode.EqualsLiteral("none")) {
|
||||
IMEHandler::MaybeDismissOnScreenKeyboard(aWindow, Sync::Yes);
|
||||
} else if (aAction.UserMightRequestOpenVKB()) {
|
||||
@ -446,10 +444,6 @@ void IMEHandler::SetInputContext(nsWindow* aWindow, InputContext& aInputContext,
|
||||
if (sIsIMMEnabled) {
|
||||
// Associate IMC with aWindow only when it's necessary.
|
||||
AssociateIMEContext(aWindow, enable && NeedsToAssociateIMC());
|
||||
} else if (oldInputContext.mIMEState.mEnabled == IMEEnabled::Plugin) {
|
||||
// Disassociate the IME context from the window when plugin loses focus
|
||||
// in pure TSF mode.
|
||||
AssociateIMEContext(aWindow, false);
|
||||
}
|
||||
if (adjustOpenState) {
|
||||
TSFTextStore::SetIMEOpenState(open);
|
||||
|
@ -1634,19 +1634,12 @@ LayoutDeviceIntRect WinUtils::ToIntRect(const RECT& aRect) {
|
||||
|
||||
/* static */
|
||||
bool WinUtils::IsIMEEnabled(const InputContext& aInputContext) {
|
||||
if (!IsIMEEnabled(aInputContext.mIMEState.mEnabled)) {
|
||||
return false;
|
||||
}
|
||||
if (aInputContext.mIMEState.mEnabled == IMEEnabled::Plugin &&
|
||||
aInputContext.mHTMLInputType.EqualsLiteral("password")) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return IsIMEEnabled(aInputContext.mIMEState.mEnabled);
|
||||
}
|
||||
|
||||
/* static */
|
||||
bool WinUtils::IsIMEEnabled(IMEEnabled aIMEState) {
|
||||
return (aIMEState == IMEEnabled::Enabled || aIMEState == IMEEnabled::Plugin);
|
||||
return aIMEState == IMEEnabled::Enabled;
|
||||
}
|
||||
|
||||
/* static */
|
||||
|
Loading…
Reference in New Issue
Block a user