VisualEditor: Putting cursor after reference list throws "offset was inside a handlesOwnChildren node" error
Closed, ResolvedPublic

Description

Steps:

  1. Open http://en.wikipedia.beta.wmflabs.org/wiki/7thfeb?veaction=edit
  2. Scroll to bottom
  3. Place cursor in slug between gallery and references list
  4. Cursor right twice

Expected outcome: Cursor ends up in slug at end of the page after the references list

Actual outcome: Error thrown: "offset was inside a handlesOwnChildren node"


Version: unspecified
Severity: normal
URL: http://en.wikipedia.beta.wmflabs.org/wiki/7thfeb?veaction=edit

bzimport set Reference to bz68588.
Jdforrester-WMF created this task.Via LegacyJul 25 2014, 8:58 PM
Catrope added a comment.Via ConduitJul 28 2014, 7:21 PM

This doesn't seem to be related to focusable nodes or the end of the document. All you need to do is put the cursor in a block slug after a references list.

Suppose the references list is at (23,25). What happens is this:

  • setSelection (25,25) is called
  • It tries to compute insertion annotations by pulling from the left
  • It does so by calling getNearestContentOffset( 24, -1 )
  • Two stack levels deeper, getRelativeOffset() notices that 24 is inside of a handlesOwnChildren node and throws an exception

Questions:

  • Why is reference list a handlesOwnChildren node? Is it because <ref> can be nested inside of <references>?
  • Why do we do offset-1 here? There is a Math.max() to guard against ending up at -1, but this bug uncovers another reason why subtracting one from an offset is dangerous and should ideally never be done
gerritbot added a comment.Via ConduitAug 20 2014, 1:56 PM

Change 155260 had a related patch set uploaded by Esanders:
Fix check for left/right annotations

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

gerritbot added a comment.Via ConduitAug 20 2014, 5:55 PM

Change 155260 merged by jenkins-bot:
Fix check for left/right annotations

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

Add Comment