mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 23:20:20 +00:00
headless-browser: Store the viewport size as DevicePixelSize
This will just avoid a bunch of needless conversion to/from IntSize in and upcoming commit.
This commit is contained in:
parent
77a46ab1b8
commit
71ccaeda16
Notes:
github-actions[bot]
2024-11-13 10:02:13 +00:00
Author: https://github.com/trflynn89 Commit: https://github.com/LadybirdBrowser/ladybird/commit/71ccaeda164 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2303
7 changed files with 13 additions and 14 deletions
|
@ -95,7 +95,7 @@ ErrorOr<void> Application::launch_test_fixtures()
|
|||
return {};
|
||||
}
|
||||
|
||||
HeadlessWebView& Application::create_web_view(Core::AnonymousBuffer theme, Gfx::IntSize window_size)
|
||||
HeadlessWebView& Application::create_web_view(Core::AnonymousBuffer theme, Web::DevicePixelSize window_size)
|
||||
{
|
||||
auto web_view = HeadlessWebView::create(move(theme), window_size);
|
||||
m_web_views.append(move(web_view));
|
||||
|
|
|
@ -11,9 +11,9 @@
|
|||
#include <AK/NonnullOwnPtr.h>
|
||||
#include <AK/RefPtr.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibGfx/Size.h>
|
||||
#include <LibImageDecoderClient/Client.h>
|
||||
#include <LibRequests/RequestClient.h>
|
||||
#include <LibWeb/PixelUnits.h>
|
||||
#include <LibWebView/Application.h>
|
||||
|
||||
namespace Ladybird {
|
||||
|
@ -40,7 +40,7 @@ public:
|
|||
static Requests::RequestClient& request_client() { return *the().m_request_client; }
|
||||
static ImageDecoderClient::Client& image_decoder_client() { return *the().m_image_decoder_client; }
|
||||
|
||||
HeadlessWebView& create_web_view(Core::AnonymousBuffer theme, Gfx::IntSize window_size);
|
||||
HeadlessWebView& create_web_view(Core::AnonymousBuffer theme, Web::DevicePixelSize window_size);
|
||||
HeadlessWebView& create_child_web_view(HeadlessWebView const&, u64 page_index);
|
||||
void destroy_web_views();
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace Ladybird {
|
|||
|
||||
static Web::DevicePixelRect const screen_rect { 0, 0, 1920, 1080 };
|
||||
|
||||
HeadlessWebView::HeadlessWebView(Core::AnonymousBuffer theme, Gfx::IntSize viewport_size)
|
||||
HeadlessWebView::HeadlessWebView(Core::AnonymousBuffer theme, Web::DevicePixelSize viewport_size)
|
||||
: m_theme(move(theme))
|
||||
, m_viewport_size(viewport_size)
|
||||
, m_test_promise(TestPromise::construct())
|
||||
|
@ -121,7 +121,7 @@ HeadlessWebView::HeadlessWebView(Core::AnonymousBuffer theme, Gfx::IntSize viewp
|
|||
};
|
||||
}
|
||||
|
||||
NonnullOwnPtr<HeadlessWebView> HeadlessWebView::create(Core::AnonymousBuffer theme, Gfx::IntSize window_size)
|
||||
NonnullOwnPtr<HeadlessWebView> HeadlessWebView::create(Core::AnonymousBuffer theme, Web::DevicePixelSize window_size)
|
||||
{
|
||||
auto view = adopt_own(*new HeadlessWebView(move(theme), window_size));
|
||||
view->initialize_client(CreateNewClient::Yes);
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
#include <LibCore/Forward.h>
|
||||
#include <LibCore/Promise.h>
|
||||
#include <LibGfx/Forward.h>
|
||||
#include <LibGfx/Size.h>
|
||||
#include <LibWeb/Page/Page.h>
|
||||
#include <LibWeb/PixelUnits.h>
|
||||
#include <LibWebView/ViewImplementation.h>
|
||||
|
@ -22,7 +21,7 @@ namespace Ladybird {
|
|||
|
||||
class HeadlessWebView final : public WebView::ViewImplementation {
|
||||
public:
|
||||
static NonnullOwnPtr<HeadlessWebView> create(Core::AnonymousBuffer theme, Gfx::IntSize window_size);
|
||||
static NonnullOwnPtr<HeadlessWebView> create(Core::AnonymousBuffer theme, Web::DevicePixelSize window_size);
|
||||
static NonnullOwnPtr<HeadlessWebView> create_child(HeadlessWebView const&, u64 page_index);
|
||||
|
||||
void clear_content_filters();
|
||||
|
@ -35,19 +34,19 @@ public:
|
|||
Function<void()> on_web_content_crashed;
|
||||
|
||||
private:
|
||||
HeadlessWebView(Core::AnonymousBuffer theme, Gfx::IntSize viewport_size);
|
||||
HeadlessWebView(Core::AnonymousBuffer theme, Web::DevicePixelSize viewport_size);
|
||||
|
||||
void update_zoom() override { }
|
||||
void initialize_client(CreateNewClient) override;
|
||||
|
||||
virtual Web::DevicePixelSize viewport_size() const override { return m_viewport_size.to_type<Web::DevicePixels>(); }
|
||||
virtual Web::DevicePixelSize viewport_size() const override { return m_viewport_size; }
|
||||
virtual Gfx::IntPoint to_content_position(Gfx::IntPoint widget_position) const override { return widget_position; }
|
||||
virtual Gfx::IntPoint to_widget_position(Gfx::IntPoint content_position) const override { return content_position; }
|
||||
|
||||
virtual void did_receive_screenshot(Badge<WebView::WebContentClient>, Gfx::ShareableBitmap const& screenshot) override;
|
||||
|
||||
Core::AnonymousBuffer m_theme;
|
||||
Gfx::IntSize m_viewport_size;
|
||||
Web::DevicePixelSize m_viewport_size;
|
||||
|
||||
RefPtr<Core::Promise<RefPtr<Gfx::Bitmap>>> m_pending_screenshot;
|
||||
|
||||
|
|
|
@ -384,7 +384,7 @@ static void run_test(HeadlessWebView& view, Test& test, Application& app)
|
|||
view.load("about:blank"sv);
|
||||
}
|
||||
|
||||
ErrorOr<void> run_tests(Core::AnonymousBuffer const& theme, Gfx::IntSize window_size)
|
||||
ErrorOr<void> run_tests(Core::AnonymousBuffer const& theme, Web::DevicePixelSize window_size)
|
||||
{
|
||||
auto& app = Application::the();
|
||||
TRY(load_test_config(app.test_root_path));
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
#include <LibCore/Forward.h>
|
||||
#include <LibCore/Promise.h>
|
||||
#include <LibGfx/Forward.h>
|
||||
#include <LibGfx/Size.h>
|
||||
#include <LibURL/Forward.h>
|
||||
#include <LibWeb/PixelUnits.h>
|
||||
|
||||
namespace Ladybird {
|
||||
|
||||
|
@ -78,7 +78,7 @@ struct TestCompletion {
|
|||
|
||||
using TestPromise = Core::Promise<TestCompletion>;
|
||||
|
||||
ErrorOr<void> run_tests(Core::AnonymousBuffer const& theme, Gfx::IntSize window_size);
|
||||
ErrorOr<void> run_tests(Core::AnonymousBuffer const& theme, Web::DevicePixelSize window_size);
|
||||
void run_dump_test(HeadlessWebView&, Test&, URL::URL const&, int timeout_in_milliseconds);
|
||||
|
||||
}
|
||||
|
|
|
@ -72,7 +72,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
auto theme = TRY(Gfx::load_system_theme(theme_path.string()));
|
||||
|
||||
// FIXME: Allow passing the window size as an argument.
|
||||
static constexpr Gfx::IntSize window_size { 800, 600 };
|
||||
static constexpr Web::DevicePixelSize window_size { 800, 600 };
|
||||
|
||||
if (!app->test_root_path.is_empty()) {
|
||||
app->test_root_path = LexicalPath::absolute_path(TRY(FileSystem::current_working_directory()), app->test_root_path);
|
||||
|
|
Loading…
Reference in a new issue