diff --git a/widget/windows/nsIMM32Handler.cpp b/widget/windows/nsIMM32Handler.cpp index 45a5ad937d39..944a1dcbc5ab 100644 --- a/widget/windows/nsIMM32Handler.cpp +++ b/widget/windows/nsIMM32Handler.cpp @@ -462,7 +462,7 @@ nsIMM32Handler::OnInputLangChange(nsWindow* aWindow, ("IMM32: OnInputLangChange, hWnd=%08x, wParam=%08x, lParam=%08x\n", aWindow->GetWindowHandle(), wParam, lParam)); - aWindow->ResetInputState(); + aWindow->NotifyIME(REQUEST_TO_COMMIT_COMPOSITION); NS_ASSERTION(!mIsComposing, "ResetInputState failed"); if (mIsComposing) { diff --git a/widget/windows/nsWindow.cpp b/widget/windows/nsWindow.cpp index eb0e48757e14..27e0edd095a6 100644 --- a/widget/windows/nsWindow.cpp +++ b/widget/windows/nsWindow.cpp @@ -6859,7 +6859,7 @@ LRESULT nsWindow::OnChar(const MSG &aMsg, } if (IMEHandler::IsComposingOn(this)) { - ResetInputState(); + IMEHandler::NotifyIME(this, REQUEST_TO_COMMIT_COMPOSITION); } wchar_t uniChar; @@ -7360,9 +7360,10 @@ nsWindow::OnSysColorChanged() ************************************************************** **************************************************************/ -NS_IMETHODIMP nsWindow::ResetInputState() +NS_IMETHODIMP +nsWindow::NotifyIME(NotificationToIME aNotification) { - return IMEHandler::NotifyIME(this, REQUEST_TO_COMMIT_COMPOSITION); + return IMEHandler::NotifyIME(this, aNotification); } NS_IMETHODIMP_(void) @@ -7386,11 +7387,6 @@ nsWindow::GetInputContext() return mInputContext; } -NS_IMETHODIMP nsWindow::CancelIMEComposition() -{ - return IMEHandler::NotifyIME(this, REQUEST_TO_CANCEL_COMPOSITION); -} - NS_IMETHODIMP nsWindow::GetToggledKeyState(uint32_t aKeyCode, bool* aLEDState) { @@ -7402,13 +7398,6 @@ nsWindow::GetToggledKeyState(uint32_t aKeyCode, bool* aLEDState) return NS_OK; } -NS_IMETHODIMP -nsWindow::OnIMEFocusChange(bool aFocus) -{ - return IMEHandler::NotifyIME(this, aFocus ? NOTIFY_IME_OF_FOCUS : - NOTIFY_IME_OF_BLUR); -} - NS_IMETHODIMP nsWindow::OnIMETextChange(uint32_t aStart, uint32_t aOldEnd, @@ -7417,12 +7406,6 @@ nsWindow::OnIMETextChange(uint32_t aStart, return IMEHandler::NotifyIMEOfTextChange(aStart, aOldEnd, aNewEnd); } -NS_IMETHODIMP -nsWindow::OnIMESelectionChange(void) -{ - return IMEHandler::NotifyIME(this, NOTIFY_IME_OF_SELECTION_CHANGE); -} - nsIMEUpdatePreference nsWindow::GetIMEUpdatePreference() { diff --git a/widget/windows/nsWindow.h b/widget/windows/nsWindow.h index 9499902df4c6..b0993dc5f461 100644 --- a/widget/windows/nsWindow.h +++ b/widget/windows/nsWindow.h @@ -163,11 +163,10 @@ public: double aDeltaZ, uint32_t aModifierFlags, uint32_t aAdditionalFlags); - NS_IMETHOD ResetInputState(); + NS_IMETHOD NotifyIME(NotificationToIME aNotification) MOZ_OVERRIDE; NS_IMETHOD_(void) SetInputContext(const InputContext& aContext, const InputContextAction& aAction); NS_IMETHOD_(InputContext) GetInputContext(); - NS_IMETHOD CancelIMEComposition(); NS_IMETHOD GetToggledKeyState(uint32_t aKeyCode, bool* aLEDState); NS_IMETHOD RegisterTouchWindow(); NS_IMETHOD UnregisterTouchWindow(); @@ -176,9 +175,7 @@ public: virtual nsTransparencyMode GetTransparencyMode(); virtual void UpdateOpaqueRegion(const nsIntRegion& aOpaqueRegion); #endif // MOZ_XUL - NS_IMETHOD OnIMEFocusChange(bool aFocus); NS_IMETHOD OnIMETextChange(uint32_t aStart, uint32_t aOldEnd, uint32_t aNewEnd); - NS_IMETHOD OnIMESelectionChange(void); virtual nsIMEUpdatePreference GetIMEUpdatePreference(); NS_IMETHOD GetNonClientMargins(nsIntMargin &margins); NS_IMETHOD SetNonClientMargins(nsIntMargin &margins); diff --git a/widget/windows/winrt/MetroWidget.cpp b/widget/windows/winrt/MetroWidget.cpp index ed201e7340a6..71b4ee17c4c7 100644 --- a/widget/windows/winrt/MetroWidget.cpp +++ b/widget/windows/winrt/MetroWidget.cpp @@ -1152,18 +1152,26 @@ MetroWidget::GetInputContext() } NS_IMETHODIMP -MetroWidget::ResetInputState() +MetroWidget::NotifyIME(NotificationToIME aNotification) { - nsTextStore::CommitComposition(false); - return NS_OK; -} - - -NS_IMETHODIMP -MetroWidget::CancelIMEComposition() -{ - nsTextStore::CommitComposition(true); - return NS_OK; + switch (aNotification) { + case REQUEST_TO_COMMIT_COMPOSITION: + nsTextStore::CommitComposition(false); + return NS_OK; + case REQUEST_TO_CANCEL_COMPOSITION: + nsTextStore::CommitComposition(true); + return NS_OK; + case NOTIFY_IME_OF_FOCUS: + return nsTextStore::OnFocusChange(true, this, + mInputContext.mIMEState.mEnabled); + case NOTIFY_IME_OF_BLUR: + return nsTextStore::OnFocusChange(false, this, + mInputContext.mIMEState.mEnabled); + case NOTIFY_IME_OF_SELECTION_CHANGE: + return nsTextStore::OnSelectionChange(); + default: + return NS_ERROR_NOT_IMPLEMENTED; + } } NS_IMETHODIMP @@ -1174,13 +1182,6 @@ MetroWidget::GetToggledKeyState(uint32_t aKeyCode, bool* aLEDState) return NS_OK; } -NS_IMETHODIMP -MetroWidget::OnIMEFocusChange(bool aFocus) -{ - return nsTextStore::OnFocusChange(aFocus, this, - mInputContext.mIMEState.mEnabled); -} - NS_IMETHODIMP MetroWidget::OnIMETextChange(uint32_t aStart, uint32_t aOldEnd, @@ -1189,12 +1190,6 @@ MetroWidget::OnIMETextChange(uint32_t aStart, return nsTextStore::OnTextChange(aStart, aOldEnd, aNewEnd); } -NS_IMETHODIMP -MetroWidget::OnIMESelectionChange(void) -{ - return nsTextStore::OnSelectionChange(); -} - NS_IMETHODIMP MetroWidget::ReparentNativeWidget(nsIWidget* aNewParent) { diff --git a/widget/windows/winrt/MetroWidget.h b/widget/windows/winrt/MetroWidget.h index d12795bc8be9..0d55d34aafa5 100644 --- a/widget/windows/winrt/MetroWidget.h +++ b/widget/windows/winrt/MetroWidget.h @@ -126,12 +126,9 @@ public: NS_IMETHOD_(void) SetInputContext(const InputContext& aContext, const InputContextAction& aAction); NS_IMETHOD_(nsIWidget::InputContext) GetInputContext(); - NS_IMETHOD ResetInputState(); - NS_IMETHOD CancelIMEComposition(); + NS_IMETHOD NotifyIME(NotificationToIME aNotification) MOZ_OVERRIDE; NS_IMETHOD GetToggledKeyState(uint32_t aKeyCode, bool* aLEDState); - NS_IMETHOD OnIMEFocusChange(bool aFocus); NS_IMETHOD OnIMETextChange(uint32_t aStart, uint32_t aOldEnd, uint32_t aNewEnd); - NS_IMETHOD OnIMESelectionChange(void); // FrameworkView helpers void SizeModeChanged();