1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 17:17:44 +00:00

Ladybird: Protect some application commands against non-Tab key windows

Currently, the only NSWindow type in the AppKit chrome is the Tab. Once
we have other window types (e.g. Inspector), commands which assume they
are used on a Tab will either crash or behave weirdly.

This changes the createNewTab: command to accept the tab from which the
new tab is created, rather than assuming that tab is the key window. So
if some JS on a page calls window.open() while a non-Tab window is key,
the new tab will be opened within the same tab group.

This also changes closeCurrentTab: to work on any key window. Regardless
of whether the key window is a Tab or some other window, pressing cmd+W
should just close that window.
This commit is contained in:
Timothy Flynn 2023-08-23 22:09:15 -04:00 committed by Tim Flynn
parent e981c13a4f
commit 70830b711e
4 changed files with 36 additions and 23 deletions

View file

@ -166,7 +166,10 @@ enum class IsHistoryNavigation {
- (void)createNewTab:(id)sender
{
auto* delegate = (ApplicationDelegate*)[NSApp delegate];
[delegate createNewTab:OptionalNone {}];
[delegate createNewTab:OptionalNone {}
fromTab:[self tab]
activateTab:Web::HTML::ActivateTab::Yes];
}
- (void)updateNavigationButtonStates