With #94891 the close handling of the context menus got reworked as its
previous attempt had some glitches. However, the introduced overhaul
had another glitch: The context menu should hide once the cursor has
left the context menu for at least 500ms. When the cursor is moved
within these 500ms, but is still outside the context menu, the timeout
is reset because the event handler storing the cursor's position calls
the "should I close the menu"-routine which resets all timeouts.
This patch replaces the hand-crafted timeout magic with event
debouncing, providing basically the same functionality, but in a more
reliable way. Doing so allows us to remove some code that became
obsolete by now.
The `within()` method had a minor flaw where it considered a cursor not
being within an element if the cursor position was at the exact right
or bottom boundary. The method is now based on
`getBoundingClientRect()` which appears to be more stable. Previously,
a context menu suddenly could have an offset of 0 causing some glitches
where the menus closed unexpectedly.
The cursor's position is stored all 50ms, which may lead to timing
issues between the debounced event and the last cursor update. To
circumvent this, the cursor position is now also updated when the
context menu is entered.
As additional measurements, the logic when exactly a context menu gets
closed is refined:
* close if cursor is outside the context menu AND no child menu is
visible or available
* close parent menu if cursor leaves child menu from any boundary where
cursor will not enter its parent menu