Skip to content

Conversation

@dandclark
Copy link
Contributor

@dandclark dandclark commented Mar 13, 2025

Make the following changes to keep the selection and composition in a consistent state after updateText()/updateSelection() calls.

  • For each selection boundary point, updateText() sets the boundary point to boundaryPoint + text.length - (rangeEnd - rangeStart) when boundaryPoint >= rangeEnd, or to rangeStart + text.length when boundaryPoint > rangeStart && boundaryPoint < rangeEnd.
  • When a composition is active during an updateText() call,
    • If the updated range does not overlap with the composed range, move the composition position in the same way as for selection.
    • If it does overlap, abort the composition.
  • When a composition is active when updateSelection() is called with a selection that differs from the current selection, abort the composition.

Resolves #111.

For normative changes, the following tasks have been completed:

@marijnh
Copy link

marijnh commented Mar 13, 2025

Thanks. These changes would solve the issues I've been running into.

aarongable pushed a commit to chromium/chromium that referenced this pull request May 20, 2025
This CL adds use counters to analyze the impact of implementing the
change proposed in [1]. Following counters are added:
1. kEditContextUpdateTextRangePrecedesOrOverlapsSelection: Tracks when
updateText is called and the update range precedes or overlaps the
selection.
2. kEditContextUpdateTextRangePrecedesCompositionRange: Tracks when
updateText is called and the update range precedes the composition
range during an active composition.
3. kEditContextUpdateTextRangeOverlapsCompositionRange: Tracks when
updateText is called and the update range overlaps with the composition
range during an active composition.
4. kEditContextUpdateSelectionDuringActiveComposition: Tracks when
updateSelection is called during an active composition.

[1] w3c/edit-context#115

These counters will help us understand how frequently these behaviors
occur before making changes to the spec implementation.

Bug: 379170477
Change-Id: I8043fdb6161137f79d8eaa3336b90d93ca25042c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6549358
Reviewed-by: Dan Clark <[email protected]>
Commit-Queue: Ashish Kumar <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1462602}
aarongable pushed a commit to chromium/chromium that referenced this pull request Oct 15, 2025
…ction

This CL implements the changes proposed in [1] to maintain consistent
selection and composition state during `EditContext::updateText` and
`Editcontext::updateSelection` calls.

[1]: w3c/edit-context#115

Bug: 379170477
Change-Id: I4a7911311d7ca4988d8cd5ae012e119cdc50b6d5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6845496
Reviewed-by: Kent Tamura <[email protected]>
Reviewed-by: Rohan Raja <[email protected]>
Commit-Queue: Ashish Kumar <[email protected]>
Reviewed-by: Alex Keng <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1530027}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The interaction between composition and updateText/updateSelection should be more clearly defined

2 participants