InputMethodController::TextInputInfo() returns wrong text offset for selection and composition.
It should return offsets in PlainText() with EmitsObjectReplacementCharacter and EmitsSpaceForNbsp TextIteratorBefore. But, selection and composition use default TextIteratorBehavior.
Current implementation:
info.value = PlainText(EphemeralRange::RangeOfContents(*element),
TextIteratorBehavior::Builder()
.SetEmitsObjectReplacementCharacter(true)
.SetEmitsSpaceForNbsp(true)
.Build());
EphemeralRange first_range = FirstEphemeralRangeOf(
GetFrame().Selection().ComputeVisibleSelectionInDOMTreeDeprecated());
PlainTextRange selection_plain_text_range =
PlainTextRangeForEphemeralRange(first_range).second;
if (selection_plain_text_range.IsNotNull()) {
info.selection_start = selection_plain_text_range.Start();
info.selection_end = selection_plain_text_range.End();
}
EphemeralRange range = CompositionEphemeralRange();
PlainTextRange composition_plain_text_range =
PlainTextRangeForEphemeralRange(range).second;
if (composition_plain_text_range.IsNotNull()) {
info.composition_start = composition_plain_text_range.Start();
info.composition_end = composition_plain_text_range.End();
}
Comment 1 by yosin@chromium.org
, Aug 17