mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 22:07:35 +00:00
LibWeb: Make load_document()'s NavigationParams non-optional
There's no mention in the spec of this being optional, all the places that call it always pass a NavigationParams directly, and we're VERIFYing that it's got a value too!
This commit is contained in:
parent
f900957d26
commit
8dc8d57418
2 changed files with 11 additions and 13 deletions
|
@ -257,11 +257,9 @@ static bool is_supported_document_mime_type(StringView mime_type)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#loading-a-document
|
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#loading-a-document
|
||||||
JS::GCPtr<DOM::Document> load_document(Optional<HTML::NavigationParams> navigation_params)
|
JS::GCPtr<DOM::Document> load_document(HTML::NavigationParams navigation_params)
|
||||||
{
|
{
|
||||||
VERIFY(navigation_params.has_value());
|
auto extracted_mime_type = navigation_params.response->header_list()->extract_mime_type().release_value_but_fixme_should_propagate_errors();
|
||||||
|
|
||||||
auto extracted_mime_type = navigation_params->response->header_list()->extract_mime_type().release_value_but_fixme_should_propagate_errors();
|
|
||||||
if (!extracted_mime_type.has_value())
|
if (!extracted_mime_type.has_value())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
|
@ -269,14 +267,14 @@ JS::GCPtr<DOM::Document> load_document(Optional<HTML::NavigationParams> navigati
|
||||||
if (!is_supported_document_mime_type(mime_type.essence()))
|
if (!is_supported_document_mime_type(mime_type.essence()))
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
auto document = DOM::Document::create_and_initialize(DOM::Document::Type::HTML, "text/html"_string, *navigation_params).release_value_but_fixme_should_propagate_errors();
|
auto document = DOM::Document::create_and_initialize(DOM::Document::Type::HTML, "text/html"_string, navigation_params).release_value_but_fixme_should_propagate_errors();
|
||||||
document->set_content_type(mime_type.essence());
|
document->set_content_type(mime_type.essence());
|
||||||
|
|
||||||
auto& realm = document->realm();
|
auto& realm = document->realm();
|
||||||
|
|
||||||
if (navigation_params->response->body()) {
|
if (navigation_params.response->body()) {
|
||||||
Optional<String> content_encoding = mime_type.parameters().get("charset"sv);
|
Optional<String> content_encoding = mime_type.parameters().get("charset"sv);
|
||||||
auto process_body = [document, url = navigation_params->response->url().value(), encoding = move(content_encoding)](ByteBuffer bytes) {
|
auto process_body = [document, url = navigation_params.response->url().value(), encoding = move(content_encoding)](ByteBuffer bytes) {
|
||||||
if (parse_document(*document, bytes, move(encoding)))
|
if (parse_document(*document, bytes, move(encoding)))
|
||||||
return;
|
return;
|
||||||
document->remove_all_children(true);
|
document->remove_all_children(true);
|
||||||
|
@ -290,11 +288,11 @@ JS::GCPtr<DOM::Document> load_document(Optional<HTML::NavigationParams> navigati
|
||||||
dbgln("FIXME: Load html page with an error if read of body failed.");
|
dbgln("FIXME: Load html page with an error if read of body failed.");
|
||||||
};
|
};
|
||||||
|
|
||||||
navigation_params->response->body()->fully_read(
|
navigation_params.response->body()->fully_read(
|
||||||
realm,
|
realm,
|
||||||
move(process_body),
|
move(process_body),
|
||||||
move(process_body_error),
|
move(process_body_error),
|
||||||
JS::NonnullGCPtr { realm.global_object() })
|
JS::NonnullGCPtr { realm.global_object() })
|
||||||
.release_value_but_fixme_should_propagate_errors();
|
.release_value_but_fixme_should_propagate_errors();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ namespace Web {
|
||||||
|
|
||||||
bool build_xml_document(DOM::Document& document, ByteBuffer const& data, Optional<String> content_encoding);
|
bool build_xml_document(DOM::Document& document, ByteBuffer const& data, Optional<String> content_encoding);
|
||||||
bool parse_document(DOM::Document& document, ByteBuffer const& data, Optional<String> content_encoding);
|
bool parse_document(DOM::Document& document, ByteBuffer const& data, Optional<String> content_encoding);
|
||||||
JS::GCPtr<DOM::Document> load_document(Optional<HTML::NavigationParams> navigation_params);
|
JS::GCPtr<DOM::Document> load_document(HTML::NavigationParams navigation_params);
|
||||||
JS::GCPtr<DOM::Document> create_document_for_inline_content(JS::GCPtr<HTML::Navigable> navigable, Optional<String> navigation_id, StringView content_html);
|
JS::GCPtr<DOM::Document> create_document_for_inline_content(JS::GCPtr<HTML::Navigable> navigable, Optional<String> navigation_id, StringView content_html);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue