Bug 1211704 - Convert IME event handler in nsWindow to native calls; r=esawin

Move the IME event handler implementation in nsWindow::OnIMEEvent to
individual native calls in nsWindow::Natives. This patch also moves most
member variables and helper functions related to IME to inside
nsWindow::Natives. This has the benefit of better organization and saves
some memory because only the top-level nsWindow now keeps IME states.

GetIMEComposition and RemoveIMEComposition are kept inside nsWindow
because they are not strictly related to IME events, and they are used
by some other event handlers in nsWindow.
This commit is contained in:
Jim Chen 2015-10-22 17:45:47 -04:00
Родитель 0e7ee1df92
Коммит a252cfa4a2
2 изменённых файлов: 639 добавлений и 630 удалений

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -49,9 +49,6 @@ public:
// Object that implements native GeckoView calls;
// nullptr for nsWindows that were not opened from GeckoView.
mozilla::UniquePtr<Natives> mNatives;
// GeckoEditable instance used by this nsWindow;
// nullptr for nsWindows that are not GeckoViews.
mozilla::widget::GeckoEditable::GlobalRef mEditable;
static void OnGlobalAndroidEvent(mozilla::AndroidGeckoEvent *ae);
static mozilla::gfx::IntSize GetAndroidScreenBounds();
@ -62,7 +59,6 @@ public:
bool OnMultitouchEvent(mozilla::AndroidGeckoEvent *ae);
void OnNativeGestureEvent(mozilla::AndroidGeckoEvent *ae);
void OnMouseEvent(mozilla::AndroidGeckoEvent *ae);
void OnIMEEvent(mozilla::AndroidGeckoEvent *ae);
void OnSizeChanged(const mozilla::gfx::IntSize& aSize);
@ -143,8 +139,6 @@ public:
NS_IMETHOD_(void) SetInputContext(const InputContext& aContext,
const InputContextAction& aAction) override;
NS_IMETHOD_(InputContext) GetInputContext() override;
nsresult NotifyIMEOfTextChange(const IMENotification& aIMENotification);
virtual nsIMEUpdatePreference GetIMEUpdatePreference() override;
LayerManager* GetLayerManager (PLayerTransactionChild* aShadowManager = nullptr,
@ -187,38 +181,8 @@ protected:
nsWindow *FindTopLevel();
bool IsTopLevel();
struct IMEChange {
int32_t mStart, mOldEnd, mNewEnd;
IMEChange() :
mStart(-1), mOldEnd(-1), mNewEnd(-1)
{
}
IMEChange(const IMENotification& aIMENotification)
: mStart(aIMENotification.mTextChangeData.mStartOffset)
, mOldEnd(aIMENotification.mTextChangeData.mRemovedEndOffset)
, mNewEnd(aIMENotification.mTextChangeData.mAddedEndOffset)
{
MOZ_ASSERT(aIMENotification.mMessage ==
mozilla::widget::NOTIFY_IME_OF_TEXT_CHANGE,
"IMEChange initialized with wrong notification");
MOZ_ASSERT(aIMENotification.mTextChangeData.IsValid(),
"The text change notification isn't initialized");
MOZ_ASSERT(aIMENotification.mTextChangeData.IsInInt32Range(),
"The text change notification is out of range");
}
bool IsEmpty() const
{
return mStart < 0;
}
};
RefPtr<mozilla::TextComposition> GetIMEComposition();
void RemoveIMEComposition();
void SendIMEDummyKeyEvents();
void AddIMETextChange(const IMEChange& aChange);
void PostFlushIMEChanges();
void FlushIMEChanges();
void ConfigureAPZCTreeManager() override;
void ConfigureAPZControllerThread() override;
@ -238,19 +202,9 @@ protected:
nsCOMPtr<nsIIdleServiceInternal> mIdleService;
bool mIMEMaskSelectionUpdate;
int32_t mIMEMaskEventsCount; // Mask events when > 0
RefPtr<mozilla::TextRangeArray> mIMERanges;
bool mIMEUpdatingContext;
nsAutoTArray<mozilla::UniquePtr<mozilla::WidgetEvent>, 8> mIMEKeyEvents;
nsAutoTArray<IMEChange, 4> mIMETextChanges;
bool mIMESelectionChanged;
bool mAwaitingFullScreen;
bool mIsFullScreen;
InputContext mInputContext;
virtual nsresult NotifyIMEInternal(
const IMENotification& aIMENotification) override;