Fix handlesOwnChildren check in getRelativeOffset

We need to keep track of depth, not just a boolean state as handlesOwnChildren
nodes can be nested (e.g. an image caption in an internal list).

Also add test for basic handlesOwnChildren case.

Bug: 63208
Change-Id: I8055dfd87bbe9743482c089662c764cb1a969281
Merge "Fix handlesOwnChildren check in getRelativeOffset"