Bug 840409 part.1 Implement widget::IMEHandler with Initialize() and Terminate() methods r=jimm

This commit is contained in:
Masayuki Nakano 2013-02-25 13:00:05 +09:00
parent 012b7c3066
commit ff8f96a75a
5 changed files with 95 additions and 10 deletions

View File

@ -52,6 +52,7 @@ CPPSRCS = \
nsWidgetFactory.cpp \
WinUtils.cpp \
WinMouseScrollHandler.cpp \
WinIMEHandler.cpp \
$(NULL)
ifdef MOZ_CRASHREPORTER

View File

@ -0,0 +1,51 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "WinIMEHandler.h"
#include "nsIMM32Handler.h"
#ifdef NS_ENABLE_TSF
#include "nsTextStore.h"
#endif // #ifdef NS_ENABLE_TSF
namespace mozilla {
namespace widget {
/******************************************************************************
* IMEHandler
******************************************************************************/
#ifdef NS_ENABLE_TSF
bool IMEHandler::sIsInTSFMode = false;
#endif // #ifdef NS_ENABLE_TSF
// static
void
IMEHandler::Initialize()
{
#ifdef NS_ENABLE_TSF
nsTextStore::Initialize();
sIsInTSFMode = nsTextStore::IsInTSFMode();
#endif // #ifdef NS_ENABLE_TSF
nsIMM32Handler::Initialize();
}
// static
void
IMEHandler::Terminate()
{
#ifdef NS_ENABLE_TSF
if (sIsInTSFMode) {
nsTextStore::Terminate();
sIsInTSFMode = false;
}
#endif // #ifdef NS_ENABLE_TSF
nsIMM32Handler::Terminate();
}
} // namespace widget
} // namespace mozilla

View File

@ -0,0 +1,35 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef WinIMEHandler_h_
#define WinIMEHandler_h_
#include "nscore.h"
namespace mozilla {
namespace widget {
/**
* IMEHandler class is a mediator class. On Windows, there are two IME API
* sets: One is IMM which is legacy API set. The other is TSF which is modern
* API set. By using this class, non-IME handler classes don't need to worry
* that we're in which mode.
*/
class IMEHandler MOZ_FINAL
{
public:
static void Initialize();
static void Terminate();
private:
#ifdef NS_ENABLE_TSF
static bool sIsInTSFMode;
#endif // #ifdef NS_ENABLE_TSF
};
} // namespace widget
} // namespace mozilla
#endif // #ifndef WinIMEHandler_h_

View File

@ -163,6 +163,11 @@ public:
return (void*) & sDisplayAttrMgr;
}
static bool IsInTSFMode()
{
return sTsfThreadMgr != nullptr;
}
protected:
nsTextStore();
~nsTextStore();

View File

@ -169,6 +169,7 @@
#include "mozilla/HangMonitor.h"
#include "nsIMM32Handler.h"
#include "WinIMEHandler.h"
using namespace mozilla::widget;
using namespace mozilla::layers;
@ -362,11 +363,7 @@ nsWindow::nsWindow() : nsWindowBase()
// WinTaskbar.cpp for details.
mozilla::widget::WinTaskbar::RegisterAppUserModelID();
gKbdLayout.LoadLayout(::GetKeyboardLayout(0));
// Init IME handler
nsIMM32Handler::Initialize();
#ifdef NS_ENABLE_TSF
nsTextStore::Initialize();
#endif
IMEHandler::Initialize();
if (SUCCEEDED(::OleInitialize(NULL))) {
sIsOleInitialized = TRUE;
}
@ -406,17 +403,13 @@ nsWindow::~nsWindow()
// Global shutdown
if (sInstanceCount == 0) {
#ifdef NS_ENABLE_TSF
nsTextStore::Terminate();
#endif
IMEHandler::Terminate();
NS_IF_RELEASE(sCursorImgContainer);
if (sIsOleInitialized) {
::OleFlushClipboard();
::OleUninitialize();
sIsOleInitialized = FALSE;
}
// delete any of the IME structures that we allocated
nsIMM32Handler::Terminate();
}
NS_IF_RELEASE(mNativeDragTarget);