PositionTemplate::IsOrphan::IsConnected() checks whether the anchor node is connected in the DOM/Flat tree. Most callers use them to check if a position is (unexpectedly) moved out of document, and if so, add extra handling.
However, these callers of them actually need to check more. When the position is moved to another document, we are unable to detect such case by IsOrphan() or IsConnected().
These callers should check IsValidFor(document) instead to also check whether the position is still in the same document.
Note:
1. These functions handle null positions in slightly different ways:
- IsConnected(): returns false
- IsOrphan(): returns false
- IsValidFor(document): returns true regardless of |document|
So the conversion might not be purely mechanical, depending on whether the callers expect null positions.
2. Callers of VisiblePositionTemplate::IsOrphan() should also be changed
Comment 1 by bugdroid1@chromium.org
, Oct 18