[Selection API] Fix selection isCollapsed in ShadowDOM
Selection isCollapsed should return true if and only if the anchor
and focus are the same [1]. This should be true even if the selection
is not in the light tree, but in the shadow tree [2].
Note that if selection is across multiple shadow trees, it will still
return true because the range endpoints are not valid and were
collapsed. That should be re-evaluated in SelectionAcrossShadowDOM.
[1] https://w3c.github.io/selection-api/#dom-selection-iscollapsed
[2] https://w3c.github.io/selection-api/#h-note-3
Change-Id: I4aaaef288ac1879644a3f719386d58c6025302bf
Bug: 4040055
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5792085
Reviewed-by: Mason Freed masonf@chromium.org
Commit-Queue: Di Zhang dizhangg@chromium.org
Cr-Commit-Position: refs/heads/main@{#1345127}