author | Masayuki Nakano <masayuki@d-toybox.com> |
Wed, 26 Jul 2017 00:57:29 +0900 | |
changeset 371584 | 258d81d739533da1d4753741119bfd18c2176483 |
parent 371583 | 51919d68802ec622a8c24a5e839e046f57f66405 |
child 371585 | dc839a86967dafca35021b3744f6dfb39264179f |
push id | 47508 |
push user | masayuki@d-toybox.com |
push date | Fri, 28 Jul 2017 13:08:11 +0000 |
treeherder | autoland@258d81d73953 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | m_kato |
bugs | 1384027 |
milestone | 56.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
dom/events/IMEStateManager.cpp | file | annotate | diff | comparison | revisions | |
dom/events/IMEStateManager.h | file | annotate | diff | comparison | revisions |
--- a/dom/events/IMEStateManager.cpp +++ b/dom/events/IMEStateManager.cpp @@ -192,38 +192,43 @@ IMEStateManager::Shutdown() delete sTextCompositions; sTextCompositions = nullptr; } // static void IMEStateManager::OnTabParentDestroying(TabParent* aTabParent) { + if (sFocusedIMETabParent == aTabParent) { + NotifyIMEOfBlurForChildProcess(); + } + if (sActiveTabParent != aTabParent) { return; } + MOZ_LOG(sISMLog, LogLevel::Info, ("OnTabParentDestroying(aTabParent=0x%p), " "The active TabParent is being destroyed", aTabParent)); // The active remote process might have crashed. sActiveTabParent = nullptr; - // TODO: Need to cancel composition without TextComposition and make - // disable IME. + // XXX: Need to disable IME? } // static void IMEStateManager::WidgetDestroyed(nsIWidget* aWidget) { if (sWidget == aWidget) { sWidget = nullptr; } if (sFocusedIMEWidget == aWidget) { + NotifyIMEOfBlurForChildProcess(); sFocusedIMEWidget = nullptr; } if (sActiveInputContextWidget == aWidget) { sActiveInputContextWidget = nullptr; } } // static @@ -243,16 +248,37 @@ IMEStateManager::StopIMEStateManagement( sPresContext = nullptr; sContent = nullptr; sActiveTabParent = nullptr; DestroyIMEContentObserver(); } // static void +IMEStateManager::NotifyIMEOfBlurForChildProcess() +{ + MOZ_LOG(sISMLog, LogLevel::Debug, + ("NotifyIMEOfBlurForChildProcess(), sFocusedIMETabParent=0x%p, " + "sFocusedIMEWidget=0x%p", + sFocusedIMETabParent.get(), sFocusedIMEWidget)); + + if (!sFocusedIMETabParent) { + MOZ_ASSERT(!sFocusedIMEWidget); + return; + } + + MOZ_ASSERT(sFocusedIMEWidget); + NotifyIME(NOTIFY_IME_OF_BLUR, sFocusedIMEWidget, sFocusedIMETabParent); + + MOZ_ASSERT(!sFocusedIMETabParent); + MOZ_ASSERT(!sFocusedIMEWidget); +} + +// static +void IMEStateManager::MaybeStartOffsetUpdatedInChild(nsIWidget* aWidget, uint32_t aStartOffset) { if (NS_WARN_IF(!sTextCompositions)) { MOZ_LOG(sISMLog, LogLevel::Warning, ("MaybeStartOffsetUpdatedInChild(aWidget=0x%p, aStartOffset=%u), " "called when there is no composition", aWidget, aStartOffset)); return; @@ -483,23 +509,29 @@ IMEStateManager::OnChangeFocusInternal(n } else { // If there is no active IMEContentObserver, it means that focused content // may be in another process. // If focus is moving from current focused remote process to different // process while the process has IME focus too, we need to notify IME of // blur here because it may be too late the blur notification to reach // this process especially when closing active window. - if (sFocusedIMETabParent && + // However, don't send blur if we're being deactivated and IME wants to + // keep composition during deactive because notifying blur will commit + // or cancel composition. + if (sFocusedIMETabParent && sFocusedIMEWidget && + (aPresContext || + !sFocusedIMEWidget->IMENotificationRequestsRef(). + WantDuringDeactive()) && !IsSameProcess(sFocusedIMETabParent, newTabParent)) { MOZ_LOG(sISMLog, LogLevel::Info, (" OnChangeFocusInternal(), notifying IME of blur of previous focused " "remote process because it may be too late actual notification to " "reach this process")); - NotifyIME(NOTIFY_IME_OF_BLUR, sFocusedIMEWidget, sFocusedIMETabParent); + NotifyIMEOfBlurForChildProcess(); } } if (!aPresContext) { MOZ_LOG(sISMLog, LogLevel::Debug, (" OnChangeFocusInternal(), " "no nsPresContext is being activated")); return NS_OK;
--- a/dom/events/IMEStateManager.h +++ b/dom/events/IMEStateManager.h @@ -269,16 +269,22 @@ protected: const InputContextAction& aAction); static IMEState GetNewIMEState(nsPresContext* aPresContext, nsIContent* aContent); static void EnsureTextCompositionArray(); static void CreateIMEContentObserver(EditorBase* aEditorBase); static void DestroyIMEContentObserver(); + /** + * NotifyIMEOfBlurForChildProcess() tries to send blur notification when + * a remote process has IME focus. Otherwise, do nothing. + */ + static void NotifyIMEOfBlurForChildProcess(); + static bool IsEditable(nsINode* node); static bool IsIMEObserverNeeded(const IMEState& aState); static nsIContent* GetRootContent(nsPresContext* aPresContext); /** * CanHandleWith() returns false if aPresContext is nullptr or it's destroyed.