Bug 840409 part.7 Define new notification for IME of focus or selection change and handle them in widget::IMEHandler::NotifyIME() r=jimm, feedback=roc

This commit is contained in:
Masayuki Nakano 2013-02-25 13:00:06 +09:00
parent 649b4e4874
commit 9abe38168e
6 changed files with 27 additions and 12 deletions

View File

@ -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
};

View File

@ -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);

View File

@ -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);

View File

@ -133,7 +133,7 @@ public:
static nsresult OnSelectionChange(void)
{
if (!sTsfTextStore) return NS_OK;
NS_ENSURE_TRUE(sTsfTextStore, NS_ERROR_NOT_AVAILABLE);
return sTsfTextStore->OnSelectionChangeInternal();
}

View File

@ -7467,17 +7467,14 @@ 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,
@ -7485,13 +7482,15 @@ nsWindow::OnIMETextChange(uint32_t aStart,
{
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()
{

View File

@ -176,10 +176,12 @@ public:
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);