Page MenuHomePhabricator

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

Details

Reference
bz68588

Event Timeline

bzimport raised the priority of this task from to High.Nov 22 2014, 3:35 AM
bzimport set Reference to bz68588.

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

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

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

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

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