1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 08:44:58 +00:00

Ladybird: Add ability to create a tab without creating a new WebContent

This commit is contained in:
Andrew Kaster 2024-01-30 09:12:14 -07:00 committed by Tim Flynn
parent 506707cc2b
commit 48ce8fb4e9
11 changed files with 36 additions and 21 deletions

View file

@ -28,7 +28,7 @@ OutOfProcessWebView::OutOfProcessWebView()
set_should_hide_unnecessary_scrollbars(true);
set_focus_policy(GUI::FocusPolicy::StrongFocus);
create_client();
initialize_client(CreateNewClient::Yes);
on_did_layout = [this](auto content_size) {
set_content_size(content_size);
@ -81,8 +81,10 @@ OutOfProcessWebView::OutOfProcessWebView()
OutOfProcessWebView::~OutOfProcessWebView() = default;
void OutOfProcessWebView::create_client()
void OutOfProcessWebView::initialize_client(WebView::ViewImplementation::CreateNewClient)
{
// FIXME: Don't create a new process when CreateNewClient is false
// We should create a new tab/window in the UI instead, and re-use the existing WebContentClient object.
m_client_state = {};
m_client_state.client = WebContentClient::try_create(*this).release_value_but_fixme_should_propagate_errors();

View file

@ -78,7 +78,7 @@ private:
virtual void did_scroll() override;
// ^WebView::ViewImplementation
virtual void create_client() override;
virtual void initialize_client(CreateNewClient) override;
virtual void update_zoom() override;
virtual Web::DevicePixelRect viewport_rect() const override;

View file

@ -334,7 +334,7 @@ void ViewImplementation::handle_web_content_process_crash()
}
m_repeated_crash_timer->restart();
create_client();
initialize_client();
VERIFY(m_client_state.client);
// Don't keep a stale backup bitmap around.

View file

@ -202,7 +202,11 @@ protected:
void handle_resize();
virtual void create_client() { }
enum class CreateNewClient {
No,
Yes,
};
virtual void initialize_client(CreateNewClient = CreateNewClient::Yes) { }
void handle_web_content_process_crash();
@ -217,6 +221,7 @@ protected:
String client_handle;
SharedBitmap front_bitmap;
SharedBitmap back_bitmap;
u64 page_index { 0 };
i32 next_bitmap_id { 0 };
bool has_usable_bitmap { false };
} m_client_state;