Page MenuHomePhabricator

IMEs: DOM corruption when overwriting cross-branchNode selection
Closed, ResolvedPublic8 Story Points

Description

Steps to reproduce

  1. In VE standalone, edit <ul><li><u>12</u></li><li><s>34</s></li></ul>
  2. Select from '2' to '3' inclusive
  3. Type with an IME that doesn't trigger keydown/keypress events (e.g. press backtick twice in Firefox on Linux with UK extended WinKeys).

Observed behaviour

Corruption - DOM merge and linear model merge are out of sync

Expected behaviour

DOM and linear model remain in sync

Explanation

This is quite a wide issue: the IME will generally corrupt the document whenever it causes a native merge of branch nodes, e.g. if the user merely selects across a paragraph boundary and types. The problem is that ve.ce.Surface#handleInsertion is not being called. It is needed to perform emulated deletion of certain selections. But with IME event models we don't have an even that forewarns us of an upcoming insertion, so we never trigger this.

Solution

We should probably trigger handleInsertion on compositionstart. It has certain side effects:

  • Deletion would happen earlier than strictly necessary. But presumably the user does want to delete the selection or they wouldn't have triggered compositionstart, so this is minor.
  • Minor premature commits would occur in some IMEs that don't select the candidate text. But experimentally it doesn't seem to be a very common issue. In any case, it's better than the current major corruption possible in a wide range of IMEs.

Event Timeline

dchan created this task.Jan 15 2016, 11:36 AM
dchan claimed this task.
dchan raised the priority of this task from to Normal.
dchan updated the task description. (Show Details)
dchan added a subscriber: dchan.
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptJan 15 2016, 11:36 AM

Change 264273 had a related patch set uploaded (by Divec):
Delete cross-branchNode selections etc. on compositionstart

https://gerrit.wikimedia.org/r/264273

Change 264273 merged by jenkins-bot:
Delete cross-branchNode selections etc. on compositionstart

https://gerrit.wikimedia.org/r/264273

Jdforrester-WMF closed this task as Resolved.Jan 19 2016, 1:00 AM
Jdforrester-WMF set Security to None.
Jdforrester-WMF edited a custom field.