mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 23:20:20 +00:00
LibWebView: Make loading an error page after a crash optional
We won't need this in headless-browser (who isn't calling this helper yet).
This commit is contained in:
parent
956b279ae1
commit
d2151e444e
Notes:
github-actions[bot]
2024-11-12 14:27:13 +00:00
Author: https://github.com/trflynn89 Commit: https://github.com/LadybirdBrowser/ladybird/commit/d2151e444eb Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2300 Reviewed-by: https://github.com/tcl3 ✅
2 changed files with 21 additions and 14 deletions
|
@ -494,7 +494,7 @@ void ViewImplementation::handle_resize()
|
|||
client().async_set_viewport_size(page_id(), this->viewport_size());
|
||||
}
|
||||
|
||||
void ViewImplementation::handle_web_content_process_crash()
|
||||
void ViewImplementation::handle_web_content_process_crash(LoadErrorPage load_error_page)
|
||||
{
|
||||
dbgln("WebContent process crashed!");
|
||||
dbgln("Consider raising an issue at https://github.com/LadybirdBrowser/ladybird/issues/new/choose");
|
||||
|
@ -515,19 +515,22 @@ void ViewImplementation::handle_web_content_process_crash()
|
|||
m_backup_bitmap = nullptr;
|
||||
|
||||
handle_resize();
|
||||
StringBuilder builder;
|
||||
builder.append("<html><head><title>Crashed: "sv);
|
||||
builder.append(escape_html_entities(m_url.to_byte_string()));
|
||||
builder.append("</title></head><body>"sv);
|
||||
builder.append("<h1>Web page crashed"sv);
|
||||
if (!m_url.host().has<Empty>()) {
|
||||
builder.appendff(" on {}", escape_html_entities(m_url.serialized_host().release_value_but_fixme_should_propagate_errors()));
|
||||
|
||||
if (load_error_page == LoadErrorPage::Yes) {
|
||||
StringBuilder builder;
|
||||
builder.append("<html><head><title>Crashed: "sv);
|
||||
builder.append(escape_html_entities(m_url.to_byte_string()));
|
||||
builder.append("</title></head><body>"sv);
|
||||
builder.append("<h1>Web page crashed"sv);
|
||||
if (!m_url.host().has<Empty>()) {
|
||||
builder.appendff(" on {}", escape_html_entities(m_url.serialized_host().release_value_but_fixme_should_propagate_errors()));
|
||||
}
|
||||
builder.append("</h1>"sv);
|
||||
auto escaped_url = escape_html_entities(m_url.to_byte_string());
|
||||
builder.appendff("The web page <a href=\"{}\">{}</a> has crashed.<br><br>You can reload the page to try again.", escaped_url, escaped_url);
|
||||
builder.append("</body></html>"sv);
|
||||
load_html(builder.to_byte_string());
|
||||
}
|
||||
builder.append("</h1>"sv);
|
||||
auto escaped_url = escape_html_entities(m_url.to_byte_string());
|
||||
builder.appendff("The web page <a href=\"{}\">{}</a> has crashed.<br><br>You can reload the page to try again.", escaped_url, escaped_url);
|
||||
builder.append("</body></html>"sv);
|
||||
load_html(builder.to_byte_string());
|
||||
}
|
||||
|
||||
static ErrorOr<LexicalPath> save_screenshot(Gfx::ShareableBitmap const& bitmap)
|
||||
|
|
|
@ -254,7 +254,11 @@ protected:
|
|||
};
|
||||
virtual void initialize_client(CreateNewClient = CreateNewClient::Yes) { }
|
||||
|
||||
void handle_web_content_process_crash();
|
||||
enum class LoadErrorPage {
|
||||
No,
|
||||
Yes,
|
||||
};
|
||||
void handle_web_content_process_crash(LoadErrorPage = LoadErrorPage::Yes);
|
||||
|
||||
struct SharedBitmap {
|
||||
i32 id { -1 };
|
||||
|
|
Loading…
Reference in a new issue