Bug 685395 part.2 Move IMEContext to mozilla::widget::InputContext r=roc

This commit is contained in:
Masayuki Nakano 2011-11-27 20:51:52 +09:00
parent 235ae0ff7d
commit cbcebd2356
23 changed files with 236 additions and 185 deletions

View File

@ -212,6 +212,7 @@ static NS_DEFINE_CID(kXTFServiceCID, NS_XTFSERVICE_CID);
using namespace mozilla::dom; using namespace mozilla::dom;
using namespace mozilla::layers; using namespace mozilla::layers;
using namespace mozilla::widget;
using namespace mozilla; using namespace mozilla;
const char kLoadAsData[] = "loadAsData"; const char kLoadAsData[] = "loadAsData";
@ -4032,16 +4033,16 @@ nsContentUtils::GetWidgetStatusFromIMEStatus(PRUint32 aState)
{ {
switch (aState & nsIContent::IME_STATUS_MASK_ENABLED) { switch (aState & nsIContent::IME_STATUS_MASK_ENABLED) {
case nsIContent::IME_STATUS_DISABLE: case nsIContent::IME_STATUS_DISABLE:
return nsIWidget::IME_STATUS_DISABLED; return InputContext::IME_DISABLED;
case nsIContent::IME_STATUS_ENABLE: case nsIContent::IME_STATUS_ENABLE:
return nsIWidget::IME_STATUS_ENABLED; return InputContext::IME_ENABLED;
case nsIContent::IME_STATUS_PASSWORD: case nsIContent::IME_STATUS_PASSWORD:
return nsIWidget::IME_STATUS_PASSWORD; return InputContext::IME_PASSWORD;
case nsIContent::IME_STATUS_PLUGIN: case nsIContent::IME_STATUS_PLUGIN:
return nsIWidget::IME_STATUS_PLUGIN; return InputContext::IME_PLUGIN;
default: default:
NS_ERROR("The given state doesn't have valid enable state"); NS_ERROR("The given state doesn't have valid enable state");
return nsIWidget::IME_STATUS_ENABLED; return InputContext::IME_ENABLED;
} }
} }

View File

@ -68,6 +68,8 @@
#include "nsIForm.h" #include "nsIForm.h"
#include "nsHTMLFormElement.h" #include "nsHTMLFormElement.h"
using namespace mozilla::widget;
/******************************************************************/ /******************************************************************/
/* nsIMEStateManager */ /* nsIMEStateManager */
/******************************************************************/ /******************************************************************/
@ -88,7 +90,7 @@ nsIMEStateManager::OnDestroyPresContext(nsPresContext* aPresContext)
nsCOMPtr<nsIWidget> widget = GetWidget(sPresContext); nsCOMPtr<nsIWidget> widget = GetWidget(sPresContext);
if (widget) { if (widget) {
PRUint32 newState = GetNewIMEState(sPresContext, nsnull); PRUint32 newState = GetNewIMEState(sPresContext, nsnull);
SetIMEState(newState, nsnull, widget, IMEContext::FOCUS_REMOVED); SetIMEState(newState, nsnull, widget, InputContext::FOCUS_REMOVED);
} }
sContent = nsnull; sContent = nsnull;
sPresContext = nsnull; sPresContext = nsnull;
@ -113,7 +115,7 @@ nsIMEStateManager::OnRemoveContent(nsPresContext* aPresContext,
if (NS_FAILED(rv)) if (NS_FAILED(rv))
widget->ResetInputState(); widget->ResetInputState();
PRUint32 newState = GetNewIMEState(sPresContext, nsnull); PRUint32 newState = GetNewIMEState(sPresContext, nsnull);
SetIMEState(newState, nsnull, widget, IMEContext::FOCUS_REMOVED); SetIMEState(newState, nsnull, widget, InputContext::FOCUS_REMOVED);
} }
sContent = nsnull; sContent = nsnull;
@ -166,12 +168,12 @@ nsIMEStateManager::OnChangeFocus(nsPresContext* aPresContext,
// the enabled state isn't changing, we should do nothing. // the enabled state isn't changing, we should do nothing.
return NS_OK; return NS_OK;
} }
IMEContext context; InputContext context;
if (!widget || NS_FAILED(widget->GetInputMode(context))) { if (!widget || NS_FAILED(widget->GetInputMode(context))) {
// this platform doesn't support IME controlling // this platform doesn't support IME controlling
return NS_OK; return NS_OK;
} }
if (context.mStatus == if (context.mIMEEnabled ==
nsContentUtils::GetWidgetStatusFromIMEStatus(newEnabledState)) { nsContentUtils::GetWidgetStatusFromIMEStatus(newEnabledState)) {
// the enabled state isn't changing. // the enabled state isn't changing.
return NS_OK; return NS_OK;
@ -205,8 +207,8 @@ nsIMEStateManager::OnInstalledMenuKeyboardListener(bool aInstalling)
{ {
sInstalledMenuKeyboardListener = aInstalling; sInstalledMenuKeyboardListener = aInstalling;
PRUint32 reason = aInstalling ? IMEContext::FOCUS_MOVED_TO_MENU PRUint32 reason = aInstalling ? InputContext::FOCUS_MOVED_TO_MENU
: IMEContext::FOCUS_MOVED_FROM_MENU; : InputContext::FOCUS_MOVED_FROM_MENU;
OnChangeFocus(sPresContext, sContent, reason); OnChangeFocus(sPresContext, sContent, reason);
} }
@ -225,13 +227,13 @@ nsIMEStateManager::UpdateIMEState(PRUint32 aNewIMEState, nsIContent* aContent)
} }
// Don't update IME state when enabled state isn't actually changed. // Don't update IME state when enabled state isn't actually changed.
IMEContext context; InputContext context;
nsresult rv = widget->GetInputMode(context); nsresult rv = widget->GetInputMode(context);
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
return; // This platform doesn't support controling the IME state. return; // This platform doesn't support controling the IME state.
} }
PRUint32 newEnabledState = aNewIMEState & nsIContent::IME_STATUS_MASK_ENABLED; PRUint32 newEnabledState = aNewIMEState & nsIContent::IME_STATUS_MASK_ENABLED;
if (context.mStatus == if (context.mIMEEnabled ==
nsContentUtils::GetWidgetStatusFromIMEStatus(newEnabledState)) { nsContentUtils::GetWidgetStatusFromIMEStatus(newEnabledState)) {
return; return;
} }
@ -239,7 +241,8 @@ nsIMEStateManager::UpdateIMEState(PRUint32 aNewIMEState, nsIContent* aContent)
// commit current composition // commit current composition
widget->ResetInputState(); widget->ResetInputState();
SetIMEState(aNewIMEState, aContent, widget, IMEContext::EDITOR_STATE_MODIFIED); SetIMEState(aNewIMEState, aContent, widget,
InputContext::EDITOR_STATE_MODIFIED);
} }
PRUint32 PRUint32
@ -300,8 +303,8 @@ nsIMEStateManager::SetIMEState(PRUint32 aState,
return; return;
PRUint32 state = nsContentUtils::GetWidgetStatusFromIMEStatus(aState); PRUint32 state = nsContentUtils::GetWidgetStatusFromIMEStatus(aState);
IMEContext context; InputContext context;
context.mStatus = state; context.mIMEEnabled = state;
if (aContent && aContent->GetNameSpaceID() == kNameSpaceID_XHTML && if (aContent && aContent->GetNameSpaceID() == kNameSpaceID_XHTML &&
(aContent->Tag() == nsGkAtoms::input || (aContent->Tag() == nsGkAtoms::input ||
@ -337,7 +340,7 @@ nsIMEStateManager::SetIMEState(PRUint32 aState,
} }
if (XRE_GetProcessType() == GeckoProcessType_Content) { if (XRE_GetProcessType() == GeckoProcessType_Content) {
context.mReason = aReason | IMEContext::FOCUS_FROM_CONTENT_PROCESS; context.mReason = aReason | InputContext::FOCUS_FROM_CONTENT_PROCESS;
} else { } else {
context.mReason = aReason; context.mReason = aReason;
} }

View File

@ -86,6 +86,7 @@
using namespace mozilla::dom; using namespace mozilla::dom;
using namespace mozilla::layers; using namespace mozilla::layers;
using namespace mozilla::widget;
static bool IsUniversalXPConnectCapable() static bool IsUniversalXPConnectCapable()
{ {
@ -1039,11 +1040,12 @@ nsDOMWindowUtils::GetIMEIsOpen(bool *aState)
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
// Open state should not be available when IME is not enabled. // Open state should not be available when IME is not enabled.
IMEContext context; InputContext context;
nsresult rv = widget->GetInputMode(context); nsresult rv = widget->GetInputMode(context);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
if (context.mStatus != nsIWidget::IME_STATUS_ENABLED) if (context.mIMEEnabled != InputContext::IME_ENABLED) {
return NS_ERROR_NOT_AVAILABLE; return NS_ERROR_NOT_AVAILABLE;
}
return widget->GetIMEOpenState(aState); return widget->GetIMEOpenState(aState);
} }
@ -1057,11 +1059,11 @@ nsDOMWindowUtils::GetIMEStatus(PRUint32 *aState)
if (!widget) if (!widget)
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
IMEContext context; InputContext context;
nsresult rv = widget->GetInputMode(context); nsresult rv = widget->GetInputMode(context);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
*aState = context.mStatus; *aState = context.mIMEEnabled;
return NS_OK; return NS_OK;
} }
@ -1075,7 +1077,7 @@ nsDOMWindowUtils::GetFocusedInputType(char** aType)
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
IMEContext context; InputContext context;
nsresult rv = widget->GetInputMode(context); nsresult rv = widget->GetInputMode(context);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);

View File

@ -96,6 +96,7 @@
using namespace mozilla; using namespace mozilla;
using namespace mozilla::dom; using namespace mozilla::dom;
using namespace mozilla::widget;
//#define DEBUG_FOCUS 1 //#define DEBUG_FOCUS 1
//#define DEBUG_FOCUS_NAVIGATION 1 //#define DEBUG_FOCUS_NAVIGATION 1
@ -340,13 +341,13 @@ nsFocusManager::GetRedirectedFocus(nsIContent* aContent)
PRUint32 PRUint32
nsFocusManager::GetFocusMoveReason(PRUint32 aFlags) nsFocusManager::GetFocusMoveReason(PRUint32 aFlags)
{ {
PRUint32 reason = IMEContext::FOCUS_MOVED_UNKNOWN; PRUint32 reason = InputContext::FOCUS_MOVED_UNKNOWN;
if (aFlags & nsIFocusManager::FLAG_BYMOUSE) { if (aFlags & nsIFocusManager::FLAG_BYMOUSE) {
reason = IMEContext::FOCUS_MOVED_BY_MOUSE; reason = InputContext::FOCUS_MOVED_BY_MOUSE;
} else if (aFlags & nsIFocusManager::FLAG_BYKEY) { } else if (aFlags & nsIFocusManager::FLAG_BYKEY) {
reason = IMEContext::FOCUS_MOVED_BY_KEY; reason = InputContext::FOCUS_MOVED_BY_KEY;
} else if (aFlags & nsIFocusManager::FLAG_BYMOVEFOCUS) { } else if (aFlags & nsIFocusManager::FLAG_BYMOVEFOCUS) {
reason = IMEContext::FOCUS_MOVED_BY_MOVEFOCUS; reason = InputContext::FOCUS_MOVED_BY_MOVEFOCUS;
} }
return reason; return reason;
@ -964,7 +965,8 @@ nsFocusManager::WindowHidden(nsIDOMWindow* aWindow)
nsIMEStateManager::OnTextStateBlur(nsnull, nsnull); nsIMEStateManager::OnTextStateBlur(nsnull, nsnull);
if (presShell) { if (presShell) {
nsIMEStateManager::OnChangeFocus(presShell->GetPresContext(), nsnull, IMEContext::FOCUS_REMOVED); nsIMEStateManager::OnChangeFocus(presShell->GetPresContext(), nsnull,
InputContext::FOCUS_REMOVED);
SetCaretVisible(presShell, false, nsnull); SetCaretVisible(presShell, false, nsnull);
} }
@ -1523,8 +1525,10 @@ nsFocusManager::Blur(nsPIDOMWindow* aWindowToClear,
// This has to happen before the focus is cleared below, otherwise, the IME // This has to happen before the focus is cleared below, otherwise, the IME
// compositionend event won't get fired at the element being blurred. // compositionend event won't get fired at the element being blurred.
nsIMEStateManager::OnTextStateBlur(nsnull, nsnull); nsIMEStateManager::OnTextStateBlur(nsnull, nsnull);
if (mActiveWindow) if (mActiveWindow) {
nsIMEStateManager::OnChangeFocus(presShell->GetPresContext(), nsnull, IMEContext::FOCUS_REMOVED); nsIMEStateManager::OnChangeFocus(presShell->GetPresContext(), nsnull,
InputContext::FOCUS_REMOVED);
}
// now adjust the actual focus, by clearing the fields in the focus manager // now adjust the actual focus, by clearing the fields in the focus manager
// and in the window. // and in the window.
@ -1803,7 +1807,8 @@ nsFocusManager::Focus(nsPIDOMWindow* aWindow,
nsIMEStateManager::OnTextStateFocus(presContext, aContent); nsIMEStateManager::OnTextStateFocus(presContext, aContent);
} else { } else {
nsIMEStateManager::OnTextStateBlur(presContext, nsnull); nsIMEStateManager::OnTextStateBlur(presContext, nsnull);
nsIMEStateManager::OnChangeFocus(presContext, nsnull, IMEContext::FOCUS_REMOVED); nsIMEStateManager::OnChangeFocus(presContext, nsnull,
InputContext::FOCUS_REMOVED);
if (!aWindowRaised) { if (!aWindowRaised) {
aWindow->UpdateCommands(NS_LITERAL_STRING("focus")); aWindow->UpdateCommands(NS_LITERAL_STRING("focus"));
} }
@ -1826,7 +1831,8 @@ nsFocusManager::Focus(nsPIDOMWindow* aWindow,
nsPresContext* presContext = presShell->GetPresContext(); nsPresContext* presContext = presShell->GetPresContext();
nsIMEStateManager::OnTextStateBlur(presContext, nsnull); nsIMEStateManager::OnTextStateBlur(presContext, nsnull);
nsIMEStateManager::OnChangeFocus(presContext, nsnull, IMEContext::FOCUS_REMOVED); nsIMEStateManager::OnChangeFocus(presContext, nsnull,
InputContext::FOCUS_REMOVED);
if (!aWindowRaised) if (!aWindowRaised)
aWindow->UpdateCommands(NS_LITERAL_STRING("focus")); aWindow->UpdateCommands(NS_LITERAL_STRING("focus"));

View File

@ -74,6 +74,7 @@
using namespace mozilla::dom; using namespace mozilla::dom;
using namespace mozilla::ipc; using namespace mozilla::ipc;
using namespace mozilla::layout; using namespace mozilla::layout;
using namespace mozilla::widget;
// The flags passed by the webProgress notifications are 16 bits shifted // The flags passed by the webProgress notifications are 16 bits shifted
// from the ones registered by webProgressListeners. // from the ones registered by webProgressListeners.
@ -567,13 +568,13 @@ TabParent::RecvGetIMEEnabled(PRUint32* aValue)
{ {
nsCOMPtr<nsIWidget> widget = GetWidget(); nsCOMPtr<nsIWidget> widget = GetWidget();
if (!widget) { if (!widget) {
*aValue = nsIWidget::IME_STATUS_DISABLED; *aValue = InputContext::IME_DISABLED;
return true; return true;
} }
IMEContext context; InputContext context;
widget->GetInputMode(context); widget->GetInputMode(context);
*aValue = context.mStatus; *aValue = context.mIMEEnabled;
return true; return true;
} }
@ -587,8 +588,8 @@ TabParent::RecvSetInputMode(const PRUint32& aValue, const nsString& aType, const
if (!widget || !AllowContentIME()) if (!widget || !AllowContentIME())
return true; return true;
IMEContext context; InputContext context;
context.mStatus = aValue; context.mIMEEnabled = aValue;
context.mHTMLInputType.Assign(aType); context.mHTMLInputType.Assign(aType);
context.mActionHint.Assign(aAction); context.mActionHint.Assign(aAction);
context.mReason = aReason; context.mReason = aReason;

View File

@ -231,8 +231,51 @@ struct nsIMEUpdatePreference {
* Contains IMEStatus plus information about the current * Contains IMEStatus plus information about the current
* input context that the IME can use as hints if desired. * input context that the IME can use as hints if desired.
*/ */
struct IMEContext {
PRUint32 mStatus; namespace mozilla {
namespace widget {
struct InputContext {
/**
* IME enabled states, the mIMEEnabled value of SetInputMode()/GetInputMode()
* should be one value of following values.
*
* WARNING: If you change these values, you also need to edit:
* nsIDOMWindowUtils.idl
* nsDOMWindowUtils::SetIMEEnabled
* nsContentUtils::GetWidgetStatusFromIMEStatus
*/
enum {
/**
* 'Disabled' means the user cannot use IME. So, the IME open state should
* be 'closed' during 'disabled'.
*/
IME_DISABLED = 0,
/**
* 'Enabled' means the user can use IME.
*/
IME_ENABLED = 1,
/**
* 'Password' state is a special case for the password editors.
* E.g., on mac, the password editors should disable the non-Roman
* keyboard layouts at getting focus. Thus, the password editor may have
* special rules on some platforms.
*/
IME_PASSWORD = 2,
/**
* 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.
*/
IME_PLUGIN = 3,
/**
* IME enabled state mask.
*/
IME_ENABLED_STATE_MASK = 0xF
};
PRUint32 mIMEEnabled;
/* Does the change come from a trusted source */ /* Does the change come from a trusted source */
enum { enum {
@ -264,6 +307,8 @@ struct IMEContext {
nsString mActionHint; nsString mActionHint;
}; };
} // namespace widget
} // namespace mozilla
/** /**
* The base class for all the widgets. It provides the interface for * The base class for all the widgets. It provides the interface for
@ -277,6 +322,7 @@ class nsIWidget : public nsISupports {
typedef mozilla::layers::LayerManager LayerManager; typedef mozilla::layers::LayerManager LayerManager;
typedef LayerManager::LayersBackend LayersBackend; typedef LayerManager::LayersBackend LayersBackend;
typedef mozilla::layers::PLayersChild PLayersChild; typedef mozilla::layers::PLayersChild PLayersChild;
typedef mozilla::widget::InputContext InputContext;
// Used in UpdateThemeGeometries. // Used in UpdateThemeGeometries.
struct ThemeGeometry { struct ThemeGeometry {
@ -1260,41 +1306,6 @@ class nsIWidget : public nsISupports {
*/ */
NS_IMETHOD GetIMEOpenState(bool* aState) = 0; NS_IMETHOD GetIMEOpenState(bool* aState) = 0;
/*
* IME enabled states, the aState value of SetIMEEnabled/GetIMEEnabled
* should be one value of following values.
*
* WARNING: If you change these values, you also need to edit:
* nsIDOMWindowUtils.idl
* nsDOMWindowUtils::SetIMEEnabled
* nsContentUtils::GetWidgetStatusFromIMEStatus
*/
enum IMEStatus {
/*
* 'Disabled' means the user cannot use IME. So, the open state should be
* 'closed' during 'disabled'.
*/
IME_STATUS_DISABLED = 0,
/*
* 'Enabled' means the user can use IME.
*/
IME_STATUS_ENABLED = 1,
/*
* 'Password' state is a special case for the password editors.
* E.g., on mac, the password editors should disable the non-Roman
* keyboard layouts at getting focus. Thus, the password editor may have
* special rules on some platforms.
*/
IME_STATUS_PASSWORD = 2,
/*
* 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.
*/
IME_STATUS_PLUGIN = 3
};
/* /*
* Destruct and don't commit the IME composition string. * Destruct and don't commit the IME composition string.
*/ */
@ -1304,14 +1315,15 @@ class nsIWidget : public nsISupports {
* Notifies the IME if the input context changes. * Notifies the IME if the input context changes.
* *
* aContext cannot be null. * aContext cannot be null.
* Set mStatus to 'Enabled' or 'Disabled' or 'Password'. * Set mIMEEnabled to 'Enabled' or 'Disabled' or 'Password' or 'Plugin'.
*/ */
NS_IMETHOD SetInputMode(const IMEContext& aContext) = 0; NS_IMETHOD SetInputMode(const InputContext& aContext) = 0;
/* /*
* Get IME is 'Enabled' or 'Disabled' or 'Password' and other input context * Get IME is 'Enabled' or 'Disabled' or 'Password' or 'Plugin' and
* other input context
*/ */
NS_IMETHOD GetInputMode(IMEContext& aContext) = 0; NS_IMETHOD GetInputMode(InputContext& aContext) = 0;
/** /**
* Set accelerated rendering to 'True' or 'False' * Set accelerated rendering to 'True' or 'False'

View File

@ -84,6 +84,7 @@ using mozilla::unused;
#define TILE_HEIGHT 2048 #define TILE_HEIGHT 2048
using namespace mozilla; using namespace mozilla;
using namespace mozilla::widget;
NS_IMPL_ISUPPORTS_INHERITED0(nsWindow, nsBaseWidget) NS_IMPL_ISUPPORTS_INHERITED0(nsWindow, nsBaseWidget)
@ -2046,16 +2047,17 @@ nsWindow::ResetInputState()
} }
NS_IMETHODIMP NS_IMETHODIMP
nsWindow::SetInputMode(const IMEContext& aContext) nsWindow::SetInputMode(const InputContext& aContext)
{ {
ALOGIME("IME: SetInputMode: s=%d trusted=%d", aContext.mStatus, aContext.mReason); ALOGIME("IME: SetInputMode: s=%d trusted=%d",
aContext.mIMEEnabled, aContext.mReason);
mIMEContext = aContext; mInputContext = aContext;
// Ensure that opening the virtual keyboard is allowed for this specific // Ensure that opening the virtual keyboard is allowed for this specific
// IMEContext depending on the content.ime.strict.policy pref // InputContext depending on the content.ime.strict.policy pref
if (aContext.mStatus != nsIWidget::IME_STATUS_DISABLED && if (aContext.mIMEEnabled != InputContext::IME_DISABLED &&
aContext.mStatus != nsIWidget::IME_STATUS_PLUGIN) { aContext.mIMEEnabled != InputContext::IME_PLUGIN) {
if (Preferences::GetBool("content.ime.strict_policy", false) && if (Preferences::GetBool("content.ime.strict_policy", false) &&
!aContext.FocusMovedByUser() && !aContext.FocusMovedByUser() &&
aContext.FocusMovedInContentProcess()) { aContext.FocusMovedInContentProcess()) {
@ -2063,14 +2065,16 @@ nsWindow::SetInputMode(const IMEContext& aContext)
} }
} }
AndroidBridge::NotifyIMEEnabled(int(aContext.mStatus), aContext.mHTMLInputType, aContext.mActionHint); AndroidBridge::NotifyIMEEnabled(int(aContext.mIMEEnabled),
aContext.mHTMLInputType,
aContext.mActionHint);
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsWindow::GetInputMode(IMEContext& aContext) nsWindow::GetInputMode(InputContext& aContext)
{ {
aContext = mIMEContext; aContext = mInputContext;
return NS_OK; return NS_OK;
} }

View File

@ -155,8 +155,8 @@ public:
NS_IMETHOD BeginResizeDrag(nsGUIEvent* aEvent, PRInt32 aHorizontal, PRInt32 aVertical) { return NS_ERROR_NOT_IMPLEMENTED; } NS_IMETHOD BeginResizeDrag(nsGUIEvent* aEvent, PRInt32 aHorizontal, PRInt32 aVertical) { return NS_ERROR_NOT_IMPLEMENTED; }
NS_IMETHOD ResetInputState(); NS_IMETHOD ResetInputState();
NS_IMETHOD SetInputMode(const IMEContext& aContext); NS_IMETHOD SetInputMode(const InputContext& aContext);
NS_IMETHOD GetInputMode(IMEContext& aContext); NS_IMETHOD GetInputMode(InputContext& aContext);
NS_IMETHOD CancelIMEComposition(); NS_IMETHOD CancelIMEComposition();
NS_IMETHOD OnIMEFocusChange(bool aFocus); NS_IMETHOD OnIMEFocusChange(bool aFocus);
@ -211,7 +211,7 @@ protected:
nsString mIMELastDispatchedComposingText; nsString mIMELastDispatchedComposingText;
nsAutoTArray<nsTextRange, 4> mIMERanges; nsAutoTArray<nsTextRange, 4> mIMERanges;
IMEContext mIMEContext; InputContext mInputContext;
static void DumpWindows(); static void DumpWindows();
static void DumpWindows(const nsTArray<nsWindow*>& wins, int indent = 0); static void DumpWindows(const nsTArray<nsWindow*>& wins, int indent = 0);

View File

@ -448,8 +448,8 @@ public:
NS_IMETHOD ResetInputState(); NS_IMETHOD ResetInputState();
NS_IMETHOD SetIMEOpenState(bool aState); NS_IMETHOD SetIMEOpenState(bool aState);
NS_IMETHOD GetIMEOpenState(bool* aState); NS_IMETHOD GetIMEOpenState(bool* aState);
NS_IMETHOD SetInputMode(const IMEContext& aContext); NS_IMETHOD SetInputMode(const InputContext& aContext);
NS_IMETHOD GetInputMode(IMEContext& aContext); NS_IMETHOD GetInputMode(InputContext& aContext);
NS_IMETHOD CancelIMEComposition(); NS_IMETHOD CancelIMEComposition();
NS_IMETHOD GetToggledKeyState(PRUint32 aKeyCode, NS_IMETHOD GetToggledKeyState(PRUint32 aKeyCode,
bool* aLEDState); bool* aLEDState);
@ -543,7 +543,7 @@ protected:
NSView<mozView>* mView; // my parallel cocoa view (ChildView or NativeScrollbarView), [STRONG] NSView<mozView>* mView; // my parallel cocoa view (ChildView or NativeScrollbarView), [STRONG]
nsRefPtr<mozilla::widget::TextInputHandler> mTextInputHandler; nsRefPtr<mozilla::widget::TextInputHandler> mTextInputHandler;
IMEContext mIMEContext; InputContext mInputContext;
NSView<mozView>* mParentView; NSView<mozView>* mParentView;
nsIWidget* mParentWidget; nsIWidget* mParentWidget;

View File

@ -1689,21 +1689,21 @@ NS_IMETHODIMP nsChildView::GetIMEOpenState(bool* aState)
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsChildView::SetInputMode(const IMEContext& aContext) NS_IMETHODIMP nsChildView::SetInputMode(const InputContext& aContext)
{ {
NS_ENSURE_TRUE(mTextInputHandler, NS_ERROR_NOT_AVAILABLE); NS_ENSURE_TRUE(mTextInputHandler, NS_ERROR_NOT_AVAILABLE);
mIMEContext = aContext; mInputContext = aContext;
switch (aContext.mStatus) { switch (aContext.mIMEEnabled) {
case nsIWidget::IME_STATUS_ENABLED: case InputContext::IME_ENABLED:
case nsIWidget::IME_STATUS_PLUGIN: case InputContext::IME_PLUGIN:
mTextInputHandler->SetASCIICapableOnly(false); mTextInputHandler->SetASCIICapableOnly(false);
mTextInputHandler->EnableIME(true); mTextInputHandler->EnableIME(true);
break; break;
case nsIWidget::IME_STATUS_DISABLED: case InputContext::IME_DISABLED:
mTextInputHandler->SetASCIICapableOnly(false); mTextInputHandler->SetASCIICapableOnly(false);
mTextInputHandler->EnableIME(false); mTextInputHandler->EnableIME(false);
break; break;
case nsIWidget::IME_STATUS_PASSWORD: case InputContext::IME_PASSWORD:
mTextInputHandler->SetASCIICapableOnly(true); mTextInputHandler->SetASCIICapableOnly(true);
mTextInputHandler->EnableIME(false); mTextInputHandler->EnableIME(false);
break; break;
@ -1713,9 +1713,9 @@ NS_IMETHODIMP nsChildView::SetInputMode(const IMEContext& aContext)
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsChildView::GetInputMode(IMEContext& aContext) NS_IMETHODIMP nsChildView::GetInputMode(InputContext& aContext)
{ {
aContext = mIMEContext; aContext = mInputContext;
return NS_OK; return NS_OK;
} }

View File

@ -58,6 +58,7 @@
#endif #endif
using namespace mozilla; using namespace mozilla;
using namespace mozilla::widget;
#ifdef PR_LOGGING #ifdef PR_LOGGING
PRLogModuleInfo* gGtkIMLog = nsnull; PRLogModuleInfo* gGtkIMLog = nsnull;
@ -85,13 +86,13 @@ static const char*
GetEnabledStateName(PRUint32 aState) GetEnabledStateName(PRUint32 aState)
{ {
switch (aState) { switch (aState) {
case nsIWidget::IME_STATUS_DISABLED: case InputContext::IME_DISABLED:
return "DISABLED"; return "DISABLED";
case nsIWidget::IME_STATUS_ENABLED: case InputContext::IME_ENABLED:
return "ENABLED"; return "ENABLED";
case nsIWidget::IME_STATUS_PASSWORD: case InputContext::IME_PASSWORD:
return "PASSWORD"; return "PASSWORD";
case nsIWidget::IME_STATUS_PLUGIN: case InputContext::IME_PLUGIN:
return "PLUG_IN"; return "PLUG_IN";
default: default:
return "UNKNOWN ENABLED STATUS!!"; return "UNKNOWN ENABLED STATUS!!";
@ -121,7 +122,7 @@ nsGtkIMModule::nsGtkIMModule(nsWindow* aOwnerWindow) :
gGtkIMLog = PR_NewLogModule("nsGtkIMModuleWidgets"); gGtkIMLog = PR_NewLogModule("nsGtkIMModuleWidgets");
} }
#endif #endif
mIMEContext.mStatus = nsIWidget::IME_STATUS_ENABLED; mInputContext.mIMEEnabled = InputContext::IME_ENABLED;
Init(); Init();
} }
@ -257,7 +258,7 @@ nsGtkIMModule::OnDestroyWindow(nsWindow* aWindow)
mOwnerWindow = nsnull; mOwnerWindow = nsnull;
mLastFocusedWindow = nsnull; mLastFocusedWindow = nsnull;
mIMEContext.mStatus = nsIWidget::IME_STATUS_DISABLED; mInputContext.mIMEEnabled = InputContext::IME_DISABLED;
PR_LOG(gGtkIMLog, PR_LOG_ALWAYS, PR_LOG(gGtkIMLog, PR_LOG_ALWAYS,
(" SUCCEEDED, Completely destroyed")); (" SUCCEEDED, Completely destroyed"));
@ -542,15 +543,16 @@ nsGtkIMModule::CancelIMEComposition(nsWindow* aCaller)
} }
nsresult nsresult
nsGtkIMModule::SetInputMode(nsWindow* aCaller, const IMEContext* aContext) nsGtkIMModule::SetInputMode(nsWindow* aCaller, const InputContext* aContext)
{ {
if (aContext->mStatus == mIMEContext.mStatus || NS_UNLIKELY(IsDestroyed())) { if (aContext->mIMEEnabled == mInputContext.mIMEEnabled ||
NS_UNLIKELY(IsDestroyed())) {
return NS_OK; return NS_OK;
} }
PR_LOG(gGtkIMLog, PR_LOG_ALWAYS, PR_LOG(gGtkIMLog, PR_LOG_ALWAYS,
("GtkIMModule(%p): SetInputMode, aCaller=%p, aState=%s mHTMLInputType=%s", ("GtkIMModule(%p): SetInputMode, aCaller=%p, aState=%s mHTMLInputType=%s",
this, aCaller, GetEnabledStateName(aContext->mStatus), this, aCaller, GetEnabledStateName(aContext->mIMEEnabled),
NS_ConvertUTF16toUTF8(aContext->mHTMLInputType).get())); NS_ConvertUTF16toUTF8(aContext->mHTMLInputType).get()));
if (aCaller != mLastFocusedWindow) { if (aCaller != mLastFocusedWindow) {
@ -568,7 +570,7 @@ nsGtkIMModule::SetInputMode(nsWindow* aCaller, const IMEContext* aContext)
if (sLastFocusedModule != this) { if (sLastFocusedModule != this) {
mIMEContext = *aContext; mInputContext = *aContext;
PR_LOG(gGtkIMLog, PR_LOG_ALWAYS, PR_LOG(gGtkIMLog, PR_LOG_ALWAYS,
(" SUCCEEDED, but we're not active")); (" SUCCEEDED, but we're not active"));
return NS_OK; return NS_OK;
@ -580,7 +582,7 @@ nsGtkIMModule::SetInputMode(nsWindow* aCaller, const IMEContext* aContext)
Blur(); Blur();
} }
mIMEContext = *aContext; mInputContext = *aContext;
// Even when aState is not enabled state, we need to set IME focus. // Even when aState is not enabled state, we need to set IME focus.
// Because some IMs are updating the status bar of them at this time. // Because some IMs are updating the status bar of them at this time.
@ -593,14 +595,14 @@ nsGtkIMModule::SetInputMode(nsWindow* aCaller, const IMEContext* aContext)
if (im) { if (im) {
if (IsEnabled()) { if (IsEnabled()) {
// Ensure that opening the virtual keyboard is allowed for this specific // Ensure that opening the virtual keyboard is allowed for this specific
// IMEContext depending on the content.ime.strict.policy pref // InputContext depending on the content.ime.strict.policy pref
if (mIMEContext.mStatus != nsIWidget::IME_STATUS_DISABLED && if (mInputContext.mIMEEnabled != InputContext::IME_DISABLED &&
mIMEContext.mStatus != nsIWidget::IME_STATUS_PLUGIN) { mInputContext.mIMEEnabled != InputContext::IME_PLUGIN) {
bool useStrictPolicy = bool useStrictPolicy =
Preferences::GetBool("content.ime.strict_policy", false); Preferences::GetBool("content.ime.strict_policy", false);
if (useStrictPolicy && !mIMEContext.FocusMovedByUser() && if (useStrictPolicy && !mInputContext.FocusMovedByUser() &&
mIMEContext.FocusMovedInContentProcess()) { mInputContext.FocusMovedInContentProcess()) {
return NS_OK; return NS_OK;
} }
} }
@ -611,10 +613,10 @@ nsGtkIMModule::SetInputMode(nsWindow* aCaller, const IMEContext* aContext)
int mode; int mode;
g_object_get(im, "hildon-input-mode", &mode, NULL); g_object_get(im, "hildon-input-mode", &mode, NULL);
if (mIMEContext.mStatus == nsIWidget::IME_STATUS_ENABLED || if (mInputContext.mIMEEnabled == InputContext::IME_ENABLED ||
mIMEContext.mStatus == nsIWidget::IME_STATUS_PLUGIN) { mInputContext.mIMEEnabled == InputContext::IME_PLUGIN) {
mode &= ~HILDON_GTK_INPUT_MODE_INVISIBLE; mode &= ~HILDON_GTK_INPUT_MODE_INVISIBLE;
} else if (mIMEContext.mStatus == nsIWidget::IME_STATUS_PASSWORD) { } else if (mInputContext.mIMEEnabled == InputContext::IME_PASSWORD) {
mode |= HILDON_GTK_INPUT_MODE_INVISIBLE; mode |= HILDON_GTK_INPUT_MODE_INVISIBLE;
} }
@ -659,10 +661,10 @@ nsGtkIMModule::SetInputMode(nsWindow* aCaller, const IMEContext* aContext)
} }
nsresult nsresult
nsGtkIMModule::GetInputMode(IMEContext* aContext) nsGtkIMModule::GetInputMode(InputContext* aContext)
{ {
NS_ENSURE_ARG_POINTER(aContext); NS_ENSURE_ARG_POINTER(aContext);
*aContext = mIMEContext; *aContext = mInputContext;
return NS_OK; return NS_OK;
} }
@ -685,7 +687,7 @@ nsGtkIMModule::GetContext()
} }
#ifndef NS_IME_ENABLED_ON_PASSWORD_FIELD #ifndef NS_IME_ENABLED_ON_PASSWORD_FIELD
if (mIMEContext.mStatus == nsIWidget::IME_STATUS_PASSWORD) { if (mInputContext.mIMEEnabled == InputContext::IME_PASSWORD) {
return mSimpleContext; return mSimpleContext;
} }
#endif // NS_IME_ENABLED_ON_PASSWORD_FIELD #endif // NS_IME_ENABLED_ON_PASSWORD_FIELD
@ -696,19 +698,19 @@ nsGtkIMModule::GetContext()
bool bool
nsGtkIMModule::IsEnabled() nsGtkIMModule::IsEnabled()
{ {
return mIMEContext.mStatus == nsIWidget::IME_STATUS_ENABLED || return mInputContext.mIMEEnabled == InputContext::IME_ENABLED ||
#ifdef NS_IME_ENABLED_ON_PASSWORD_FIELD #ifdef NS_IME_ENABLED_ON_PASSWORD_FIELD
mIMEContext.mStatus == nsIWidget::IME_STATUS_PASSWORD || mInputContext.mIMEEnabled == InputContext::IME_PASSWORD ||
#endif // NS_IME_ENABLED_ON_PASSWORD_FIELD #endif // NS_IME_ENABLED_ON_PASSWORD_FIELD
mIMEContext.mStatus == nsIWidget::IME_STATUS_PLUGIN; mInputContext.mIMEEnabled == InputContext::IME_PLUGIN;
} }
bool bool
nsGtkIMModule::IsEditable() nsGtkIMModule::IsEditable()
{ {
return mIMEContext.mStatus == nsIWidget::IME_STATUS_ENABLED || return mInputContext.mIMEEnabled == InputContext::IME_ENABLED ||
mIMEContext.mStatus == nsIWidget::IME_STATUS_PLUGIN || mInputContext.mIMEEnabled == InputContext::IME_PLUGIN ||
mIMEContext.mStatus == nsIWidget::IME_STATUS_PASSWORD; mInputContext.mIMEEnabled == InputContext::IME_PASSWORD;
} }
void void

View File

@ -47,6 +47,7 @@
#include "nsAutoPtr.h" #include "nsAutoPtr.h"
#include "nsTArray.h" #include "nsTArray.h"
#include "nsGUIEvent.h" #include "nsGUIEvent.h"
#include "nsIWidget.h"
// If software keyboard is needed in password field and uses GTK2 IM module // If software keyboard is needed in password field and uses GTK2 IM module
// for inputting characters, we need to enable IME in password field too. // for inputting characters, we need to enable IME in password field too.
@ -58,6 +59,9 @@ class nsWindow;
class nsGtkIMModule class nsGtkIMModule
{ {
protected:
typedef mozilla::widget::InputContext InputContext;
public: public:
nsrefcnt AddRef() nsrefcnt AddRef()
{ {
@ -112,8 +116,9 @@ public:
// IME related nsIWidget methods. // IME related nsIWidget methods.
nsresult ResetInputState(nsWindow* aCaller); nsresult ResetInputState(nsWindow* aCaller);
nsresult SetInputMode(nsWindow* aCaller, const IMEContext* aContext); nsresult SetInputMode(nsWindow* aCaller,
nsresult GetInputMode(IMEContext* aContext); const InputContext* aContext);
nsresult GetInputMode(InputContext* aContext);
nsresult CancelIMEComposition(nsWindow* aCaller); nsresult CancelIMEComposition(nsWindow* aCaller);
// If a software keyboard has been opened, this returns TRUE. // If a software keyboard has been opened, this returns TRUE.
@ -148,9 +153,9 @@ protected:
// always "closed", so it closes IME forcedly. // always "closed", so it closes IME forcedly.
GtkIMContext *mDummyContext; GtkIMContext *mDummyContext;
// IME enabled state and other things defined in IMEContext. // IME enabled state and other things defined in InputContext.
// Use following helper methods if you don't need the detail of the status. // Use following helper methods if you don't need the detail of the status.
IMEContext mIMEContext; InputContext mInputContext;
// mCompositionStart is the start offset of the composition string in the // mCompositionStart is the start offset of the composition string in the
// current content. When <textarea> or <input> have focus, it means offset // current content. When <textarea> or <input> have focus, it means offset

View File

@ -115,6 +115,7 @@
#include "stdlib.h" #include "stdlib.h"
using namespace mozilla; using namespace mozilla;
using namespace mozilla::widget;
static bool sAccessibilityChecked = false; static bool sAccessibilityChecked = false;
/* static */ /* static */
@ -6576,16 +6577,16 @@ nsWindow::ResetInputState()
} }
NS_IMETHODIMP NS_IMETHODIMP
nsWindow::SetInputMode(const IMEContext& aContext) nsWindow::SetInputMode(const InputContext& aContext)
{ {
return mIMModule ? mIMModule->SetInputMode(this, &aContext) : NS_OK; return mIMModule ? mIMModule->SetInputMode(this, &aContext) : NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsWindow::GetInputMode(IMEContext& aContext) nsWindow::GetInputMode(InputContext& aContext)
{ {
if (!mIMModule) { if (!mIMModule) {
aContext.mStatus = nsIWidget::IME_STATUS_DISABLED; aContext.mIMEEnabled = InputContext::IME_DISABLED;
return NS_OK; return NS_OK;
} }
return mIMModule->GetInputMode(&aContext); return mIMModule->GetInputMode(&aContext);

View File

@ -320,8 +320,8 @@ public:
bool *aIsCancelled); bool *aIsCancelled);
NS_IMETHOD ResetInputState(); NS_IMETHOD ResetInputState();
NS_IMETHOD SetInputMode(const IMEContext& aContext); NS_IMETHOD SetInputMode(const InputContext& aContext);
NS_IMETHOD GetInputMode(IMEContext& aContext); NS_IMETHOD GetInputMode(InputContext& aContext);
NS_IMETHOD CancelIMEComposition(); NS_IMETHOD CancelIMEComposition();
NS_IMETHOD OnIMEFocusChange(bool aFocus); NS_IMETHOD OnIMEFocusChange(bool aFocus);
NS_IMETHOD GetToggledKeyState(PRUint32 aKeyCode, bool* aLEDState); NS_IMETHOD GetToggledKeyState(PRUint32 aKeyCode, bool* aLEDState);

View File

@ -154,6 +154,7 @@ extern "C" {
} }
using namespace mozilla; using namespace mozilla;
using namespace mozilla::widget;
// imported in nsWidgetFactory.cpp // imported in nsWidgetFactory.cpp
bool gDisableNativeTheme = false; bool gDisableNativeTheme = false;
@ -3215,22 +3216,24 @@ x11EventFilter(void* message, long* result)
#endif #endif
NS_IMETHODIMP NS_IMETHODIMP
nsWindow::SetInputMode(const IMEContext& aContext) nsWindow::SetInputMode(const InputContext& aContext)
{ {
NS_ENSURE_TRUE(mWidget, NS_ERROR_FAILURE); NS_ENSURE_TRUE(mWidget, NS_ERROR_FAILURE);
// SetSoftwareKeyboardState uses mIMEContext, // SetSoftwareKeyboardState uses mInputContext,
// so, before calling that, record aContext in mIMEContext. // so, before calling that, record aContext in mInputContext.
mIMEContext = aContext; mInputContext = aContext;
#if defined(MOZ_X11) && (MOZ_PLATFORM_MAEMO == 6) #if defined(MOZ_X11) && (MOZ_PLATFORM_MAEMO == 6)
if (sPluginIMEAtom) { if (sPluginIMEAtom) {
static QCoreApplication::EventFilter currentEventFilter = NULL; static QCoreApplication::EventFilter currentEventFilter = NULL;
if (mIMEContext.mStatus == nsIWidget::IME_STATUS_PLUGIN && currentEventFilter != x11EventFilter) { if (mInputContext.mIMEEnabled == InputContext::IME_PLUGIN &&
currentEventFilter != x11EventFilter) {
// Install event filter for listening Plugin IME state changes // Install event filter for listening Plugin IME state changes
previousEventFilter = QCoreApplication::instance()->setEventFilter(x11EventFilter); previousEventFilter = QCoreApplication::instance()->setEventFilter(x11EventFilter);
currentEventFilter = x11EventFilter; currentEventFilter = x11EventFilter;
} else if (mIMEContext.mStatus != nsIWidget::IME_STATUS_PLUGIN && currentEventFilter == x11EventFilter) { } else if (mInputContext.mIMEEnabled != InputContext::IME_PLUGIN &&
currentEventFilter == x11EventFilter) {
// Remove event filter // Remove event filter
QCoreApplication::instance()->setEventFilter(previousEventFilter); QCoreApplication::instance()->setEventFilter(previousEventFilter);
currentEventFilter = previousEventFilter; currentEventFilter = previousEventFilter;
@ -3243,10 +3246,10 @@ nsWindow::SetInputMode(const IMEContext& aContext)
} }
#endif #endif
switch (mIMEContext.mStatus) { switch (mInputContext.mIMEEnabled) {
case nsIWidget::IME_STATUS_ENABLED: case InputContext::IME_ENABLED:
case nsIWidget::IME_STATUS_PASSWORD: case InputContext::IME_PASSWORD:
case nsIWidget::IME_STATUS_PLUGIN: case InputContext::IME_PLUGIN:
SetSoftwareKeyboardState(true); SetSoftwareKeyboardState(true);
break; break;
default: default:
@ -3258,9 +3261,9 @@ nsWindow::SetInputMode(const IMEContext& aContext)
} }
NS_IMETHODIMP NS_IMETHODIMP
nsWindow::GetInputMode(IMEContext& aContext) nsWindow::GetInputMode(InputContext& aContext)
{ {
aContext = mIMEContext; aContext = mInputContext;
return NS_OK; return NS_OK;
} }
@ -3268,14 +3271,15 @@ void
nsWindow::SetSoftwareKeyboardState(bool aOpen) nsWindow::SetSoftwareKeyboardState(bool aOpen)
{ {
if (aOpen) { if (aOpen) {
NS_ENSURE_TRUE(mIMEContext.mStatus != nsIWidget::IME_STATUS_DISABLED,); NS_ENSURE_TRUE(mInputContext.mIMEEnabled !=
InputContext::IME_DISABLED, );
// Ensure that opening the virtual keyboard is allowed for this specific // Ensure that opening the virtual keyboard is allowed for this specific
// IMEContext depending on the content.ime.strict.policy pref // InputContext depending on the content.ime.strict.policy pref
if (mIMEContext.mStatus != nsIWidget::IME_STATUS_PLUGIN) { if (mInputContext.mIMEEnabled != InputContext::IME_PLUGIN) {
if (Preferences::GetBool("content.ime.strict_policy", false) && if (Preferences::GetBool("content.ime.strict_policy", false) &&
!mIMEContext.FocusMovedByUser() && !mInputContext.FocusMovedByUser() &&
mIMEContext.FocusMovedInContentProcess()) { mInputContext.FocusMovedInContentProcess()) {
return; return;
} }
} }

View File

@ -194,8 +194,8 @@ public:
NS_IMETHOD GetAttention(PRInt32 aCycleCount); NS_IMETHOD GetAttention(PRInt32 aCycleCount);
NS_IMETHOD BeginResizeDrag (nsGUIEvent* aEvent, PRInt32 aHorizontal, PRInt32 aVertical); NS_IMETHOD BeginResizeDrag (nsGUIEvent* aEvent, PRInt32 aHorizontal, PRInt32 aVertical);
NS_IMETHODIMP SetInputMode(const IMEContext& aContext); NS_IMETHODIMP SetInputMode(const InputContext& aContext);
NS_IMETHODIMP GetInputMode(IMEContext& aContext); NS_IMETHODIMP GetInputMode(InputContext& aContext);
// //
// utility methods // utility methods
@ -250,7 +250,7 @@ protected:
// leaving fullscreen // leaving fullscreen
nsSizeMode mLastSizeMode; nsSizeMode mLastSizeMode;
IMEContext mIMEContext; InputContext mInputContext;
/** /**
* Event handlers (proxied from the actual qwidget). * Event handlers (proxied from the actual qwidget).

View File

@ -46,6 +46,7 @@
#include "mozilla/Preferences.h" #include "mozilla/Preferences.h"
using namespace mozilla; using namespace mozilla;
using namespace mozilla::widget;
/******************************************************************/ /******************************************************************/
/* nsTextStore */ /* nsTextStore */
@ -1637,7 +1638,7 @@ nsTextStore::SetInputModeInternal(PRUint32 aState)
VARIANT variant; VARIANT variant;
variant.vt = VT_I4; variant.vt = VT_I4;
variant.lVal = aState != nsIWidget::IME_STATUS_ENABLED; variant.lVal = aState != InputContext::IME_ENABLED;
// Set two contexts, the base context (mContext) and the top // Set two contexts, the base context (mContext) and the top
// if the top context is not the same as the base context // if the top context is not the same as the base context

View File

@ -110,6 +110,9 @@ public: /*ITfContextOwnerCompositionSink*/
STDMETHODIMP OnUpdateComposition(ITfCompositionView*, ITfRange*); STDMETHODIMP OnUpdateComposition(ITfCompositionView*, ITfRange*);
STDMETHODIMP OnEndComposition(ITfCompositionView*); STDMETHODIMP OnEndComposition(ITfCompositionView*);
protected:
typedef mozilla::widget::InputContext InputContext;
public: public:
static void Initialize(void); static void Initialize(void);
static void Terminate(void); static void Terminate(void);
@ -122,10 +125,10 @@ public:
sTsfTextStore->CommitCompositionInternal(aDiscard); sTsfTextStore->CommitCompositionInternal(aDiscard);
} }
static void SetInputMode(const IMEContext& aContext) static void SetInputMode(const InputContext& aContext)
{ {
if (!sTsfTextStore) return; if (!sTsfTextStore) return;
sTsfTextStore->SetInputModeInternal(aContext.mStatus); sTsfTextStore->SetInputModeInternal(aContext.mIMEEnabled);
} }
static nsresult OnFocusChange(bool, nsWindow*, PRUint32); static nsresult OnFocusChange(bool, nsWindow*, PRUint32);

View File

@ -406,7 +406,7 @@ nsWindow::nsWindow() : nsBaseWidget()
mLastKeyboardLayout = 0; mLastKeyboardLayout = 0;
mAssumeWheelIsZoomUntil = 0; mAssumeWheelIsZoomUntil = 0;
mBlurSuppressLevel = 0; mBlurSuppressLevel = 0;
mIMEContext.mStatus = nsIWidget::IME_STATUS_ENABLED; mInputContext.mIMEEnabled = InputContext::IME_ENABLED;
#ifdef MOZ_XUL #ifdef MOZ_XUL
mTransparentSurface = nsnull; mTransparentSurface = nsnull;
mMemoryDC = nsnull; mMemoryDC = nsnull;
@ -8065,36 +8065,37 @@ NS_IMETHODIMP nsWindow::GetIMEOpenState(bool* aState)
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsWindow::SetInputMode(const IMEContext& aContext) NS_IMETHODIMP nsWindow::SetInputMode(const InputContext& aContext)
{ {
PRUint32 status = aContext.mStatus; PRUint32 status = aContext.mIMEEnabled;
#ifdef NS_ENABLE_TSF #ifdef NS_ENABLE_TSF
nsTextStore::SetInputMode(aContext); nsTextStore::SetInputMode(aContext);
#endif //NS_ENABLE_TSF #endif //NS_ENABLE_TSF
#ifdef DEBUG_KBSTATE #ifdef DEBUG_KBSTATE
PR_LOG(gWindowsLog, PR_LOG_ALWAYS, PR_LOG(gWindowsLog, PR_LOG_ALWAYS,
("SetInputMode: %s\n", (status == nsIWidget::IME_STATUS_ENABLED || ("SetInputMode: %s\n", (status == InputContext::IME_ENABLED ||
status == nsIWidget::IME_STATUS_PLUGIN) ? status == InputContext::IME_PLUGIN) ?
"Enabled" : "Disabled")); "Enabled" : "Disabled"));
#endif #endif
if (nsIMM32Handler::IsComposing()) { if (nsIMM32Handler::IsComposing()) {
ResetInputState(); ResetInputState();
} }
mIMEContext = aContext; mInputContext = aContext;
bool enable = (status == nsIWidget::IME_STATUS_ENABLED || bool enable = (status == InputContext::IME_ENABLED ||
status == nsIWidget::IME_STATUS_PLUGIN); status == InputContext::IME_PLUGIN);
AssociateDefaultIMC(enable); AssociateDefaultIMC(enable);
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsWindow::GetInputMode(IMEContext& aContext) NS_IMETHODIMP nsWindow::GetInputMode(InputContext& aContext)
{ {
#ifdef DEBUG_KBSTATE #ifdef DEBUG_KBSTATE
PR_LOG(gWindowsLog, PR_LOG_ALWAYS, PR_LOG(gWindowsLog, PR_LOG_ALWAYS,
("GetInputMode: %s\n", mIMEContext.mStatus ? "Enabled" : "Disabled"); ("GetInputMode: %s\n", mInputContext.mIMEEnabled ?
"Enabled" : "Disabled");
#endif #endif
aContext = mIMEContext; aContext = mInputContext;
return NS_OK; return NS_OK;
} }
@ -8127,7 +8128,8 @@ nsWindow::GetToggledKeyState(PRUint32 aKeyCode, bool* aLEDState)
NS_IMETHODIMP NS_IMETHODIMP
nsWindow::OnIMEFocusChange(bool aFocus) nsWindow::OnIMEFocusChange(bool aFocus)
{ {
nsresult rv = nsTextStore::OnFocusChange(aFocus, this, mIMEContext.mStatus); nsresult rv = nsTextStore::OnFocusChange(aFocus, this,
mInputContext.mIMEEnabled);
if (rv == NS_ERROR_NOT_AVAILABLE) if (rv == NS_ERROR_NOT_AVAILABLE)
rv = NS_ERROR_NOT_IMPLEMENTED; // TSF is not enabled, maybe. rv = NS_ERROR_NOT_IMPLEMENTED; // TSF is not enabled, maybe.
return rv; return rv;

View File

@ -181,8 +181,8 @@ public:
NS_IMETHOD ResetInputState(); NS_IMETHOD ResetInputState();
NS_IMETHOD SetIMEOpenState(bool aState); NS_IMETHOD SetIMEOpenState(bool aState);
NS_IMETHOD GetIMEOpenState(bool* aState); NS_IMETHOD GetIMEOpenState(bool* aState);
NS_IMETHOD SetInputMode(const IMEContext& aContext); NS_IMETHOD SetInputMode(const InputContext& aContext);
NS_IMETHOD GetInputMode(IMEContext& aContext); NS_IMETHOD GetInputMode(InputContext& aContext);
NS_IMETHOD CancelIMEComposition(); NS_IMETHOD CancelIMEComposition();
NS_IMETHOD GetToggledKeyState(PRUint32 aKeyCode, bool* aLEDState); NS_IMETHOD GetToggledKeyState(PRUint32 aKeyCode, bool* aLEDState);
NS_IMETHOD RegisterTouchWindow(); NS_IMETHOD RegisterTouchWindow();
@ -262,7 +262,10 @@ public:
virtual bool AutoErase(HDC dc); virtual bool AutoErase(HDC dc);
nsIntPoint* GetLastPoint() { return &mLastPoint; } nsIntPoint* GetLastPoint() { return &mLastPoint; }
// needed in nsIMM32Handler.cpp // needed in nsIMM32Handler.cpp
bool PluginHasFocus() { return mIMEContext.mStatus == nsIWidget::IME_STATUS_PLUGIN; } bool PluginHasFocus()
{
return mInputContext.mIMEEnabled == InputContext::IME_PLUGIN;
}
bool IsTopLevelWidget() { return mIsTopWidgetWindow; } bool IsTopLevelWidget() { return mIsTopWidgetWindow; }
/** /**
* Start allowing Direct3D9 to be used by widgets when GetLayerManager is * Start allowing Direct3D9 to be used by widgets when GetLayerManager is
@ -533,7 +536,7 @@ protected:
PRUint32 mBlurSuppressLevel; PRUint32 mBlurSuppressLevel;
DWORD_PTR mOldStyle; DWORD_PTR mOldStyle;
DWORD_PTR mOldExStyle; DWORD_PTR mOldExStyle;
IMEContext mIMEContext; InputContext mInputContext;
nsNativeDragTarget* mNativeDragTarget; nsNativeDragTarget* mNativeDragTarget;
HKL mLastKeyboardLayout; HKL mLastKeyboardLayout;
nsPopupType mPopupType; nsPopupType mPopupType;

View File

@ -409,10 +409,11 @@ PuppetWidget::SetIMEOpenState(bool aState)
} }
NS_IMETHODIMP NS_IMETHODIMP
PuppetWidget::SetInputMode(const IMEContext& aContext) PuppetWidget::SetInputMode(const InputContext& aContext)
{ {
if (mTabChild && if (mTabChild &&
mTabChild->SendSetInputMode(aContext.mStatus, aContext.mHTMLInputType, mTabChild->SendSetInputMode(aContext.mIMEEnabled,
aContext.mHTMLInputType,
aContext.mActionHint, aContext.mReason)) aContext.mActionHint, aContext.mReason))
return NS_OK; return NS_OK;
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
@ -428,10 +429,10 @@ PuppetWidget::GetIMEOpenState(bool *aState)
} }
NS_IMETHODIMP NS_IMETHODIMP
PuppetWidget::GetInputMode(IMEContext& aContext) PuppetWidget::GetInputMode(InputContext& aContext)
{ {
if (mTabChild && if (mTabChild &&
mTabChild->SendGetIMEEnabled(&aContext.mStatus)) mTabChild->SendGetIMEEnabled(&aContext.mIMEEnabled))
return NS_OK; return NS_OK;
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }

View File

@ -170,8 +170,8 @@ public:
NS_IMETHOD ResetInputState(); NS_IMETHOD ResetInputState();
NS_IMETHOD SetIMEOpenState(bool aState); NS_IMETHOD SetIMEOpenState(bool aState);
NS_IMETHOD GetIMEOpenState(bool *aState); NS_IMETHOD GetIMEOpenState(bool *aState);
NS_IMETHOD SetInputMode(const IMEContext& aContext); NS_IMETHOD SetInputMode(const InputContext& aContext);
NS_IMETHOD GetInputMode(IMEContext& aContext); NS_IMETHOD GetInputMode(InputContext& aContext);
NS_IMETHOD CancelComposition(); NS_IMETHOD CancelComposition();
NS_IMETHOD OnIMEFocusChange(bool aFocus); NS_IMETHOD OnIMEFocusChange(bool aFocus);
NS_IMETHOD OnIMETextChange(PRUint32 aOffset, PRUint32 aEnd, NS_IMETHOD OnIMETextChange(PRUint32 aOffset, PRUint32 aEnd,

View File

@ -144,8 +144,8 @@ public:
NS_IMETHOD ResetInputState() { return NS_OK; } NS_IMETHOD ResetInputState() { return NS_OK; }
NS_IMETHOD SetIMEOpenState(bool aState) { return NS_ERROR_NOT_IMPLEMENTED; } NS_IMETHOD SetIMEOpenState(bool aState) { return NS_ERROR_NOT_IMPLEMENTED; }
NS_IMETHOD GetIMEOpenState(bool* aState) { return NS_ERROR_NOT_IMPLEMENTED; } NS_IMETHOD GetIMEOpenState(bool* aState) { return NS_ERROR_NOT_IMPLEMENTED; }
NS_IMETHOD SetInputMode(const IMEContext& aContext) { return NS_ERROR_NOT_IMPLEMENTED; } NS_IMETHOD SetInputMode(const InputContext& aContext) { return NS_ERROR_NOT_IMPLEMENTED; }
NS_IMETHOD GetInputMode(IMEContext& aContext) { return NS_ERROR_NOT_IMPLEMENTED; } NS_IMETHOD GetInputMode(InputContext& aContext) { return NS_ERROR_NOT_IMPLEMENTED; }
NS_IMETHOD CancelIMEComposition() { return NS_OK; } NS_IMETHOD CancelIMEComposition() { return NS_OK; }
NS_IMETHOD SetAcceleratedRendering(bool aEnabled); NS_IMETHOD SetAcceleratedRendering(bool aEnabled);
virtual bool GetAcceleratedRendering(); virtual bool GetAcceleratedRendering();