Commit Graph
112 Commits
Author SHA1 Message Date
Masayuki Nakano 7310f1cf4d Bug 1904192 - Make TextControlState::SetValue suppress TextEditor to dispatch input events even after dispatching input event during composition r=m_kato,geckoview-reviewers
`input` event listeners may be async functions and may set the text control
element value after the editor ends dispatching an `input` event.  Even in this
case, the `input` event listener should not be called recursively by committing
composition which is caused by setting the value because the value is
overwritten by the setting value which was intended by the web app.

Unfortunately, we cannot check whether the value setter is an async `input`
event listener.  Therefore, we need to suppress `input` events even after the
editor ends dispatching `input` event.

On the other hand, we should not suppress `input` event if the value is set
by a `compositionupdate` event listener which runs before the editor starts
handling the latest composition change because once we do that, the app won't
receive `input` event for the composition.  Therefore, we should not suppress
the editor starts handling the composition change (including during
`beforeinput` event dispatching, but the `beforeinput` is not cancelable, so,
the result will be odd, therefore, we have no tests for the cases).

Therefore, this patch adds a new method to `TextComposition` to make
`TextControlState::SetValue` can check whether the editor is handling the
latest composition change or after that.  So, during composition, setting
value should cause `input` events between `TextComposition` starts dispatching a
`compositionupdate` event and `EditorBase` starts handling `eCompositionChange`
event which is dispatched after `compositionupdate`.

Differential Revision: https://phabricator.services.mozilla.com/D214676
2024-06-25 03:52:54 +00:00
Makoto Kato b122cf296c Bug 1888330 - Don't use composition if unnecessary. r=geckoview-reviewers,masayuki,ohall
Chrome/Android doesn't dispatch composition event when
`InputConnection.commitText` is called from input method without composition.

So we should use same way as compatibility.

Differential Revision: https://phabricator.services.mozilla.com/D210197
2024-05-31 10:21:33 +00:00
Masayuki Nakano c6185be88c Bug 1832726 - part 1: Make Android widget always dispatch keyboard events during composition r=m_kato,geckoview-reviewers
I think that we don't need the prefs to disable the behavior because the
behavior conforms to UI Events definition and we've shipped the behavior in
2018.  Therefore, nobody shouldn't require to disable the behavior.

Differential Revision: https://phabricator.services.mozilla.com/D177999
2023-05-16 22:42:59 +00:00
Makoto Kato bc53997204 Bug 1827386 - Part 1. NativeWeakPtr::Detach returns MozPromise to detect whether dispoer is finished. r=geckoview-reviewers,owlish
Actually, `NativeWeakPtr::Detach` may not release JNI ojbect immediately because
it depends on JNI object's `OnWeakNonIntrusiveDetach`i implementation.
`SessionAccessibility`'s `OnWeakNonIntrusiveDetach` implementation uses the
runnable to run on Android UI thread then disposer runs on main thread, so
if Detach is finished, JNI object isn't detached yet.

If calling `NativeWeakPtrHolder::Attach` immediately with same/recycled Java
object after `NettiveWeakPtr::Detach`, it is possible to run disposer for JNI
object by `OnWeakNonIntrusiveDetach` after Attach is finished. So it may
release newer attached object unfortunately.

So I would like to add a way to waiting for detach JNI object using
`MozPromise`.

Also, `MozPromise.h` includes `Natives.h` header (for `GeckoResult` support).
So I cannot modify inline method to use `MozPromise` due to recursive. So I
split implementation with `NativesInlines.h` as workaround.

Differential Revision: https://phabricator.services.mozilla.com/D175335
2023-05-09 05:13:32 +00:00
Olli Pettay f18298c006 Bug 1807812 - Remove WidgetEventTime::mTime, r=masayuki,geckoview-reviewers,m_kato
HTMLSelectEventListener changes are needed, since currently that code works somewhat by accident given that
mTime often contains totally bogus values, like PR_IntervalNow(). Those changes then reveal issues also in
browser_editAddressDialog.js.

Differential Revision: https://phabricator.services.mozilla.com/D165618
2023-01-02 12:31:40 +00:00
Makoto Kato 3a87cc5be5 Bug 1714496 - Part 1. Implement Image keyboard support. r=geckoview-reviewers,calu
GBoard has image keyboard support, and spec issue is resolved [*1]. So this
adds image keyboard support via GBoard and Android 7.1+.

*1 https://github.com/w3c/input-events/issues/117

Differential Revision: https://phabricator.services.mozilla.com/D157713
2022-10-07 09:03:31 +00:00
Masayuki Nakano 76e8fb822d Bug 1792515 - Rename InputContext::mHTMLInputInputmode to mHTMLInputMode r=m_kato,geckoview-reviewers
Now, `inputmode` attribute (`inputMode` in the DOM interface) is a global
attribute for `contenteditable`.  Therefore, `Input` is not necessary and
`Inputmode` should be `InputMode`.

Differential Revision: https://phabricator.services.mozilla.com/D158244
2022-09-29 14:06:03 +00:00
Sandor Molnar 761cdbb956 Backed out changeset a00513981ecf (bug 1792515) for causing bug 1792767 CLOSED TREE 2022-09-29 04:56:22 +03:00
Masayuki Nakano fe522290da Bug 1792515 - Rename InputContext::mHTMLInputInputmode to mHTMLInputMode r=m_kato,geckoview-reviewers
Now, `inputmode` attribute (`inputMode` in the DOM interface) is a global
attribute for `contenteditable`.  Therefore, `Input` is not necessary and
`Inputmode` should be `InputMode`.

Depends on D157894

Differential Revision: https://phabricator.services.mozilla.com/D158244
2022-09-28 23:55:23 +00:00
Makoto Kato 08350f39b6 Bug 1778277 - Don't use native key bindings to dispatch process key. r=masayuki,geckoview-reviewers,owlish
GeckoView dispatch keyboard event to child process directly and it doesn't
support non-e10s mode. But since about:config will run on chrome process,
GeckoView will dispatch it to parent process.

By bug 1430241, we don't use native key binding when dispatching key event on
parent process. But we forget it for process key event. So even if process key,
we shouldn't use native key binding.

Differential Revision: https://phabricator.services.mozilla.com/D153416
2022-08-04 00:44:43 +00:00
Makoto Kato 445040a49a Bug 1767556 - Don't remove composing state when composition is started from first character. r=geckoview-reviewers,agi
This occurs since newer GBoard's behaviour seems to be changed.

When `GeckoEditable` receives text change from Gecko, it is possible to remove
composing state if composition is started from first character.

If Gecko's text change by IME, we shouldn't reset text state in `onTextChange`.
`mCausedOnlyByComposition` means that this change is by IME.

Differential Revision: https://phabricator.services.mozilla.com/D146159
2022-05-15 07:27:48 +00:00
Makoto Kato cdae332d33 Bug 1761176 - Set insertion marker location for IME. r=geckoview-reviewers,agi
When using Android with physical keyboard, IME's candidate window is sometimes
misplaced. Some IME/keyboards require insertion marker location to set IME's
candidate window position.

So we should set it from caret rectangle.

Differential Revision: https://phabricator.services.mozilla.com/D141931
2022-03-28 05:29:21 +00:00
Masayuki Nakano 96abd21908 Bug 1746104 - part 6-1: Make IMENotification::SelectionChangeDataBase and WidgetQueryContentEvent::Reply have AnchorOffset and FocusOffset r=m_kato,geckoview-reviewers
`StartOffset` and `EndOffset` of `IMENotification::SelectionChangeDataBase`
depend on whether the range is reversed or not.  Therefore, their actual
meaning is "anchor offset" and "focus offset" in the DOM selection terms.

Similarly, `SelectionStartOffset` and `SelectionEndOffset` of
`WidgetQueryContentEvent::Reply` are exactly same ones.

Therefore, they should be renamed to `AnchorOffset` and `FocusOffset` for
making what they return clearer.

Differential Revision: https://phabricator.services.mozilla.com/D137427
2022-02-07 22:33:39 +00:00
Masayuki Nakano 01a0864593 Bug 1746104 - part 5-4: Make widget code handle no selection case at getting selection change notifications r=m_kato,geckoview-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D137425
2022-02-07 22:33:38 +00:00
Makoto Kato a586a2c9fc Bug 1597897 - Use LayoutDeviceIntRect directly for IME composition rect. r=geckoview-reviewers,agi
Actually `nsIWidget::GetDefaultScale()` will always return 1.0 on GeckoView
([*1] and [*2]). When calculating CSS rect, although we have to consider zoom
factor too, but `ConvertRectArrayToJavaRectFArray` doesn't yet. So then,
GeckoView will notify IME of incorrect rect.

Now we already know the layout device rect, so we should use it directly
instead of converting to CSS unit.

Also, there is no way to add tests since we cannot have the physical keyboard
tests on geckoview-junit.

*1 https://searchfox.org/mozilla-central/rev/4646b826a25d3825cf209db890862b45fa09ffc3/widget/android/nsWindow.cpp#1919-1928
*2 https://searchfox.org/mozilla-central/rev/4646b826a25d3825cf209db890862b45fa09ffc3/widget/android/ScreenHelperAndroid.cpp#39-41

Differential Revision: https://phabricator.services.mozilla.com/D133710
2021-12-15 02:13:03 +00:00
Nika Layzell 0e975d0e8d Bug 1741665 - Align nsCString's public size_type better with other C++ APIs, r=mccr8,geckoview-reviewers,agi
Differential Revision: https://phabricator.services.mozilla.com/D131422
2021-12-13 21:47:56 +00:00
Makoto Kato f4565062c4 Bug 1741312 - Set reversed selection from selection cache. r=geckoview-reviewers,agi
This is a regression of bug 1724811.

I should consider that selection order is reversed when fixing bug 1724811.

Differential Revision: https://phabricator.services.mozilla.com/D131196
2021-11-17 02:32:45 +00:00
Makoto Kato f19b239892 Bug 1724811 - Use selection data from notification instead of get current selection. r=geckoview-reviewers,agi
Although root cause isn't bug 1713334, this occurs after landing it.

When inputting "." by Swiftkey, it generates key event then dispatches it to
Gecko. After text is changed by this key event, we will update this change
to GeckoView.

But when this occurs, we post invalid selection change to GeckoView, then
`GeckoEditableChild` throws `IllegalArgumentException`.

Normal
======
1. Dispatch "." text change.
2. Receive text and selection change notification by 1.
3. Posted text/selection change notification to GV's parent

This situation
==============
1. Dispatch "." text change.
2. Receive text and selection change notification by 1.
3. Dispatch next "." text change.
4. Posted 2.'s text/selection change notification to GV's parent.
5. `GeckoEditableChild` throws `IllegalArgumentException`.

So when step 4.., we should use 2.'s change data. But since we query current
Gecko's selection data, we may use invalid selection data.

So we should cache selection change, then use it.

Differential Revision: https://phabricator.services.mozilla.com/D124435
2021-09-06 12:38:26 +00:00
Makoto Kato ccfe92e588 Bug 1670129 - Changing inputmode to none should dismiss software keyboard. r=geckoview-reviewers,agi
When focus isn't changed and inputmode in focused element is changed to none,
we should dismiss software keyboard.

Also, this has same issue for changing from none to text to show software
keyboard.

When changing inputmode, icNotifyIMEContext is called then we should control
software keyboard open/close state too.

Differential Revision: https://phabricator.services.mozilla.com/D122491
2021-08-30 01:30:30 +00:00
Makoto Kato 6027bd9464 Bug 1724850 - Don't show software keyboard for some input types. r=geckoview-reviewers,agi
When re-focusing input type that has the prompt such as `<input type=week>`,
we show software keyboard unfortunately. We shouldn't show it.

Differential Revision: https://phabricator.services.mozilla.com/D122198
2021-08-16 17:35:14 +00:00
Makoto Kato e96b56c3f3 Bug 1713588 - Don't sync shadow text during composing. r=geckoview-reviewers,agi
Gecko's text API has a hint whether text change notification is by IME
composing. If by IME composing, it is unnecessary to synchronize it by
onSelectionChange because JavaScript doesn't block/change inputted text.
It means that shadow (Java) text is always matched to Gecko text.

So we don't have to synchronize shadow text during composing.

Differential Revision: https://phabricator.services.mozilla.com/D116476
2021-06-08 00:33:59 +00:00
Makoto Kato 547ab48654 Bug 1655896 -Use TextChangeData.MergeWith instead. r=geckoview-reviewers,agi
deleteSurroundingText may create multiple text transactions. This test
failure occurs when multiple text transactions are dispatched to Gecko.

GeckoEditableSupport records text changes by Gecko then it notifies Java
of text changes. And it merges old text changes with new text changes by
AddIMETextChange to reduce JNI/Binder calls if possible.

This issue is that AddIMETextChange creates incorrect text change range
by merging text change ranges.

Actually, TextChangeData already has merge function now, so we should use it
instead of own merge function in GeckoEditableSupport.

Differential Revision: https://phabricator.services.mozilla.com/D111207
2021-04-12 03:14:24 +00:00
Makoto Kato fa2ca7fc51 Bug 1650705 - Don't dispatch unnecessary input event when we dispatch composition start with selected text. r=geckoview-reviewers,agi
Actually, before starting composition, we always remove current selected
text. So it causes that input event is fired by this operation. This is
different of Blink.

`TextEventDispatcher` can set composition string using selected text when
starting composition. So we can reduce this input event.

Also, I mistake bug 1499076 fix. By this fix, we always fires input event
when having selected text even if it is unnecessary. This changeset has
this fix too.

Differential Revision: https://phabricator.services.mozilla.com/D105464
2021-02-21 17:12:13 +00:00
Makoto Kato 22b37e61da Bug 1684967 - Don't dispose GeckoEditableChild during JNI call. r=geckoview-reviewers,aklotz
This is a regression by bug 1651705.

After landing it, we use read-write lock to access GeckoEditableChild object.
But when using form submission with target=_blank, since we use some nested
event loop to open new window in same process, we may try to dispose
GeckoEditableChild even if it is still used. Then, it may be dead lock.

So I add a blocker class helper not to dispose GeckoEditableChild immediately.

Differential Revision: https://phabricator.services.mozilla.com/D103742
2021-02-04 06:23:54 +00:00
Masayuki Nakano 9c26cefd0e Bug 1683226 - part 1: Make IMEState::Enabled an enum class r=m_kato,geckoview-reviewers
Before deleting `IMEState::Enabled::PLUGIN`, let's make it an enum class
for making the change safer.  Almost all of this change is done by
"replace" of VSCode.

Differential Revision: https://phabricator.services.mozilla.com/D100100
2020-12-21 05:52:03 +00:00
Masayuki Nakano 7e741e472e Bug 1678553 - part 13: Make WidgetQueryContentEvent use Maybe to store some data r=m_kato,geckoview-reviewers
Sorry for this big patch.

This makes `WidgetQueryContentEvent::Reply` is stored with `Maybe` to get
rid of `WidgetQueryContentEvent`.  And `Reply` stores offset and string
with `Maybe` and ``OffsetAndData<uint32_t>`, and also tentative caret offset
with `Maybe`.  Then, we can get rid of `WidgetQueryContentEvent::NOT_FOUND`.

Note that I tried to make `OffsetAndData` have a method to create `NSRange`
for cocoa widget.  However, it causes the column limit`to 100 or longer
and that causes unrelated changes in `TextEvents.h` and `IMEData.h`.
Therefore, I create an inline function in `TextInputHandler.mm` instead.

Differential Revision: https://phabricator.services.mozilla.com/D98264
2020-12-02 05:32:19 +00:00
Simon Giesecke 46908cfb51 Bug 1660470 - Add missing include directives/forward declarations. r=nika
Differential Revision: https://phabricator.services.mozilla.com/D87865
2020-11-23 16:21:38 +00:00
Sylvestre Ledru 2785fba8c1 Bug 1519636 - Reformat with clang-format-11 to the Google coding style r=andi,sg,geckoview-reviewers,snorp
It is bringing some minor changes

# ignore-this-changeset

Differential Revision: https://phabricator.services.mozilla.com/D90795
2020-11-18 09:05:59 +00:00
Makoto Kato 3312eb0ef4 Bug 1666796 - Replace ALOGIME with MOZ_LOG in GeckoEditableSupport on Nightly. r=geckoview-reviewers,agi
When debugging text issue on GV, I sometimes enable `DEBUG_ANDROID_IME` to
output log. But I think that it is better to use `MOZ_LOG` since we can get
the log on Fenix build.

If using GVE, we can output log via the following command.

```
adb shell am start -n org.mozilla.geckoview_example/.GeckoViewActivity --es env0 "MOZ_LOG=GeckoEditableSupport:5"
```

But this change is Nightly only due to footprint etc at first.

Differential Revision: https://phabricator.services.mozilla.com/D92449
2020-10-05 16:11:02 +00:00
Makoto Kato 7d4ec260d8 Bug 1425291 - Part 5. Support autocalitalize attribute on GeckoView. r=geckoview-reviewers,snorp
`android.view.inputmethod.EditorInfo` has `inputType` feild that can control
capitalize of software keyboard. GeckoView should use it for autocapitalize
attribute support.

Differential Revision: https://phabricator.services.mozilla.com/D86678
2020-09-15 14:26:21 +00:00
Aaron Klotz 3d3e9d4835 Bug 1651705: Part 5 - GeckoEditableSupport updates to support NativeWeakPtr; r=m_kato,geckoview-reviewers
This patch is similar to part 4 but for `GeckoEditableSupport`.

Conversions over to `NativeWeakPtr` are pretty straight forward thanks to the
type system.  Basically we take a `NativeWeakPtr`, call `Access()` on it, and
if the accessor is truthy, then we call whatever methods we need to call.

Creation of new pointers is done using `NativeWeakPtrHolder::Attach()` and
detaching of strong references is done by `NativeWeakPtr::Detach()`.

Differential Revision: https://phabricator.services.mozilla.com/D87364
2020-09-21 21:48:44 +00:00
Butkovits Atila db3fabb58e Backed out 7 changesets (bug 1651705) as requested by Aklotz. CLOSED TREE
Backed out changeset 60730e8394ae (bug 1651705)
Backed out changeset c441ae751191 (bug 1651705)
Backed out changeset c289f06ceba2 (bug 1651705)
Backed out changeset d4491ef94b3e (bug 1651705)
Backed out changeset 1cca90ffab83 (bug 1651705)
Backed out changeset 9b1ce53e6472 (bug 1651705)
Backed out changeset a31251ba4566 (bug 1651705)
2020-09-01 20:39:15 +03:00
Aaron Klotz 1f438e8bcb Bug 1651705: Part 5 - GeckoEditableSupport updates to support NativeWeakPtr; r=m_kato,geckoview-reviewers
This patch is similar to part 4 but for `GeckoEditableSupport`.

Conversions over to `NativeWeakPtr` are pretty straight forward thanks to the
type system.  Basically we take a `NativeWeakPtr`, call `Access()` on it, and
if the accessor is truthy, then we call whatever methods we need to call.

Creation of new pointers is done using `NativeWeakPtrHolder::Attach()` and
detaching of strong references is done by `NativeWeakPtr::Detach()`.

Differential Revision: https://phabricator.services.mozilla.com/D87364
2020-09-01 14:34:29 +00:00
Narcis Beleuzu dd6345077d Backed out 7 changesets (bug 1651705) for mochitest failures on test_resizers_resizing_elements.html . CLOSED TREE
Backed out changeset 7fd32a3fb6e7 (bug 1651705)
Backed out changeset de4edbcb15c1 (bug 1651705)
Backed out changeset 531e71369f68 (bug 1651705)
Backed out changeset 84590e96de88 (bug 1651705)
Backed out changeset 7d9d2d44b2ee (bug 1651705)
Backed out changeset 9ffca762753c (bug 1651705)
Backed out changeset 2d79f4348b36 (bug 1651705)
2020-08-28 23:06:39 +03:00
Aaron Klotz 3b95d25478 Bug 1651705: Part 5 - GeckoEditableSupport updates to support NativeWeakPtr; r=m_kato,geckoview-reviewers
This patch is similar to part 4 but for `GeckoEditableSupport`.

Conversions over to `NativeWeakPtr` are pretty straight forward thanks to the
type system.  Basically we take a `NativeWeakPtr`, call `Access()` on it, and
if the accessor is truthy, then we call whatever methods we need to call.

Creation of new pointers is done using `NativeWeakPtrHolder::Attach()` and
detaching of strong references is done by `NativeWeakPtr::Detach()`.

Differential Revision: https://phabricator.services.mozilla.com/D87364
2020-08-27 20:14:45 +00:00
Makoto Kato 5faa3c257c Bug 1653862 - Set InputContext after getting focus. r=geckoview-reviewers,snorp
This is timing issue to set `InputContext` that is used by setting keyboard
layout.

`InputContext` is set by chrome process only. Since we want to use it on
child process, we store cached value by `NOTIFY_IME_OF_FOCUS`. But before
setting it, we may use old cached value unfortunately.

So we have to wait until valid cached `InputContext` is set.

Also, I add some assertions for this check.

Differential Revision: https://phabricator.services.mozilla.com/D85821
2020-08-06 18:02:20 +00:00
Makoto Kato 4540d12294 Bug 1651257 - iFLYTEC IME often commits composition string unfortunately. r=geckoview-reviewers,snorp
This is timing issue when using iFLYTEC keyboard in Xiaomi App Store.

Although replace text transaction often dispatch dummy text change, it may be
unnecessary when other text change is already in text change queue. This issue
occurs if dummy text change is dispatched in the queue and other text change
is also dispatched in the queue.

`AddIMETextChange` merges old text change with newer text change when its range
is overlapped, but it doesn't consider range is same. So if same range, we
should adjust old end simply.

GV-junit test case emulates this situation, but since this is timing issue,
we won't reproduce this by this test case. But it is useful to check future
regressions.

Differential Revision: https://phabricator.services.mozilla.com/D84140
2020-07-21 13:50:46 +00:00
Makoto Kato cb5c64d241 Bug 1633621 - Synchronize Java text and Gecko text at force when getting focus. r=geckoview-reviewers,agi
If client script wants to commit composition string per input, it sometimes
use the following script.

```
let input = document.getElementById('input');
input.addEventListener('input', () => {
  input.blur();
  input.focus();
});
```

Since `blur` will commit composition string, this script can commit text. But
since Gecko has an optimization for this situation, focus won't be lost
completely.

Although GeckoView synchronizes Java text and selection with Gecko text when
getting focus, this sample may be failed due to timing issue. `blur` tries to
commit string, but result is never returned since focus is lost as temporary
(although text is finally committed in Gecko.). Then, GeckoView are waiting
for result that is never returned forever, So this synchronization is failed.

When getting focus again, we should synchronize it at force.

Differential Revision: https://phabricator.services.mozilla.com/D80147
2020-07-06 16:26:08 +00:00
Makoto Kato 161b8fe759 Bug 1593683 - Part 2. Handle arrow left/right key when having composition. r=geckoview-reviewers,esawin
Most IMEs handle arrow key, then set caret position by IME. But GBoard doesn't
handle it. GBoard will dispatch key event to application for arrow left/right
even if having IME composition.

Since Gecko doesn't dispatch key press during IME composition due to DOM UI
events spec, we have to emulate arrow key's behaviour.

And, `GeckoEditable` has a hack that composition text is committed when
dispatching key event. This hack is unnecessary after landing
bug 1613804 that `InputConnection.finishComposingText` is implemented.

Differential Revision: https://phabricator.services.mozilla.com/D76658
2020-06-01 08:36:29 +00:00
Makoto Kato 21bec2f883 Bug 1593683 - Part 1. Restore caret position after committing composition. r=geckoview-reviewers,esawin
When calling `InputConnection.finishComposingText` commits composition string,
but caret position isn't changed. But
`RemoveComposition(COMMIT_IME_COMPOSITION)` sets caret position to end of
string.

So we have to restore caret position after calling
`RemoveComposition(COMMIT_IME_COMPOSITION)` via `finishComposingText`.

Differential Revision: https://phabricator.services.mozilla.com/D76657
2020-06-01 08:36:26 +00:00
Mihai Alexandru Michis a4a8dd1067 Backed out 2 changesets (bug 1593683) for causing failures in test_selectevents.html
Backed out changeset 05d7ad574df4 (bug 1593683)
Backed out changeset 16cc9284bc5f (bug 1593683)
2020-06-01 06:29:24 +03:00
Makoto Kato e37e9e2446 Bug 1593683 - Part 2. Handle arrow left/right key when having composition. r=geckoview-reviewers,esawin
Most IMEs handle arrow key, then set caret position by IME. But GBoard doesn't
handle it. GBoard will dispatch key event to application for arrow left/right
even if having IME composition.

Since Gecko doesn't dispatch key press during IME composition due to DOM UI
events spec, we have to emulate arrow key's behaviour.

And, `GeckoEditable` has a hack that composition text is committed when
dispatching key event. This hack is unnecessary after landing
bug 1613804 that `InputConnection.finishComposingText` is implemented.

Differential Revision: https://phabricator.services.mozilla.com/D76658
2020-05-28 15:38:03 +00:00
Makoto Kato c661d9a74a Bug 1593683 - Part 1. Restore caret position after committing composition. r=geckoview-reviewers,esawin
When calling `InputConnection.finishComposingText` commits composition string,
but caret position isn't changed. But
`RemoveComposition(COMMIT_IME_COMPOSITION)` sets caret position to end of
string.

So we have to restore caret position after calling
`RemoveComposition(COMMIT_IME_COMPOSITION)` via `finishComposingText`.

Differential Revision: https://phabricator.services.mozilla.com/D76657
2020-05-28 15:38:03 +00:00
Makoto Kato 3161da9a83 Bug 1639071 - Don't dispatch key press when key down handler calls preventDefault. r=geckoview-reviewers,esawin
If key down event handler calls `event.preventDefault()`, web browser
shouldn't fire key press event. But GeckoView may fire key press
unfortunately if using software keyboard.

So we don't fire key press event when dispatching `eKeyDown` returns
`nsEventStatus_eConsumeNoDefault`.

Differential Revision: https://phabricator.services.mozilla.com/D75981
2020-05-30 07:00:46 +00:00
Aaron Klotz 383ce64df3 Bug 1637452: Part 1 - Fix JNI includes in widget/android; r=geckoview-reviewers,agi
Differential Revision: https://phabricator.services.mozilla.com/D75364
2020-05-15 17:04:10 +00:00
Makoto Kato d5505908fc Bug 1596920 - Don't set selection on dispatching key event if unnecessary. r=geckoview-reviewers,snorp
Actually we emulate key event (down, press and up) from replace transaction of
`Editable`. When dispatching key press, we always update current caret position.

Most situations is the following.
1. Dispatch keypress
2. Dispatch another keypress
3. Receive merged text/selection change result by 1. and 2.
4. Sync shadow (Java's Editable) text with 3.'s result. It means selection is
   correct position now.
5. Dispatch keypress with correct position.

When this issue occurs, the following situation occurs.
1. Dispatch keypress
2. Dispatch another keypress
3. Receive text/selection change result of 1.
4. Sync shadow (Java's Editable) text with 3.'s result. It means selection is
   old position now.
5. Dispatch another keypress with old position.
6. Receive text/selection change result of 2.
7. Receive text/selection change result of 5.

So when dispatching key press, we shouldn't always update selection if unnecessary.
Because selection range is already often set before dispatching key press.

Differential Revision: https://phabricator.services.mozilla.com/D71179
2020-04-28 14:02:10 +00:00
Makoto Kato e39dd9c295 Bug 1629730 - Remove unnecessary AKEYCODE defines from GeckoEditableSupport. r=geckoview-reviewers,agi
Old NDK requires AKEYCODE defines for newer API version, but it is unnecessary
to define it when using NDK r20.

Differential Revision: https://phabricator.services.mozilla.com/D70786
2020-04-15 21:25:46 +00:00
Makoto Kato 5c13f61fcd Bug 1618754 - Part 1. Support inputmode=none to hide software keyboard. r=geckoview-reviewers,snorp
`inputmode=none` has to close software keyboard. `inputmode` value is lower
case except to `mozAwesomebar` by bug 1618763, so we don't have to use
`equalsIgnoreCase` for `inputmode`.

Differential Revision: https://phabricator.services.mozilla.com/D67459
2020-03-26 18:22:47 +00:00
Makoto Kato b124b785f2 Bug 1613804 - InputConnection.finishComposingText should commit composition text. r=geckoview-reviewers,snorp
Gecko don't commit composition when software keyboard calls
InputConnection.finishComposingText. It is incompatible with Blink's behaviour.

BaseInputConnection.finishComposingText() implementation is the following.

1. Begin batch edit.
2. Remove all composition span flag.
3. End batch edit.

So if no composition after batch edit is finished, we should commit it on Gecko
to synchronize composition state.

Differential Revision: https://phabricator.services.mozilla.com/D66370
2020-03-13 18:01:50 +00:00
Makoto Kato 89120f6ed6 Bug 1499076 - Dispatch key down event before firing input event. r=geckoview-reviewers,snorp
When deleting text by backspace key of VKB, VKB might use `InputConnection.setComposingText`, not using KeyEvent. So although we dispatch dummy key event, the order of events is incorrect. We should dispatch keydown before input event.

Differential Revision: https://phabricator.services.mozilla.com/D64892
2020-03-02 22:27:44 +00:00