Bug 1217700 part.1 nsIWidget should return reference to IMENotificationRequests r=m_kato
IMEContentObserver may need to change notifications to send when TextInputProcessor begins input transaction. In current design, IMEContentObserver needs to retrieve IMENotificationRequests at every change. However, if nsIWidget returns a reference to its IMENotificationRequests, IMEContentObserver can call it only once. For that purpose, this patch changes nsIWidget::GetIMENotificationRequests() to nsIWidget::IMENotificationRequestsRef() and make it return |const IMENotificationRequests&|. However, if the lifetime of the instance of IMENotificationRequest is shorter than the widget instance's, it's dangerous. Therefore, it always returns TextEventDispatcher::mIMENotificationRequests. TextEventDispatcher's lifetime is longer than the widget. Therefore, this guarantees the lifetime. On the other hand, widget needs to update TextEventDispatcher::mIMENotificationRequests before calls of nsIWidget::IMENotificationRequestsRef(). Therefore, this patch makes TextEventDispatcher update proper IMENotificationRequests when it gets focus or starts new input transaction and clear mIMENotificationRequests when it loses focus. Note that TextEventDispatcher gets proper requests both from native text event dispatcher listener (typically, implemented by native IME handler class) and TextInputProcessor when TextInputProcessor has input transaction because even if TextInputProcessor overrides native IME, native IME still needs to know the content changes since they may get new input transaction after that. However, there may not be native IME handler in content process. If it runs in Android, PuppetWidget may have native IME handler because widget directly handles IME in e10s mode for Android. Otherwise, native IME handler is in its parent process. So, if TextInputHandler has input transaction in content process, PuppetWidget needs to behave as native event handler. Therefore, this patch makes PuppetWidget inherit TextEventDispatcherListener and implements PuppetWidget::IMENotificationRequestsRef(). MozReview-Commit-ID: 2SW3moONTOX
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
#include "mozilla/layers/WebRenderLayerManager.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/TextComposition.h"
|
||||
#include "mozilla/TextEventDispatcher.h"
|
||||
#include "mozilla/TextEvents.h"
|
||||
#include "mozilla/Unused.h"
|
||||
#include "BasicLayers.h"
|
||||
@@ -80,7 +81,8 @@ const size_t PuppetWidget::kMaxDimension = 4000;
|
||||
static bool gRemoteDesktopBehaviorEnabled = false;
|
||||
static bool gRemoteDesktopBehaviorInitialized = false;
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED0(PuppetWidget, nsBaseWidget)
|
||||
NS_IMPL_ISUPPORTS_INHERITED(PuppetWidget, nsBaseWidget
|
||||
, TextEventDispatcherListener)
|
||||
|
||||
PuppetWidget::PuppetWidget(TabChild* aTabChild)
|
||||
: mTabChild(aTabChild)
|
||||
@@ -866,33 +868,6 @@ PuppetWidget::NotifyIMEOfCompositionUpdate(
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
IMENotificationRequests
|
||||
PuppetWidget::GetIMENotificationRequests()
|
||||
{
|
||||
if (mNativeTextEventDispatcherListener) {
|
||||
// Use mNativeTextEventDispatcherListener for retrieving IME notification
|
||||
// requests because non-native IME may have transaction.
|
||||
return mNativeTextEventDispatcherListener->GetIMENotificationRequests();
|
||||
}
|
||||
|
||||
// e10s requires IME content cache in in the TabParent for handling query
|
||||
// content event only with the parent process. Therefore, this process
|
||||
// needs to receive a lot of information from the focused editor to sent
|
||||
// the latest content to the parent process.
|
||||
if (mInputContext.mIMEState.mEnabled == IMEState::PLUGIN) {
|
||||
// But if a plugin has focus, we cannot receive text nor selection change
|
||||
// in the plugin. Therefore, PuppetWidget needs to receive only position
|
||||
// change event for updating the editor rect cache.
|
||||
return IMENotificationRequests(
|
||||
mIMENotificationRequestsOfParent.mWantUpdates |
|
||||
IMENotificationRequests::NOTIFY_POSITION_CHANGE);
|
||||
}
|
||||
return IMENotificationRequests(
|
||||
mIMENotificationRequestsOfParent.mWantUpdates |
|
||||
IMENotificationRequests::NOTIFY_TEXT_CHANGE |
|
||||
IMENotificationRequests::NOTIFY_POSITION_CHANGE);
|
||||
}
|
||||
|
||||
nsresult
|
||||
PuppetWidget::NotifyIMEOfTextChange(const IMENotification& aIMENotification)
|
||||
{
|
||||
@@ -1547,5 +1522,48 @@ PuppetWidget::OnWindowedPluginKeyEvent(const NativeEventData& aKeyEventData,
|
||||
return NS_SUCCESS_EVENT_HANDLED_ASYNCHRONOUSLY;
|
||||
}
|
||||
|
||||
// TextEventDispatcherListener
|
||||
|
||||
NS_IMETHODIMP
|
||||
PuppetWidget::NotifyIME(TextEventDispatcher* aTextEventDispatcher,
|
||||
const IMENotification& aNotification)
|
||||
{
|
||||
MOZ_ASSERT(aTextEventDispatcher == mTextEventDispatcher);
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(IMENotificationRequests)
|
||||
PuppetWidget::GetIMENotificationRequests()
|
||||
{
|
||||
if (mInputContext.mIMEState.mEnabled == IMEState::PLUGIN) {
|
||||
// If a plugin has focus, we cannot receive text nor selection change
|
||||
// in the plugin. Therefore, PuppetWidget needs to receive only position
|
||||
// change event for updating the editor rect cache.
|
||||
return IMENotificationRequests(
|
||||
mIMENotificationRequestsOfParent.mWantUpdates |
|
||||
IMENotificationRequests::NOTIFY_POSITION_CHANGE);
|
||||
}
|
||||
return IMENotificationRequests(
|
||||
mIMENotificationRequestsOfParent.mWantUpdates |
|
||||
IMENotificationRequests::NOTIFY_TEXT_CHANGE |
|
||||
IMENotificationRequests::NOTIFY_POSITION_CHANGE);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(void)
|
||||
PuppetWidget::OnRemovedFrom(TextEventDispatcher* aTextEventDispatcher)
|
||||
{
|
||||
MOZ_ASSERT(aTextEventDispatcher == mTextEventDispatcher);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(void)
|
||||
PuppetWidget::WillDispatchKeyboardEvent(
|
||||
TextEventDispatcher* aTextEventDispatcher,
|
||||
WidgetKeyboardEvent& aKeyboardEvent,
|
||||
uint32_t aIndexOfKeypress,
|
||||
void* aData)
|
||||
{
|
||||
MOZ_ASSERT(aTextEventDispatcher == mTextEventDispatcher);
|
||||
}
|
||||
|
||||
} // namespace widget
|
||||
} // namespace mozilla
|
||||
|
||||
Reference in New Issue
Block a user