mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 08:47:34 +00:00
Ladybird: Add IPC call for creating a new child tab
This will be used for choosing a navigable that requires opening a new tab or new window. Such as calls to window.open(), or specific WebDriver calls.
This commit is contained in:
parent
7245f6f11c
commit
677bdc2a4f
17 changed files with 144 additions and 19 deletions
|
@ -250,7 +250,8 @@ static void copy_data_to_clipboard(StringView data, NSPasteboardType pasteboard_
|
|||
[self setNeedsDisplay:YES];
|
||||
};
|
||||
|
||||
m_web_view_bridge->on_new_tab = [self](auto activate_tab) {
|
||||
m_web_view_bridge->on_new_web_view = [self](auto activate_tab, auto, auto) {
|
||||
// FIXME: Create a child tab that re-uses the ConnectionFromClient of the parent tab
|
||||
return [self.observer onCreateNewTab:"about:blank"sv activateTab:activate_tab];
|
||||
};
|
||||
|
||||
|
|
|
@ -483,6 +483,31 @@ Tab& BrowserWindow::new_tab_from_content(StringView html, Web::HTML::ActivateTab
|
|||
return tab;
|
||||
}
|
||||
|
||||
Tab& BrowserWindow::new_child_tab(Web::HTML::ActivateTab activate_tab, Tab& parent, Web::HTML::WebViewHints hints, Optional<u64> page_index)
|
||||
{
|
||||
return create_new_tab(activate_tab, parent, hints, page_index);
|
||||
}
|
||||
|
||||
Tab& BrowserWindow::create_new_tab(Web::HTML::ActivateTab activate_tab, Tab& parent, Web::HTML::WebViewHints, Optional<u64> page_index)
|
||||
{
|
||||
if (!page_index.has_value())
|
||||
return create_new_tab(activate_tab);
|
||||
|
||||
// FIXME: Respect hints for:
|
||||
// popup: Create new window
|
||||
// width, height: size of window
|
||||
// screen_x, screen_y: positioning of window on the screen
|
||||
auto* tab = new Tab(this, m_web_content_options, m_webdriver_content_ipc_path, parent.view().client(), page_index.value());
|
||||
|
||||
VERIFY(m_current_tab != nullptr);
|
||||
|
||||
m_tabs_container->addTab(tab, "New Tab");
|
||||
if (activate_tab == Web::HTML::ActivateTab::Yes)
|
||||
m_tabs_container->setCurrentWidget(tab);
|
||||
initialize_tab(tab);
|
||||
return *tab;
|
||||
}
|
||||
|
||||
Tab& BrowserWindow::create_new_tab(Web::HTML::ActivateTab activate_tab)
|
||||
{
|
||||
auto* tab = new Tab(this, m_web_content_options, m_webdriver_content_ipc_path);
|
||||
|
@ -494,6 +519,13 @@ Tab& BrowserWindow::create_new_tab(Web::HTML::ActivateTab activate_tab)
|
|||
m_tabs_container->addTab(tab, "New Tab");
|
||||
if (activate_tab == Web::HTML::ActivateTab::Yes)
|
||||
m_tabs_container->setCurrentWidget(tab);
|
||||
initialize_tab(tab);
|
||||
|
||||
return *tab;
|
||||
}
|
||||
|
||||
void BrowserWindow::initialize_tab(Tab* tab)
|
||||
{
|
||||
|
||||
QObject::connect(tab, &Tab::title_changed, this, &BrowserWindow::tab_title_changed);
|
||||
QObject::connect(tab, &Tab::favicon_changed, this, &BrowserWindow::tab_favicon_changed);
|
||||
|
@ -506,9 +538,9 @@ Tab& BrowserWindow::create_new_tab(Web::HTML::ActivateTab activate_tab)
|
|||
new_tab_from_url(ak_url_from_qurl(urls[i]), Web::HTML::ActivateTab::No);
|
||||
});
|
||||
|
||||
tab->view().on_new_tab = [this](auto activate_tab) {
|
||||
auto& tab = new_tab_from_url("about:blank"sv, activate_tab);
|
||||
return tab.view().handle();
|
||||
tab->view().on_new_web_view = [this, tab](auto activate_tab, Web::HTML::WebViewHints hints, Optional<u64> page_index) {
|
||||
auto& new_tab = new_child_tab(activate_tab, *tab, hints, page_index);
|
||||
return new_tab.view().handle();
|
||||
};
|
||||
|
||||
tab->view().on_tab_open_request = [this](auto url, auto activate_tab) {
|
||||
|
@ -553,7 +585,6 @@ Tab& BrowserWindow::create_new_tab(Web::HTML::ActivateTab activate_tab)
|
|||
};
|
||||
|
||||
tab->focus_location_editor();
|
||||
return *tab;
|
||||
}
|
||||
|
||||
void BrowserWindow::activate_tab(int index)
|
||||
|
|
|
@ -75,6 +75,7 @@ public slots:
|
|||
void tab_favicon_changed(int index, QIcon const& icon);
|
||||
Tab& new_tab_from_url(AK::URL const&, Web::HTML::ActivateTab);
|
||||
Tab& new_tab_from_content(StringView html, Web::HTML::ActivateTab);
|
||||
Tab& new_child_tab(Web::HTML::ActivateTab, Tab& parent, Web::HTML::WebViewHints, Optional<u64> page_index);
|
||||
void activate_tab(int index);
|
||||
void close_tab(int index);
|
||||
void close_current_tab();
|
||||
|
@ -101,6 +102,8 @@ private:
|
|||
virtual void closeEvent(QCloseEvent*) override;
|
||||
|
||||
Tab& create_new_tab(Web::HTML::ActivateTab activate_tab);
|
||||
Tab& create_new_tab(Web::HTML::ActivateTab, Tab& parent, Web::HTML::WebViewHints, Optional<u64> page_index);
|
||||
void initialize_tab(Tab*);
|
||||
|
||||
void debug_request(ByteString const& request, ByteString const& argument = "");
|
||||
|
||||
|
|
|
@ -77,6 +77,8 @@ public:
|
|||
};
|
||||
void update_palette(PaletteMode = PaletteMode::Default);
|
||||
|
||||
using ViewImplementation::client;
|
||||
|
||||
signals:
|
||||
void urls_dropped(QList<QUrl> const&);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue