1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 06:17:35 +00:00

LibWeb: Port Element::local_name and TagNames from Deprecated String

Which pretty much needs to be done together due to the amount of places
where they are compared together.

This also involves porting over StackOfOpenElements over to FlyString
from DeprecatedFly string to prevent a gazillion calls to
`.to_deprecated_fly_string` calls in HTMLParser.
This commit is contained in:
Shannon Booth 2023-10-01 20:07:44 +13:00 committed by Sam Atkins
parent bbfe0d3a82
commit 9303e9e76f
30 changed files with 163 additions and 158 deletions

View file

@ -56,12 +56,12 @@ void XMLDocumentBuilder::element_start(const XML::Name& name, HashMap<XML::Name,
// FIXME: This should not live here at all.
if (auto it = attributes.find("xmlns"); it != attributes.end()) {
if (name == HTML::TagNames::html && it->value != Namespace::HTML) {
if (name == HTML::TagNames::html.to_deprecated_fly_string() && it->value != Namespace::HTML) {
m_has_error = true;
return;
}
if (name == HTML::TagNames::svg) {
if (name == HTML::TagNames::svg.to_deprecated_fly_string()) {
if (it->value != Namespace::SVG) {
m_has_error = true;
return;
@ -71,17 +71,17 @@ void XMLDocumentBuilder::element_start(const XML::Name& name, HashMap<XML::Name,
}
}
auto node = DOM::create_element(m_document, name, m_namespace).release_value_but_fixme_should_propagate_errors();
auto node = DOM::create_element(m_document, MUST(FlyString::from_deprecated_fly_string(name)), m_namespace).release_value_but_fixme_should_propagate_errors();
// When an XML parser with XML scripting support enabled creates a script element,
// it must have its parser document set and its "force async" flag must be unset.
// FIXME: If the parser was created as part of the XML fragment parsing algorithm, then the element must be marked as "already started" also.
if (m_scripting_support == XMLScriptingSupport::Enabled && HTML::TagNames::script == name) {
if (m_scripting_support == XMLScriptingSupport::Enabled && HTML::TagNames::script.to_deprecated_fly_string() == name) {
auto& script_element = static_cast<HTML::HTMLScriptElement&>(*node);
script_element.set_parser_document(Badge<XMLDocumentBuilder> {}, m_document);
script_element.set_force_async(Badge<XMLDocumentBuilder> {}, false);
}
if (HTML::TagNames::template_ == m_current_node->node_name().to_deprecated_fly_string()) {
if (HTML::TagNames::template_.to_deprecated_fly_string() == m_current_node->node_name().to_deprecated_fly_string()) {
// When an XML parser would append a node to a template element, it must instead append it to the template element's template contents (a DocumentFragment node).
MUST(static_cast<HTML::HTMLTemplateElement&>(*m_current_node).content()->append_child(node));
} else {
@ -101,7 +101,7 @@ void XMLDocumentBuilder::element_end(const XML::Name& name)
VERIFY(m_current_node->node_name().equals_ignoring_ascii_case(name));
// When an XML parser with XML scripting support enabled creates a script element, [...]
// When the element's end tag is subsequently parsed,
if (m_scripting_support == XMLScriptingSupport::Enabled && HTML::TagNames::script == name) {
if (m_scripting_support == XMLScriptingSupport::Enabled && HTML::TagNames::script.to_deprecated_fly_string() == name) {
// the user agent must perform a microtask checkpoint,
HTML::perform_a_microtask_checkpoint();
// and then prepare the script element.