Bug 801989 part.1 Add mNativeIMEContext to InputContext and TextComposition should use it instead of nsIWidget r=smaug, sr=roc

This commit is contained in:
Masayuki Nakano 2012-10-27 08:35:20 +09:00
parent 1307cac3ab
commit 00776d0733
6 changed files with 20 additions and 10 deletions

View File

@ -24,9 +24,7 @@ TextComposition::TextComposition(nsPresContext* aPresContext,
nsINode* aNode,
nsGUIEvent* aEvent) :
mPresContext(aPresContext), mNode(aNode),
// temporarily, we should assume that one native IME context is per native
// widget.
mNativeContext(aEvent->widget),
mNativeContext(aEvent->widget->GetInputContext().mNativeIMEContext),
mIsSynthesizedForTests(
(aEvent->flags & NS_EVENT_FLAG_SYNTHETIC_TEST_EVENT) != 0)
{
@ -44,9 +42,7 @@ TextComposition::TextComposition(const TextComposition& aOther)
bool
TextComposition::MatchesNativeContext(nsIWidget* aWidget) const
{
// temporarily, we should assume that one native IME context is per one
// native widget.
return mNativeContext == static_cast<void*>(aWidget);
return mNativeContext == aWidget->GetInputContext().mNativeIMEContext;
}
bool

View File

@ -156,7 +156,8 @@ parent:
*/
sync EndIMEComposition(bool cancel) returns (nsString composition);
sync GetInputContext() returns (int32_t IMEEnabled, int32_t IMEOpen);
sync GetInputContext() returns (int32_t IMEEnabled, int32_t IMEOpen,
int64_t NativeIMEContext);
SetInputContext(int32_t IMEEnabled,
int32_t IMEOpen,

View File

@ -743,18 +743,21 @@ TabParent::RecvEndIMEComposition(const bool& aCancel,
bool
TabParent::RecvGetInputContext(int32_t* aIMEEnabled,
int32_t* aIMEOpen)
int32_t* aIMEOpen,
int64_t* aNativeIMEContext)
{
nsCOMPtr<nsIWidget> widget = GetWidget();
if (!widget) {
*aIMEEnabled = IMEState::DISABLED;
*aIMEOpen = IMEState::OPEN_STATE_NOT_SUPPORTED;
*aNativeIMEContext = 0;
return true;
}
InputContext context = widget->GetInputContext();
*aIMEEnabled = static_cast<int32_t>(context.mIMEState.mEnabled);
*aIMEOpen = static_cast<int32_t>(context.mIMEState.mOpen);
*aNativeIMEContext = reinterpret_cast<int64_t>(context.mNativeIMEContext);
return true;
}

View File

@ -123,7 +123,8 @@ public:
virtual bool RecvEndIMEComposition(const bool& aCancel,
nsString* aComposition);
virtual bool RecvGetInputContext(int32_t* aIMEEnabled,
int32_t* aIMEOpen);
int32_t* aIMEOpen,
int64_t* aNativeIMEContext);
virtual bool RecvSetInputContext(const int32_t& aIMEEnabled,
const int32_t& aIMEOpen,
const nsString& aType,

View File

@ -278,6 +278,8 @@ struct IMEState {
};
struct InputContext {
InputContext() : mNativeIMEContext(nullptr) {}
IMEState mIMEState;
/* The type of the input if the input is a html input field */
@ -288,6 +290,11 @@ struct InputContext {
/* A hint for the action that is performed when the input is submitted */
nsString mActionHint;
/* Native IME context for the widget. This doesn't come from the argument of
SetInputContext(). If there is only one context in the process, this may
be nullptr. */
void* mNativeIMEContext;
};
struct InputContextAction {

View File

@ -382,9 +382,11 @@ PuppetWidget::GetInputContext()
InputContext context;
if (mTabChild) {
int32_t enabled, open;
mTabChild->SendGetInputContext(&enabled, &open);
int64_t nativeIMEContext;
mTabChild->SendGetInputContext(&enabled, &open, &nativeIMEContext);
context.mIMEState.mEnabled = static_cast<IMEState::Enabled>(enabled);
context.mIMEState.mOpen = static_cast<IMEState::Open>(open);
context.mNativeIMEContext = reinterpret_cast<void*>(nativeIMEContext);
}
return context;
}