Oh, I misunderstood this bug. Although a puppet widget is created at [very first state of `BrowserChild` creation](https://searchfox.org/mozilla-central/rev/43c40b22c776d098afb89d5237da3464a7545532/dom/ipc/BrowserChild.cpp#379,385). So, I don't know why it's not accessible from `nsPresContext`... However, `IMEStateManager::UpdateIMEState` relaxes about the situation: ``` #ifdef DEBUG { nsCOMPtr<nsIWidget> currentTextInputHandlingWidget = sFocusedPresContext->GetTextInputHandlingWidget(); MOZ_ASSERT(!currentTextInputHandlingWidget || currentTextInputHandlingWidget == textInputHandlingWidget); } #endif // DEBUG ``` This assertion came from bug 1342552, but I don't remember the detail, and I was struggling with the complicated management of the view and the view manager. I guess that it's enough to make `IMEStateManager::CreateIMEContentObserver` use `MOZ_ASSERT_IF(currentTextInputHandlingWidget, currentTextInputHandlingWidget == textInputHandlingWidget)` instead and need to change all `sFocusedPresContext->GetTextInputHandlingWidget()` callers to use `sFocusedPresContext` and need to add an accessor for it for [`EditorEventListner`](https://searchfox.org/mozilla-central/rev/7fc94186f1a759790c56e41a90ab350d78dbda30/editor/libeditor/EditorEventListener.cpp#659).
Bug 1870960 Comment 10 Edit History
Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.
Oh, I misunderstood this bug. Although a puppet widget is created at [very first state of `BrowserChild` creation](https://searchfox.org/mozilla-central/rev/43c40b22c776d098afb89d5237da3464a7545532/dom/ipc/BrowserChild.cpp#379,385). So, I don't know why it's not accessible from `nsPresContext`... However, `IMEStateManager::UpdateIMEState` relaxes about the situation: ```cpp #ifdef DEBUG { nsCOMPtr<nsIWidget> currentTextInputHandlingWidget = sFocusedPresContext->GetTextInputHandlingWidget(); MOZ_ASSERT(!currentTextInputHandlingWidget || currentTextInputHandlingWidget == textInputHandlingWidget); } #endif // DEBUG ``` This assertion came from bug 1342552, but I don't remember the detail, and I was struggling with the complicated management of the view and the view manager. I guess that it's enough to make `IMEStateManager::CreateIMEContentObserver` use `MOZ_ASSERT_IF(currentTextInputHandlingWidget, currentTextInputHandlingWidget == textInputHandlingWidget)` instead and need to change all `sFocusedPresContext->GetTextInputHandlingWidget()` callers to use `sFocusedPresContext` and need to add an accessor for it for [`EditorEventListner`](https://searchfox.org/mozilla-central/rev/7fc94186f1a759790c56e41a90ab350d78dbda30/editor/libeditor/EditorEventListener.cpp#659).