From 16d6de6b90d99f8cd6e4611d8f59e9579df3a6d8 Mon Sep 17 00:00:00 2001 From: "masayuki%d-toybox.com" Date: Wed, 20 Feb 2008 07:16:07 +0000 Subject: [PATCH] Bug 417315 Cannot use IME menus during IME transaction #1 r=josh+roc, sr=roc, a1.9=beltzner git-svn-id: svn://10.0.0.236/trunk@246044 18797224-902f-48f8-a5cc-f745e15eee43 --- .../content/events/src/nsIMEStateManager.cpp | 9 ------ mozilla/layout/base/nsPresShell.cpp | 19 +----------- mozilla/widget/public/nsGUIEvent.h | 29 +++++++++++++++++++ mozilla/widget/public/nsIKBStateControl.h | 9 ------ mozilla/widget/src/cocoa/nsChildView.mm | 4 --- 5 files changed, 30 insertions(+), 40 deletions(-) diff --git a/mozilla/content/events/src/nsIMEStateManager.cpp b/mozilla/content/events/src/nsIMEStateManager.cpp index 0ebcb9aaeea..90ab12e28c0 100755 --- a/mozilla/content/events/src/nsIMEStateManager.cpp +++ b/mozilla/content/events/src/nsIMEStateManager.cpp @@ -179,15 +179,6 @@ nsIMEStateManager::OnDeactivate(nsPresContext* aPresContext) return NS_OK; sActiveWindow = nsnull; -#ifdef NS_KBSC_USE_SHARED_CONTEXT - // Reset the latest content. When the window is activated, the IME state - // may be changed on other applications. - sContent = nsnull; - // We should enable the IME state for other applications. - nsCOMPtr kb = GetKBStateControl(aPresContext); - if (kb) - SetIMEState(aPresContext, nsIContent::IME_STATUS_ENABLE, kb); -#endif // NS_KBSC_USE_SHARED_CONTEXT return NS_OK; } diff --git a/mozilla/layout/base/nsPresShell.cpp b/mozilla/layout/base/nsPresShell.cpp index 385a21200e9..eb121749a92 100644 --- a/mozilla/layout/base/nsPresShell.cpp +++ b/mozilla/layout/base/nsPresShell.cpp @@ -5622,23 +5622,7 @@ PresShell::HandleEvent(nsIView *aView, if (mCurrentEventFrame) { esm->GetFocusedContent(getter_AddRefs(mCurrentEventContent)); } else { -#if defined(MOZ_X11) || defined(XP_WIN) -#if defined(MOZ_X11) - if (NS_IS_IME_EVENT(aEvent)) { - // bug 52416 (MOZ_X11) - // Lookup region (candidate window) of UNIX IME grabs - // input focus from Mozilla but wants to send IME event - // to redraw pre-edit (composed) string - // If Mozilla does not have input focus and event is IME, - // sends IME event to pre-focused element -#else - if (NS_IS_KEY_EVENT(aEvent) || NS_IS_IME_EVENT(aEvent)) { - // bug 292263 (XP_WIN) - // If software keyboard has focus, it may send the key messages and - // the IME messages to pre-focused window. Therefore, if Mozilla - // doesn't have focus and event is key event or IME event, we should - // send the events to pre-focused element. -#endif /* defined(MOZ_X11) */ + if (NS_TargetUnfocusedEventToLastFocusedContent(aEvent)) { nsPIDOMWindow *ourWindow = mDocument->GetWindow(); if (ourWindow) { nsIFocusController *focusController = @@ -5659,7 +5643,6 @@ PresShell::HandleEvent(nsIView *aView, } } } -#endif /* defined(MOZ_X11) || defined(XP_WIN) */ if (!mCurrentEventContent) { mCurrentEventContent = mDocument->GetRootContent(); } diff --git a/mozilla/widget/public/nsGUIEvent.h b/mozilla/widget/public/nsGUIEvent.h index ad36b759495..c2ea0b99a6a 100644 --- a/mozilla/widget/public/nsGUIEvent.h +++ b/mozilla/widget/public/nsGUIEvent.h @@ -1180,4 +1180,33 @@ enum nsDragDropEventStatus { #define NS_TEXTRANGE_CONVERTEDTEXT 0x04 #define NS_TEXTRANGE_SELECTEDCONVERTEDTEXT 0x05 +static PRBool NS_TargetUnfocusedEventToLastFocusedContent(nsEvent* aEvent) +{ +#if defined(MOZ_X11) || defined(XP_MACOSX) + // bug 52416 (MOZ_X11) + // Lookup region (candidate window) of UNIX IME grabs + // input focus from Mozilla but wants to send IME event + // to redraw pre-edit (composed) string + // If Mozilla does not have input focus and event is IME, + // sends IME event to pre-focused element + + // bug 417315 (XP_MACOSX) + // The commit event when the window is deactivating is sent after + // the next focused widget getting the focus. + // We need to send the commit event to last focused content. + + return NS_IS_IME_EVENT(aEvent); +#elif defined(XP_WIN) + // bug 292263 (XP_WIN) + // If software keyboard has focus, it may send the key messages and + // the IME messages to pre-focused window. Therefore, if Mozilla + // doesn't have focus and event is key event or IME event, we should + // send the events to pre-focused element. + + return NS_IS_KEY_EVENT(aEvent) || NS_IS_IME_EVENT(aEvent); +#else + return PR_FALSE; +#endif +} + #endif // nsGUIEvent_h__ diff --git a/mozilla/widget/public/nsIKBStateControl.h b/mozilla/widget/public/nsIKBStateControl.h index ea555ceb959..4774ebe6a1f 100644 --- a/mozilla/widget/public/nsIKBStateControl.h +++ b/mozilla/widget/public/nsIKBStateControl.h @@ -47,15 +47,6 @@ { 0xa7, 0xfd, 0x17, 0x75, 0x01, 0xad, 0xec, 0x98 } } -#if defined(XP_MACOSX) -/* - * If the all applications use same context for IME, i.e., When gecko changes - * the state of IME, the same changes can be on other processes. - * Then, NS_KBSC_USE_SHARED_CONTEXT should be defined. - */ -#define NS_KBSC_USE_SHARED_CONTEXT 1 -#endif - /** * interface to control keyboard input state */ diff --git a/mozilla/widget/src/cocoa/nsChildView.mm b/mozilla/widget/src/cocoa/nsChildView.mm index 8dceef6703b..8f7d76f9165 100644 --- a/mozilla/widget/src/cocoa/nsChildView.mm +++ b/mozilla/widget/src/cocoa/nsChildView.mm @@ -4183,8 +4183,6 @@ static BOOL keyUpAlreadySentKeyDown = NO; // nil -- otherwise the keyboard focus can end up in the wrong NSView. - (BOOL)resignFirstResponder { - nsTSMManager::CommitIME(); - return [super resignFirstResponder]; } @@ -4219,8 +4217,6 @@ static BOOL keyUpAlreadySentKeyDown = NO; nsAutoRetainView kungFuDeathGrip(self); - nsTSMManager::CommitIME(); - [self sendFocusEvent:NS_DEACTIVATE]; [self sendFocusEvent:NS_LOSTFOCUS]; }