mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 20:07:34 +00:00
Ladybird: Allow creating new tabs with plain HTML
This will allow us to internally create a new tab with HTML, to be used by the View Source command.
This commit is contained in:
parent
9c4ce1b80b
commit
a718a1f3a6
10 changed files with 83 additions and 29 deletions
|
@ -28,6 +28,11 @@
|
|||
fromTab:(nullable Tab*)tab
|
||||
activateTab:(Web::HTML::ActivateTab)activate_tab;
|
||||
|
||||
- (nonnull TabController*)createNewTab:(StringView)html
|
||||
url:(URL const&)url
|
||||
fromTab:(nullable Tab*)tab
|
||||
activateTab:(Web::HTML::ActivateTab)activate_tab;
|
||||
|
||||
- (void)removeTab:(nonnull TabController*)controller;
|
||||
|
||||
- (Browser::CookieJar&)cookieJar;
|
||||
|
|
|
@ -86,19 +86,20 @@
|
|||
fromTab:(Tab*)tab
|
||||
activateTab:(Web::HTML::ActivateTab)activate_tab
|
||||
{
|
||||
auto* controller = [[TabController alloc] init:url.value_or(m_new_tab_page_url)];
|
||||
[controller showWindow:nil];
|
||||
auto* controller = [self createNewTab:activate_tab fromTab:tab];
|
||||
[controller loadURL:url.value_or(m_new_tab_page_url)];
|
||||
|
||||
if (tab) {
|
||||
[[tab tabGroup] addWindow:controller.window];
|
||||
return controller;
|
||||
}
|
||||
|
||||
// FIXME: Can we create the tabbed window above without it becoming active in the first place?
|
||||
if (activate_tab == Web::HTML::ActivateTab::No) {
|
||||
[tab orderFront:nil];
|
||||
}
|
||||
}
|
||||
- (nonnull TabController*)createNewTab:(StringView)html
|
||||
url:(URL const&)url
|
||||
fromTab:(nullable Tab*)tab
|
||||
activateTab:(Web::HTML::ActivateTab)activate_tab
|
||||
{
|
||||
auto* controller = [self createNewTab:activate_tab fromTab:tab];
|
||||
[controller loadHTML:html url:url];
|
||||
|
||||
[self.managed_tabs addObject:controller];
|
||||
return controller;
|
||||
}
|
||||
|
||||
|
@ -124,6 +125,25 @@
|
|||
|
||||
#pragma mark - Private methods
|
||||
|
||||
- (nonnull TabController*)createNewTab:(Web::HTML::ActivateTab)activate_tab
|
||||
fromTab:(nullable Tab*)tab
|
||||
{
|
||||
auto* controller = [[TabController alloc] init];
|
||||
[controller showWindow:nil];
|
||||
|
||||
if (tab) {
|
||||
[[tab tabGroup] addWindow:controller.window];
|
||||
|
||||
// FIXME: Can we create the tabbed window above without it becoming active in the first place?
|
||||
if (activate_tab == Web::HTML::ActivateTab::No) {
|
||||
[tab orderFront:nil];
|
||||
}
|
||||
}
|
||||
|
||||
[self.managed_tabs addObject:controller];
|
||||
return controller;
|
||||
}
|
||||
|
||||
- (void)closeCurrentTab:(id)sender
|
||||
{
|
||||
auto* current_window = [NSApp keyWindow];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue