Permalink
Browse files

Bug 840409 part.7 Define new notification for IME of focus or selecti…

…on change and handle them in widget::IMEHandler::NotifyIME() r=jimm, feedback=roc
  • Loading branch information...
1 parent e551514 commit 6860ef57f15db0a777800a09fcb6df1f357a1ea0 @masayuki-nakano masayuki-nakano committed Feb 25, 2013
View
@@ -102,7 +102,15 @@ typedef uint16_t Modifiers;
// NotificationToIME is shared by nsIMEStateManager and TextComposition.
enum NotificationToIME {
+ // XXX We should replace NOTIFY_IME_OF_CURSOR_POS_CHANGED with
+ // NOTIFY_IME_OF_SELECTION_CHANGE later.
NOTIFY_IME_OF_CURSOR_POS_CHANGED,
+ // An editable content is getting focus
+ NOTIFY_IME_OF_FOCUS,
+ // An editable content is losing focus
+ NOTIFY_IME_OF_BLUR,
+ // Selection in the focused editable content is changed
+ NOTIFY_IME_OF_SELECTION_CHANGE,
REQUEST_TO_COMMIT_COMPOSITION,
REQUEST_TO_CANCEL_COMPOSITION
};
@@ -104,6 +104,14 @@ IMEHandler::NotifyIME(nsWindow* aWindow,
#ifdef NS_ENABLE_TSF
if (sIsInTSFMode) {
switch (aNotification) {
+ case NOTIFY_IME_OF_SELECTION_CHANGE:
+ return nsTextStore::OnSelectionChange();
+ case NOTIFY_IME_OF_FOCUS:
+ return nsTextStore::OnFocusChange(true, aWindow,
+ aWindow->GetInputContext().mIMEState.mEnabled);
+ case NOTIFY_IME_OF_BLUR:
+ return nsTextStore::OnFocusChange(false, aWindow,
+ aWindow->GetInputContext().mIMEState.mEnabled);
case REQUEST_TO_COMMIT_COMPOSITION:
if (nsTextStore::IsComposingOn(aWindow)) {
nsTextStore::CommitComposition(false);
@@ -2817,9 +2817,7 @@ nsTextStore::OnFocusChange(bool aGotFocus,
GetIMEEnabledName(aIMEEnabled), sTsfThreadMgr, sTsfTextStore));
// no change notifications if TSF is disabled
- if (!sTsfThreadMgr || !sTsfTextStore) {
- return NS_ERROR_NOT_AVAILABLE;
- }
+ NS_ENSURE_TRUE(sTsfThreadMgr && sTsfTextStore, NS_ERROR_NOT_AVAILABLE);
if (aGotFocus) {
bool bRet = sTsfTextStore->Create(aFocusedWidget, aIMEEnabled);
@@ -133,7 +133,7 @@ class nsTextStore MOZ_FINAL : public ITextStoreACP,
static nsresult OnSelectionChange(void)
{
- if (!sTsfTextStore) return NS_OK;
+ NS_ENSURE_TRUE(sTsfTextStore, NS_ERROR_NOT_AVAILABLE);
return sTsfTextStore->OnSelectionChangeInternal();
}
@@ -7467,31 +7467,30 @@ nsWindow::GetToggledKeyState(uint32_t aKeyCode, bool* aLEDState)
return NS_OK;
}
-#ifdef NS_ENABLE_TSF
NS_IMETHODIMP
nsWindow::OnIMEFocusChange(bool aFocus)
{
- nsresult rv = nsTextStore::OnFocusChange(aFocus, this,
- mInputContext.mIMEState.mEnabled);
- if (rv == NS_ERROR_NOT_AVAILABLE)
- rv = NS_OK; // TSF is not enabled, maybe.
- return rv;
+ return IMEHandler::NotifyIME(this, aFocus ? NOTIFY_IME_OF_FOCUS :
+ NOTIFY_IME_OF_BLUR);
}
+#ifdef NS_ENABLE_TSF
NS_IMETHODIMP
nsWindow::OnIMETextChange(uint32_t aStart,
uint32_t aOldEnd,
uint32_t aNewEnd)
{
return nsTextStore::OnTextChange(aStart, aOldEnd, aNewEnd);
}
+#endif // #ifdef NS_ENABLE_TSF
NS_IMETHODIMP
nsWindow::OnIMESelectionChange(void)
{
- return nsTextStore::OnSelectionChange();
+ return IMEHandler::NotifyIME(this, NOTIFY_IME_OF_SELECTION_CHANGE);
}
+#ifdef NS_ENABLE_TSF
nsIMEUpdatePreference
nsWindow::GetIMEUpdatePreference()
{
@@ -176,10 +176,12 @@ class nsWindow : public nsWindowBase
virtual nsTransparencyMode GetTransparencyMode();
virtual void UpdateOpaqueRegion(const nsIntRegion& aOpaqueRegion);
#endif // MOZ_XUL
-#ifdef NS_ENABLE_TSF
NS_IMETHOD OnIMEFocusChange(bool aFocus);
+#ifdef NS_ENABLE_TSF
NS_IMETHOD OnIMETextChange(uint32_t aStart, uint32_t aOldEnd, uint32_t aNewEnd);
+#endif // NS_ENABLE_TSF
NS_IMETHOD OnIMESelectionChange(void);
+#ifdef NS_ENABLE_TSF
virtual nsIMEUpdatePreference GetIMEUpdatePreference();
#endif // NS_ENABLE_TSF
NS_IMETHOD GetNonClientMargins(nsIntMargin &margins);

0 comments on commit 6860ef5

Please sign in to comment.