1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 18:17:44 +00:00

LibWeb: Make Web::Namespace::Foo strings be FlyString

This required dealing with a *lot* of fallout, but it's all basically
just switching from DeprecatedFlyString to either FlyString or
Optional<FlyString> in a hundred places to accommodate the change.
This commit is contained in:
Andreas Kling 2023-11-04 18:42:04 +01:00
parent 6b20a109c6
commit 3ff81dcb65
31 changed files with 184 additions and 185 deletions

View file

@ -70,12 +70,15 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Document>> DOMImplementation::create_docume
xml_document->set_origin(document().origin());
// 7. documents content type is determined by namespace:
auto deprecated_namespace = namespace_.has_value() ? namespace_->to_deprecated_string() : DeprecatedString::empty();
// FIXME: This conversion is ugly
Optional<FlyString> namespace_to_use;
if (namespace_.has_value())
namespace_to_use = namespace_.value();
if (deprecated_namespace == Namespace::HTML) {
if (namespace_to_use == Namespace::HTML) {
// -> HTML namespace
xml_document->set_content_type("application/xhtml+xml"_string);
} else if (deprecated_namespace == Namespace::SVG) {
} else if (namespace_to_use == Namespace::SVG) {
// -> SVG namespace
xml_document->set_content_type("image/svg+xml"_string);
} else {
@ -104,17 +107,17 @@ JS::NonnullGCPtr<Document> DOMImplementation::create_html_document(Optional<Stri
MUST(html_document->append_child(*doctype));
// 4. Append the result of creating an element given doc, html, and the HTML namespace, to doc.
auto html_element = create_element(html_document, HTML::TagNames::html, MUST(FlyString::from_deprecated_fly_string(Namespace::HTML))).release_value_but_fixme_should_propagate_errors();
auto html_element = create_element(html_document, HTML::TagNames::html, Namespace::HTML).release_value_but_fixme_should_propagate_errors();
MUST(html_document->append_child(html_element));
// 5. Append the result of creating an element given doc, head, and the HTML namespace, to the html element created earlier.
auto head_element = create_element(html_document, HTML::TagNames::head, MUST(FlyString::from_deprecated_fly_string(Namespace::HTML))).release_value_but_fixme_should_propagate_errors();
auto head_element = create_element(html_document, HTML::TagNames::head, Namespace::HTML).release_value_but_fixme_should_propagate_errors();
MUST(html_element->append_child(head_element));
// 6. If title is given:
if (title.has_value()) {
// 1. Append the result of creating an element given doc, title, and the HTML namespace, to the head element created earlier.
auto title_element = create_element(html_document, HTML::TagNames::title, MUST(FlyString::from_deprecated_fly_string(Namespace::HTML))).release_value_but_fixme_should_propagate_errors();
auto title_element = create_element(html_document, HTML::TagNames::title, Namespace::HTML).release_value_but_fixme_should_propagate_errors();
MUST(head_element->append_child(title_element));
// 2. Append a new Text node, with its data set to title (which could be the empty string) and its node document set to doc, to the title element created earlier.
@ -123,7 +126,7 @@ JS::NonnullGCPtr<Document> DOMImplementation::create_html_document(Optional<Stri
}
// 7. Append the result of creating an element given doc, body, and the HTML namespace, to the html element created earlier.
auto body_element = create_element(html_document, HTML::TagNames::body, MUST(FlyString::from_deprecated_fly_string(Namespace::HTML))).release_value_but_fixme_should_propagate_errors();
auto body_element = create_element(html_document, HTML::TagNames::body, Namespace::HTML).release_value_but_fixme_should_propagate_errors();
MUST(html_element->append_child(body_element));
// 8. docs origin is thiss associated documents origin.

View file

@ -741,7 +741,7 @@ WebIDL::ExceptionOr<void> Document::set_title(String const& title)
else {
// 1. Let element be the result of creating an element given the document element's node document, title,
// and the SVG namespace.
element = TRY(DOM::create_element(*this, HTML::TagNames::title, MUST(FlyString::from_deprecated_fly_string(Namespace::SVG))));
element = TRY(DOM::create_element(*this, HTML::TagNames::title, Namespace::SVG));
// 2. Insert element as the first child of the document element.
document_element->insert_before(*element, nullptr);
@ -752,7 +752,7 @@ WebIDL::ExceptionOr<void> Document::set_title(String const& title)
}
// -> If the document element is in the HTML namespace
else if (document_element && document_element->namespace_() == Namespace::HTML) {
else if (document_element && document_element->namespace_uri() == Namespace::HTML) {
auto title_element = this->title_element();
auto* head_element = this->head();
@ -770,7 +770,7 @@ WebIDL::ExceptionOr<void> Document::set_title(String const& title)
else {
// 1. Let element be the result of creating an element given the document element's node document, title,
// and the HTML namespace.
element = TRY(DOM::create_element(*this, HTML::TagNames::title, MUST(FlyString::from_deprecated_fly_string(Namespace::HTML))));
element = TRY(DOM::create_element(*this, HTML::TagNames::title, Namespace::HTML));
// 2. Append element to the head element.
TRY(head_element->append_child(*element));
@ -1358,7 +1358,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Element>> Document::create_element(String c
// 5. Let namespace be the HTML namespace, if this is an HTML document or thiss content type is "application/xhtml+xml"; otherwise null.
Optional<FlyString> namespace_;
if (document_type() == Type::HTML || content_type() == "application/xhtml+xml"sv)
namespace_ = MUST(FlyString::from_deprecated_fly_string(Namespace::HTML));
namespace_ = Namespace::HTML;
// 6. Return the result of creating an element given this, localName, namespace, null, is, and with the synchronous custom elements flag set.
return TRY(DOM::create_element(*this, MUST(FlyString::from_deprecated_fly_string(local_name)), move(namespace_), {}, move(is_value), true));
@ -1369,12 +1369,12 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Element>> Document::create_element(String c
WebIDL::ExceptionOr<JS::NonnullGCPtr<Element>> Document::create_element_ns(Optional<String> const& namespace_, String const& qualified_name, Variant<String, ElementCreationOptions> const& options)
{
// FIXME: This conversion is ugly
StringView namespace_view;
Optional<FlyString> namespace_to_use;
if (namespace_.has_value())
namespace_view = namespace_->bytes_as_string_view();
namespace_to_use = namespace_.value();
// 1. Let namespace, prefix, and localName be the result of passing namespace and qualifiedName to validate and extract.
auto extracted_qualified_name = TRY(validate_and_extract(realm(), namespace_view, qualified_name.to_deprecated_string()));
auto extracted_qualified_name = TRY(validate_and_extract(realm(), namespace_to_use, qualified_name.to_deprecated_string()));
// 2. Let is be null.
Optional<String> is_value;
@ -2435,7 +2435,7 @@ void Document::set_window(HTML::Window& window)
JS::GCPtr<HTML::CustomElementDefinition> Document::lookup_custom_element_definition(Optional<FlyString> const& namespace_, FlyString const& local_name, Optional<String> const& is) const
{
// 1. If namespace is not the HTML namespace, return null.
if (namespace_ != MUST(FlyString::from_deprecated_fly_string(Namespace::HTML)))
if (namespace_ != Namespace::HTML)
return nullptr;
// 2. If document's browsing context is null, return null.
@ -3005,12 +3005,12 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Attr>> Document::create_attribute(String co
WebIDL::ExceptionOr<JS::NonnullGCPtr<Attr>> Document::create_attribute_ns(Optional<String> const& namespace_, String const& qualified_name)
{
// FIXME: This conversion is ugly
StringView namespace_view;
Optional<FlyString> namespace_to_use;
if (namespace_.has_value())
namespace_view = namespace_->bytes_as_string_view();
namespace_to_use = namespace_.value();
// 1. Let namespace, prefix, and localName be the result of passing namespace and qualifiedName to validate and extract.
auto extracted_qualified_name = TRY(validate_and_extract(realm(), namespace_view, qualified_name.to_deprecated_string()));
auto extracted_qualified_name = TRY(validate_and_extract(realm(), namespace_to_use, qualified_name.to_deprecated_string()));
// 2. Return a new attribute whose namespace is namespace, namespace prefix is prefix, local name is localName, and node document is this.

View file

@ -79,21 +79,21 @@ static bool build_markdown_document(DOM::Document& document, ByteBuffer const& d
static bool build_text_document(DOM::Document& document, ByteBuffer const& data)
{
auto html_element = DOM::create_element(document, HTML::TagNames::html, MUST(FlyString::from_deprecated_fly_string(Namespace::HTML))).release_value_but_fixme_should_propagate_errors();
auto html_element = DOM::create_element(document, HTML::TagNames::html, Namespace::HTML).release_value_but_fixme_should_propagate_errors();
MUST(document.append_child(html_element));
auto head_element = DOM::create_element(document, HTML::TagNames::head, MUST(FlyString::from_deprecated_fly_string(Namespace::HTML))).release_value_but_fixme_should_propagate_errors();
auto head_element = DOM::create_element(document, HTML::TagNames::head, Namespace::HTML).release_value_but_fixme_should_propagate_errors();
MUST(html_element->append_child(head_element));
auto title_element = DOM::create_element(document, HTML::TagNames::title, MUST(FlyString::from_deprecated_fly_string(Namespace::HTML))).release_value_but_fixme_should_propagate_errors();
auto title_element = DOM::create_element(document, HTML::TagNames::title, Namespace::HTML).release_value_but_fixme_should_propagate_errors();
MUST(head_element->append_child(title_element));
auto title_text = document.create_text_node(MUST(String::from_deprecated_string(document.url().basename())));
MUST(title_element->append_child(title_text));
auto body_element = DOM::create_element(document, HTML::TagNames::body, MUST(FlyString::from_deprecated_fly_string(Namespace::HTML))).release_value_but_fixme_should_propagate_errors();
auto body_element = DOM::create_element(document, HTML::TagNames::body, Namespace::HTML).release_value_but_fixme_should_propagate_errors();
MUST(html_element->append_child(body_element));
auto pre_element = DOM::create_element(document, HTML::TagNames::pre, MUST(FlyString::from_deprecated_fly_string(Namespace::HTML))).release_value_but_fixme_should_propagate_errors();
auto pre_element = DOM::create_element(document, HTML::TagNames::pre, Namespace::HTML).release_value_but_fixme_should_propagate_errors();
MUST(body_element->append_child(pre_element));
MUST(pre_element->append_child(document.create_text_node(String::from_utf8(StringView { data }).release_value_but_fixme_should_propagate_errors())));
@ -110,22 +110,22 @@ static bool build_image_document(DOM::Document& document, ByteBuffer const& data
if (!bitmap)
return false;
auto html_element = DOM::create_element(document, HTML::TagNames::html, MUST(FlyString::from_deprecated_fly_string(Namespace::HTML))).release_value_but_fixme_should_propagate_errors();
auto html_element = DOM::create_element(document, HTML::TagNames::html, Namespace::HTML).release_value_but_fixme_should_propagate_errors();
MUST(document.append_child(html_element));
auto head_element = DOM::create_element(document, HTML::TagNames::head, MUST(FlyString::from_deprecated_fly_string(Namespace::HTML))).release_value_but_fixme_should_propagate_errors();
auto head_element = DOM::create_element(document, HTML::TagNames::head, Namespace::HTML).release_value_but_fixme_should_propagate_errors();
MUST(html_element->append_child(head_element));
auto title_element = DOM::create_element(document, HTML::TagNames::title, MUST(FlyString::from_deprecated_fly_string(Namespace::HTML))).release_value_but_fixme_should_propagate_errors();
auto title_element = DOM::create_element(document, HTML::TagNames::title, Namespace::HTML).release_value_but_fixme_should_propagate_errors();
MUST(head_element->append_child(title_element));
auto basename = LexicalPath::basename(document.url().serialize_path());
auto title_text = document.heap().allocate<DOM::Text>(document.realm(), document, MUST(String::formatted("{} [{}x{}]", basename, bitmap->width(), bitmap->height())));
MUST(title_element->append_child(*title_text));
auto body_element = DOM::create_element(document, HTML::TagNames::body, MUST(FlyString::from_deprecated_fly_string(Namespace::HTML))).release_value_but_fixme_should_propagate_errors();
auto body_element = DOM::create_element(document, HTML::TagNames::body, Namespace::HTML).release_value_but_fixme_should_propagate_errors();
MUST(html_element->append_child(body_element));
auto image_element = DOM::create_element(document, HTML::TagNames::img, MUST(FlyString::from_deprecated_fly_string(Namespace::HTML))).release_value_but_fixme_should_propagate_errors();
auto image_element = DOM::create_element(document, HTML::TagNames::img, Namespace::HTML).release_value_but_fixme_should_propagate_errors();
MUST(image_element->set_attribute(HTML::AttributeNames::src, MUST(document.url().to_string())));
MUST(body_element->append_child(image_element));
@ -160,16 +160,16 @@ bool build_xml_document(DOM::Document& document, ByteBuffer const& data)
static bool build_video_document(DOM::Document& document)
{
auto html_element = DOM::create_element(document, HTML::TagNames::html, MUST(FlyString::from_deprecated_fly_string(Namespace::HTML))).release_value_but_fixme_should_propagate_errors();
auto html_element = DOM::create_element(document, HTML::TagNames::html, Namespace::HTML).release_value_but_fixme_should_propagate_errors();
MUST(document.append_child(html_element));
auto head_element = DOM::create_element(document, HTML::TagNames::head, MUST(FlyString::from_deprecated_fly_string(Namespace::HTML))).release_value_but_fixme_should_propagate_errors();
auto head_element = DOM::create_element(document, HTML::TagNames::head, Namespace::HTML).release_value_but_fixme_should_propagate_errors();
MUST(html_element->append_child(head_element));
auto body_element = DOM::create_element(document, HTML::TagNames::body, MUST(FlyString::from_deprecated_fly_string(Namespace::HTML))).release_value_but_fixme_should_propagate_errors();
auto body_element = DOM::create_element(document, HTML::TagNames::body, Namespace::HTML).release_value_but_fixme_should_propagate_errors();
MUST(html_element->append_child(body_element));
auto video_element = DOM::create_element(document, HTML::TagNames::video, MUST(FlyString::from_deprecated_fly_string(Namespace::HTML))).release_value_but_fixme_should_propagate_errors();
auto video_element = DOM::create_element(document, HTML::TagNames::video, Namespace::HTML).release_value_but_fixme_should_propagate_errors();
MUST(video_element->set_attribute(HTML::AttributeNames::src, MUST(document.url().to_string())));
MUST(video_element->set_attribute(HTML::AttributeNames::autoplay, String {}));
MUST(video_element->set_attribute(HTML::AttributeNames::controls, String {}));
@ -180,16 +180,16 @@ static bool build_video_document(DOM::Document& document)
static bool build_audio_document(DOM::Document& document)
{
auto html_element = DOM::create_element(document, HTML::TagNames::html, MUST(FlyString::from_deprecated_fly_string(Namespace::HTML))).release_value_but_fixme_should_propagate_errors();
auto html_element = DOM::create_element(document, HTML::TagNames::html, Namespace::HTML).release_value_but_fixme_should_propagate_errors();
MUST(document.append_child(html_element));
auto head_element = DOM::create_element(document, HTML::TagNames::head, MUST(FlyString::from_deprecated_fly_string(Namespace::HTML))).release_value_but_fixme_should_propagate_errors();
auto head_element = DOM::create_element(document, HTML::TagNames::head, Namespace::HTML).release_value_but_fixme_should_propagate_errors();
MUST(html_element->append_child(head_element));
auto body_element = DOM::create_element(document, HTML::TagNames::body, MUST(FlyString::from_deprecated_fly_string(Namespace::HTML))).release_value_but_fixme_should_propagate_errors();
auto body_element = DOM::create_element(document, HTML::TagNames::body, Namespace::HTML).release_value_but_fixme_should_propagate_errors();
MUST(html_element->append_child(body_element));
auto video_element = DOM::create_element(document, HTML::TagNames::audio, MUST(FlyString::from_deprecated_fly_string(Namespace::HTML))).release_value_but_fixme_should_propagate_errors();
auto video_element = DOM::create_element(document, HTML::TagNames::audio, Namespace::HTML).release_value_but_fixme_should_propagate_errors();
MUST(video_element->set_attribute(HTML::AttributeNames::src, MUST(document.url().to_string())));
MUST(video_element->set_attribute(HTML::AttributeNames::autoplay, String {}));
MUST(video_element->set_attribute(HTML::AttributeNames::controls, String {}));

View file

@ -185,7 +185,7 @@ WebIDL::ExceptionOr<void> Element::set_attribute(DeprecatedFlyString const& name
// 2. If this is in the HTML namespace and its node document is an HTML document, then set qualifiedName to qualifiedName in ASCII lowercase.
// FIXME: Handle the second condition, assume it is an HTML document for now.
bool insert_as_lowercase = namespace_() == Namespace::HTML;
bool insert_as_lowercase = namespace_uri() == Namespace::HTML;
// 3. Let attribute be the first attribute in thiss attribute list whose qualified name is qualifiedName, and null otherwise.
auto* attribute = m_attributes->get_attribute(name);
@ -211,10 +211,10 @@ WebIDL::ExceptionOr<void> Element::set_attribute(DeprecatedFlyString const& name
}
// https://dom.spec.whatwg.org/#validate-and-extract
WebIDL::ExceptionOr<QualifiedName> validate_and_extract(JS::Realm& realm, DeprecatedFlyString namespace_, DeprecatedFlyString qualified_name)
WebIDL::ExceptionOr<QualifiedName> validate_and_extract(JS::Realm& realm, Optional<FlyString> namespace_, DeprecatedFlyString qualified_name)
{
// 1. If namespace is the empty string, then set it to null.
if (namespace_.is_empty())
if (namespace_.has_value() && namespace_.value().is_empty())
namespace_ = {};
// 2. Validate qualifiedName.
@ -234,7 +234,7 @@ WebIDL::ExceptionOr<QualifiedName> validate_and_extract(JS::Realm& realm, Deprec
}
// 6. If prefix is non-null and namespace is null, then throw a "NamespaceError" DOMException.
if (prefix.has_value() && namespace_.is_null())
if (prefix.has_value() && !namespace_.has_value())
return WebIDL::NamespaceError::create(realm, "Prefix is non-null and namespace is null."_fly_string);
// 7. If prefix is "xml" and namespace is not the XML namespace, then throw a "NamespaceError" DOMException.
@ -256,12 +256,13 @@ WebIDL::ExceptionOr<QualifiedName> validate_and_extract(JS::Realm& realm, Deprec
// https://dom.spec.whatwg.org/#dom-element-setattributens
WebIDL::ExceptionOr<void> Element::set_attribute_ns(Optional<String> const& namespace_, FlyString const& qualified_name, FlyString const& value)
{
DeprecatedFlyString deprecated_namespace;
// FIXME: This conversion is ugly
Optional<FlyString> namespace_to_use;
if (namespace_.has_value())
deprecated_namespace = namespace_->to_deprecated_string();
namespace_to_use = namespace_.value();
// 1. Let namespace, prefix, and localName be the result of passing namespace and qualifiedName to validate and extract.
auto extracted_qualified_name = TRY(validate_and_extract(realm(), deprecated_namespace, qualified_name.to_deprecated_fly_string()));
auto extracted_qualified_name = TRY(validate_and_extract(realm(), namespace_to_use, qualified_name.to_deprecated_fly_string()));
// 2. Set an attribute value for this using localName, value, and also prefix and namespace.
set_attribute_value(extracted_qualified_name.local_name(), value.to_deprecated_fly_string(), extracted_qualified_name.prefix(), extracted_qualified_name.deprecated_namespace_());
@ -343,7 +344,7 @@ WebIDL::ExceptionOr<bool> Element::toggle_attribute(FlyString const& name, Optio
// 2. If this is in the HTML namespace and its node document is an HTML document, then set qualifiedName to qualifiedName in ASCII lowercase.
// FIXME: Handle the second condition, assume it is an HTML document for now.
bool insert_as_lowercase = namespace_() == Namespace::HTML;
bool insert_as_lowercase = namespace_uri() == Namespace::HTML;
// 3. Let attribute be the first attribute in thiss attribute list whose qualified name is qualifiedName, and null otherwise.
auto* attribute = m_attributes->get_attribute(name);
@ -632,7 +633,7 @@ DOMTokenList* Element::class_list()
WebIDL::ExceptionOr<JS::NonnullGCPtr<ShadowRoot>> Element::attach_shadow(ShadowRootInit init)
{
// 1. If thiss namespace is not the HTML namespace, then throw a "NotSupportedError" DOMException.
if (namespace_() != Namespace::HTML)
if (namespace_uri() != Namespace::HTML)
return WebIDL::NotSupportedError::create(realm(), "Element's namespace is not the HTML namespace"_fly_string);
// 2. If thiss local name is not one of the following:
@ -823,7 +824,7 @@ CSS::CSSStyleDeclaration* Element::style_for_bindings()
void Element::make_html_uppercased_qualified_name()
{
// This is allowed by the spec: "User agents could optimize qualified name and HTML-uppercased qualified name by storing them in internal slots."
if (namespace_() == Namespace::HTML && document().document_type() == Document::Type::HTML)
if (namespace_uri() == Namespace::HTML && document().document_type() == Document::Type::HTML)
m_html_uppercased_qualified_name = MUST(Infra::to_ascii_uppercase(qualified_name()));
else
m_html_uppercased_qualified_name = qualified_name();
@ -1413,7 +1414,7 @@ WebIDL::ExceptionOr<void> Element::insert_adjacent_html(String const& position,
if (!is<Element>(*context)
|| (context->document().document_type() == Document::Type::HTML
&& static_cast<Element const&>(*context).local_name() == "html"sv
&& static_cast<Element const&>(*context).namespace_() == Namespace::HTML)) {
&& static_cast<Element const&>(*context).namespace_uri() == Namespace::HTML)) {
// FIXME: let context be a new Element with
// - body as its local name,
// - The HTML namespace as its namespace, and

View file

@ -441,6 +441,6 @@ private:
template<>
inline bool Node::fast_is<Element>() const { return is_element(); }
WebIDL::ExceptionOr<QualifiedName> validate_and_extract(JS::Realm&, DeprecatedFlyString namespace_, DeprecatedFlyString qualified_name);
WebIDL::ExceptionOr<QualifiedName> validate_and_extract(JS::Realm&, Optional<FlyString> namespace_, DeprecatedFlyString qualified_name);
}

View file

@ -624,7 +624,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Element>> create_element(Document& document
auto qualified_name = QualifiedName { local_name, prefix, namespace_ };
if (namespace_ == MUST(FlyString::from_deprecated_fly_string(Namespace::HTML))) {
if (namespace_ == Namespace::HTML) {
auto element = create_html_element(realm, document, move(qualified_name));
element->set_is_value(move(is_value));
element->set_custom_element_state(CustomElementState::Uncustomized);
@ -637,7 +637,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Element>> create_element(Document& document
return element;
}
if (namespace_ == MUST(FlyString::from_deprecated_fly_string(Namespace::SVG))) {
if (namespace_ == Namespace::SVG) {
auto element = create_svg_element(realm, document, qualified_name);
if (element) {
element->set_is_value(move(is_value));
@ -646,7 +646,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Element>> create_element(Document& document
}
}
if (namespace_ == MUST(FlyString::from_deprecated_fly_string(Namespace::MathML))) {
if (namespace_ == Namespace::MathML) {
auto element = create_mathml_element(realm, document, qualified_name);
if (element) {
element->set_is_value(move(is_value));

View file

@ -90,7 +90,7 @@ Element* HTMLCollection::named_item(FlyString const& name_) const
if (auto it = elements.find_if([&](auto& entry) { return entry->deprecated_attribute(HTML::AttributeNames::id) == name; }); it != elements.end())
return *it;
// - it is in the HTML namespace and has a name attribute whose value is key;
if (auto it = elements.find_if([&](auto& entry) { return entry->namespace_() == Namespace::HTML && entry->name() == name; }); it != elements.end())
if (auto it = elements.find_if([&](auto& entry) { return entry->namespace_uri() == Namespace::HTML && entry->name() == name; }); it != elements.end())
return *it;
// or null if there is no such element.
return nullptr;
@ -115,7 +115,7 @@ Vector<DeprecatedString> HTMLCollection::supported_property_names() const
}
// 2. If element is in the HTML namespace and has a name attribute whose value is neither the empty string nor is in result, append elements name attribute value to result.
if (element->namespace_() == Namespace::HTML && element->has_attribute(HTML::AttributeNames::name)) {
if (element->namespace_uri() == Namespace::HTML && element->has_attribute(HTML::AttributeNames::name)) {
auto name = element->deprecated_attribute(HTML::AttributeNames::name);
if (!name.is_empty() && !result.contains_slow(name))

View file

@ -60,7 +60,7 @@ Vector<DeprecatedString> NamedNodeMap::supported_property_names() const
// 2. If this NamedNodeMap objects element is in the HTML namespace and its node document is an HTML document, then for each name in names:
// FIXME: Handle the second condition, assume it is an HTML document for now.
if (associated_element().namespace_() == Namespace::HTML) {
if (associated_element().namespace_uri() == Namespace::HTML) {
// 1. Let lowercaseName be name, in ASCII lowercase.
// 2. If lowercaseName is not equal to name, remove name from names.
names.remove_all_matching([](auto const& name) { return name != name.to_lowercase(); });
@ -157,7 +157,7 @@ Attr const* NamedNodeMap::get_attribute(StringView qualified_name, size_t* item_
// 1. If element is in the HTML namespace and its node document is an HTML document, then set qualifiedName to qualifiedName in ASCII lowercase.
// FIXME: Handle the second condition, assume it is an HTML document for now.
bool compare_as_lowercase = associated_element().namespace_() == Namespace::HTML;
bool compare_as_lowercase = associated_element().namespace_uri() == Namespace::HTML;
// 2. Return the first attribute in elements attribute list whose qualified name is qualifiedName; otherwise null.
for (auto const& attribute : m_attributes) {

View file

@ -149,7 +149,7 @@ JS::NonnullGCPtr<HTMLCollection> ParentNode::get_elements_by_tag_name(Deprecated
auto qualified_name_in_ascii_lowercase = MUST(FlyString::from_deprecated_fly_string(qualified_name.to_lowercase()));
return HTMLCollection::create(*this, HTMLCollection::Scope::Descendants, [qualified_name, qualified_name_in_ascii_lowercase](Element const& element) {
// - Whose namespace is the HTML namespace and whose qualified name is qualifiedName, in ASCII lowercase.
if (element.namespace_() == Namespace::HTML)
if (element.namespace_uri() == Namespace::HTML)
return element.qualified_name() == qualified_name_in_ascii_lowercase;
// - Whose namespace is not the HTML namespace and whose qualified name is qualifiedName.

View file

@ -1181,7 +1181,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<DocumentFragment>> Range::create_contextual
// - "body" as its local name,
// - The HTML namespace as its namespace, and
// - The context object's node document as its node document.
element = TRY(DOM::create_element(node->document(), HTML::TagNames::body, MUST(FlyString::from_deprecated_fly_string(Namespace::HTML))));
element = TRY(DOM::create_element(node->document(), HTML::TagNames::body, Namespace::HTML));
}
// 3. Let fragment node be the result of invoking the fragment parsing algorithm with fragment as markup, and element as the context element.