Bug 685395 part.4 IME open state should be able to set/get by InputContext r=roc, sr=matspal

This commit is contained in:
Masayuki Nakano
2011-11-27 20:51:53 +09:00
parent c7b04c3d79
commit d3338a0721
22 changed files with 264 additions and 293 deletions

View File

@@ -1290,11 +1290,6 @@ public:
static void TraceWrapper(nsWrapperCache* aCache, TraceCallback aCallback, static void TraceWrapper(nsWrapperCache* aCache, TraceCallback aCallback,
void *aClosure); void *aClosure);
/**
* Convert nsIContent::IME_STATUS_* to nsIWidget::IME_STATUS_*
*/
static PRUint32 GetWidgetStatusFromIMEStatus(PRUint32 aState);
/* /*
* Notify when the first XUL menu is opened and when the all XUL menus are * Notify when the first XUL menu is opened and when the all XUL menus are
* closed. At opening, aInstalling should be TRUE, otherwise, it should be * closed. At opening, aInstalling should be TRUE, otherwise, it should be

View File

@@ -4027,25 +4027,6 @@ nsContentUtils::DropJSObjects(void* aScriptObjectHolder)
return rv; return rv;
} }
/* static */
PRUint32
nsContentUtils::GetWidgetStatusFromIMEStatus(PRUint32 aState)
{
switch (aState & nsIContent::IME_STATUS_MASK_ENABLED) {
case nsIContent::IME_STATUS_DISABLE:
return InputContext::IME_DISABLED;
case nsIContent::IME_STATUS_ENABLE:
return InputContext::IME_ENABLED;
case nsIContent::IME_STATUS_PASSWORD:
return InputContext::IME_PASSWORD;
case nsIContent::IME_STATUS_PLUGIN:
return InputContext::IME_PLUGIN;
default:
NS_ERROR("The given state doesn't have valid enable state");
return InputContext::IME_ENABLED;
}
}
/* static */ /* static */
void void
nsContentUtils::NotifyInstalledMenuKeyboardListener(bool aInstalling) nsContentUtils::NotifyInstalledMenuKeyboardListener(bool aInstalling)

View File

@@ -69,6 +69,26 @@
using namespace mozilla::widget; using namespace mozilla::widget;
static
/* static */
IMEState::Enabled
GetWidgetStatusFromIMEStatus(PRUint32 aState)
{
switch (aState & nsIContent::IME_STATUS_MASK_ENABLED) {
case nsIContent::IME_STATUS_DISABLE:
return IMEState::DISABLED;
case nsIContent::IME_STATUS_ENABLE:
return IMEState::ENABLED;
case nsIContent::IME_STATUS_PASSWORD:
return IMEState::PASSWORD;
case nsIContent::IME_STATUS_PLUGIN:
return IMEState::PLUGIN;
default:
NS_ERROR("The given state doesn't have valid enable state");
return IMEState::ENABLED;
}
}
/******************************************************************/ /******************************************************************/
/* nsIMEStateManager */ /* nsIMEStateManager */
/******************************************************************/ /******************************************************************/
@@ -181,8 +201,8 @@ nsIMEStateManager::OnChangeFocusInternal(nsPresContext* aPresContext,
return NS_OK; return NS_OK;
} }
InputContext context = widget->GetInputContext(); InputContext context = widget->GetInputContext();
if (context.mIMEEnabled == if (context.mIMEState.mEnabled ==
nsContentUtils::GetWidgetStatusFromIMEStatus(newEnabledState)) { GetWidgetStatusFromIMEStatus(newEnabledState)) {
// the enabled state isn't changing. // the enabled state isn't changing.
return NS_OK; return NS_OK;
} }
@@ -245,8 +265,8 @@ 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.
InputContext context = widget->GetInputContext(); InputContext context = widget->GetInputContext();
PRUint32 newEnabledState = aNewIMEState & nsIContent::IME_STATUS_MASK_ENABLED; PRUint32 newEnabledState = aNewIMEState & nsIContent::IME_STATUS_MASK_ENABLED;
if (context.mIMEEnabled == if (context.mIMEState.mEnabled ==
nsContentUtils::GetWidgetStatusFromIMEStatus(newEnabledState)) { GetWidgetStatusFromIMEStatus(newEnabledState)) {
return; return;
} }
@@ -311,13 +331,10 @@ nsIMEStateManager::SetIMEState(PRUint32 aState,
nsIWidget* aWidget, nsIWidget* aWidget,
InputContextAction aAction) InputContextAction aAction)
{ {
if (aState & nsIContent::IME_STATUS_MASK_ENABLED) { NS_ENSURE_TRUE(aWidget, );
if (!aWidget)
return;
PRUint32 state = nsContentUtils::GetWidgetStatusFromIMEStatus(aState);
InputContext context; InputContext context;
context.mIMEEnabled = state; context.mIMEState.mEnabled = GetWidgetStatusFromIMEStatus(aState);
if (aContent && aContent->GetNameSpaceID() == kNameSpaceID_XHTML && if (aContent && aContent->GetNameSpaceID() == kNameSpaceID_XHTML &&
(aContent->Tag() == nsGkAtoms::input || (aContent->Tag() == nsGkAtoms::input ||
@@ -359,13 +376,15 @@ nsIMEStateManager::SetIMEState(PRUint32 aState,
aAction.mCause = InputContextAction::CAUSE_UNKNOWN_CHROME; aAction.mCause = InputContextAction::CAUSE_UNKNOWN_CHROME;
} }
aWidget->SetInputContext(context, aAction);
nsContentUtils::AddScriptRunner(new IMEEnabledStateChangedEvent(state));
}
if (aState & nsIContent::IME_STATUS_MASK_OPENED) { if (aState & nsIContent::IME_STATUS_MASK_OPENED) {
bool open = !!(aState & nsIContent::IME_STATUS_OPEN); bool open = !!(aState & nsIContent::IME_STATUS_OPEN);
aWidget->SetIMEOpenState(open); context.mIMEState.mOpen = open ? IMEState::OPEN : IMEState::CLOSED;
}
aWidget->SetInputContext(context, aAction);
if (aState & nsIContent::IME_STATUS_MASK_ENABLED) {
nsContentUtils::AddScriptRunner(
new IMEEnabledStateChangedEvent(context.mIMEState.mEnabled));
} }
} }

View File

@@ -55,6 +55,7 @@ class nsISelection;
class nsIMEStateManager class nsIMEStateManager
{ {
protected: protected:
typedef mozilla::widget::IMEState IMEState;
typedef mozilla::widget::InputContext InputContext; typedef mozilla::widget::InputContext InputContext;
typedef mozilla::widget::InputContextAction InputContextAction; typedef mozilla::widget::InputContextAction InputContextAction;

View File

@@ -1041,11 +1041,15 @@ nsDOMWindowUtils::GetIMEIsOpen(bool *aState)
// Open state should not be available when IME is not enabled. // Open state should not be available when IME is not enabled.
InputContext context = widget->GetInputContext(); InputContext context = widget->GetInputContext();
if (context.mIMEEnabled != InputContext::IME_ENABLED) { if (context.mIMEState.mEnabled != IMEState::ENABLED) {
return NS_ERROR_NOT_AVAILABLE; return NS_ERROR_NOT_AVAILABLE;
} }
return widget->GetIMEOpenState(aState); if (context.mIMEState.mOpen == IMEState::OPEN_STATE_NOT_SUPPORTED) {
return NS_ERROR_NOT_IMPLEMENTED;
}
*aState = (context.mIMEState.mOpen == IMEState::OPEN);
return NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP
@@ -1058,7 +1062,7 @@ nsDOMWindowUtils::GetIMEStatus(PRUint32 *aState)
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
InputContext context = widget->GetInputContext(); InputContext context = widget->GetInputContext();
*aState = context.mIMEEnabled; *aState = static_cast<PRUint32>(context.mIMEState.mEnabled);
return NS_OK; return NS_OK;
} }

View File

@@ -172,18 +172,15 @@ parent:
*/ */
sync EndIMEComposition(bool cancel) returns (nsString composition); sync EndIMEComposition(bool cancel) returns (nsString composition);
sync GetInputContext() returns (PRUint32 value); sync GetInputContext() returns (PRInt32 IMEEnabled, PRInt32 IMEOpen);
SetInputContext(PRUint32 value, SetInputContext(PRInt32 IMEEnabled,
PRInt32 IMEOpen,
nsString type, nsString type,
nsString actionHint, nsString actionHint,
PRInt32 cause, PRInt32 cause,
PRInt32 focusChange); PRInt32 focusChange);
sync GetIMEOpenState() returns (bool value);
SetIMEOpenState(bool value);
/** /**
* Gets the DPI of the screen corresponding to this browser. * Gets the DPI of the screen corresponding to this browser.
*/ */

View File

@@ -564,35 +564,42 @@ TabParent::RecvEndIMEComposition(const bool& aCancel,
} }
bool bool
TabParent::RecvGetInputContext(PRUint32* aValue) TabParent::RecvGetInputContext(PRInt32* aIMEEnabled,
PRInt32* aIMEOpen)
{ {
nsCOMPtr<nsIWidget> widget = GetWidget(); nsCOMPtr<nsIWidget> widget = GetWidget();
if (!widget) { if (!widget) {
*aValue = InputContext::IME_DISABLED; *aIMEEnabled = IMEState::DISABLED;
*aIMEOpen = IMEState::OPEN_STATE_NOT_SUPPORTED;
return true; return true;
} }
InputContext context = widget->GetInputContext(); InputContext context = widget->GetInputContext();
*aValue = context.mIMEEnabled; *aIMEEnabled = static_cast<PRInt32>(context.mIMEState.mEnabled);
*aIMEOpen = static_cast<PRInt32>(context.mIMEState.mOpen);
return true; return true;
} }
bool bool
TabParent::RecvSetInputContext(const PRUint32& aValue, TabParent::RecvSetInputContext(const PRInt32& aIMEEnabled,
const PRInt32& aIMEOpen,
const nsString& aType, const nsString& aType,
const nsString& aActionHint, const nsString& aActionHint,
const PRInt32& aCause, const PRInt32& aCause,
const PRInt32& aFocusChange) const PRInt32& aFocusChange)
{ {
// mIMETabParent (which is actually static) tracks which if any TabParent has IMEFocus // mIMETabParent (which is actually static) tracks which if any TabParent has IMEFocus
// When the input mode is set to anything but IME_STATUS_NONE, mIMETabParent should be set to this // When the input mode is set to anything but IMEState::DISABLED,
mIMETabParent = aValue & nsIContent::IME_STATUS_MASK_ENABLED ? this : nsnull; // mIMETabParent should be set to this
mIMETabParent =
aIMEEnabled != static_cast<PRInt32>(IMEState::DISABLED) ? this : nsnull;
nsCOMPtr<nsIWidget> widget = GetWidget(); nsCOMPtr<nsIWidget> widget = GetWidget();
if (!widget || !AllowContentIME()) if (!widget || !AllowContentIME())
return true; return true;
InputContext context; InputContext context;
context.mIMEEnabled = aValue; context.mIMEState.mEnabled = static_cast<IMEState::Enabled>(aIMEEnabled);
context.mIMEState.mOpen = static_cast<IMEState::Open>(aIMEOpen);
context.mHTMLInputType.Assign(aType); context.mHTMLInputType.Assign(aType);
context.mActionHint.Assign(aActionHint); context.mActionHint.Assign(aActionHint);
InputContextAction action( InputContextAction action(
@@ -605,30 +612,12 @@ TabParent::RecvSetInputContext(const PRUint32& aValue,
return true; return true;
nsAutoString state; nsAutoString state;
state.AppendInt(aValue); state.AppendInt(aIMEEnabled);
observerService->NotifyObservers(nsnull, "ime-enabled-state-changed", state.get()); observerService->NotifyObservers(nsnull, "ime-enabled-state-changed", state.get());
return true; return true;
} }
bool
TabParent::RecvGetIMEOpenState(bool* aValue)
{
nsCOMPtr<nsIWidget> widget = GetWidget();
if (widget)
widget->GetIMEOpenState(aValue);
return true;
}
bool
TabParent::RecvSetIMEOpenState(const bool& aValue)
{
nsCOMPtr<nsIWidget> widget = GetWidget();
if (widget && AllowContentIME())
widget->SetIMEOpenState(aValue);
return true;
}
bool bool
TabParent::RecvGetDPI(float* aValue) TabParent::RecvGetDPI(float* aValue)
{ {

View File

@@ -103,14 +103,14 @@ public:
virtual bool RecvNotifyIMETextHint(const nsString& aText); virtual bool RecvNotifyIMETextHint(const nsString& aText);
virtual bool RecvEndIMEComposition(const bool& aCancel, virtual bool RecvEndIMEComposition(const bool& aCancel,
nsString* aComposition); nsString* aComposition);
virtual bool RecvGetInputContext(PRUint32* aValue); virtual bool RecvGetInputContext(PRInt32* aIMEEnabled,
virtual bool RecvSetInputContext(const PRUint32& aValue, PRInt32* aIMEOpen);
virtual bool RecvSetInputContext(const PRInt32& aIMEEnabled,
const PRInt32& aIMEOpen,
const nsString& aType, const nsString& aType,
const nsString& aActionHint, const nsString& aActionHint,
const PRInt32& aCause, const PRInt32& aCause,
const PRInt32& aFocusChange); const PRInt32& aFocusChange);
virtual bool RecvGetIMEOpenState(bool* aValue);
virtual bool RecvSetIMEOpenState(const bool& aValue);
virtual bool RecvSetCursor(const PRUint32& aValue); virtual bool RecvSetCursor(const PRUint32& aValue);
virtual bool RecvSetBackgroundColor(const nscolor& aValue); virtual bool RecvSetBackgroundColor(const nscolor& aValue);
virtual bool RecvGetDPI(float* aValue); virtual bool RecvGetDPI(float* aValue);

View File

@@ -118,9 +118,8 @@ typedef nsEventStatus (* EVENT_CALLBACK)(nsGUIEvent *event);
#endif #endif
#define NS_IWIDGET_IID \ #define NS_IWIDGET_IID \
{ 0xb4fa00ae, 0x913c, 0x42b1, \ { 0x34460b01, 0x3dc2, 0x4b58, \
{ 0x93, 0xc8, 0x41, 0x57, 0x1e, 0x3d, 0x94, 0x99 } } { 0x8e, 0xd3, 0x7e, 0x7c, 0x33, 0xb5, 0x78, 0x8b } }
/* /*
* Window shadow styles * Window shadow styles
* Also used for the -moz-window-shadow CSS property * Also used for the -moz-window-shadow CSS property
@@ -235,9 +234,9 @@ struct nsIMEUpdatePreference {
namespace mozilla { namespace mozilla {
namespace widget { namespace widget {
struct InputContext { struct IMEState {
/** /**
* IME enabled states, the mIMEEnabled value of * IME enabled states, the mEnabled value of
* SetInputContext()/GetInputContext() should be one value of following * SetInputContext()/GetInputContext() should be one value of following
* values. * values.
* *
@@ -245,45 +244,77 @@ struct InputContext {
* nsIDOMWindowUtils.idl * nsIDOMWindowUtils.idl
* nsContentUtils::GetWidgetStatusFromIMEStatus * nsContentUtils::GetWidgetStatusFromIMEStatus
*/ */
enum { enum Enabled {
/** /**
* 'Disabled' means the user cannot use IME. So, the IME open state should * 'Disabled' means the user cannot use IME. So, the IME open state should
* be 'closed' during 'disabled'. * be 'closed' during 'disabled'.
*/ */
IME_DISABLED = 0, DISABLED,
/** /**
* 'Enabled' means the user can use IME. * 'Enabled' means the user can use IME.
*/ */
IME_ENABLED = 1, ENABLED,
/** /**
* 'Password' state is a special case for the password editors. * 'Password' state is a special case for the password editors.
* E.g., on mac, the password editors should disable the non-Roman * E.g., on mac, the password editors should disable the non-Roman
* keyboard layouts at getting focus. Thus, the password editor may have * keyboard layouts at getting focus. Thus, the password editor may have
* special rules on some platforms. * special rules on some platforms.
*/ */
IME_PASSWORD = 2, PASSWORD,
/** /**
* This state is used when a plugin is focused. * This state is used when a plugin is focused.
* When a plug-in is focused content, we should send native events * When a plug-in is focused content, we should send native events
* directly. Because we don't process some native events, but they may * directly. Because we don't process some native events, but they may
* be needed by the plug-in. * be needed by the plug-in.
*/ */
IME_PLUGIN = 3, PLUGIN
/**
* IME enabled state mask.
*/
IME_ENABLED_STATE_MASK = 0xF
}; };
Enabled mEnabled;
PRUint32 mIMEEnabled; /**
* IME open states the mOpen value of SetInputContext() should be one value of
* OPEN, CLOSE or DONT_CHANGE_OPEN_STATE. GetInputContext() should return
* OPEN, CLOSE or OPEN_STATE_NOT_SUPPORTED.
*/
enum Open {
/**
* 'Unsupported' means the platform cannot return actual IME open state.
* This value is used only by GetInputContext().
*/
OPEN_STATE_NOT_SUPPORTED,
/**
* 'Don't change' means the widget shouldn't change IME open state when
* SetInputContext() is called.
*/
DONT_CHANGE_OPEN_STATE = OPEN_STATE_NOT_SUPPORTED,
/**
* 'Open' means that IME should compose in its primary language (or latest
* input mode except direct ASCII character input mode). Even if IME is
* opened by this value, users should be able to close IME by theirselves.
* Web contents can specify this value by |ime-mode: active;|.
*/
OPEN,
/**
* 'Closed' means that IME shouldn't handle key events (or should handle
* as ASCII character inputs on mobile device). Even if IME is closed by
* this value, users should be able to open IME by theirselves.
* Web contents can specify this value by |ime-mode: inactive;|.
*/
CLOSED
};
Open mOpen;
IMEState() : mEnabled(ENABLED), mOpen(DONT_CHANGE_OPEN_STATE) { }
};
struct InputContext {
IMEState mIMEState;
/* The type of the input if the input is a html input field */ /* The type of the input if the input is a html input field */
nsString mHTMLInputType; nsString mHTMLInputType;
/* A hint for the action that is performed when the input is submitted */ /* A hint for the action that is performed when the input is submitted */
nsString mActionHint; nsString mActionHint;
InputContext() : mIMEEnabled(IME_ENABLED) {}
}; };
struct InputContextAction { struct InputContextAction {
@@ -355,6 +386,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::IMEState IMEState;
typedef mozilla::widget::InputContext InputContext; typedef mozilla::widget::InputContext InputContext;
typedef mozilla::widget::InputContextAction InputContextAction; typedef mozilla::widget::InputContextAction InputContextAction;
@@ -1326,20 +1358,6 @@ class nsIWidget : public nsISupports {
* http://bugzilla.mozilla.org/show_bug.cgi?id=16940#c48 * http://bugzilla.mozilla.org/show_bug.cgi?id=16940#c48
*/ */
/*
* Set the state to 'Opened' or 'Closed'.
* If aState is TRUE, IME open state is set to 'Opened'.
* If aState is FALSE, set to 'Closed'.
*/
NS_IMETHOD SetIMEOpenState(bool aState) = 0;
/*
* Get IME is 'Opened' or 'Closed'.
* If IME is 'Opened', aState is set true.
* If IME is 'Closed', aState is set false.
*/
NS_IMETHOD GetIMEOpenState(bool* aState) = 0;
/* /*
* Destruct and don't commit the IME composition string. * Destruct and don't commit the IME composition string.
*/ */

View File

@@ -2050,21 +2050,22 @@ NS_IMETHODIMP_(void)
nsWindow::SetInputContext(const InputContext& aContext, nsWindow::SetInputContext(const InputContext& aContext,
const InputContextAction& aAction) const InputContextAction& aAction)
{ {
ALOGIME("IME: SetInputContext: s=%d action=0x%X, 0x%X", ALOGIME("IME: SetInputContext: s=0x%X, 0x%X, action=0x%X, 0x%X",
aContext.mIMEEnabled, aAction.mCause, aAction.mFocusChange); aContext.mIMEState.mEnabled, aContext.mIMEState.mOpen,
aAction.mCause, aAction.mFocusChange);
mInputContext = 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
// InputContext depending on the content.ime.strict.policy pref // InputContext depending on the content.ime.strict.policy pref
if (aContext.mIMEEnabled != InputContext::IME_DISABLED && if (aContext.mIMEState.mEnabled != IMEState::DISABLED &&
aContext.mIMEEnabled != InputContext::IME_PLUGIN && aContext.mIMEState.mEnabled != IMEState::PLUGIN &&
Preferences::GetBool("content.ime.strict_policy", false) && Preferences::GetBool("content.ime.strict_policy", false) &&
!aAction.ContentGotFocusByTrustedCause()) { !aAction.ContentGotFocusByTrustedCause()) {
return; return;
} }
AndroidBridge::NotifyIMEEnabled(int(aContext.mIMEEnabled), AndroidBridge::NotifyIMEEnabled(int(aContext.mIMEState.mEnabled),
aContext.mHTMLInputType, aContext.mHTMLInputType,
aContext.mActionHint); aContext.mActionHint);
} }
@@ -2072,6 +2073,7 @@ nsWindow::SetInputContext(const InputContext& aContext,
NS_IMETHODIMP_(InputContext) NS_IMETHODIMP_(InputContext)
nsWindow::GetInputContext() nsWindow::GetInputContext()
{ {
mInputContext.mIMEState.mOpen = IMEState::OPEN_STATE_NOT_SUPPORTED;
return mInputContext; return mInputContext;
} }

View File

@@ -446,8 +446,6 @@ public:
NS_IMETHOD ForceUpdateNativeMenuAt(const nsAString& indexString); NS_IMETHOD ForceUpdateNativeMenuAt(const nsAString& indexString);
NS_IMETHOD ResetInputState(); NS_IMETHOD ResetInputState();
NS_IMETHOD SetIMEOpenState(bool aState);
NS_IMETHOD GetIMEOpenState(bool* aState);
NS_IMETHOD_(void) SetInputContext(const InputContext& aContext, NS_IMETHOD_(void) SetInputContext(const InputContext& aContext,
const InputContextAction& aAction); const InputContextAction& aAction);
NS_IMETHOD_(InputContext) GetInputContext(); NS_IMETHOD_(InputContext) GetInputContext();

View File

@@ -1673,39 +1673,27 @@ NS_IMETHODIMP nsChildView::ResetInputState()
return NS_OK; return NS_OK;
} }
// 'open' means that it can take non-ASCII chars
NS_IMETHODIMP nsChildView::SetIMEOpenState(bool aState)
{
NS_ENSURE_TRUE(mTextInputHandler, NS_ERROR_NOT_AVAILABLE);
mTextInputHandler->SetIMEOpenState(aState);
return NS_OK;
}
// 'open' means that it can take non-ASCII chars
NS_IMETHODIMP nsChildView::GetIMEOpenState(bool* aState)
{
NS_ENSURE_TRUE(mTextInputHandler, NS_ERROR_NOT_AVAILABLE);
*aState = mTextInputHandler->IsIMEOpened();
return NS_OK;
}
NS_IMETHODIMP_(void) NS_IMETHODIMP_(void)
nsChildView::SetInputContext(const InputContext& aContext, nsChildView::SetInputContext(const InputContext& aContext,
const InputContextAction& aAction) const InputContextAction& aAction)
{ {
NS_ENSURE_TRUE(mTextInputHandler, ); NS_ENSURE_TRUE(mTextInputHandler, );
mInputContext = aContext; mInputContext = aContext;
switch (aContext.mIMEEnabled) { switch (aContext.mIMEState.mEnabled) {
case InputContext::IME_ENABLED: case IMEState::ENABLED:
case InputContext::IME_PLUGIN: case IMEState::PLUGIN:
mTextInputHandler->SetASCIICapableOnly(false); mTextInputHandler->SetASCIICapableOnly(false);
mTextInputHandler->EnableIME(true); mTextInputHandler->EnableIME(true);
if (mInputContext.mIMEState.mOpen != IMEState::DONT_CHANGE_OPEN_STATE) {
mTextInputHandler->SetIMEOpenState(
mInputContext.mIMEState.mOpen == IMEState::OPEN);
}
break; break;
case InputContext::IME_DISABLED: case IMEState::DISABLED:
mTextInputHandler->SetASCIICapableOnly(false); mTextInputHandler->SetASCIICapableOnly(false);
mTextInputHandler->EnableIME(false); mTextInputHandler->EnableIME(false);
break; break;
case InputContext::IME_PASSWORD: case IMEState::PASSWORD:
mTextInputHandler->SetASCIICapableOnly(true); mTextInputHandler->SetASCIICapableOnly(true);
mTextInputHandler->EnableIME(false); mTextInputHandler->EnableIME(false);
break; break;
@@ -1717,6 +1705,19 @@ nsChildView::SetInputContext(const InputContext& aContext,
NS_IMETHODIMP_(InputContext) NS_IMETHODIMP_(InputContext)
nsChildView::GetInputContext() nsChildView::GetInputContext()
{ {
switch (mInputContext.mIMEState.mEnabled) {
case IMEState::ENABLED:
case IMEState::PLUGIN:
if (mTextInputHandler) {
mInputContext.mIMEState.mOpen =
mTextInputHandler->IsIMEOpened() ? IMEState::OPEN : IMEState::CLOSED;
break;
}
// If mTextInputHandler is null, set CLOSED instead...
default:
mInputContext.mIMEState.mOpen = IMEState::CLOSED;
break;
}
return mInputContext; return mInputContext;
} }

View File

@@ -86,13 +86,13 @@ static const char*
GetEnabledStateName(PRUint32 aState) GetEnabledStateName(PRUint32 aState)
{ {
switch (aState) { switch (aState) {
case InputContext::IME_DISABLED: case IMEState::DISABLED:
return "DISABLED"; return "DISABLED";
case InputContext::IME_ENABLED: case IMEState::ENABLED:
return "ENABLED"; return "ENABLED";
case InputContext::IME_PASSWORD: case IMEState::PASSWORD:
return "PASSWORD"; return "PASSWORD";
case InputContext::IME_PLUGIN: case IMEState::PLUGIN:
return "PLUG_IN"; return "PLUG_IN";
default: default:
return "UNKNOWN ENABLED STATUS!!"; return "UNKNOWN ENABLED STATUS!!";
@@ -122,7 +122,6 @@ nsGtkIMModule::nsGtkIMModule(nsWindow* aOwnerWindow) :
gGtkIMLog = PR_NewLogModule("nsGtkIMModuleWidgets"); gGtkIMLog = PR_NewLogModule("nsGtkIMModuleWidgets");
} }
#endif #endif
mInputContext.mIMEEnabled = InputContext::IME_ENABLED;
Init(); Init();
} }
@@ -258,7 +257,7 @@ nsGtkIMModule::OnDestroyWindow(nsWindow* aWindow)
mOwnerWindow = nsnull; mOwnerWindow = nsnull;
mLastFocusedWindow = nsnull; mLastFocusedWindow = nsnull;
mInputContext.mIMEEnabled = InputContext::IME_DISABLED; mInputContext.mIMEState.mEnabled = IMEState::DISABLED;
PR_LOG(gGtkIMLog, PR_LOG_ALWAYS, PR_LOG(gGtkIMLog, PR_LOG_ALWAYS,
(" SUCCEEDED, Completely destroyed")); (" SUCCEEDED, Completely destroyed"));
@@ -547,14 +546,14 @@ nsGtkIMModule::SetInputContext(nsWindow* aCaller,
const InputContext* aContext, const InputContext* aContext,
const InputContextAction* aAction) const InputContextAction* aAction)
{ {
if (aContext->mIMEEnabled == mInputContext.mIMEEnabled || if (aContext->mIMEState.mEnabled == mInputContext.mIMEState.mEnabled ||
NS_UNLIKELY(IsDestroyed())) { NS_UNLIKELY(IsDestroyed())) {
return; return;
} }
PR_LOG(gGtkIMLog, PR_LOG_ALWAYS, PR_LOG(gGtkIMLog, PR_LOG_ALWAYS,
("GtkIMModule(%p): SetInputContext, aCaller=%p, aState=%s mHTMLInputType=%s", ("GtkIMModule(%p): SetInputContext, aCaller=%p, aState=%s mHTMLInputType=%s",
this, aCaller, GetEnabledStateName(aContext->mIMEEnabled), this, aCaller, GetEnabledStateName(aContext->mIMEState.mEnabled),
NS_ConvertUTF16toUTF8(aContext->mHTMLInputType).get())); NS_ConvertUTF16toUTF8(aContext->mHTMLInputType).get()));
if (aCaller != mLastFocusedWindow) { if (aCaller != mLastFocusedWindow) {
@@ -598,8 +597,8 @@ nsGtkIMModule::SetInputContext(nsWindow* aCaller,
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
// InputContext depending on the content.ime.strict.policy pref // InputContext depending on the content.ime.strict.policy pref
if (mInputContext.mIMEEnabled != InputContext::IME_DISABLED && if (mInputContext.mIMEState.mEnabled != IMEState::DISABLED &&
mInputContext.mIMEEnabled != InputContext::IME_PLUGIN && mInputContext.mIMEState.mEnabled != IMEState::PLUGIN &&
Preferences::GetBool("content.ime.strict_policy", false) && Preferences::GetBool("content.ime.strict_policy", false) &&
!aAction->ContentGotFocusByTrustedCause()) { !aAction->ContentGotFocusByTrustedCause()) {
return; return;
@@ -611,10 +610,10 @@ nsGtkIMModule::SetInputContext(nsWindow* aCaller,
int mode; int mode;
g_object_get(im, "hildon-input-mode", &mode, NULL); g_object_get(im, "hildon-input-mode", &mode, NULL);
if (mInputContext.mIMEEnabled == InputContext::IME_ENABLED || if (mInputContext.mIMEState.mEnabled == IMEState::ENABLED ||
mInputContext.mIMEEnabled == InputContext::IME_PLUGIN) { mInputContext.mIMEState.mEnabled == IMEState::PLUGIN) {
mode &= ~HILDON_GTK_INPUT_MODE_INVISIBLE; mode &= ~HILDON_GTK_INPUT_MODE_INVISIBLE;
} else if (mInputContext.mIMEEnabled == InputContext::IME_PASSWORD) { } else if (mInputContext.mIMEState.mEnabled == IMEState::PASSWORD) {
mode |= HILDON_GTK_INPUT_MODE_INVISIBLE; mode |= HILDON_GTK_INPUT_MODE_INVISIBLE;
} }
@@ -659,6 +658,7 @@ nsGtkIMModule::SetInputContext(nsWindow* aCaller,
InputContext InputContext
nsGtkIMModule::GetInputContext() nsGtkIMModule::GetInputContext()
{ {
mInputContext.mIMEState.mOpen = IMEState::OPEN_STATE_NOT_SUPPORTED;
return mInputContext; return mInputContext;
} }
@@ -681,7 +681,7 @@ nsGtkIMModule::GetContext()
} }
#ifndef NS_IME_ENABLED_ON_PASSWORD_FIELD #ifndef NS_IME_ENABLED_ON_PASSWORD_FIELD
if (mInputContext.mIMEEnabled == InputContext::IME_PASSWORD) { if (mInputContext.mIMEState.mEnabled == IMEState::PASSWORD) {
return mSimpleContext; return mSimpleContext;
} }
#endif // NS_IME_ENABLED_ON_PASSWORD_FIELD #endif // NS_IME_ENABLED_ON_PASSWORD_FIELD
@@ -692,19 +692,19 @@ nsGtkIMModule::GetContext()
bool bool
nsGtkIMModule::IsEnabled() nsGtkIMModule::IsEnabled()
{ {
return mInputContext.mIMEEnabled == InputContext::IME_ENABLED || return mInputContext.mIMEState.mEnabled == IMEState::ENABLED ||
#ifdef NS_IME_ENABLED_ON_PASSWORD_FIELD #ifdef NS_IME_ENABLED_ON_PASSWORD_FIELD
mInputContext.mIMEEnabled == InputContext::IME_PASSWORD || mInputContext.mIMEState.mEnabled == IMEState::PASSWORD ||
#endif // NS_IME_ENABLED_ON_PASSWORD_FIELD #endif // NS_IME_ENABLED_ON_PASSWORD_FIELD
mInputContext.mIMEEnabled == InputContext::IME_PLUGIN; mInputContext.mIMEState.mEnabled == IMEState::PLUGIN;
} }
bool bool
nsGtkIMModule::IsEditable() nsGtkIMModule::IsEditable()
{ {
return mInputContext.mIMEEnabled == InputContext::IME_ENABLED || return mInputContext.mIMEState.mEnabled == IMEState::ENABLED ||
mInputContext.mIMEEnabled == InputContext::IME_PLUGIN || mInputContext.mIMEState.mEnabled == IMEState::PLUGIN ||
mInputContext.mIMEEnabled == InputContext::IME_PASSWORD; mInputContext.mIMEState.mEnabled == IMEState::PASSWORD;
} }
void void

View File

@@ -6591,7 +6591,8 @@ nsWindow::GetInputContext()
{ {
InputContext context; InputContext context;
if (!mIMModule) { if (!mIMModule) {
context.mIMEEnabled = InputContext::IME_DISABLED; context.mIMEState.mEnabled = IMEState::DISABLED;
context.mIMEState.mOpen = IMEState::OPEN_STATE_NOT_SUPPORTED;
} else { } else {
context = mIMModule->GetInputContext(); context = mIMModule->GetInputContext();
} }

View File

@@ -3228,12 +3228,12 @@ nsWindow::SetInputContext(const InputContext& 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 (mInputContext.mIMEEnabled == InputContext::IME_PLUGIN && if (mInputContext.mIMEState.mEnabled == IMEState::PLUGIN &&
currentEventFilter != x11EventFilter) { 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 (mInputContext.mIMEEnabled != InputContext::IME_PLUGIN && } else if (mInputContext.mIMEState.mEnabled != IMEState::PLUGIN &&
currentEventFilter == x11EventFilter) { currentEventFilter == x11EventFilter) {
// Remove event filter // Remove event filter
QCoreApplication::instance()->setEventFilter(previousEventFilter); QCoreApplication::instance()->setEventFilter(previousEventFilter);
@@ -3247,10 +3247,10 @@ nsWindow::SetInputContext(const InputContext& aContext,
} }
#endif #endif
switch (mInputContext.mIMEEnabled) { switch (mInputContext.mIMEState.mEnabled) {
case InputContext::IME_ENABLED: case IMEState::ENABLED:
case InputContext::IME_PASSWORD: case IMEState::PASSWORD:
case InputContext::IME_PLUGIN: case IMEState::PLUGIN:
SetSoftwareKeyboardState(true, aAction); SetSoftwareKeyboardState(true, aAction);
break; break;
default: default:
@@ -3262,6 +3262,7 @@ nsWindow::SetInputContext(const InputContext& aContext,
NS_IMETHODIMP_(InputContext) NS_IMETHODIMP_(InputContext)
nsWindow::GetInputContext() nsWindow::GetInputContext()
{ {
mInputContext.mIMEState.mOpen = IMEState::OPEN_STATE_NOT_SUPPORTED;
return mInputContext; return mInputContext;
} }
@@ -3270,12 +3271,11 @@ nsWindow::SetSoftwareKeyboardState(bool aOpen,
const InputContextAction& aAction) const InputContextAction& aAction)
{ {
if (aOpen) { if (aOpen) {
NS_ENSURE_TRUE(mInputContext.mIMEEnabled != NS_ENSURE_TRUE(mInputContext.mIMEState.mEnabled != IMEState::DISABLED,);
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
// InputContext depending on the content.ime.strict.policy pref // InputContext depending on the content.ime.strict.policy pref
if (mInputContext.mIMEEnabled != InputContext::IME_PLUGIN && if (mInputContext.mIMEState.mEnabled != IMEState::PLUGIN &&
Preferences::GetBool("content.ime.strict_policy", false) && Preferences::GetBool("content.ime.strict_policy", false) &&
!aAction.ContentGotFocusByTrustedCause()) { !aAction.ContentGotFocusByTrustedCause()) {
return; return;

View File

@@ -88,7 +88,7 @@ nsTextStore::~nsTextStore()
bool bool
nsTextStore::Create(nsWindow* aWindow, nsTextStore::Create(nsWindow* aWindow,
PRUint32 aIMEState) IMEState::Enabled aIMEEnabled)
{ {
if (!mDocumentMgr) { if (!mDocumentMgr) {
// Create document manager // Create document manager
@@ -101,7 +101,7 @@ nsTextStore::Create(nsWindow* aWindow,
static_cast<ITextStoreACP*>(this), static_cast<ITextStoreACP*>(this),
getter_AddRefs(mContext), &mEditCookie); getter_AddRefs(mContext), &mEditCookie);
if (SUCCEEDED(hr)) { if (SUCCEEDED(hr)) {
SetInputContextInternal(aIMEState); SetInputContextInternal(aIMEEnabled);
hr = mDocumentMgr->Push(mContext); hr = mDocumentMgr->Push(mContext);
} }
if (SUCCEEDED(hr)) { if (SUCCEEDED(hr)) {
@@ -1478,7 +1478,7 @@ nsTextStore::OnEndComposition(ITfCompositionView* pComposition)
nsresult nsresult
nsTextStore::OnFocusChange(bool aFocus, nsTextStore::OnFocusChange(bool aFocus,
nsWindow* aWindow, nsWindow* aWindow,
PRUint32 aIMEEnabled) IMEState::Enabled aIMEEnabled)
{ {
// no change notifications if TSF is disabled // no change notifications if TSF is disabled
if (!sTsfThreadMgr || !sTsfTextStore) if (!sTsfThreadMgr || !sTsfTextStore)
@@ -1631,14 +1631,14 @@ nsTextStore::GetIMEOpenState(void)
} }
void void
nsTextStore::SetInputContextInternal(PRUint32 aState) nsTextStore::SetInputContextInternal(IMEState::Enabled aState)
{ {
PR_LOG(sTextStoreLog, PR_LOG_ALWAYS, PR_LOG(sTextStoreLog, PR_LOG_ALWAYS,
("TSF: SetInputContext, state=%lu\n", aState)); ("TSF: SetInputContext, state=%ld\n", static_cast<PRInt32>(aState)));
VARIANT variant; VARIANT variant;
variant.vt = VT_I4; variant.vt = VT_I4;
variant.lVal = aState != InputContext::IME_ENABLED; variant.lVal = (aState != IMEState::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

@@ -111,6 +111,7 @@ public: /*ITfContextOwnerCompositionSink*/
STDMETHODIMP OnEndComposition(ITfCompositionView*); STDMETHODIMP OnEndComposition(ITfCompositionView*);
protected: protected:
typedef mozilla::widget::IMEState IMEState;
typedef mozilla::widget::InputContext InputContext; typedef mozilla::widget::InputContext InputContext;
public: public:
@@ -128,10 +129,10 @@ public:
static void SetInputContext(const InputContext& aContext) static void SetInputContext(const InputContext& aContext)
{ {
if (!sTsfTextStore) return; if (!sTsfTextStore) return;
sTsfTextStore->SetInputContextInternal(aContext.mIMEEnabled); sTsfTextStore->SetInputContextInternal(aContext.mIMEState.mEnabled);
} }
static nsresult OnFocusChange(bool, nsWindow*, PRUint32); static nsresult OnFocusChange(bool, nsWindow*, IMEState::Enabled);
static nsresult OnTextChange(PRUint32 aStart, static nsresult OnTextChange(PRUint32 aStart,
PRUint32 aOldEnd, PRUint32 aOldEnd,
@@ -183,7 +184,7 @@ protected:
nsTextStore(); nsTextStore();
~nsTextStore(); ~nsTextStore();
bool Create(nsWindow*, PRUint32); bool Create(nsWindow*, IMEState::Enabled);
bool Destroy(void); bool Destroy(void);
// If aDispatchTextEvent is true, this method will dispatch text event if // If aDispatchTextEvent is true, this method will dispatch text event if
@@ -194,7 +195,7 @@ protected:
bool aDispatchTextEvent = false); bool aDispatchTextEvent = false);
HRESULT OnStartCompositionInternal(ITfCompositionView*, ITfRange*, bool); HRESULT OnStartCompositionInternal(ITfCompositionView*, ITfRange*, bool);
void CommitCompositionInternal(bool); void CommitCompositionInternal(bool);
void SetInputContextInternal(PRUint32 aState); void SetInputContextInternal(IMEState::Enabled aState);
nsresult OnTextChangeInternal(PRUint32, PRUint32, PRUint32); nsresult OnTextChangeInternal(PRUint32, PRUint32, PRUint32);
void OnTextChangeMsgInternal(void); void OnTextChangeMsgInternal(void);
nsresult OnSelectionChangeInternal(void); nsresult OnSelectionChangeInternal(void);

View File

@@ -406,7 +406,6 @@ nsWindow::nsWindow() : nsBaseWidget()
mLastKeyboardLayout = 0; mLastKeyboardLayout = 0;
mAssumeWheelIsZoomUntil = 0; mAssumeWheelIsZoomUntil = 0;
mBlurSuppressLevel = 0; mBlurSuppressLevel = 0;
mInputContext.mIMEEnabled = InputContext::IME_ENABLED;
#ifdef MOZ_XUL #ifdef MOZ_XUL
mTransparentSurface = nsnull; mTransparentSurface = nsnull;
mMemoryDC = nsnull; mMemoryDC = nsnull;
@@ -8031,72 +8030,56 @@ NS_IMETHODIMP nsWindow::ResetInputState()
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsWindow::SetIMEOpenState(bool aState)
{
#ifdef DEBUG_KBSTATE
PR_LOG(gWindowsLog, PR_LOG_ALWAYS,
("SetIMEOpenState %s\n", (aState ? "Open" : "Close")));
#endif
#ifdef NS_ENABLE_TSF
nsTextStore::SetIMEOpenState(aState);
#endif //NS_ENABLE_TSF
nsIMEContext IMEContext(mWnd);
if (IMEContext.IsValid()) {
::ImmSetOpenStatus(IMEContext.get(), aState ? TRUE : FALSE);
}
return NS_OK;
}
NS_IMETHODIMP nsWindow::GetIMEOpenState(bool* aState)
{
nsIMEContext IMEContext(mWnd);
if (IMEContext.IsValid()) {
BOOL isOpen = ::ImmGetOpenStatus(IMEContext.get());
*aState = isOpen ? true : false;
} else
*aState = false;
#ifdef NS_ENABLE_TSF
*aState |= nsTextStore::GetIMEOpenState();
#endif //NS_ENABLE_TSF
return NS_OK;
}
NS_IMETHODIMP_(void) NS_IMETHODIMP_(void)
nsWindow::SetInputContext(const InputContext& aContext, nsWindow::SetInputContext(const InputContext& aContext,
const InputContextAction& aAction) const InputContextAction& aAction)
{ {
PRUint32 status = aContext.mIMEEnabled;
#ifdef NS_ENABLE_TSF #ifdef NS_ENABLE_TSF
nsTextStore::SetInputContext(aContext); nsTextStore::SetInputContext(aContext);
#endif //NS_ENABLE_TSF #endif //NS_ENABLE_TSF
#ifdef DEBUG_KBSTATE
PR_LOG(gWindowsLog, PR_LOG_ALWAYS,
("SetInputMode: %s\n", (status == InputContext::IME_ENABLED ||
status == InputContext::IME_PLUGIN) ?
"Enabled" : "Disabled"));
#endif
if (nsIMM32Handler::IsComposing()) { if (nsIMM32Handler::IsComposing()) {
ResetInputState(); ResetInputState();
} }
mInputContext = aContext; mInputContext = aContext;
bool enable = (status == InputContext::IME_ENABLED || bool enable = (mInputContext.mIMEState.mEnabled == IMEState::ENABLED ||
status == InputContext::IME_PLUGIN); mInputContext.mIMEState.mEnabled == IMEState::PLUGIN);
AssociateDefaultIMC(enable); AssociateDefaultIMC(enable);
if (enable &&
mInputContext.mIMEState.mOpen != IMEState::DONT_CHANGE_OPEN_STATE) {
bool open = (mInputContext.mIMEState.mOpen == IMEState::OPEN);
#ifdef NS_ENABLE_TSF
nsTextStore::SetIMEOpenState(open);
#endif //NS_ENABLE_TSF
nsIMEContext IMEContext(mWnd);
if (IMEContext.IsValid()) {
::ImmSetOpenStatus(IMEContext.get(), open);
}
}
} }
NS_IMETHODIMP_(InputContext) NS_IMETHODIMP_(InputContext)
nsWindow::GetInputContext() nsWindow::GetInputContext()
{ {
#ifdef DEBUG_KBSTATE mInputContext.mIMEState.mOpen = IMEState::CLOSED;
PR_LOG(gWindowsLog, PR_LOG_ALWAYS, switch (mInputContext.mIMEState.mEnabled) {
("GetInputMode: %s\n", mInputContext.mIMEEnabled ? case IMEState::ENABLED:
"Enabled" : "Disabled"); case IMEState::PLUGIN: {
#endif nsIMEContext IMEContext(mWnd);
if (IMEContext.IsValid()) {
mInputContext.mIMEState.mOpen =
::ImmGetOpenStatus(IMEContext.get()) ? IMEState::OPEN :
IMEState::CLOSED;
}
#ifdef NS_ENABLE_TSF
if (mInputContext.mIMEState.mOpen == IMEState::CLOSED &&
nsTextStore::GetIMEOpenState()) {
mInputContext.mIMEState.mOpen = IMEState::OPEN;
}
#endif //NS_ENABLE_TSF
}
}
return mInputContext; return mInputContext;
} }
@@ -8130,7 +8113,7 @@ NS_IMETHODIMP
nsWindow::OnIMEFocusChange(bool aFocus) nsWindow::OnIMEFocusChange(bool aFocus)
{ {
nsresult rv = nsTextStore::OnFocusChange(aFocus, this, nsresult rv = nsTextStore::OnFocusChange(aFocus, this,
mInputContext.mIMEEnabled); mInputContext.mIMEState.mEnabled);
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

@@ -179,8 +179,6 @@ public:
PRUint32 aNativeMessage, PRUint32 aNativeMessage,
PRUint32 aModifierFlags); PRUint32 aModifierFlags);
NS_IMETHOD ResetInputState(); NS_IMETHOD ResetInputState();
NS_IMETHOD SetIMEOpenState(bool aState);
NS_IMETHOD GetIMEOpenState(bool* aState);
NS_IMETHOD_(void) SetInputContext(const InputContext& aContext, NS_IMETHOD_(void) SetInputContext(const InputContext& aContext,
const InputContextAction& aAction); const InputContextAction& aAction);
NS_IMETHOD_(InputContext) GetInputContext(); NS_IMETHOD_(InputContext) GetInputContext();
@@ -265,7 +263,7 @@ public:
// needed in nsIMM32Handler.cpp // needed in nsIMM32Handler.cpp
bool PluginHasFocus() bool PluginHasFocus()
{ {
return mInputContext.mIMEEnabled == InputContext::IME_PLUGIN; return (mInputContext.mIMEState.mEnabled == IMEState::PLUGIN);
} }
bool IsTopLevelWidget() { return mIsTopWidgetWindow; } bool IsTopLevelWidget() { return mIsTopWidgetWindow; }
/** /**

View File

@@ -399,15 +399,6 @@ PuppetWidget::CancelComposition()
return IMEEndComposition(true); return IMEEndComposition(true);
} }
NS_IMETHODIMP
PuppetWidget::SetIMEOpenState(bool aState)
{
if (mTabChild &&
mTabChild->SendSetIMEOpenState(aState))
return NS_OK;
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP_(void) NS_IMETHODIMP_(void)
PuppetWidget::SetInputContext(const InputContext& aContext, PuppetWidget::SetInputContext(const InputContext& aContext,
const InputContextAction& aAction) const InputContextAction& aAction)
@@ -415,28 +406,24 @@ PuppetWidget::SetInputContext(const InputContext& aContext,
if (!mTabChild) { if (!mTabChild) {
return; return;
} }
mTabChild->SendSetInputContext(aContext.mIMEEnabled, mTabChild->SendSetInputContext(
static_cast<PRInt32>(aContext.mIMEState.mEnabled),
static_cast<PRInt32>(aContext.mIMEState.mOpen),
aContext.mHTMLInputType, aContext.mHTMLInputType,
aContext.mActionHint, aContext.mActionHint,
static_cast<PRInt32>(aAction.mCause), static_cast<PRInt32>(aAction.mCause),
static_cast<PRInt32>(aAction.mFocusChange)); static_cast<PRInt32>(aAction.mFocusChange));
} }
NS_IMETHODIMP
PuppetWidget::GetIMEOpenState(bool *aState)
{
if (mTabChild &&
mTabChild->SendGetIMEOpenState(aState))
return NS_OK;
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP_(InputContext) NS_IMETHODIMP_(InputContext)
PuppetWidget::GetInputContext() PuppetWidget::GetInputContext()
{ {
InputContext context; InputContext context;
if (mTabChild) { if (mTabChild) {
mTabChild->SendGetInputContext(&context.mIMEEnabled); PRInt32 enabled, open;
mTabChild->SendGetInputContext(&enabled, &open);
context.mIMEState.mEnabled = static_cast<IMEState::Enabled>(enabled);
context.mIMEState.mOpen = static_cast<IMEState::Open>(open);
} }
return context; return context;
} }

View File

@@ -168,8 +168,6 @@ public:
virtual gfxASurface* GetThebesSurface(); virtual gfxASurface* GetThebesSurface();
NS_IMETHOD ResetInputState(); NS_IMETHOD ResetInputState();
NS_IMETHOD SetIMEOpenState(bool aState);
NS_IMETHOD GetIMEOpenState(bool *aState);
NS_IMETHOD_(void) SetInputContext(const InputContext& aContext, NS_IMETHOD_(void) SetInputContext(const InputContext& aContext,
const InputContextAction& aAction); const InputContextAction& aAction);
NS_IMETHOD_(InputContext) GetInputContext(); NS_IMETHOD_(InputContext) GetInputContext();

View File

@@ -142,8 +142,6 @@ public:
virtual nsresult ActivateNativeMenuItemAt(const nsAString& indexString) { return NS_ERROR_NOT_IMPLEMENTED; } virtual nsresult ActivateNativeMenuItemAt(const nsAString& indexString) { return NS_ERROR_NOT_IMPLEMENTED; }
virtual nsresult ForceUpdateNativeMenuAt(const nsAString& indexString) { return NS_ERROR_NOT_IMPLEMENTED; } virtual nsresult ForceUpdateNativeMenuAt(const nsAString& indexString) { return NS_ERROR_NOT_IMPLEMENTED; }
NS_IMETHOD ResetInputState() { return NS_OK; } NS_IMETHOD ResetInputState() { return NS_OK; }
NS_IMETHOD SetIMEOpenState(bool aState) { return NS_ERROR_NOT_IMPLEMENTED; }
NS_IMETHOD GetIMEOpenState(bool* aState) { 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();