From 3bf2045197ff98febe5e362e8e52be2fe0259f40 Mon Sep 17 00:00:00 2001 From: Masayuki Nakano Date: Thu, 29 Jun 2017 16:03:57 +0900 Subject: [PATCH] Bug 1376417 - part1: IMEInputHandler should notify Cocoa of layout change with [NSTextInputContext invalidateCharacterCoordinates] r=m_kato I found invalidateCharacterCoordinates in NSTextInputContext. It's available 10.6 and later. Calling this API does NOT make visible candidate window follow window move nor something to change layout, though. But we should call it. MozReview-Commit-ID: KbllLDwlMOz --HG-- extra : rebase_source : 175377bf7dd703dcd304ffbb8648e350080c07fc --- widget/cocoa/TextInputHandler.h | 1 + widget/cocoa/TextInputHandler.mm | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/widget/cocoa/TextInputHandler.h b/widget/cocoa/TextInputHandler.h index 57cafd3f18cd..a84151e74c1d 100644 --- a/widget/cocoa/TextInputHandler.h +++ b/widget/cocoa/TextInputHandler.h @@ -813,6 +813,7 @@ public: virtual void OnFocusChangeInGecko(bool aFocus); void OnSelectionChange(const IMENotification& aIMENotification); + void OnLayoutChange(); /** * Call [NSTextInputContext handleEvent] for mouse event support of IME diff --git a/widget/cocoa/TextInputHandler.mm b/widget/cocoa/TextInputHandler.mm index 5c19d71b6f1e..a2713a8f7b53 100644 --- a/widget/cocoa/TextInputHandler.mm +++ b/widget/cocoa/TextInputHandler.mm @@ -2772,6 +2772,9 @@ IMEInputHandler::NotifyIME(TextEventDispatcher* aTextEventDispatcher, case NOTIFY_IME_OF_SELECTION_CHANGE: OnSelectionChange(aNotification); return NS_OK; + case NOTIFY_IME_OF_POSITION_CHANGE: + OnLayoutChange(); + return NS_OK; default: return NS_ERROR_NOT_IMPLEMENTED; } @@ -4270,6 +4273,20 @@ IMEInputHandler::OnSelectionChange(const IMENotification& aIMENotification) } } +void +IMEInputHandler::OnLayoutChange() +{ + NS_OBJC_BEGIN_TRY_ABORT_BLOCK; + + if (!IsFocused()) { + return; + } + NSTextInputContext* inputContext = [mView inputContext]; + [inputContext invalidateCharacterCoordinates]; + + NS_OBJC_END_TRY_ABORT_BLOCK; +} + bool IMEInputHandler::OnHandleEvent(NSEvent* aEvent) {