diff --git a/Userland/Libraries/LibWeb/Bindings/AudioConstructor.cpp b/Userland/Libraries/LibWeb/Bindings/AudioConstructor.cpp index bdf4c1d047..fe10c55881 100644 --- a/Userland/Libraries/LibWeb/Bindings/AudioConstructor.cpp +++ b/Userland/Libraries/LibWeb/Bindings/AudioConstructor.cpp @@ -43,7 +43,7 @@ JS::ThrowCompletionOr> AudioConstructor::construct( auto& document = window.associated_document(); // 2. Let audio be the result of creating an element given document, audio, and the HTML namespace. - auto audio = TRY(Bindings::throw_dom_exception_if_needed(vm, [&]() { return DOM::create_element(document, HTML::TagNames::audio, Namespace::HTML); })); + auto audio = TRY(Bindings::throw_dom_exception_if_needed(vm, [&]() { return DOM::create_element(document, HTML::TagNames::audio, MUST(FlyString::from_deprecated_fly_string(Namespace::HTML))); })); // 3. Set an attribute value for audio using "preload" and "auto". MUST(audio->set_attribute(HTML::AttributeNames::preload, "auto"_string)); diff --git a/Userland/Libraries/LibWeb/Bindings/ImageConstructor.cpp b/Userland/Libraries/LibWeb/Bindings/ImageConstructor.cpp index 06ebc87ddb..15729e6a94 100644 --- a/Userland/Libraries/LibWeb/Bindings/ImageConstructor.cpp +++ b/Userland/Libraries/LibWeb/Bindings/ImageConstructor.cpp @@ -43,7 +43,7 @@ JS::ThrowCompletionOr> ImageConstructor::construct( auto& document = window.associated_document(); // 2. Let img be the result of creating an element given document, img, and the HTML namespace. - auto image_element = TRY(Bindings::throw_dom_exception_if_needed(vm, [&]() { return DOM::create_element(document, HTML::TagNames::img, Namespace::HTML); })); + auto image_element = TRY(Bindings::throw_dom_exception_if_needed(vm, [&]() { return DOM::create_element(document, HTML::TagNames::img, MUST(FlyString::from_deprecated_fly_string(Namespace::HTML))); })); // 3. If width is given, then set an attribute value for img using "width" and width. if (vm.argument_count() > 0) { diff --git a/Userland/Libraries/LibWeb/Bindings/OptionConstructor.cpp b/Userland/Libraries/LibWeb/Bindings/OptionConstructor.cpp index be599b3d67..df6f4704d7 100644 --- a/Userland/Libraries/LibWeb/Bindings/OptionConstructor.cpp +++ b/Userland/Libraries/LibWeb/Bindings/OptionConstructor.cpp @@ -47,7 +47,7 @@ JS::ThrowCompletionOr> OptionConstructor::construct auto& document = window.associated_document(); // 2. Let option be the result of creating an element given document, option, and the HTML namespace. - auto element = TRY(Bindings::throw_dom_exception_if_needed(vm, [&]() { return DOM::create_element(document, HTML::TagNames::option, Namespace::HTML); })); + auto element = TRY(Bindings::throw_dom_exception_if_needed(vm, [&]() { return DOM::create_element(document, HTML::TagNames::option, MUST(FlyString::from_deprecated_fly_string(Namespace::HTML))); })); JS::NonnullGCPtr option_element = verify_cast(*element); // 3. If text is not the empty string, then append to option a new Text node whose data is text. diff --git a/Userland/Libraries/LibWeb/DOM/DOMImplementation.cpp b/Userland/Libraries/LibWeb/DOM/DOMImplementation.cpp index 01e24b2e84..b16608ee0b 100644 --- a/Userland/Libraries/LibWeb/DOM/DOMImplementation.cpp +++ b/Userland/Libraries/LibWeb/DOM/DOMImplementation.cpp @@ -104,17 +104,17 @@ JS::NonnullGCPtr DOMImplementation::create_html_document(Optionalappend_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, Namespace::HTML).release_value_but_fixme_should_propagate_errors(); + 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(); 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, Namespace::HTML).release_value_but_fixme_should_propagate_errors(); + 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(); 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, Namespace::HTML).release_value_but_fixme_should_propagate_errors(); + 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(); 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 +123,7 @@ JS::NonnullGCPtr DOMImplementation::create_html_document(Optionalappend_child(body_element)); // 8. doc’s origin is this’s associated document’s origin. diff --git a/Userland/Libraries/LibWeb/DOM/Document.cpp b/Userland/Libraries/LibWeb/DOM/Document.cpp index 8dab6c5d3b..427327756a 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.cpp +++ b/Userland/Libraries/LibWeb/DOM/Document.cpp @@ -741,7 +741,7 @@ WebIDL::ExceptionOr 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, Namespace::SVG)); + element = TRY(DOM::create_element(*this, HTML::TagNames::title, MUST(FlyString::from_deprecated_fly_string(Namespace::SVG)))); // 2. Insert element as the first child of the document element. document_element->insert_before(*element, nullptr); @@ -770,7 +770,7 @@ WebIDL::ExceptionOr 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, Namespace::HTML)); + element = TRY(DOM::create_element(*this, HTML::TagNames::title, MUST(FlyString::from_deprecated_fly_string(Namespace::HTML)))); // 2. Append element to the head element. TRY(head_element->append_child(*element)); @@ -1356,12 +1356,12 @@ WebIDL::ExceptionOr> Document::create_element(String c } // 5. Let namespace be the HTML namespace, if this is an HTML document or this’s content type is "application/xhtml+xml"; otherwise null. - DeprecatedFlyString namespace_; + Optional namespace_; if (document_type() == Type::HTML || content_type() == "application/xhtml+xml"sv) - namespace_ = Namespace::HTML; + namespace_ = MUST(FlyString::from_deprecated_fly_string(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)), namespace_, {}, move(is_value), true)); + return TRY(DOM::create_element(*this, MUST(FlyString::from_deprecated_fly_string(local_name)), move(namespace_), {}, move(is_value), true)); } // https://dom.spec.whatwg.org/#dom-document-createelementns @@ -1387,7 +1387,7 @@ WebIDL::ExceptionOr> Document::create_element_ns(Optio } // 4. Return the result of creating an element given document, localName, namespace, prefix, is, and with the synchronous custom elements flag set. - return TRY(DOM::create_element(*this, extracted_qualified_name.local_name(), extracted_qualified_name.deprecated_namespace_(), extracted_qualified_name.prefix(), move(is_value), true)); + return TRY(DOM::create_element(*this, extracted_qualified_name.local_name(), extracted_qualified_name.namespace_(), extracted_qualified_name.prefix(), move(is_value), true)); } JS::NonnullGCPtr Document::create_document_fragment() diff --git a/Userland/Libraries/LibWeb/DOM/DocumentLoading.cpp b/Userland/Libraries/LibWeb/DOM/DocumentLoading.cpp index 07b66a6754..3ab9d0a983 100644 --- a/Userland/Libraries/LibWeb/DOM/DocumentLoading.cpp +++ b/Userland/Libraries/LibWeb/DOM/DocumentLoading.cpp @@ -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, Namespace::HTML).release_value_but_fixme_should_propagate_errors(); + 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(); MUST(document.append_child(html_element)); - auto head_element = DOM::create_element(document, HTML::TagNames::head, Namespace::HTML).release_value_but_fixme_should_propagate_errors(); + 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(); MUST(html_element->append_child(head_element)); - auto title_element = DOM::create_element(document, HTML::TagNames::title, Namespace::HTML).release_value_but_fixme_should_propagate_errors(); + 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(); 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, Namespace::HTML).release_value_but_fixme_should_propagate_errors(); + 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(); MUST(html_element->append_child(body_element)); - auto pre_element = DOM::create_element(document, HTML::TagNames::pre, Namespace::HTML).release_value_but_fixme_should_propagate_errors(); + 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(); 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, Namespace::HTML).release_value_but_fixme_should_propagate_errors(); + 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(); MUST(document.append_child(html_element)); - auto head_element = DOM::create_element(document, HTML::TagNames::head, Namespace::HTML).release_value_but_fixme_should_propagate_errors(); + 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(); MUST(html_element->append_child(head_element)); - auto title_element = DOM::create_element(document, HTML::TagNames::title, Namespace::HTML).release_value_but_fixme_should_propagate_errors(); + 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(); MUST(head_element->append_child(title_element)); auto basename = LexicalPath::basename(document.url().serialize_path()); auto title_text = document.heap().allocate(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, Namespace::HTML).release_value_but_fixme_should_propagate_errors(); + 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(); MUST(html_element->append_child(body_element)); - auto image_element = DOM::create_element(document, HTML::TagNames::img, Namespace::HTML).release_value_but_fixme_should_propagate_errors(); + 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(); 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, Namespace::HTML).release_value_but_fixme_should_propagate_errors(); + 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(); MUST(document.append_child(html_element)); - auto head_element = DOM::create_element(document, HTML::TagNames::head, Namespace::HTML).release_value_but_fixme_should_propagate_errors(); + 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(); MUST(html_element->append_child(head_element)); - auto body_element = DOM::create_element(document, HTML::TagNames::body, Namespace::HTML).release_value_but_fixme_should_propagate_errors(); + 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(); MUST(html_element->append_child(body_element)); - auto video_element = DOM::create_element(document, HTML::TagNames::video, Namespace::HTML).release_value_but_fixme_should_propagate_errors(); + 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(); 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, Namespace::HTML).release_value_but_fixme_should_propagate_errors(); + 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(); MUST(document.append_child(html_element)); - auto head_element = DOM::create_element(document, HTML::TagNames::head, Namespace::HTML).release_value_but_fixme_should_propagate_errors(); + 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(); MUST(html_element->append_child(head_element)); - auto body_element = DOM::create_element(document, HTML::TagNames::body, Namespace::HTML).release_value_but_fixme_should_propagate_errors(); + 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(); MUST(html_element->append_child(body_element)); - auto video_element = DOM::create_element(document, HTML::TagNames::audio, Namespace::HTML).release_value_but_fixme_should_propagate_errors(); + 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(); 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 {})); diff --git a/Userland/Libraries/LibWeb/DOM/ElementFactory.cpp b/Userland/Libraries/LibWeb/DOM/ElementFactory.cpp index 790bbe2837..72e8e5cafe 100644 --- a/Userland/Libraries/LibWeb/DOM/ElementFactory.cpp +++ b/Userland/Libraries/LibWeb/DOM/ElementFactory.cpp @@ -490,7 +490,7 @@ static JS::GCPtr create_mathml_element(JS::Realm& realm, return nullptr; } // https://dom.spec.whatwg.org/#concept-create-element -WebIDL::ExceptionOr> create_element(Document& document, FlyString local_name, DeprecatedFlyString namespace_, Optional prefix, Optional is_value, bool synchronous_custom_elements_flag) +WebIDL::ExceptionOr> create_element(Document& document, FlyString local_name, Optional namespace_, Optional prefix, Optional is_value, bool synchronous_custom_elements_flag) { auto& realm = document.realm(); @@ -504,7 +504,8 @@ WebIDL::ExceptionOr> create_element(Document& document // NOTE: We collapse this into just returning an element where necessary. // 4. Let definition be the result of looking up a custom element definition given document, namespace, localName, and is. - auto definition = document.lookup_custom_element_definition(namespace_, local_name.to_deprecated_fly_string(), is_value); + DeprecatedFlyString deprecated_namespace = namespace_.has_value() ? namespace_.value().to_deprecated_fly_string() : DeprecatedFlyString {}; + auto definition = document.lookup_custom_element_definition(deprecated_namespace, local_name.to_deprecated_fly_string(), is_value); // 5. If definition is non-null, and definition’s name is not equal to its local name (i.e., definition represents a customized built-in element), then: if (definition && definition->name() != definition->local_name()) { @@ -624,7 +625,7 @@ WebIDL::ExceptionOr> create_element(Document& document auto qualified_name = QualifiedName { local_name, prefix, namespace_ }; - if (namespace_ == Namespace::HTML) { + if (namespace_ == MUST(FlyString::from_deprecated_fly_string(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 +638,7 @@ WebIDL::ExceptionOr> create_element(Document& document return element; } - if (namespace_ == Namespace::SVG) { + if (namespace_ == MUST(FlyString::from_deprecated_fly_string(Namespace::SVG))) { auto element = create_svg_element(realm, document, qualified_name); if (element) { element->set_is_value(move(is_value)); @@ -646,7 +647,7 @@ WebIDL::ExceptionOr> create_element(Document& document } } - if (namespace_ == Namespace::MathML) { + if (namespace_ == MUST(FlyString::from_deprecated_fly_string(Namespace::MathML))) { auto element = create_mathml_element(realm, document, qualified_name); if (element) { element->set_is_value(move(is_value)); diff --git a/Userland/Libraries/LibWeb/DOM/ElementFactory.h b/Userland/Libraries/LibWeb/DOM/ElementFactory.h index 0743a33cb7..5b4bd55081 100644 --- a/Userland/Libraries/LibWeb/DOM/ElementFactory.h +++ b/Userland/Libraries/LibWeb/DOM/ElementFactory.h @@ -15,6 +15,6 @@ ErrorOr> valid_local_names_for_given_html_element_interfac bool is_unknown_html_element(FlyString const& tag_name); // FIXME: The spec doesn't say what the default value of synchronous_custom_elements_flag should be. -WebIDL::ExceptionOr> create_element(Document&, FlyString local_name, DeprecatedFlyString namespace_, Optional prefix = {}, Optional is = Optional {}, bool synchronous_custom_elements_flag = false); +WebIDL::ExceptionOr> create_element(Document&, FlyString local_name, Optional namespace_, Optional prefix = {}, Optional is = Optional {}, bool synchronous_custom_elements_flag = false); } diff --git a/Userland/Libraries/LibWeb/DOM/Node.cpp b/Userland/Libraries/LibWeb/DOM/Node.cpp index 8b1c00e477..fada450841 100644 --- a/Userland/Libraries/LibWeb/DOM/Node.cpp +++ b/Userland/Libraries/LibWeb/DOM/Node.cpp @@ -809,7 +809,7 @@ JS::NonnullGCPtr Node::clone_node(Document* document, bool clone_children) if (is(this)) { // 1. Let copy be the result of creating an element, given document, node’s local name, node’s namespace, node’s namespace prefix, and node’s is value, with the synchronous custom elements flag unset. auto& element = *verify_cast(this); - auto element_copy = DOM::create_element(*document, element.local_name(), element.namespace_(), element.prefix(), element.is_value(), false).release_value_but_fixme_should_propagate_errors(); + auto element_copy = DOM::create_element(*document, element.local_name(), element.namespace_uri(), element.prefix(), element.is_value(), false).release_value_but_fixme_should_propagate_errors(); // 2. For each attribute in node’s attribute list: element.for_each_attribute([&](auto& name, auto& value) { diff --git a/Userland/Libraries/LibWeb/DOM/Range.cpp b/Userland/Libraries/LibWeb/DOM/Range.cpp index 0e8ba573d6..905c5989ea 100644 --- a/Userland/Libraries/LibWeb/DOM/Range.cpp +++ b/Userland/Libraries/LibWeb/DOM/Range.cpp @@ -1181,7 +1181,7 @@ WebIDL::ExceptionOr> 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, Namespace::HTML)); + element = TRY(DOM::create_element(node->document(), HTML::TagNames::body, MUST(FlyString::from_deprecated_fly_string(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. diff --git a/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp b/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp index 640697520b..febd9e78de 100644 --- a/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp +++ b/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp @@ -244,10 +244,10 @@ WebIDL::ExceptionOr BrowsingContext document->set_ready_for_post_load_tasks(true); // 18. Ensure that document has a single child html node, which itself has two empty child nodes: a head element, and a body element. - auto html_node = TRY(DOM::create_element(document, HTML::TagNames::html, Namespace::HTML)); - auto head_element = TRY(DOM::create_element(document, HTML::TagNames::head, Namespace::HTML)); + auto html_node = TRY(DOM::create_element(document, HTML::TagNames::html, MUST(FlyString::from_deprecated_fly_string(Namespace::HTML)))); + auto head_element = TRY(DOM::create_element(document, HTML::TagNames::head, MUST(FlyString::from_deprecated_fly_string(Namespace::HTML)))); TRY(html_node->append_child(head_element)); - auto body_element = TRY(DOM::create_element(document, HTML::TagNames::body, Namespace::HTML)); + auto body_element = TRY(DOM::create_element(document, HTML::TagNames::body, MUST(FlyString::from_deprecated_fly_string(Namespace::HTML)))); TRY(html_node->append_child(body_element)); TRY(document->append_child(html_node)); diff --git a/Userland/Libraries/LibWeb/HTML/DOMParser.cpp b/Userland/Libraries/LibWeb/HTML/DOMParser.cpp index 9150bd9ae3..57c446fb99 100644 --- a/Userland/Libraries/LibWeb/HTML/DOMParser.cpp +++ b/Userland/Libraries/LibWeb/HTML/DOMParser.cpp @@ -71,7 +71,7 @@ JS::NonnullGCPtr DOMParser::parse_from_string(StringView string, // 1. Assert: document has no child nodes. document->remove_all_children(true); // 2. Let root be the result of creating an element given document, "parsererror", and "http://www.mozilla.org/newlayout/xml/parsererror.xml". - auto root = DOM::create_element(*document, "parsererror"_fly_string, "http://www.mozilla.org/newlayout/xml/parsererror.xml").release_value_but_fixme_should_propagate_errors(); + auto root = DOM::create_element(*document, "parsererror"_fly_string, "http://www.mozilla.org/newlayout/xml/parsererror.xml"_fly_string).release_value_but_fixme_should_propagate_errors(); // FIXME: 3. Optionally, add attributes or children to root to describe the nature of the parsing error. // 4. Append root to document. MUST(document->append_child(*root)); diff --git a/Userland/Libraries/LibWeb/HTML/HTMLDetailsElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLDetailsElement.cpp index 653df30042..d9cdc17d28 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLDetailsElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLDetailsElement.cpp @@ -112,11 +112,11 @@ WebIDL::ExceptionOr HTMLDetailsElement::create_shadow_tree(JS::Realm& real shadow_root->set_slot_assignment(Bindings::SlotAssignmentMode::Manual); // The first slot is expected to take the details element's first summary element child, if any. - auto summary_slot = TRY(DOM::create_element(document(), HTML::TagNames::slot, Namespace::HTML)); + auto summary_slot = TRY(DOM::create_element(document(), HTML::TagNames::slot, MUST(FlyString::from_deprecated_fly_string(Namespace::HTML)))); MUST(shadow_root->append_child(summary_slot)); // The second slot is expected to take the details element's remaining descendants, if any. - auto descendants_slot = TRY(DOM::create_element(document(), HTML::TagNames::slot, Namespace::HTML)); + auto descendants_slot = TRY(DOM::create_element(document(), HTML::TagNames::slot, MUST(FlyString::from_deprecated_fly_string(Namespace::HTML)))); MUST(shadow_root->append_child(descendants_slot)); m_summary_slot = static_cast(*summary_slot); diff --git a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp index 30dfff9399..87fa4fda50 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp @@ -536,7 +536,7 @@ void HTMLInputElement::create_text_input_shadow_tree() { auto shadow_root = heap().allocate(realm(), document(), *this, Bindings::ShadowRootMode::Closed); auto initial_value = m_value; - auto element = DOM::create_element(document(), HTML::TagNames::div, Namespace::HTML).release_value_but_fixme_should_propagate_errors(); + auto element = DOM::create_element(document(), HTML::TagNames::div, MUST(FlyString::from_deprecated_fly_string(Namespace::HTML))).release_value_but_fixme_should_propagate_errors(); MUST(element->set_attribute(HTML::AttributeNames::style, R"~~~( display: flex; height: 100%; @@ -555,7 +555,7 @@ void HTMLInputElement::create_text_input_shadow_tree() MUST(m_placeholder_element->append_child(*m_placeholder_text_node)); MUST(element->append_child(*m_placeholder_element)); - m_inner_text_element = DOM::create_element(document(), HTML::TagNames::div, Namespace::HTML).release_value_but_fixme_should_propagate_errors(); + m_inner_text_element = DOM::create_element(document(), HTML::TagNames::div, MUST(FlyString::from_deprecated_fly_string(Namespace::HTML))).release_value_but_fixme_should_propagate_errors(); MUST(m_inner_text_element->style_for_bindings()->set_property(CSS::PropertyID::Height, "1lh"sv)); m_text_node = heap().allocate(realm(), document(), MUST(String::from_deprecated_string(initial_value))); @@ -587,7 +587,7 @@ void HTMLInputElement::create_color_input_shadow_tree() auto color = value_sanitization_algorithm(m_value); - auto border = DOM::create_element(document(), HTML::TagNames::div, Namespace::HTML).release_value_but_fixme_should_propagate_errors(); + auto border = DOM::create_element(document(), HTML::TagNames::div, MUST(FlyString::from_deprecated_fly_string(Namespace::HTML))).release_value_but_fixme_should_propagate_errors(); MUST(border->set_attribute(HTML::AttributeNames::style, R"~~~( width: fit-content; height: fit-content; @@ -596,7 +596,7 @@ void HTMLInputElement::create_color_input_shadow_tree() background-color: ButtonFace; )~~~"_string)); - m_color_well_element = DOM::create_element(document(), HTML::TagNames::div, Namespace::HTML).release_value_but_fixme_should_propagate_errors(); + m_color_well_element = DOM::create_element(document(), HTML::TagNames::div, MUST(FlyString::from_deprecated_fly_string(Namespace::HTML))).release_value_but_fixme_should_propagate_errors(); MUST(m_color_well_element->set_attribute(HTML::AttributeNames::style, R"~~~( width: 24px; height: 24px; diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTableElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLTableElement.cpp index be2e88718f..71739e1b0d 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLTableElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLTableElement.cpp @@ -118,7 +118,7 @@ JS::NonnullGCPtr HTMLTableElement::create_caption() return *maybe_caption; } - auto caption = DOM::create_element(document(), TagNames::caption, Namespace::HTML).release_value_but_fixme_should_propagate_errors(); + auto caption = DOM::create_element(document(), TagNames::caption, MUST(FlyString::from_deprecated_fly_string(Namespace::HTML))).release_value_but_fixme_should_propagate_errors(); MUST(pre_insert(caption, first_child())); return static_cast(*caption); } @@ -196,7 +196,7 @@ JS::NonnullGCPtr HTMLTableElement::create_t_head() if (maybe_thead) return *maybe_thead; - auto thead = DOM::create_element(document(), TagNames::thead, Namespace::HTML).release_value_but_fixme_should_propagate_errors(); + auto thead = DOM::create_element(document(), TagNames::thead, MUST(FlyString::from_deprecated_fly_string(Namespace::HTML))).release_value_but_fixme_should_propagate_errors(); // We insert the new thead after any or elements DOM::Node* child_to_insert_before = nullptr; @@ -272,7 +272,7 @@ JS::NonnullGCPtr HTMLTableElement::create_t_foot() if (maybe_tfoot) return *maybe_tfoot; - auto tfoot = DOM::create_element(document(), TagNames::tfoot, Namespace::HTML).release_value_but_fixme_should_propagate_errors(); + auto tfoot = DOM::create_element(document(), TagNames::tfoot, MUST(FlyString::from_deprecated_fly_string(Namespace::HTML))).release_value_but_fixme_should_propagate_errors(); MUST(append_child(tfoot)); return static_cast(*tfoot); } @@ -302,7 +302,7 @@ JS::NonnullGCPtr HTMLTableElement::t_bodies() // https://html.spec.whatwg.org/multipage/tables.html#dom-table-createtbody JS::NonnullGCPtr HTMLTableElement::create_t_body() { - auto tbody = DOM::create_element(document(), TagNames::tbody, Namespace::HTML).release_value_but_fixme_should_propagate_errors(); + auto tbody = DOM::create_element(document(), TagNames::tbody, MUST(FlyString::from_deprecated_fly_string(Namespace::HTML))).release_value_but_fixme_should_propagate_errors(); // We insert the new tbody after the last element DOM::Node* child_to_insert_before = nullptr; @@ -365,9 +365,9 @@ WebIDL::ExceptionOr> HTMLTableElement::ins if (index < -1 || index > (long)rows_length) { return WebIDL::IndexSizeError::create(realm(), "Index is negative or greater than the number of rows"_fly_string); } - auto& tr = static_cast(*TRY(DOM::create_element(document(), TagNames::tr, Namespace::HTML))); + auto& tr = static_cast(*TRY(DOM::create_element(document(), TagNames::tr, MUST(FlyString::from_deprecated_fly_string(Namespace::HTML))))); if (rows_length == 0 && !has_child_of_type()) { - auto tbody = TRY(DOM::create_element(document(), TagNames::tbody, Namespace::HTML)); + auto tbody = TRY(DOM::create_element(document(), TagNames::tbody, MUST(FlyString::from_deprecated_fly_string(Namespace::HTML)))); TRY(tbody->append_child(tr)); TRY(append_child(tbody)); } else if (rows_length == 0) { diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTableRowElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLTableRowElement.cpp index f07f16aa0c..1aa1858aea 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLTableRowElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLTableRowElement.cpp @@ -132,7 +132,7 @@ WebIDL::ExceptionOr> HTMLTableRowElement: return WebIDL::IndexSizeError::create(realm(), "Index is negative or greater than the number of cells"_fly_string); // 2. Let table cell be the result of creating an element given this tr element's node document, td, and the HTML namespace. - auto& table_cell = static_cast(*TRY(DOM::create_element(document(), HTML::TagNames::td, Namespace::HTML))); + auto& table_cell = static_cast(*TRY(DOM::create_element(document(), HTML::TagNames::td, MUST(FlyString::from_deprecated_fly_string(Namespace::HTML))))); // 3. If index is equal to −1 or equal to the number of items in cells collection, then append table cell to this tr element. if (index == -1 || index == cells_collection_size) diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTableSectionElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLTableSectionElement.cpp index 7a39e25366..6c180846bc 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLTableSectionElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLTableSectionElement.cpp @@ -57,7 +57,7 @@ WebIDL::ExceptionOr> HTMLTableSectionEleme return WebIDL::IndexSizeError::create(realm(), "Index is negative or greater than the number of rows"_fly_string); // 2. Let table row be the result of creating an element given this element's node document, tr, and the HTML namespace. - auto& table_row = static_cast(*TRY(DOM::create_element(document(), TagNames::tr, Namespace::HTML))); + auto& table_row = static_cast(*TRY(DOM::create_element(document(), TagNames::tr, MUST(FlyString::from_deprecated_fly_string(Namespace::HTML))))); // 3. If index is −1 or equal to the number of items in the rows collection, then append table row to this element. if (index == -1 || index == rows_collection_size) diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTextAreaElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLTextAreaElement.cpp index 01ce0b4486..0a6824e9bc 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLTextAreaElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLTextAreaElement.cpp @@ -97,9 +97,9 @@ void HTMLTextAreaElement::create_shadow_tree_if_needed() return; auto shadow_root = heap().allocate(realm(), document(), *this, Bindings::ShadowRootMode::Closed); - auto element = MUST(DOM::create_element(document(), HTML::TagNames::div, Namespace::HTML)); + auto element = MUST(DOM::create_element(document(), HTML::TagNames::div, MUST(FlyString::from_deprecated_fly_string(Namespace::HTML)))); - m_inner_text_element = MUST(DOM::create_element(document(), HTML::TagNames::div, Namespace::HTML)); + m_inner_text_element = MUST(DOM::create_element(document(), HTML::TagNames::div, MUST(FlyString::from_deprecated_fly_string(Namespace::HTML)))); m_text_node = heap().allocate(realm(), document(), String {}); m_text_node->set_always_editable(true); diff --git a/Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp b/Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp index c74a929958..74de116d4d 100644 --- a/Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp +++ b/Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp @@ -564,7 +564,7 @@ void HTMLParser::handle_before_html(HTMLToken& token) // -> Anything else AnythingElse: // Create an html element whose node document is the Document object. Append it to the Document object. Put this element in the stack of open elements. - auto element = create_element(document(), HTML::TagNames::html, Namespace::HTML).release_value_but_fixme_should_propagate_errors(); + auto element = create_element(document(), HTML::TagNames::html, MUST(FlyString::from_deprecated_fly_string(Namespace::HTML))).release_value_but_fixme_should_propagate_errors(); MUST(document().append_child(element)); m_stack_of_open_elements.push(element); @@ -684,7 +684,7 @@ JS::NonnullGCPtr HTMLParser::create_element_for(HTMLToken const& t // 9. Let element be the result of creating an element given document, localName, given namespace, null, and is. // If will execute script is true, set the synchronous custom elements flag; otherwise, leave it unset. - auto element = create_element(*document, local_name, namespace_, {}, is_value, will_execute_script).release_value_but_fixme_should_propagate_errors(); + auto element = create_element(*document, local_name, MUST(FlyString::from_deprecated_fly_string(namespace_)), {}, is_value, will_execute_script).release_value_but_fixme_should_propagate_errors(); // 10. Append each attribute in the given token to element. // FIXME: This isn't the exact `append` the spec is talking about. @@ -3772,7 +3772,7 @@ Vector> HTMLParser::parse_html_fragment(DOM::Element& cont } // 5. Let root be a new html element with no attributes. - auto root = create_element(context_element.document(), HTML::TagNames::html, Namespace::HTML).release_value_but_fixme_should_propagate_errors(); + auto root = create_element(context_element.document(), HTML::TagNames::html, MUST(FlyString::from_deprecated_fly_string(Namespace::HTML))).release_value_but_fixme_should_propagate_errors(); // 6. Append the element root to the Document node created above. MUST(temp_document->append_child(root)); diff --git a/Userland/Libraries/LibWeb/WebDriver/Screenshot.cpp b/Userland/Libraries/LibWeb/WebDriver/Screenshot.cpp index b61430c8c8..7b43f554c7 100644 --- a/Userland/Libraries/LibWeb/WebDriver/Screenshot.cpp +++ b/Userland/Libraries/LibWeb/WebDriver/Screenshot.cpp @@ -58,7 +58,7 @@ Response capture_element_screenshot(Painter const& painter, Page& page, DOM::Ele auto viewport_rect = page.top_level_traversable()->viewport_rect(); rect.intersect(page.enclosing_device_rect(viewport_rect).to_type()); - auto canvas_element = DOM::create_element(element.document(), HTML::TagNames::canvas, Namespace::HTML).release_value_but_fixme_should_propagate_errors(); + auto canvas_element = DOM::create_element(element.document(), HTML::TagNames::canvas, MUST(FlyString::from_deprecated_fly_string(Namespace::HTML))).release_value_but_fixme_should_propagate_errors(); auto& canvas = verify_cast(*canvas_element); if (!canvas.create_bitmap(rect.width(), rect.height())) { diff --git a/Userland/Libraries/LibWeb/XML/XMLDocumentBuilder.cpp b/Userland/Libraries/LibWeb/XML/XMLDocumentBuilder.cpp index 8529d09796..428c3b28b4 100644 --- a/Userland/Libraries/LibWeb/XML/XMLDocumentBuilder.cpp +++ b/Userland/Libraries/LibWeb/XML/XMLDocumentBuilder.cpp @@ -67,7 +67,7 @@ void XMLDocumentBuilder::element_start(const XML::Name& name, HashMap