Bug 1053053 part.2 Notify child process's IMEStateManager of that it should stop manageing IME state r=smaug

This commit is contained in:
Masayuki Nakano 2015-07-01 22:19:11 +09:00
parent b95cd67450
commit 52a95fd7ea
5 changed files with 55 additions and 0 deletions

View File

@ -16,6 +16,7 @@
#include "mozilla/Services.h"
#include "mozilla/TextComposition.h"
#include "mozilla/TextEvents.h"
#include "mozilla/unused.h"
#include "mozilla/dom/HTMLFormElement.h"
#include "mozilla/dom/TabParent.h"
@ -240,6 +241,26 @@ IMEStateManager::OnTabParentDestroying(TabParent* aTabParent)
// disable IME.
}
// static
void
IMEStateManager::StopIMEStateManagement()
{
MOZ_LOG(sISMLog, LogLevel::Info,
("ISM: IMEStateManager::StopIMEStateManagement()"));
// NOTE: Don't set input context from here since this has already lost
// the rights to change input context.
if (sTextCompositions && sPresContext) {
NotifyIME(REQUEST_TO_COMMIT_COMPOSITION, sPresContext);
}
sPresContext = nullptr;
NS_IF_RELEASE(sContent);
sContent = nullptr;
sActiveTabParent = nullptr;
DestroyIMEContentObserver();
}
// static
nsresult
IMEStateManager::OnDestroyPresContext(nsPresContext* aPresContext)
@ -411,6 +432,18 @@ IMEStateManager::OnChangeFocusInternal(nsPresContext* aPresContext,
return NS_OK;
}
nsIContentParent* currentContentParent =
sActiveTabParent ? sActiveTabParent->Manager() : nullptr;
nsIContentParent* newContentParent =
newTabParent ? newTabParent->Manager() : nullptr;
if (sActiveTabParent && currentContentParent != newContentParent) {
MOZ_LOG(sISMLog, LogLevel::Debug,
("ISM: IMEStateManager::OnChangeFocusInternal(), notifying previous "
"focused child process of parent process or another child process "
"getting focus"));
unused << sActiveTabParent->SendStopIMEStateManagement();
}
nsCOMPtr<nsIWidget> widget =
(sPresContext == aPresContext) ? oldWidget.get() :
aPresContext->GetRootWidget();

View File

@ -65,6 +65,12 @@ public:
const InputContext& aInputContext,
const InputContextAction& aAction);
/**
* StopIMEStateManagement() is called when the process should stop managing
* IME state.
*/
static void StopIMEStateManagement();
static nsresult OnDestroyPresContext(nsPresContext* aPresContext);
static nsresult OnRemoveContent(nsPresContext* aPresContext,
nsIContent* aContent);

View File

@ -576,6 +576,12 @@ child:
ParentActivated(bool aActivated);
/**
* StopIMEStateManagement() is called when the process loses focus and
* should stop managing IME state.
*/
StopIMEStateManagement();
/**
* @see nsIDOMWindowUtils sendMouseEvent.
*/

View File

@ -20,6 +20,7 @@
#include "mozilla/dom/workers/ServiceWorkerManager.h"
#include "mozilla/dom/indexedDB/PIndexedDBPermissionRequestChild.h"
#include "mozilla/plugins/PluginWidgetChild.h"
#include "mozilla/IMEStateManager.h"
#include "mozilla/ipc/DocumentRendererChild.h"
#include "mozilla/ipc/FileDescriptorUtils.h"
#include "mozilla/layers/APZCCallbackHelper.h"
@ -2199,6 +2200,13 @@ bool TabChild::RecvParentActivated(const bool& aActivated)
return true;
}
bool
TabChild::RecvStopIMEStateManagement()
{
IMEStateManager::StopIMEStateManagement();
return true;
}
bool
TabChild::RecvMouseEvent(const nsString& aType,
const float& aX,

View File

@ -529,6 +529,8 @@ protected:
virtual bool RecvParentActivated(const bool& aActivated) override;
virtual bool RecvStopIMEStateManagement() override;
#ifdef MOZ_WIDGET_GONK
void MaybeRequestPreinitCamera();
#endif