mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-12 09:20:36 +00:00
LibWebView+Ladybird: Begin de-duplicate WebView implementations
This starts moving code equally shared between the OOPWV and Ladybird WebContentView implementations to WebView::ViewImplementation, beginning with the client state.
This commit is contained in:
parent
121181e392
commit
5411adca22
Notes:
sideshowbarker
2024-07-17 01:47:29 +09:00
Author: https://github.com/linusg Commit: https://github.com/SerenityOS/serenity/commit/5411adca22 Pull-request: https://github.com/SerenityOS/serenity/pull/16983
8 changed files with 50 additions and 48 deletions
|
@ -607,12 +607,6 @@ void WebContentView::hideEvent(QHideEvent* event)
|
|||
client().async_set_system_visibility_state(false);
|
||||
}
|
||||
|
||||
WebContentClient& WebContentView::client()
|
||||
{
|
||||
VERIFY(m_client_state.client);
|
||||
return *m_client_state.client;
|
||||
}
|
||||
|
||||
void WebContentView::create_client()
|
||||
{
|
||||
m_client_state = {};
|
||||
|
|
|
@ -190,6 +190,9 @@ private:
|
|||
static constexpr auto ZOOM_MAX_LEVEL = 5.0f;
|
||||
static constexpr auto ZOOM_STEP = 0.1f;
|
||||
|
||||
// ^WebView::ViewImplementation
|
||||
virtual void create_client() override;
|
||||
|
||||
void request_repaint();
|
||||
void update_viewport_rect();
|
||||
void handle_resize();
|
||||
|
@ -216,28 +219,10 @@ private:
|
|||
|
||||
Gfx::IntRect m_viewport_rect;
|
||||
|
||||
void create_client();
|
||||
WebContentClient& client();
|
||||
|
||||
void handle_web_content_process_crash();
|
||||
|
||||
AK::URL m_url;
|
||||
|
||||
struct SharedBitmap {
|
||||
i32 id { -1 };
|
||||
i32 pending_paints { 0 };
|
||||
RefPtr<Gfx::Bitmap> bitmap;
|
||||
};
|
||||
|
||||
struct ClientState {
|
||||
RefPtr<WebContentClient> client;
|
||||
SharedBitmap front_bitmap;
|
||||
SharedBitmap back_bitmap;
|
||||
i32 next_bitmap_id { 0 };
|
||||
bool has_usable_bitmap { false };
|
||||
bool got_repaint_requests_while_painting { false };
|
||||
} m_client_state;
|
||||
|
||||
RefPtr<Gfx::Bitmap> m_backup_bitmap;
|
||||
|
||||
StringView m_webdriver_content_ipc_path;
|
||||
|
|
|
@ -394,6 +394,7 @@ if (BUILD_LAGOM)
|
|||
# WebView
|
||||
list(APPEND LIBWEBVIEW_SOURCES "../../Userland/Libraries/LibWebView/DOMTreeModel.cpp")
|
||||
list(APPEND LIBWEBVIEW_SOURCES "../../Userland/Libraries/LibWebView/StylePropertiesModel.cpp")
|
||||
list(APPEND LIBWEBVIEW_SOURCES "../../Userland/Libraries/LibWebView/ViewImplementation.cpp")
|
||||
list(APPEND LIBWEBVIEW_SOURCES "../../Userland/Libraries/LibWebView/WebContentClient.cpp")
|
||||
|
||||
compile_ipc(${SERENITY_PROJECT_ROOT}/Userland/Services/WebContent/WebContentServer.ipc WebContent/WebContentServerEndpoint.h)
|
||||
|
|
|
@ -4,6 +4,7 @@ set(SOURCES
|
|||
OutOfProcessWebView.cpp
|
||||
RequestServerAdapter.cpp
|
||||
StylePropertiesModel.cpp
|
||||
ViewImplementation.cpp
|
||||
WebContentClient.cpp
|
||||
WebSocketClientAdapter.cpp
|
||||
)
|
||||
|
|
|
@ -582,12 +582,6 @@ void OutOfProcessWebView::request_repaint()
|
|||
client().async_paint(m_client_state.back_bitmap.bitmap->rect().translated(horizontal_scrollbar().value(), vertical_scrollbar().value()), m_client_state.back_bitmap.id);
|
||||
}
|
||||
|
||||
WebContentClient& OutOfProcessWebView::client()
|
||||
{
|
||||
VERIFY(m_client_state.client);
|
||||
return *m_client_state.client;
|
||||
}
|
||||
|
||||
void OutOfProcessWebView::debug_request(DeprecatedString const& request, DeprecatedString const& argument)
|
||||
{
|
||||
client().async_debug_request(request, argument);
|
||||
|
|
|
@ -152,6 +152,7 @@ private:
|
|||
virtual void did_scroll() override;
|
||||
|
||||
// ^WebView::ViewImplementation
|
||||
virtual void create_client() override;
|
||||
virtual void notify_server_did_layout(Badge<WebContentClient>, Gfx::IntSize content_size) override;
|
||||
virtual void notify_server_did_paint(Badge<WebContentClient>, i32 bitmap_id) override;
|
||||
virtual void notify_server_did_invalidate_content_rect(Badge<WebContentClient>, Gfx::IntRect const&) override;
|
||||
|
@ -207,9 +208,6 @@ private:
|
|||
void handle_resize();
|
||||
void update_zoom();
|
||||
|
||||
void create_client();
|
||||
WebContentClient& client();
|
||||
|
||||
void handle_web_content_process_crash();
|
||||
|
||||
using InputEvent = Variant<GUI::KeyEvent, GUI::MouseEvent>;
|
||||
|
@ -218,21 +216,6 @@ private:
|
|||
|
||||
AK::URL m_url;
|
||||
|
||||
struct SharedBitmap {
|
||||
i32 id { -1 };
|
||||
i32 pending_paints { 0 };
|
||||
RefPtr<Gfx::Bitmap> bitmap;
|
||||
};
|
||||
|
||||
struct ClientState {
|
||||
RefPtr<WebContentClient> client;
|
||||
SharedBitmap front_bitmap;
|
||||
SharedBitmap back_bitmap;
|
||||
i32 next_bitmap_id { 0 };
|
||||
bool has_usable_bitmap { false };
|
||||
bool got_repaint_requests_while_painting { false };
|
||||
} m_client_state;
|
||||
|
||||
RefPtr<Gfx::Bitmap> m_backup_bitmap;
|
||||
RefPtr<GUI::Dialog> m_dialog;
|
||||
|
||||
|
|
23
Userland/Libraries/LibWebView/ViewImplementation.cpp
Normal file
23
Userland/Libraries/LibWebView/ViewImplementation.cpp
Normal file
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* Copyright (c) 2023, Linus Groh <linusg@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibWebView/ViewImplementation.h>
|
||||
|
||||
namespace WebView {
|
||||
|
||||
WebContentClient& ViewImplementation::client()
|
||||
{
|
||||
VERIFY(m_client_state.client);
|
||||
return *m_client_state.client;
|
||||
}
|
||||
|
||||
WebContentClient const& ViewImplementation::client() const
|
||||
{
|
||||
VERIFY(m_client_state.client);
|
||||
return *m_client_state.client;
|
||||
}
|
||||
|
||||
}
|
|
@ -11,6 +11,7 @@
|
|||
#include <LibGfx/StandardCursor.h>
|
||||
#include <LibWeb/Forward.h>
|
||||
#include <LibWebView/Forward.h>
|
||||
#include <LibWebView/WebContentClient.h>
|
||||
|
||||
namespace WebView {
|
||||
|
||||
|
@ -68,6 +69,26 @@ public:
|
|||
virtual Gfx::IntRect notify_server_did_request_fullscreen_window() = 0;
|
||||
virtual void notify_server_did_request_file(Badge<WebContentClient>, DeprecatedString const& path, i32) = 0;
|
||||
virtual void notify_server_did_finish_handling_input_event(bool event_was_accepted) = 0;
|
||||
|
||||
protected:
|
||||
WebContentClient& client();
|
||||
WebContentClient const& client() const;
|
||||
virtual void create_client() = 0;
|
||||
|
||||
struct SharedBitmap {
|
||||
i32 id { -1 };
|
||||
i32 pending_paints { 0 };
|
||||
RefPtr<Gfx::Bitmap> bitmap;
|
||||
};
|
||||
|
||||
struct ClientState {
|
||||
RefPtr<WebContentClient> client;
|
||||
SharedBitmap front_bitmap;
|
||||
SharedBitmap back_bitmap;
|
||||
i32 next_bitmap_id { 0 };
|
||||
bool has_usable_bitmap { false };
|
||||
bool got_repaint_requests_while_painting { false };
|
||||
} m_client_state;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue