2017-03-01 23:29:30 +03:00
|
|
|
/* -*- Mode: c++; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef mozilla_widget_GeckoEditableSupport_h
|
|
|
|
#define mozilla_widget_GeckoEditableSupport_h
|
|
|
|
|
|
|
|
#include "GeneratedJNIWrappers.h"
|
|
|
|
#include "nsAppShell.h"
|
|
|
|
#include "nsIWidget.h"
|
|
|
|
#include "nsTArray.h"
|
|
|
|
|
|
|
|
#include "mozilla/TextEventDispatcher.h"
|
|
|
|
#include "mozilla/TextEventDispatcherListener.h"
|
|
|
|
#include "mozilla/UniquePtr.h"
|
|
|
|
|
|
|
|
class nsWindow;
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
|
|
|
class TextComposition;
|
|
|
|
|
|
|
|
namespace widget {
|
|
|
|
|
|
|
|
class GeckoEditableSupport final
|
|
|
|
: public TextEventDispatcherListener
|
2017-03-02 21:47:14 +03:00
|
|
|
, public java::GeckoEditableChild::Natives<GeckoEditableSupport>
|
2017-03-01 23:29:30 +03:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
Rules for managing IME between Gecko and Java:
|
|
|
|
|
|
|
|
* Gecko controls the text content, and Java shadows the Gecko text
|
|
|
|
through text updates
|
|
|
|
* Gecko and Java maintain separate selections, and synchronize when
|
|
|
|
needed through selection updates and set-selection events
|
|
|
|
* Java controls the composition, and Gecko shadows the Java
|
|
|
|
composition through update composition events
|
|
|
|
*/
|
|
|
|
|
2017-03-02 21:47:14 +03:00
|
|
|
using EditableBase =
|
|
|
|
java::GeckoEditableChild::Natives<GeckoEditableSupport>;
|
2017-12-14 06:57:21 +03:00
|
|
|
using EditableClient = java::TextInputController::EditableClient;
|
|
|
|
using EditableListener = java::TextInputController::EditableListener;
|
2017-03-01 23:29:30 +03:00
|
|
|
|
|
|
|
// RAII helper class that automatically sends an event reply through
|
|
|
|
// OnImeSynchronize, as required by events like OnImeReplaceText.
|
|
|
|
class AutoIMESynchronize
|
|
|
|
{
|
|
|
|
GeckoEditableSupport* const mGES;
|
|
|
|
public:
|
|
|
|
AutoIMESynchronize(GeckoEditableSupport* ges) : mGES(ges) {}
|
|
|
|
~AutoIMESynchronize() { mGES->OnImeSynchronize(); }
|
|
|
|
};
|
|
|
|
|
|
|
|
struct IMETextChange final {
|
|
|
|
int32_t mStart, mOldEnd, mNewEnd;
|
|
|
|
|
|
|
|
IMETextChange() :
|
|
|
|
mStart(-1), mOldEnd(-1), mNewEnd(-1) {}
|
|
|
|
|
|
|
|
IMETextChange(const IMENotification& aIMENotification)
|
|
|
|
: mStart(aIMENotification.mTextChangeData.mStartOffset)
|
|
|
|
, mOldEnd(aIMENotification.mTextChangeData.mRemovedEndOffset)
|
|
|
|
, mNewEnd(aIMENotification.mTextChangeData.mAddedEndOffset)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aIMENotification.mMessage == NOTIFY_IME_OF_TEXT_CHANGE,
|
|
|
|
"IMETextChange 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; }
|
|
|
|
};
|
|
|
|
|
|
|
|
enum FlushChangesFlag
|
|
|
|
{
|
|
|
|
// Not retrying.
|
|
|
|
FLUSH_FLAG_NONE,
|
|
|
|
// Retrying due to IME text changes during flush.
|
|
|
|
FLUSH_FLAG_RETRY,
|
|
|
|
// Retrying due to IME sync exceptions during flush.
|
|
|
|
FLUSH_FLAG_RECOVER
|
|
|
|
};
|
|
|
|
|
|
|
|
enum RemoveCompositionFlag
|
|
|
|
{
|
|
|
|
CANCEL_IME_COMPOSITION,
|
|
|
|
COMMIT_IME_COMPOSITION
|
|
|
|
};
|
|
|
|
|
Bug 1343075 - Use GeckoEditableSupport from PuppetWidget; r=masayuki r=rbarker r=snorp r=esawin
Bug 1343075 - 1a. Add TextEventDispatcherListener::GetIMEUpdatePreference; r=masayuki
Add a GetIMEUpdatePreference method to TextEventDispatcherListener to
optionally control which IME notifications are received by NotifyIME.
This patch also makes nsBaseWidget forward its GetIMEUpdatePreference
call to the widget's native TextEventDispatcherListener.
Bug 1343075 - 1b. Implement GetIMEUpdatePreference for all TextEventDispatcherListener; r=masayuki
This patch implements GetIMEUpdatePreference for all
TextEventDispatcherListener implementations, by moving previous
implementations of nsIWidget::GetIMEUpdatePreference.
Bug 1343075 - 2. Allow setting a PuppetWidget's native TextEventDispatcherListener; r=masayuki
In PuppetWidget, add getter and setter for the widget's native
TextEventDispatcherListener. This allows overriding of PuppetWidget's
default IME handling. For example, on Android, the PuppetWidget's native
TextEventDispatcherListener will communicate directly with Java IME code
in the main process.
Bug 1343075 - 3. Add AIDL interface for main process; r=rbarker
Add AIDL definition and implementation for an interface for the main
process that child processes can access.
Bug 1343075 - 4. Set Gecko thread JNIEnv for child process; r=snorp
Add a JNIEnv* parameter to XRE_SetAndroidChildFds, which is used to set
the Gecko thread JNIEnv for child processes. XRE_SetAndroidChildFds is
the only Android-specific entry point for child processes, so I think
it's the most logical place to initialize JNI.
Bug 1343075 - 5. Support multiple remote GeckoEditableChild; r=esawin
Support remote GeckoEditableChild instances that are created in the
content processes and connect to the parent process GeckoEditableParent
through binders.
Support having multiple GeckoEditableChild instances in GeckoEditable by
keeping track of which child is currently focused, and only allow
calls to/from the focused child by using access tokens.
Bug 1343075 - 6. Add method to get GeckoEditableParent instance; r=esawin
Add IProcessManager.getEditableParent, which a content process can call
to get the GeckoEditableParent instance that corresponds to a given
content process tab, from the main process.
Bug 1343075 - 7. Support GeckoEditableSupport in content processes; r=esawin
Support creating and running GeckoEditableSupport attached to a
PuppetWidget in content processes.
Because we don't know PuppetWidget's lifetime as well as nsWindow's,
when attached to PuppetWidget, we need to attach/detach our native
object on focus/blur, respectively.
Bug 1343075 - 8. Connect GeckoEditableSupport on PuppetWidget creation; r=esawin
Listen to the "tab-child-created" notification and attach our content
process GeckoEditableSupport to the new PuppetWidget.
Bug 1343075 - 9. Update auto-generated bindings; r=me
2017-03-08 06:34:39 +03:00
|
|
|
const bool mIsRemote;
|
2017-03-01 23:29:30 +03:00
|
|
|
nsWindow::WindowPtr<GeckoEditableSupport> mWindow; // Parent only
|
|
|
|
RefPtr<TextEventDispatcher> mDispatcher;
|
2017-03-02 21:47:14 +03:00
|
|
|
java::GeckoEditableChild::GlobalRef mEditable;
|
Bug 1343075 - Use GeckoEditableSupport from PuppetWidget; r=masayuki r=rbarker r=snorp r=esawin
Bug 1343075 - 1a. Add TextEventDispatcherListener::GetIMEUpdatePreference; r=masayuki
Add a GetIMEUpdatePreference method to TextEventDispatcherListener to
optionally control which IME notifications are received by NotifyIME.
This patch also makes nsBaseWidget forward its GetIMEUpdatePreference
call to the widget's native TextEventDispatcherListener.
Bug 1343075 - 1b. Implement GetIMEUpdatePreference for all TextEventDispatcherListener; r=masayuki
This patch implements GetIMEUpdatePreference for all
TextEventDispatcherListener implementations, by moving previous
implementations of nsIWidget::GetIMEUpdatePreference.
Bug 1343075 - 2. Allow setting a PuppetWidget's native TextEventDispatcherListener; r=masayuki
In PuppetWidget, add getter and setter for the widget's native
TextEventDispatcherListener. This allows overriding of PuppetWidget's
default IME handling. For example, on Android, the PuppetWidget's native
TextEventDispatcherListener will communicate directly with Java IME code
in the main process.
Bug 1343075 - 3. Add AIDL interface for main process; r=rbarker
Add AIDL definition and implementation for an interface for the main
process that child processes can access.
Bug 1343075 - 4. Set Gecko thread JNIEnv for child process; r=snorp
Add a JNIEnv* parameter to XRE_SetAndroidChildFds, which is used to set
the Gecko thread JNIEnv for child processes. XRE_SetAndroidChildFds is
the only Android-specific entry point for child processes, so I think
it's the most logical place to initialize JNI.
Bug 1343075 - 5. Support multiple remote GeckoEditableChild; r=esawin
Support remote GeckoEditableChild instances that are created in the
content processes and connect to the parent process GeckoEditableParent
through binders.
Support having multiple GeckoEditableChild instances in GeckoEditable by
keeping track of which child is currently focused, and only allow
calls to/from the focused child by using access tokens.
Bug 1343075 - 6. Add method to get GeckoEditableParent instance; r=esawin
Add IProcessManager.getEditableParent, which a content process can call
to get the GeckoEditableParent instance that corresponds to a given
content process tab, from the main process.
Bug 1343075 - 7. Support GeckoEditableSupport in content processes; r=esawin
Support creating and running GeckoEditableSupport attached to a
PuppetWidget in content processes.
Because we don't know PuppetWidget's lifetime as well as nsWindow's,
when attached to PuppetWidget, we need to attach/detach our native
object on focus/blur, respectively.
Bug 1343075 - 8. Connect GeckoEditableSupport on PuppetWidget creation; r=esawin
Listen to the "tab-child-created" notification and attach our content
process GeckoEditableSupport to the new PuppetWidget.
Bug 1343075 - 9. Update auto-generated bindings; r=me
2017-03-08 06:34:39 +03:00
|
|
|
bool mEditableAttached;
|
2017-03-01 23:29:30 +03:00
|
|
|
InputContext mInputContext;
|
|
|
|
AutoTArray<UniquePtr<mozilla::WidgetEvent>, 4> mIMEKeyEvents;
|
|
|
|
AutoTArray<IMETextChange, 4> mIMETextChanges;
|
|
|
|
RefPtr<TextRangeArray> mIMERanges;
|
|
|
|
int32_t mIMEMaskEventsCount; // Mask events when > 0.
|
|
|
|
bool mIMEUpdatingContext;
|
|
|
|
bool mIMESelectionChanged;
|
|
|
|
bool mIMETextChangedDuringFlush;
|
|
|
|
bool mIMEMonitorCursor;
|
|
|
|
|
|
|
|
nsIWidget* GetWidget() const
|
|
|
|
{
|
|
|
|
return mDispatcher ? mDispatcher->GetWidget() : mWindow;
|
|
|
|
}
|
|
|
|
|
Bug 1343075 - Use GeckoEditableSupport from PuppetWidget; r=masayuki r=rbarker r=snorp r=esawin
Bug 1343075 - 1a. Add TextEventDispatcherListener::GetIMEUpdatePreference; r=masayuki
Add a GetIMEUpdatePreference method to TextEventDispatcherListener to
optionally control which IME notifications are received by NotifyIME.
This patch also makes nsBaseWidget forward its GetIMEUpdatePreference
call to the widget's native TextEventDispatcherListener.
Bug 1343075 - 1b. Implement GetIMEUpdatePreference for all TextEventDispatcherListener; r=masayuki
This patch implements GetIMEUpdatePreference for all
TextEventDispatcherListener implementations, by moving previous
implementations of nsIWidget::GetIMEUpdatePreference.
Bug 1343075 - 2. Allow setting a PuppetWidget's native TextEventDispatcherListener; r=masayuki
In PuppetWidget, add getter and setter for the widget's native
TextEventDispatcherListener. This allows overriding of PuppetWidget's
default IME handling. For example, on Android, the PuppetWidget's native
TextEventDispatcherListener will communicate directly with Java IME code
in the main process.
Bug 1343075 - 3. Add AIDL interface for main process; r=rbarker
Add AIDL definition and implementation for an interface for the main
process that child processes can access.
Bug 1343075 - 4. Set Gecko thread JNIEnv for child process; r=snorp
Add a JNIEnv* parameter to XRE_SetAndroidChildFds, which is used to set
the Gecko thread JNIEnv for child processes. XRE_SetAndroidChildFds is
the only Android-specific entry point for child processes, so I think
it's the most logical place to initialize JNI.
Bug 1343075 - 5. Support multiple remote GeckoEditableChild; r=esawin
Support remote GeckoEditableChild instances that are created in the
content processes and connect to the parent process GeckoEditableParent
through binders.
Support having multiple GeckoEditableChild instances in GeckoEditable by
keeping track of which child is currently focused, and only allow
calls to/from the focused child by using access tokens.
Bug 1343075 - 6. Add method to get GeckoEditableParent instance; r=esawin
Add IProcessManager.getEditableParent, which a content process can call
to get the GeckoEditableParent instance that corresponds to a given
content process tab, from the main process.
Bug 1343075 - 7. Support GeckoEditableSupport in content processes; r=esawin
Support creating and running GeckoEditableSupport attached to a
PuppetWidget in content processes.
Because we don't know PuppetWidget's lifetime as well as nsWindow's,
when attached to PuppetWidget, we need to attach/detach our native
object on focus/blur, respectively.
Bug 1343075 - 8. Connect GeckoEditableSupport on PuppetWidget creation; r=esawin
Listen to the "tab-child-created" notification and attach our content
process GeckoEditableSupport to the new PuppetWidget.
Bug 1343075 - 9. Update auto-generated bindings; r=me
2017-03-08 06:34:39 +03:00
|
|
|
nsresult BeginInputTransaction(TextEventDispatcher* aDispatcher)
|
|
|
|
{
|
|
|
|
if (mIsRemote) {
|
|
|
|
return aDispatcher->BeginInputTransaction(this);
|
|
|
|
} else {
|
|
|
|
return aDispatcher->BeginNativeInputTransaction();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-01 23:29:30 +03:00
|
|
|
virtual ~GeckoEditableSupport() {}
|
|
|
|
|
|
|
|
RefPtr<TextComposition> GetComposition() const;
|
|
|
|
void RemoveComposition(
|
|
|
|
RemoveCompositionFlag aFlag = COMMIT_IME_COMPOSITION);
|
|
|
|
void SendIMEDummyKeyEvent(nsIWidget* aWidget, EventMessage msg);
|
|
|
|
void AddIMETextChange(const IMETextChange& aChange);
|
|
|
|
void PostFlushIMEChanges();
|
|
|
|
void FlushIMEChanges(FlushChangesFlag aFlags = FLUSH_FLAG_NONE);
|
|
|
|
void FlushIMEText(FlushChangesFlag aFlags = FLUSH_FLAG_NONE);
|
|
|
|
void AsyncNotifyIME(int32_t aNotification);
|
|
|
|
void UpdateCompositionRects();
|
|
|
|
|
|
|
|
public:
|
|
|
|
template<typename Functor>
|
|
|
|
static void OnNativeCall(Functor&& aCall)
|
|
|
|
{
|
|
|
|
struct IMEEvent : nsAppShell::LambdaEvent<Functor>
|
|
|
|
{
|
2017-09-06 15:57:08 +03:00
|
|
|
IMEEvent(Functor&& l) : nsAppShell::LambdaEvent<Functor>(Move(l)) {}
|
2017-03-01 23:29:30 +03:00
|
|
|
|
|
|
|
nsAppShell::Event::Type ActivityType() const override
|
|
|
|
{
|
2017-03-02 21:47:14 +03:00
|
|
|
using GES = GeckoEditableSupport;
|
2017-09-06 15:57:08 +03:00
|
|
|
if (this->lambda.IsTarget(&GES::OnKeyEvent) ||
|
|
|
|
this->lambda.IsTarget(&GES::OnImeReplaceText) ||
|
|
|
|
this->lambda.IsTarget(&GES::OnImeUpdateComposition)) {
|
2017-03-02 21:47:14 +03:00
|
|
|
return nsAppShell::Event::Type::kUIActivity;
|
|
|
|
}
|
|
|
|
return nsAppShell::Event::Type::kGeneralActivity;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Run() override
|
|
|
|
{
|
2017-09-06 15:57:08 +03:00
|
|
|
if (!this->lambda.GetNativeObject()) {
|
2017-03-02 21:47:14 +03:00
|
|
|
// Ignore stale calls after disposal.
|
|
|
|
jni::GetGeckoThreadEnv()->ExceptionClear();
|
|
|
|
return;
|
|
|
|
}
|
2017-09-06 15:57:08 +03:00
|
|
|
nsAppShell::LambdaEvent<Functor>::Run();
|
2017-03-01 23:29:30 +03:00
|
|
|
}
|
|
|
|
};
|
|
|
|
nsAppShell::PostEvent(mozilla::MakeUnique<IMEEvent>(
|
|
|
|
mozilla::Move(aCall)));
|
|
|
|
}
|
|
|
|
|
Bug 1343075 - Use GeckoEditableSupport from PuppetWidget; r=masayuki r=rbarker r=snorp r=esawin
Bug 1343075 - 1a. Add TextEventDispatcherListener::GetIMEUpdatePreference; r=masayuki
Add a GetIMEUpdatePreference method to TextEventDispatcherListener to
optionally control which IME notifications are received by NotifyIME.
This patch also makes nsBaseWidget forward its GetIMEUpdatePreference
call to the widget's native TextEventDispatcherListener.
Bug 1343075 - 1b. Implement GetIMEUpdatePreference for all TextEventDispatcherListener; r=masayuki
This patch implements GetIMEUpdatePreference for all
TextEventDispatcherListener implementations, by moving previous
implementations of nsIWidget::GetIMEUpdatePreference.
Bug 1343075 - 2. Allow setting a PuppetWidget's native TextEventDispatcherListener; r=masayuki
In PuppetWidget, add getter and setter for the widget's native
TextEventDispatcherListener. This allows overriding of PuppetWidget's
default IME handling. For example, on Android, the PuppetWidget's native
TextEventDispatcherListener will communicate directly with Java IME code
in the main process.
Bug 1343075 - 3. Add AIDL interface for main process; r=rbarker
Add AIDL definition and implementation for an interface for the main
process that child processes can access.
Bug 1343075 - 4. Set Gecko thread JNIEnv for child process; r=snorp
Add a JNIEnv* parameter to XRE_SetAndroidChildFds, which is used to set
the Gecko thread JNIEnv for child processes. XRE_SetAndroidChildFds is
the only Android-specific entry point for child processes, so I think
it's the most logical place to initialize JNI.
Bug 1343075 - 5. Support multiple remote GeckoEditableChild; r=esawin
Support remote GeckoEditableChild instances that are created in the
content processes and connect to the parent process GeckoEditableParent
through binders.
Support having multiple GeckoEditableChild instances in GeckoEditable by
keeping track of which child is currently focused, and only allow
calls to/from the focused child by using access tokens.
Bug 1343075 - 6. Add method to get GeckoEditableParent instance; r=esawin
Add IProcessManager.getEditableParent, which a content process can call
to get the GeckoEditableParent instance that corresponds to a given
content process tab, from the main process.
Bug 1343075 - 7. Support GeckoEditableSupport in content processes; r=esawin
Support creating and running GeckoEditableSupport attached to a
PuppetWidget in content processes.
Because we don't know PuppetWidget's lifetime as well as nsWindow's,
when attached to PuppetWidget, we need to attach/detach our native
object on focus/blur, respectively.
Bug 1343075 - 8. Connect GeckoEditableSupport on PuppetWidget creation; r=esawin
Listen to the "tab-child-created" notification and attach our content
process GeckoEditableSupport to the new PuppetWidget.
Bug 1343075 - 9. Update auto-generated bindings; r=me
2017-03-08 06:34:39 +03:00
|
|
|
// Constructor for main process GeckoEditableChild.
|
2017-03-01 23:29:30 +03:00
|
|
|
GeckoEditableSupport(nsWindow::NativePtr<GeckoEditableSupport>* aPtr,
|
|
|
|
nsWindow* aWindow,
|
2017-03-02 21:47:14 +03:00
|
|
|
java::GeckoEditableChild::Param aEditableChild)
|
Bug 1343075 - Use GeckoEditableSupport from PuppetWidget; r=masayuki r=rbarker r=snorp r=esawin
Bug 1343075 - 1a. Add TextEventDispatcherListener::GetIMEUpdatePreference; r=masayuki
Add a GetIMEUpdatePreference method to TextEventDispatcherListener to
optionally control which IME notifications are received by NotifyIME.
This patch also makes nsBaseWidget forward its GetIMEUpdatePreference
call to the widget's native TextEventDispatcherListener.
Bug 1343075 - 1b. Implement GetIMEUpdatePreference for all TextEventDispatcherListener; r=masayuki
This patch implements GetIMEUpdatePreference for all
TextEventDispatcherListener implementations, by moving previous
implementations of nsIWidget::GetIMEUpdatePreference.
Bug 1343075 - 2. Allow setting a PuppetWidget's native TextEventDispatcherListener; r=masayuki
In PuppetWidget, add getter and setter for the widget's native
TextEventDispatcherListener. This allows overriding of PuppetWidget's
default IME handling. For example, on Android, the PuppetWidget's native
TextEventDispatcherListener will communicate directly with Java IME code
in the main process.
Bug 1343075 - 3. Add AIDL interface for main process; r=rbarker
Add AIDL definition and implementation for an interface for the main
process that child processes can access.
Bug 1343075 - 4. Set Gecko thread JNIEnv for child process; r=snorp
Add a JNIEnv* parameter to XRE_SetAndroidChildFds, which is used to set
the Gecko thread JNIEnv for child processes. XRE_SetAndroidChildFds is
the only Android-specific entry point for child processes, so I think
it's the most logical place to initialize JNI.
Bug 1343075 - 5. Support multiple remote GeckoEditableChild; r=esawin
Support remote GeckoEditableChild instances that are created in the
content processes and connect to the parent process GeckoEditableParent
through binders.
Support having multiple GeckoEditableChild instances in GeckoEditable by
keeping track of which child is currently focused, and only allow
calls to/from the focused child by using access tokens.
Bug 1343075 - 6. Add method to get GeckoEditableParent instance; r=esawin
Add IProcessManager.getEditableParent, which a content process can call
to get the GeckoEditableParent instance that corresponds to a given
content process tab, from the main process.
Bug 1343075 - 7. Support GeckoEditableSupport in content processes; r=esawin
Support creating and running GeckoEditableSupport attached to a
PuppetWidget in content processes.
Because we don't know PuppetWidget's lifetime as well as nsWindow's,
when attached to PuppetWidget, we need to attach/detach our native
object on focus/blur, respectively.
Bug 1343075 - 8. Connect GeckoEditableSupport on PuppetWidget creation; r=esawin
Listen to the "tab-child-created" notification and attach our content
process GeckoEditableSupport to the new PuppetWidget.
Bug 1343075 - 9. Update auto-generated bindings; r=me
2017-03-08 06:34:39 +03:00
|
|
|
: mIsRemote(!aWindow)
|
|
|
|
, mWindow(aPtr, aWindow)
|
2017-03-02 21:47:14 +03:00
|
|
|
, mEditable(aEditableChild)
|
Bug 1343075 - Use GeckoEditableSupport from PuppetWidget; r=masayuki r=rbarker r=snorp r=esawin
Bug 1343075 - 1a. Add TextEventDispatcherListener::GetIMEUpdatePreference; r=masayuki
Add a GetIMEUpdatePreference method to TextEventDispatcherListener to
optionally control which IME notifications are received by NotifyIME.
This patch also makes nsBaseWidget forward its GetIMEUpdatePreference
call to the widget's native TextEventDispatcherListener.
Bug 1343075 - 1b. Implement GetIMEUpdatePreference for all TextEventDispatcherListener; r=masayuki
This patch implements GetIMEUpdatePreference for all
TextEventDispatcherListener implementations, by moving previous
implementations of nsIWidget::GetIMEUpdatePreference.
Bug 1343075 - 2. Allow setting a PuppetWidget's native TextEventDispatcherListener; r=masayuki
In PuppetWidget, add getter and setter for the widget's native
TextEventDispatcherListener. This allows overriding of PuppetWidget's
default IME handling. For example, on Android, the PuppetWidget's native
TextEventDispatcherListener will communicate directly with Java IME code
in the main process.
Bug 1343075 - 3. Add AIDL interface for main process; r=rbarker
Add AIDL definition and implementation for an interface for the main
process that child processes can access.
Bug 1343075 - 4. Set Gecko thread JNIEnv for child process; r=snorp
Add a JNIEnv* parameter to XRE_SetAndroidChildFds, which is used to set
the Gecko thread JNIEnv for child processes. XRE_SetAndroidChildFds is
the only Android-specific entry point for child processes, so I think
it's the most logical place to initialize JNI.
Bug 1343075 - 5. Support multiple remote GeckoEditableChild; r=esawin
Support remote GeckoEditableChild instances that are created in the
content processes and connect to the parent process GeckoEditableParent
through binders.
Support having multiple GeckoEditableChild instances in GeckoEditable by
keeping track of which child is currently focused, and only allow
calls to/from the focused child by using access tokens.
Bug 1343075 - 6. Add method to get GeckoEditableParent instance; r=esawin
Add IProcessManager.getEditableParent, which a content process can call
to get the GeckoEditableParent instance that corresponds to a given
content process tab, from the main process.
Bug 1343075 - 7. Support GeckoEditableSupport in content processes; r=esawin
Support creating and running GeckoEditableSupport attached to a
PuppetWidget in content processes.
Because we don't know PuppetWidget's lifetime as well as nsWindow's,
when attached to PuppetWidget, we need to attach/detach our native
object on focus/blur, respectively.
Bug 1343075 - 8. Connect GeckoEditableSupport on PuppetWidget creation; r=esawin
Listen to the "tab-child-created" notification and attach our content
process GeckoEditableSupport to the new PuppetWidget.
Bug 1343075 - 9. Update auto-generated bindings; r=me
2017-03-08 06:34:39 +03:00
|
|
|
, mEditableAttached(!mIsRemote)
|
2017-03-01 23:29:30 +03:00
|
|
|
, mIMERanges(new TextRangeArray())
|
|
|
|
, mIMEMaskEventsCount(1) // Mask IME events since there's no focus yet
|
|
|
|
, mIMEUpdatingContext(false)
|
|
|
|
, mIMESelectionChanged(false)
|
|
|
|
, mIMETextChangedDuringFlush(false)
|
|
|
|
, mIMEMonitorCursor(false)
|
|
|
|
{}
|
|
|
|
|
Bug 1343075 - Use GeckoEditableSupport from PuppetWidget; r=masayuki r=rbarker r=snorp r=esawin
Bug 1343075 - 1a. Add TextEventDispatcherListener::GetIMEUpdatePreference; r=masayuki
Add a GetIMEUpdatePreference method to TextEventDispatcherListener to
optionally control which IME notifications are received by NotifyIME.
This patch also makes nsBaseWidget forward its GetIMEUpdatePreference
call to the widget's native TextEventDispatcherListener.
Bug 1343075 - 1b. Implement GetIMEUpdatePreference for all TextEventDispatcherListener; r=masayuki
This patch implements GetIMEUpdatePreference for all
TextEventDispatcherListener implementations, by moving previous
implementations of nsIWidget::GetIMEUpdatePreference.
Bug 1343075 - 2. Allow setting a PuppetWidget's native TextEventDispatcherListener; r=masayuki
In PuppetWidget, add getter and setter for the widget's native
TextEventDispatcherListener. This allows overriding of PuppetWidget's
default IME handling. For example, on Android, the PuppetWidget's native
TextEventDispatcherListener will communicate directly with Java IME code
in the main process.
Bug 1343075 - 3. Add AIDL interface for main process; r=rbarker
Add AIDL definition and implementation for an interface for the main
process that child processes can access.
Bug 1343075 - 4. Set Gecko thread JNIEnv for child process; r=snorp
Add a JNIEnv* parameter to XRE_SetAndroidChildFds, which is used to set
the Gecko thread JNIEnv for child processes. XRE_SetAndroidChildFds is
the only Android-specific entry point for child processes, so I think
it's the most logical place to initialize JNI.
Bug 1343075 - 5. Support multiple remote GeckoEditableChild; r=esawin
Support remote GeckoEditableChild instances that are created in the
content processes and connect to the parent process GeckoEditableParent
through binders.
Support having multiple GeckoEditableChild instances in GeckoEditable by
keeping track of which child is currently focused, and only allow
calls to/from the focused child by using access tokens.
Bug 1343075 - 6. Add method to get GeckoEditableParent instance; r=esawin
Add IProcessManager.getEditableParent, which a content process can call
to get the GeckoEditableParent instance that corresponds to a given
content process tab, from the main process.
Bug 1343075 - 7. Support GeckoEditableSupport in content processes; r=esawin
Support creating and running GeckoEditableSupport attached to a
PuppetWidget in content processes.
Because we don't know PuppetWidget's lifetime as well as nsWindow's,
when attached to PuppetWidget, we need to attach/detach our native
object on focus/blur, respectively.
Bug 1343075 - 8. Connect GeckoEditableSupport on PuppetWidget creation; r=esawin
Listen to the "tab-child-created" notification and attach our content
process GeckoEditableSupport to the new PuppetWidget.
Bug 1343075 - 9. Update auto-generated bindings; r=me
2017-03-08 06:34:39 +03:00
|
|
|
// Constructor for content process GeckoEditableChild.
|
|
|
|
GeckoEditableSupport(java::GeckoEditableChild::Param aEditableChild)
|
|
|
|
: GeckoEditableSupport(nullptr, nullptr, aEditableChild)
|
|
|
|
{}
|
|
|
|
|
2017-03-01 23:29:30 +03:00
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
|
|
|
|
// TextEventDispatcherListener methods
|
|
|
|
NS_IMETHOD NotifyIME(TextEventDispatcher* aTextEventDispatcher,
|
|
|
|
const IMENotification& aNotification) override;
|
|
|
|
|
2017-04-11 15:24:55 +03:00
|
|
|
NS_IMETHOD_(IMENotificationRequests) GetIMENotificationRequests() override;
|
Bug 1343075 - Use GeckoEditableSupport from PuppetWidget; r=masayuki r=rbarker r=snorp r=esawin
Bug 1343075 - 1a. Add TextEventDispatcherListener::GetIMEUpdatePreference; r=masayuki
Add a GetIMEUpdatePreference method to TextEventDispatcherListener to
optionally control which IME notifications are received by NotifyIME.
This patch also makes nsBaseWidget forward its GetIMEUpdatePreference
call to the widget's native TextEventDispatcherListener.
Bug 1343075 - 1b. Implement GetIMEUpdatePreference for all TextEventDispatcherListener; r=masayuki
This patch implements GetIMEUpdatePreference for all
TextEventDispatcherListener implementations, by moving previous
implementations of nsIWidget::GetIMEUpdatePreference.
Bug 1343075 - 2. Allow setting a PuppetWidget's native TextEventDispatcherListener; r=masayuki
In PuppetWidget, add getter and setter for the widget's native
TextEventDispatcherListener. This allows overriding of PuppetWidget's
default IME handling. For example, on Android, the PuppetWidget's native
TextEventDispatcherListener will communicate directly with Java IME code
in the main process.
Bug 1343075 - 3. Add AIDL interface for main process; r=rbarker
Add AIDL definition and implementation for an interface for the main
process that child processes can access.
Bug 1343075 - 4. Set Gecko thread JNIEnv for child process; r=snorp
Add a JNIEnv* parameter to XRE_SetAndroidChildFds, which is used to set
the Gecko thread JNIEnv for child processes. XRE_SetAndroidChildFds is
the only Android-specific entry point for child processes, so I think
it's the most logical place to initialize JNI.
Bug 1343075 - 5. Support multiple remote GeckoEditableChild; r=esawin
Support remote GeckoEditableChild instances that are created in the
content processes and connect to the parent process GeckoEditableParent
through binders.
Support having multiple GeckoEditableChild instances in GeckoEditable by
keeping track of which child is currently focused, and only allow
calls to/from the focused child by using access tokens.
Bug 1343075 - 6. Add method to get GeckoEditableParent instance; r=esawin
Add IProcessManager.getEditableParent, which a content process can call
to get the GeckoEditableParent instance that corresponds to a given
content process tab, from the main process.
Bug 1343075 - 7. Support GeckoEditableSupport in content processes; r=esawin
Support creating and running GeckoEditableSupport attached to a
PuppetWidget in content processes.
Because we don't know PuppetWidget's lifetime as well as nsWindow's,
when attached to PuppetWidget, we need to attach/detach our native
object on focus/blur, respectively.
Bug 1343075 - 8. Connect GeckoEditableSupport on PuppetWidget creation; r=esawin
Listen to the "tab-child-created" notification and attach our content
process GeckoEditableSupport to the new PuppetWidget.
Bug 1343075 - 9. Update auto-generated bindings; r=me
2017-03-08 06:34:39 +03:00
|
|
|
|
2017-03-01 23:29:30 +03:00
|
|
|
NS_IMETHOD_(void) OnRemovedFrom(
|
|
|
|
TextEventDispatcher* aTextEventDispatcher) override;
|
|
|
|
|
|
|
|
NS_IMETHOD_(void) WillDispatchKeyboardEvent(
|
|
|
|
TextEventDispatcher* aTextEventDispatcher,
|
|
|
|
WidgetKeyboardEvent& aKeyboardEvent,
|
|
|
|
uint32_t aIndexOfKeypress,
|
|
|
|
void* aData) override;
|
|
|
|
|
|
|
|
void SetInputContext(const InputContext& aContext,
|
|
|
|
const InputContextAction& aAction);
|
|
|
|
|
|
|
|
InputContext GetInputContext();
|
|
|
|
|
2017-03-02 21:47:14 +03:00
|
|
|
// GeckoEditableChild methods
|
2017-03-01 23:29:30 +03:00
|
|
|
using EditableBase::AttachNative;
|
|
|
|
|
|
|
|
void OnDetach() {
|
2017-03-02 21:47:14 +03:00
|
|
|
RefPtr<GeckoEditableSupport> self(this);
|
Bug 1343075 - Use GeckoEditableSupport from PuppetWidget; r=masayuki r=rbarker r=snorp r=esawin
Bug 1343075 - 1a. Add TextEventDispatcherListener::GetIMEUpdatePreference; r=masayuki
Add a GetIMEUpdatePreference method to TextEventDispatcherListener to
optionally control which IME notifications are received by NotifyIME.
This patch also makes nsBaseWidget forward its GetIMEUpdatePreference
call to the widget's native TextEventDispatcherListener.
Bug 1343075 - 1b. Implement GetIMEUpdatePreference for all TextEventDispatcherListener; r=masayuki
This patch implements GetIMEUpdatePreference for all
TextEventDispatcherListener implementations, by moving previous
implementations of nsIWidget::GetIMEUpdatePreference.
Bug 1343075 - 2. Allow setting a PuppetWidget's native TextEventDispatcherListener; r=masayuki
In PuppetWidget, add getter and setter for the widget's native
TextEventDispatcherListener. This allows overriding of PuppetWidget's
default IME handling. For example, on Android, the PuppetWidget's native
TextEventDispatcherListener will communicate directly with Java IME code
in the main process.
Bug 1343075 - 3. Add AIDL interface for main process; r=rbarker
Add AIDL definition and implementation for an interface for the main
process that child processes can access.
Bug 1343075 - 4. Set Gecko thread JNIEnv for child process; r=snorp
Add a JNIEnv* parameter to XRE_SetAndroidChildFds, which is used to set
the Gecko thread JNIEnv for child processes. XRE_SetAndroidChildFds is
the only Android-specific entry point for child processes, so I think
it's the most logical place to initialize JNI.
Bug 1343075 - 5. Support multiple remote GeckoEditableChild; r=esawin
Support remote GeckoEditableChild instances that are created in the
content processes and connect to the parent process GeckoEditableParent
through binders.
Support having multiple GeckoEditableChild instances in GeckoEditable by
keeping track of which child is currently focused, and only allow
calls to/from the focused child by using access tokens.
Bug 1343075 - 6. Add method to get GeckoEditableParent instance; r=esawin
Add IProcessManager.getEditableParent, which a content process can call
to get the GeckoEditableParent instance that corresponds to a given
content process tab, from the main process.
Bug 1343075 - 7. Support GeckoEditableSupport in content processes; r=esawin
Support creating and running GeckoEditableSupport attached to a
PuppetWidget in content processes.
Because we don't know PuppetWidget's lifetime as well as nsWindow's,
when attached to PuppetWidget, we need to attach/detach our native
object on focus/blur, respectively.
Bug 1343075 - 8. Connect GeckoEditableSupport on PuppetWidget creation; r=esawin
Listen to the "tab-child-created" notification and attach our content
process GeckoEditableSupport to the new PuppetWidget.
Bug 1343075 - 9. Update auto-generated bindings; r=me
2017-03-08 06:34:39 +03:00
|
|
|
nsAppShell::PostEvent([this, self] {
|
|
|
|
mEditableAttached = false;
|
|
|
|
DisposeNative(mEditable);
|
2017-03-02 21:47:14 +03:00
|
|
|
});
|
2017-03-01 23:29:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// Handle an Android KeyEvent.
|
|
|
|
void OnKeyEvent(int32_t aAction, int32_t aKeyCode, int32_t aScanCode,
|
|
|
|
int32_t aMetaState, int32_t aKeyPressMetaState,
|
|
|
|
int64_t aTime, int32_t aDomPrintableKeyValue,
|
|
|
|
int32_t aRepeatCount, int32_t aFlags,
|
|
|
|
bool aIsSynthesizedImeKey,
|
|
|
|
jni::Object::Param originalEvent);
|
|
|
|
|
|
|
|
// Synchronize Gecko thread with the InputConnection thread.
|
|
|
|
void OnImeSynchronize();
|
|
|
|
|
|
|
|
// Replace a range of text with new text.
|
|
|
|
void OnImeReplaceText(int32_t aStart, int32_t aEnd,
|
|
|
|
jni::String::Param aText);
|
|
|
|
|
|
|
|
// Add styling for a range within the active composition.
|
|
|
|
void OnImeAddCompositionRange(int32_t aStart, int32_t aEnd,
|
|
|
|
int32_t aRangeType, int32_t aRangeStyle, int32_t aRangeLineStyle,
|
|
|
|
bool aRangeBoldLine, int32_t aRangeForeColor,
|
|
|
|
int32_t aRangeBackColor, int32_t aRangeLineColor);
|
|
|
|
|
|
|
|
// Update styling for the active composition using previous-added ranges.
|
2017-04-28 03:59:42 +03:00
|
|
|
void OnImeUpdateComposition(int32_t aStart, int32_t aEnd, int32_t aFlags);
|
2017-03-01 23:29:30 +03:00
|
|
|
|
|
|
|
// Set cursor mode whether IME requests
|
|
|
|
void OnImeRequestCursorUpdates(int aRequestMode);
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace widget
|
|
|
|
} // namespace mozill
|
|
|
|
|
|
|
|
#endif // mozilla_widget_GeckoEditableSupport_h
|