mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-21 09:49:21 +00:00
UI/AppKit: Do not open child web views with an about:blank URL
This is overriding the URL passed to e.g. window.open and link clicks on an <a target=_blank> element. Note: This alone is not enough to support such use cases. We will also need to actually implement opening child web views. But getting this fix out of the way first makes that patch a bit simpler.
This commit is contained in:
parent
89b6cd3fb1
commit
e6965b11e4
Notes:
github-actions[bot]
2024-09-18 08:11:10 +00:00
Author: https://github.com/trflynn89
Commit: e6965b11e4
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1422
5 changed files with 8 additions and 5 deletions
|
@ -97,7 +97,10 @@
|
||||||
activateTab:(Web::HTML::ActivateTab)activate_tab
|
activateTab:(Web::HTML::ActivateTab)activate_tab
|
||||||
{
|
{
|
||||||
auto* controller = [self createNewTab:activate_tab fromTab:tab];
|
auto* controller = [self createNewTab:activate_tab fromTab:tab];
|
||||||
[controller loadURL:url.value_or(WebView::Application::chrome_options().new_tab_page_url)];
|
|
||||||
|
if (url.has_value()) {
|
||||||
|
[controller loadURL:*url];
|
||||||
|
}
|
||||||
|
|
||||||
return controller;
|
return controller;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
@protocol LadybirdWebViewObserver <NSObject>
|
@protocol LadybirdWebViewObserver <NSObject>
|
||||||
|
|
||||||
- (String const&)onCreateNewTab:(URL::URL const&)url
|
- (String const&)onCreateNewTab:(Optional<URL::URL> const&)url
|
||||||
activateTab:(Web::HTML::ActivateTab)activate_tab;
|
activateTab:(Web::HTML::ActivateTab)activate_tab;
|
||||||
|
|
||||||
- (String const&)onCreateNewTab:(StringView)html
|
- (String const&)onCreateNewTab:(StringView)html
|
||||||
|
|
|
@ -323,7 +323,7 @@ static void copy_data_to_clipboard(StringView data, NSPasteboardType pasteboard_
|
||||||
return String {};
|
return String {};
|
||||||
}
|
}
|
||||||
// FIXME: Create a child tab that re-uses the ConnectionFromClient of the parent tab
|
// FIXME: Create a child tab that re-uses the ConnectionFromClient of the parent tab
|
||||||
return [self.observer onCreateNewTab:"about:blank"sv activateTab:activate_tab];
|
return [self.observer onCreateNewTab:{} activateTab:activate_tab];
|
||||||
};
|
};
|
||||||
|
|
||||||
m_web_view_bridge->on_request_web_content = [weak_self]() {
|
m_web_view_bridge->on_request_web_content = [weak_self]() {
|
||||||
|
|
|
@ -268,7 +268,7 @@ static constexpr CGFloat const WINDOW_HEIGHT = 800;
|
||||||
|
|
||||||
#pragma mark - LadybirdWebViewObserver
|
#pragma mark - LadybirdWebViewObserver
|
||||||
|
|
||||||
- (String const&)onCreateNewTab:(URL::URL const&)url
|
- (String const&)onCreateNewTab:(Optional<URL::URL> const&)url
|
||||||
activateTab:(Web::HTML::ActivateTab)activate_tab
|
activateTab:(Web::HTML::ActivateTab)activate_tab
|
||||||
{
|
{
|
||||||
auto* delegate = (ApplicationDelegate*)[NSApp delegate];
|
auto* delegate = (ApplicationDelegate*)[NSApp delegate];
|
||||||
|
|
|
@ -214,7 +214,7 @@ static NSString* const TOOLBAR_TAB_OVERVIEW_IDENTIFIER = @"ToolbarTabOverviewIde
|
||||||
|
|
||||||
self.tab.titlebarAppearsTransparent = NO;
|
self.tab.titlebarAppearsTransparent = NO;
|
||||||
|
|
||||||
[delegate createNewTab:OptionalNone {}
|
[delegate createNewTab:WebView::Application::chrome_options().new_tab_page_url
|
||||||
fromTab:[self tab]
|
fromTab:[self tab]
|
||||||
activateTab:Web::HTML::ActivateTab::Yes];
|
activateTab:Web::HTML::ActivateTab::Yes];
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue