1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 10:38:11 +00:00

Ladybird+LibWebView: Respawn with same JS interpreter after crash

WebView::ViewImplementation now remembers which JS interpreter it
started with, and uses the same setting if the WebContent process
crashes and we have to spawn a new one.
This commit is contained in:
Andreas Kling 2023-07-22 12:41:25 +02:00 committed by Tim Flynn
parent 8b23bbf58e
commit 5d6169793a
7 changed files with 25 additions and 15 deletions

View file

@ -25,7 +25,8 @@ REGISTER_WIDGET(WebView, OutOfProcessWebView)
namespace WebView {
OutOfProcessWebView::OutOfProcessWebView()
OutOfProcessWebView::OutOfProcessWebView(UseJavaScriptBytecode use_javascript_bytecode)
: ViewImplementation(use_javascript_bytecode)
{
set_should_hide_unnecessary_scrollbars(true);
set_focus_policy(GUI::FocusPolicy::StrongFocus);
@ -35,7 +36,7 @@ OutOfProcessWebView::OutOfProcessWebView()
OutOfProcessWebView::~OutOfProcessWebView() = default;
void OutOfProcessWebView::create_client(EnableCallgrindProfiling, UseJavaScriptBytecode)
void OutOfProcessWebView::create_client(EnableCallgrindProfiling)
{
m_client_state = {};

View file

@ -55,7 +55,7 @@ public:
void set_content_scales_to_viewport(bool);
private:
OutOfProcessWebView();
explicit OutOfProcessWebView(UseJavaScriptBytecode = UseJavaScriptBytecode::No);
// ^Widget
virtual void paint_event(GUI::PaintEvent&) override;
@ -78,7 +78,7 @@ private:
virtual void did_scroll() override;
// ^WebView::ViewImplementation
virtual void create_client(EnableCallgrindProfiling = EnableCallgrindProfiling::No, UseJavaScriptBytecode = UseJavaScriptBytecode::No) override;
virtual void create_client(EnableCallgrindProfiling = EnableCallgrindProfiling::No) override;
virtual void update_zoom() 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, Gfx::IntSize) override;

View file

@ -14,7 +14,8 @@
namespace WebView {
ViewImplementation::ViewImplementation()
ViewImplementation::ViewImplementation(UseJavaScriptBytecode use_javascript_bytecode)
: m_use_javascript_bytecode(use_javascript_bytecode)
{
m_backing_store_shrink_timer = Core::Timer::create_single_shot(3000, [this] {
resize_backing_stores_if_needed(WindowResizeInProgress::No);

View file

@ -74,6 +74,8 @@ public:
void clear_inspected_dom_node();
i32 get_hovered_node_id();
UseJavaScriptBytecode use_javascript_bytecode() const { return m_use_javascript_bytecode; }
void debug_request(DeprecatedString const& request, DeprecatedString const& argument = {});
void run_javascript(StringView);
@ -158,7 +160,7 @@ protected:
static constexpr auto ZOOM_MAX_LEVEL = 5.0f;
static constexpr auto ZOOM_STEP = 0.1f;
ViewImplementation();
explicit ViewImplementation(UseJavaScriptBytecode);
WebContentClient& client();
WebContentClient const& client() const;
@ -173,7 +175,7 @@ protected:
void request_repaint();
void handle_resize();
virtual void create_client(EnableCallgrindProfiling = EnableCallgrindProfiling::No, UseJavaScriptBytecode = UseJavaScriptBytecode::No) { }
virtual void create_client(EnableCallgrindProfiling = EnableCallgrindProfiling::No) { }
#if !defined(AK_OS_SERENITY)
ErrorOr<NonnullRefPtr<WebView::WebContentClient>> launch_web_content_process(ReadonlySpan<String> candidate_web_content_paths, EnableCallgrindProfiling = EnableCallgrindProfiling::No, IsLayoutTestMode = IsLayoutTestMode::No, UseJavaScriptBytecode = UseJavaScriptBytecode::No);
@ -210,6 +212,8 @@ protected:
size_t m_crash_count = 0;
RefPtr<Core::Timer> m_repeated_crash_timer;
UseJavaScriptBytecode m_use_javascript_bytecode {};
};
}