LibWeb: Don't compare the focus chain's GC::Root contents by reference

The focus chain always consists of newly created GC::Root objects, so
the condition always produced `false`. The fix is to use GC::Root's
overloaded operator== method, which compares the pointers of the stored
type.

This fixes Figma dropdowns and context menus instantly disappearing
upon opening them. This is because they become focused when they insert
them. Because of this bug, it would fire blur events all the way up to
and including the window. Figma listens for the blur event on the
window, and when received, it will instantly hide dropdowns and context
menus. The intention behind this seems to be hiding them when the user
clicks off the browser window, or switches tab.
This commit is contained in:
Luke Wilde 2025-01-30 14:32:24 +00:00 committed by Andreas Kling
commit bf34b63439
Notes: github-actions[bot] 2025-01-30 18:31:37 +00:00
4 changed files with 89 additions and 4 deletions

View file

@ -44,7 +44,7 @@ static void run_focus_update_steps(Vector<GC::Root<DOM::Node>> old_chain, Vector
// pop the last entry from old chain and the last entry from new chain and redo this step.
while (!old_chain.is_empty()
&& !new_chain.is_empty()
&& &old_chain.last() == &new_chain.last()) {
&& old_chain.last() == new_chain.last()) {
(void)old_chain.take_last();
(void)new_chain.take_last();
}