Anchor a cascading submenu to its parent menu item

The current implementation of cascading menus is anchoring
a submenu to the top-level anchor view using a carefully
computed offset. This offset is only correct for the case when
the submenu is being shown normally, but not when it is
flipped due to insufficient space below.

More over, when the window containing the anchor is scrolled,
the pre-computed might become completely irrelevant, as
parent menus might change their above/below state.

This CL allows a PopupWindow to be anchored to a view in
another popup window (previously it was only possible to
anchor to a view in the main app window).

Cascading submenu is now tracking its parent item position
correctly.

Bug: 35768002
Test: android.cts.widget.PopupWindowTest.testAnchorInPopup
Change-Id: Id163d739de05729a9fa7e5fedebc9ec0037ed80e
3 files changed