mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 07:17:35 +00:00
LibWeb: Port Document interface from DeprecatedString to String
This commit is contained in:
parent
9d88e14f20
commit
e74031a396
15 changed files with 108 additions and 96 deletions
|
@ -210,7 +210,7 @@ JS::NonnullGCPtr<BrowsingContext> BrowsingContext::create_a_new_browsing_context
|
|||
window->set_associated_document(*document);
|
||||
|
||||
document->set_quirks_mode(DOM::QuirksMode::Yes);
|
||||
document->set_content_type("text/html");
|
||||
document->set_content_type("text/html"_string);
|
||||
document->set_origin(origin);
|
||||
document->set_url(AK::URL("about:blank"));
|
||||
document->set_cross_origin_opener_policy(coop);
|
||||
|
@ -370,7 +370,7 @@ WebIDL::ExceptionOr<BrowsingContext::BrowsingContextAndDocument> BrowsingContext
|
|||
document->set_document_type(DOM::Document::Type::HTML);
|
||||
|
||||
// content type: "text/html"
|
||||
document->set_content_type("text/html");
|
||||
document->set_content_type("text/html"_string);
|
||||
|
||||
// mode: "quirks"
|
||||
document->set_quirks_mode(DOM::QuirksMode::Yes);
|
||||
|
@ -626,7 +626,7 @@ void BrowsingContext::scroll_to_anchor(DeprecatedString const& fragment)
|
|||
|
||||
auto element = document->get_element_by_id(fragment);
|
||||
if (!element) {
|
||||
auto candidates = document->get_elements_by_name(fragment);
|
||||
auto candidates = document->get_elements_by_name(MUST(String::from_deprecated_string(fragment)));
|
||||
for (auto& candidate : candidates->collect_matching_elements()) {
|
||||
if (is<HTML::HTMLAnchorElement>(*candidate)) {
|
||||
element = &verify_cast<HTML::HTMLAnchorElement>(*candidate);
|
||||
|
|
|
@ -43,7 +43,7 @@ JS::NonnullGCPtr<DOM::Document> DOMParser::parse_from_string(StringView string,
|
|||
// -> "text/html"
|
||||
// 1. Set document's type to "html".
|
||||
document = HTML::HTMLDocument::create(realm(), verify_cast<HTML::Window>(relevant_global_object(*this)).associated_document().url());
|
||||
document->set_content_type(Bindings::idl_enum_to_string(type).to_deprecated_string());
|
||||
document->set_content_type(Bindings::idl_enum_to_string(type));
|
||||
document->set_document_type(DOM::Document::Type::HTML);
|
||||
|
||||
// 2. Create an HTML parser parser, associated with document.
|
||||
|
@ -57,7 +57,7 @@ JS::NonnullGCPtr<DOM::Document> DOMParser::parse_from_string(StringView string,
|
|||
} else {
|
||||
// -> Otherwise
|
||||
document = DOM::Document::create(realm(), verify_cast<HTML::Window>(relevant_global_object(*this)).associated_document().url());
|
||||
document->set_content_type(Bindings::idl_enum_to_string(type).to_deprecated_string());
|
||||
document->set_content_type(Bindings::idl_enum_to_string(type));
|
||||
|
||||
// 1. Create an XML parser parse, associated with document, and with XML scripting support disabled.
|
||||
XML::Parser parser(string, { .resolve_external_resource = resolve_xml_resource });
|
||||
|
|
|
@ -125,7 +125,7 @@ WebIDL::ExceptionOr<void> HTMLElement::set_content_editable(StringView content_e
|
|||
void HTMLElement::set_inner_text(StringView text)
|
||||
{
|
||||
remove_all_children();
|
||||
MUST(append_child(document().create_text_node(text)));
|
||||
MUST(append_child(document().create_text_node(MUST(String::from_utf8(text)))));
|
||||
|
||||
set_needs_style_update(true);
|
||||
}
|
||||
|
|
|
@ -346,7 +346,7 @@ void HTMLLinkElement::process_stylesheet_resource(bool success, Fetch::Infrastru
|
|||
if (auto charset = deprecated_attribute(HTML::AttributeNames::charset); !charset.is_null())
|
||||
encoding = charset;
|
||||
else
|
||||
encoding = document().encoding_or_default();
|
||||
encoding = document().encoding_or_default().to_deprecated_string();
|
||||
|
||||
auto decoder = TextCodec::decoder_for(encoding);
|
||||
|
||||
|
|
|
@ -290,8 +290,7 @@ void HTMLScriptElement::prepare_script()
|
|||
}
|
||||
|
||||
if (!encoding.has_value()) {
|
||||
auto document_encoding = document().encoding_or_default();
|
||||
encoding = String::from_deprecated_string(document_encoding).release_value_but_fixme_should_propagate_errors();
|
||||
encoding = document().encoding_or_default();
|
||||
}
|
||||
|
||||
VERIFY(encoding.has_value());
|
||||
|
|
|
@ -136,7 +136,7 @@ HTMLParser::HTMLParser(DOM::Document& document, StringView input, DeprecatedStri
|
|||
m_document->set_parser({}, *this);
|
||||
auto standardized_encoding = TextCodec::get_standardized_encoding(encoding);
|
||||
VERIFY(standardized_encoding.has_value());
|
||||
m_document->set_encoding(standardized_encoding.value());
|
||||
m_document->set_encoding(MUST(String::from_utf8(standardized_encoding.value())));
|
||||
}
|
||||
|
||||
HTMLParser::HTMLParser(DOM::Document& document)
|
||||
|
@ -3774,7 +3774,7 @@ JS::NonnullGCPtr<HTMLParser> HTMLParser::create_for_scripting(DOM::Document& doc
|
|||
JS::NonnullGCPtr<HTMLParser> HTMLParser::create_with_uncertain_encoding(DOM::Document& document, ByteBuffer const& input)
|
||||
{
|
||||
if (document.has_encoding())
|
||||
return document.heap().allocate_without_realm<HTMLParser>(document, input, document.encoding().value());
|
||||
return document.heap().allocate_without_realm<HTMLParser>(document, input, document.encoding().value().to_deprecated_string());
|
||||
auto encoding = run_encoding_sniffing_algorithm(document, input);
|
||||
dbgln_if(HTML_PARSER_DEBUG, "The encoding sniffing algorithm returned encoding '{}'", encoding);
|
||||
return document.heap().allocate_without_realm<HTMLParser>(document, input, encoding);
|
||||
|
|
|
@ -91,7 +91,7 @@ JS::GCPtr<DOM::Document> WindowEnvironmentSettingsObject::responsible_document()
|
|||
DeprecatedString WindowEnvironmentSettingsObject::api_url_character_encoding()
|
||||
{
|
||||
// Return the current character encoding of window's associated Document.
|
||||
return m_window->associated_document().encoding_or_default();
|
||||
return m_window->associated_document().encoding_or_default().to_deprecated_string();
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/window-object.html#script-settings-for-window-objects:api-base-url
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue