Closed Bug 1216666 Opened 9 years ago Closed 9 years ago

Rewrite selection and composition handling

Categories

(Firefox for Android Graveyard :: Keyboards and IME, defect)

defect
Not set
normal

Tracking

(firefox44 affected, firefox45 fixed, b2g-v2.5 fixed)

RESOLVED FIXED
Firefox 45
Tracking Status
firefox44 --- affected
firefox45 --- fixed
b2g-v2.5 --- fixed

People

(Reporter: jchen, Assigned: jchen)

References

Details

Attachments

(3 files)

Right now, the Gecko side tries to mirror the selection on the Java side. To make IME code more robust, we should let the Java side mirror the Gecko side, similar to what we already do for text changes.

Also, right now the Java side fires off additional "update composition" events periodically to update the composition. To make it more efficient and to make the IME code work better with JS code associated with the input field, we should merge these update composition events into events like text change and span change.
This simplifies the selection handling code in GeckoEditable a lot.

Currently, the Gecko-side selection tries to mirror the Java-side
selection, but this is difficult because the Gecko selection has some
subtle but important behavior differences from the Java selection.
This patch separates out Gecko selection from Java selection so that
they're only loosely coupled. The two selections will periodically
synchronize through events and notifications, but at certain times they
may fall out-of-sync, for example when a composition is active. This
shouldn't affect functionality in a major way, and it's an acceptable
trade-off.
Attachment #8681315 - Flags: review?(esawin)
Currently, GeckoEditable periodically fires update composition events to
update the Gecko composition styling. To make the code more efficient
and more robust in dealing with content JS code, this patch merges these
events into events like replacing text, setting span, and removing span.
As a result, a setComposingText call now results in one replacing text
event instead of a replacing text event plus an update composition event.
Attachment #8681316 - Flags: review?(esawin)
GeckoEditable currently synthesizes key events when committing strings,
to improve web compatibility. However, synthesizing keys is causing
performance problems when the string is long. This patch limits key
synthesis to single-character strings. For longer strings, we commit the
string as a whole. We have other ways of ensuring web compatibility now
(sending dummy key events), so this restriction should not cause
regressions.
Attachment #8681317 - Flags: review?(esawin)
Comment on attachment 8681315 [details] [diff] [review]
Separate out Gecko selection from Java selection (v1)

Review of attachment 8681315 [details] [diff] [review]:
-----------------------------------------------------------------

This looks good, nice code reduction, too.
Attachment #8681315 - Flags: review?(esawin) → review+
Comment on attachment 8681316 [details] [diff] [review]
Update composition as part of replacing text or changing span (v1)

Review of attachment 8681316 [details] [diff] [review]:
-----------------------------------------------------------------

Batching composition events sounds good, can we easily extend the tests to verify it's not messing things up or dropping events?

::: mobile/android/base/GeckoEditable.java
@@ +478,5 @@
> +     * @return Whether there was a composition
> +     */
> +    private boolean icMaybeSendComposition(final CharSequence sequence,
> +                                           final boolean useEntireText,
> +                                           final boolean notifyGecko) {

It might be nicer to use enums instead and avoid boolean arguments for more explicit "flags" handling.
Attachment #8681316 - Flags: review?(esawin) → review+
Attachment #8681317 - Flags: review?(esawin) → review+
https://hg.mozilla.org/mozilla-central/rev/746b7e8e0bf5
https://hg.mozilla.org/mozilla-central/rev/7f90ff1386f7
https://hg.mozilla.org/mozilla-central/rev/3993c6a8d6e6
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 45
Product: Firefox for Android → Firefox for Android Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: