In this example: <div>foo<br></div> VP(div, 2) != VP(br, 0) There are a couple of problems in initDeepPosition. First, in the fall through code, where neither upstream() nor downstream() are candidates, we canonicalize to next in most cases, whereas we claim that we always canonicalize to the candidate that appears first in the DOM. Second, in the fall through code, prev is just the first candidate found when going backward through the DOM. There may be another equivalent candidate if you go further, and we should canonicalize to that one. In the example above, VP(div, 2) gets into the fall through code, prev is [br, 0], which is equivalent to [foo, 3]. [foo, 3] should be used, but [br, 0] is used instead.
Note, remove the workaround in VisiblePosition::isEqualIgnoringAffinity when this is fixed.
Justin says he thinks this sounds like rdar://5096134 is a result of the workaround not being in affect for WebKit Accessibility's TextMarkers.
r21904