mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 13:21:05 +00:00
Bug 1121313 - Part 2. Don't generate composition event on child process if parent process doesn't send composition event by NotifyIME. r=masayuki
This commit is contained in:
parent
78081000a4
commit
d73239b1ac
@ -267,15 +267,18 @@ parent:
|
||||
/**
|
||||
* Instructs chrome to end any pending composition
|
||||
*
|
||||
* cancel PR_TRUE if composition should be cancelled
|
||||
* cancel true if composition should be cancelled
|
||||
* noCompositionEvent true if no composition event is fired by commit or
|
||||
* cancel
|
||||
* composition Text to commit before ending the composition
|
||||
*
|
||||
* if cancel is PR_TRUE,
|
||||
* if cancel is true,
|
||||
* widget should return empty string for composition
|
||||
* if cancel is PR_FALSE,
|
||||
* if cancel is false,
|
||||
* widget should return the current composition text
|
||||
*/
|
||||
prio(urgent) sync EndIMEComposition(bool cancel) returns (nsString composition);
|
||||
prio(urgent) sync EndIMEComposition(bool cancel)
|
||||
returns (bool noCompositionEvent, nsString composition);
|
||||
|
||||
/**
|
||||
* Request that the parent process move focus to the browser's frame. If
|
||||
|
@ -259,6 +259,7 @@ TabParent::TabParent(nsIContentParent* aManager,
|
||||
, mWritingMode()
|
||||
, mIMEComposing(false)
|
||||
, mIMECompositionEnding(false)
|
||||
, mIMEEventCountAfterEnding(0)
|
||||
, mIMECompositionStart(0)
|
||||
, mIMESeqno(0)
|
||||
, mIMECompositionRectOffset(0)
|
||||
@ -1990,8 +1991,10 @@ TabParent::SendCompositionEvent(WidgetCompositionEvent& event)
|
||||
|
||||
mIMEComposing = !event.CausesDOMCompositionEndEvent();
|
||||
mIMECompositionStart = std::min(mIMESelectionAnchor, mIMESelectionFocus);
|
||||
if (mIMECompositionEnding)
|
||||
if (mIMECompositionEnding) {
|
||||
mIMEEventCountAfterEnding++;
|
||||
return true;
|
||||
}
|
||||
event.mSeqno = ++mIMESeqno;
|
||||
return PBrowserParent::SendCompositionEvent(event);
|
||||
}
|
||||
@ -2009,6 +2012,7 @@ TabParent::SendCompositionChangeEvent(WidgetCompositionEvent& event)
|
||||
{
|
||||
if (mIMECompositionEnding) {
|
||||
mIMECompositionText = event.mData;
|
||||
mIMEEventCountAfterEnding++;
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -2099,6 +2103,7 @@ TabParent::GetRenderFrame()
|
||||
|
||||
bool
|
||||
TabParent::RecvEndIMEComposition(const bool& aCancel,
|
||||
bool* aNoCompositionEvent,
|
||||
nsString* aComposition)
|
||||
{
|
||||
nsCOMPtr<nsIWidget> widget = GetWidget();
|
||||
@ -2106,11 +2111,13 @@ TabParent::RecvEndIMEComposition(const bool& aCancel,
|
||||
return true;
|
||||
|
||||
mIMECompositionEnding = true;
|
||||
mIMEEventCountAfterEnding = 0;
|
||||
|
||||
widget->NotifyIME(IMENotification(aCancel ? REQUEST_TO_CANCEL_COMPOSITION :
|
||||
REQUEST_TO_COMMIT_COMPOSITION));
|
||||
|
||||
mIMECompositionEnding = false;
|
||||
*aNoCompositionEvent = !mIMEEventCountAfterEnding;
|
||||
*aComposition = mIMECompositionText;
|
||||
mIMECompositionText.Truncate(0);
|
||||
return true;
|
||||
|
@ -195,6 +195,7 @@ public:
|
||||
InfallibleTArray<LayoutDeviceIntRect>&& aCompositionRects,
|
||||
const LayoutDeviceIntRect& aCaretRect) MOZ_OVERRIDE;
|
||||
virtual bool RecvEndIMEComposition(const bool& aCancel,
|
||||
bool* aNoCompositionEvent,
|
||||
nsString* aComposition) MOZ_OVERRIDE;
|
||||
virtual bool RecvGetInputContext(int32_t* aIMEEnabled,
|
||||
int32_t* aIMEOpen,
|
||||
@ -418,6 +419,7 @@ protected:
|
||||
mozilla::WritingMode mWritingMode;
|
||||
bool mIMEComposing;
|
||||
bool mIMECompositionEnding;
|
||||
uint32_t mIMEEventCountAfterEnding;
|
||||
// Buffer to store composition text during ResetInputState
|
||||
// Compositions in almost all cases are small enough for nsAutoString
|
||||
nsAutoString mIMECompositionText;
|
||||
|
@ -109,7 +109,6 @@ PuppetWidget::Create(nsIWidget *aParent,
|
||||
mDrawTarget = gfxPlatform::GetPlatform()->
|
||||
CreateOffscreenContentDrawTarget(IntSize(1, 1), SurfaceFormat::B8G8R8A8);
|
||||
|
||||
mIMEComposing = false;
|
||||
mNeedIMEStateInit = MightNeedIMEFocus(aInitData);
|
||||
|
||||
PuppetWidget* parent = static_cast<PuppetWidget*>(aParent);
|
||||
@ -305,9 +304,6 @@ PuppetWidget::DispatchEvent(WidgetGUIEvent* event, nsEventStatus& aStatus)
|
||||
|
||||
aStatus = nsEventStatus_eIgnore;
|
||||
|
||||
if (event->message == NS_COMPOSITION_START) {
|
||||
mIMEComposing = true;
|
||||
}
|
||||
uint32_t seqno = kLatestSeqno;
|
||||
switch (event->mClass) {
|
||||
case eCompositionEventClass:
|
||||
@ -330,11 +326,6 @@ PuppetWidget::DispatchEvent(WidgetGUIEvent* event, nsEventStatus& aStatus)
|
||||
aStatus = mAttachedWidgetListener->HandleEvent(event, mUseAttachedEvents);
|
||||
}
|
||||
|
||||
if (event->mClass == eCompositionEventClass &&
|
||||
event->AsCompositionEvent()->CausesDOMCompositionEndEvent()) {
|
||||
mIMEComposing = false;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -402,19 +393,21 @@ PuppetWidget::IMEEndComposition(bool aCancel)
|
||||
#endif
|
||||
|
||||
nsEventStatus status;
|
||||
bool noCompositionEvent = true;
|
||||
WidgetCompositionEvent compositionCommitEvent(true, NS_COMPOSITION_COMMIT,
|
||||
this);
|
||||
InitEvent(compositionCommitEvent, nullptr);
|
||||
// SendEndIMEComposition is always called since ResetInputState
|
||||
// should always be called even if we aren't composing something.
|
||||
if (!mTabChild ||
|
||||
!mTabChild->SendEndIMEComposition(aCancel,
|
||||
!mTabChild->SendEndIMEComposition(aCancel, &noCompositionEvent,
|
||||
&compositionCommitEvent.mData)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (!mIMEComposing)
|
||||
if (noCompositionEvent) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
compositionCommitEvent.mSeqno = mIMELastReceivedSeqno;
|
||||
DispatchEvent(&compositionCommitEvent, status);
|
||||
|
@ -259,7 +259,6 @@ private:
|
||||
mozilla::RefPtr<DrawTarget> mDrawTarget;
|
||||
// IME
|
||||
nsIMEUpdatePreference mIMEPreferenceOfParent;
|
||||
bool mIMEComposing;
|
||||
// Latest seqno received through events
|
||||
uint32_t mIMELastReceivedSeqno;
|
||||
// Chrome's seqno value when last blur occurred
|
||||
|
Loading…
Reference in New Issue
Block a user