mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-26 06:18:59 +00:00
LibWeb: Use standardized encoding names, add encoding attribute to document
This commit is contained in:
parent
f3d2053bff
commit
ed2689c00a
Notes:
sideshowbarker
2024-07-19 02:29:02 +09:00
Author: https://github.com/Lubrsi
Commit: ed2689c00a
Pull-request: https://github.com/SerenityOS/serenity/pull/4070
Reviewed-by: https://github.com/awesomekling
5 changed files with 20 additions and 5 deletions
|
@ -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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue