LibWeb: Use Content-Type header to set document encoding

Co-authored-by: Shannon Booth <shannon@serenityos.org>
This commit is contained in:
Gingeh 2024-10-20 19:39:50 +11:00 committed by Andrew Kaster
commit 8e342e3e23
Notes: github-actions[bot] 2024-10-23 17:32:00 +00:00
3 changed files with 7 additions and 6 deletions

View file

@ -91,9 +91,9 @@ static WebIDL::ExceptionOr<JS::NonnullGCPtr<DOM::Document>> load_html_document(H
// causes a load event to be fired.
else {
// FIXME: Parse as we receive the document data, instead of waiting for the whole document to be fetched first.
auto process_body = JS::create_heap_function(document->heap(), [document, url = navigation_params.response->url().value()](ByteBuffer data) {
Platform::EventLoopPlugin::the().deferred_invoke([document = document, data = move(data), url = url] {
auto parser = HTML::HTMLParser::create_with_uncertain_encoding(document, data);
auto process_body = JS::create_heap_function(document->heap(), [document, url = navigation_params.response->url().value(), mime_type = navigation_params.response->header_list()->extract_mime_type()](ByteBuffer data) {
Platform::EventLoopPlugin::the().deferred_invoke([document = document, data = move(data), url = url, mime_type] {
auto parser = HTML::HTMLParser::create_with_uncertain_encoding(document, data, mime_type);
parser->run(url);
});
});