mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-27 02:05:07 +02:00
LibWeb: Use standardized encoding names, add encoding attribute to document
This commit is contained in:
Notes:
sideshowbarker
2024-07-19 02:29:02 +09:00
Author: https://github.com/Lubrsi Commit: https://github.com/SerenityOS/serenity/commit/ed2689c00a0 Pull-request: https://github.com/SerenityOS/serenity/pull/4070 Reviewed-by: https://github.com/awesomekling
@@ -27,6 +27,7 @@
|
||||
//#define PARSER_DEBUG
|
||||
|
||||
#include <AK/Utf32View.h>
|
||||
#include <LibTextCodec/Decoder.h>
|
||||
#include <LibWeb/DOM/Comment.h>
|
||||
#include <LibWeb/DOM/Document.h>
|
||||
#include <LibWeb/DOM/DocumentType.h>
|
||||
@@ -110,7 +111,7 @@ static Vector<FlyString> s_quirks_public_ids = {
|
||||
|
||||
RefPtr<DOM::Document> parse_html_document(const StringView& data, const URL& url, const String& encoding)
|
||||
{
|
||||
HTMLDocumentParser parser(data, encoding);
|
||||
HTMLDocumentParser parser(data, TextCodec::get_standardized_encoding(encoding));
|
||||
parser.run(url);
|
||||
return parser.document();
|
||||
}
|
||||
@@ -119,12 +120,14 @@ HTMLDocumentParser::HTMLDocumentParser(const StringView& input, const String& en
|
||||
: m_tokenizer(input, encoding)
|
||||
{
|
||||
m_document = DOM::Document::create();
|
||||
m_document->set_encoding(encoding);
|
||||
}
|
||||
|
||||
HTMLDocumentParser::HTMLDocumentParser(const StringView& input, const String& encoding, DOM::Document& existing_document)
|
||||
: m_tokenizer(input, encoding)
|
||||
, m_document(existing_document)
|
||||
{
|
||||
m_document->set_encoding(encoding);
|
||||
}
|
||||
|
||||
HTMLDocumentParser::~HTMLDocumentParser()
|
||||
|
||||
Reference in New Issue
Block a user