mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 03:55:24 +00:00
LibWeb: Use FlyString for create_element() namespace strings
This commit is contained in:
parent
8f82bd044b
commit
f052823f5f
Notes:
sideshowbarker
2024-07-16 23:52:10 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/f052823f5f
21 changed files with 65 additions and 64 deletions
|
@ -43,7 +43,7 @@ JS::ThrowCompletionOr<JS::NonnullGCPtr<JS::Object>> 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));
|
||||
|
|
|
@ -43,7 +43,7 @@ JS::ThrowCompletionOr<JS::NonnullGCPtr<JS::Object>> 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) {
|
||||
|
|
|
@ -47,7 +47,7 @@ JS::ThrowCompletionOr<JS::NonnullGCPtr<JS::Object>> 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<HTML::HTMLOptionElement> option_element = verify_cast<HTML::HTMLOptionElement>(*element);
|
||||
|
||||
// 3. If text is not the empty string, then append to option a new Text node whose data is text.
|
||||
|
|
|
@ -104,17 +104,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, 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<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, Namespace::HTML).release_value_but_fixme_should_propagate_errors();
|
||||
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();
|
||||
MUST(html_element->append_child(body_element));
|
||||
|
||||
// 8. doc’s origin is this’s associated document’s origin.
|
||||
|
|
|
@ -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, 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<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, 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<JS::NonnullGCPtr<Element>> 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<FlyString> 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<JS::NonnullGCPtr<Element>> 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<DocumentFragment> Document::create_document_fragment()
|
||||
|
|
|
@ -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<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, 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 {}));
|
||||
|
|
|
@ -490,7 +490,7 @@ static JS::GCPtr<MathML::MathMLElement> create_mathml_element(JS::Realm& realm,
|
|||
return nullptr;
|
||||
}
|
||||
// https://dom.spec.whatwg.org/#concept-create-element
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<Element>> create_element(Document& document, FlyString local_name, DeprecatedFlyString namespace_, Optional<FlyString> prefix, Optional<String> is_value, bool synchronous_custom_elements_flag)
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<Element>> create_element(Document& document, FlyString local_name, Optional<FlyString> namespace_, Optional<FlyString> prefix, Optional<String> is_value, bool synchronous_custom_elements_flag)
|
||||
{
|
||||
auto& realm = document.realm();
|
||||
|
||||
|
@ -504,7 +504,8 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Element>> 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<JS::NonnullGCPtr<Element>> 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<JS::NonnullGCPtr<Element>> 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<JS::NonnullGCPtr<Element>> 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));
|
||||
|
|
|
@ -15,6 +15,6 @@ ErrorOr<FixedArray<FlyString>> 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<JS::NonnullGCPtr<Element>> create_element(Document&, FlyString local_name, DeprecatedFlyString namespace_, Optional<FlyString> prefix = {}, Optional<String> is = Optional<String> {}, bool synchronous_custom_elements_flag = false);
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<Element>> create_element(Document&, FlyString local_name, Optional<FlyString> namespace_, Optional<FlyString> prefix = {}, Optional<String> is = Optional<String> {}, bool synchronous_custom_elements_flag = false);
|
||||
|
||||
}
|
||||
|
|
|
@ -809,7 +809,7 @@ JS::NonnullGCPtr<Node> Node::clone_node(Document* document, bool clone_children)
|
|||
if (is<Element>(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<Element>(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) {
|
||||
|
|
|
@ -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, 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.
|
||||
|
|
|
@ -244,10 +244,10 @@ WebIDL::ExceptionOr<BrowsingContext::BrowsingContextAndDocument> 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));
|
||||
|
||||
|
|
|
@ -71,7 +71,7 @@ JS::NonnullGCPtr<DOM::Document> 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));
|
||||
|
|
|
@ -112,11 +112,11 @@ WebIDL::ExceptionOr<void> 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<HTML::HTMLSlotElement&>(*summary_slot);
|
||||
|
|
|
@ -536,7 +536,7 @@ void HTMLInputElement::create_text_input_shadow_tree()
|
|||
{
|
||||
auto shadow_root = heap().allocate<DOM::ShadowRoot>(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<DOM::Text>(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;
|
||||
|
|
|
@ -118,7 +118,7 @@ JS::NonnullGCPtr<HTMLTableCaptionElement> 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<HTMLTableCaptionElement&>(*caption);
|
||||
}
|
||||
|
@ -196,7 +196,7 @@ JS::NonnullGCPtr<HTMLTableSectionElement> 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 <caption> or <colgroup> elements
|
||||
DOM::Node* child_to_insert_before = nullptr;
|
||||
|
@ -272,7 +272,7 @@ JS::NonnullGCPtr<HTMLTableSectionElement> 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<HTMLTableSectionElement&>(*tfoot);
|
||||
}
|
||||
|
@ -302,7 +302,7 @@ JS::NonnullGCPtr<DOM::HTMLCollection> HTMLTableElement::t_bodies()
|
|||
// https://html.spec.whatwg.org/multipage/tables.html#dom-table-createtbody
|
||||
JS::NonnullGCPtr<HTMLTableSectionElement> 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 <tbody> element
|
||||
DOM::Node* child_to_insert_before = nullptr;
|
||||
|
@ -365,9 +365,9 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<HTMLTableRowElement>> 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<HTMLTableRowElement&>(*TRY(DOM::create_element(document(), TagNames::tr, Namespace::HTML)));
|
||||
auto& tr = static_cast<HTMLTableRowElement&>(*TRY(DOM::create_element(document(), TagNames::tr, MUST(FlyString::from_deprecated_fly_string(Namespace::HTML)))));
|
||||
if (rows_length == 0 && !has_child_of_type<HTMLTableRowElement>()) {
|
||||
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) {
|
||||
|
|
|
@ -132,7 +132,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<HTMLTableCellElement>> 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<HTMLTableCellElement&>(*TRY(DOM::create_element(document(), HTML::TagNames::td, Namespace::HTML)));
|
||||
auto& table_cell = static_cast<HTMLTableCellElement&>(*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)
|
||||
|
|
|
@ -57,7 +57,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<HTMLTableRowElement>> 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<HTMLTableRowElement&>(*TRY(DOM::create_element(document(), TagNames::tr, Namespace::HTML)));
|
||||
auto& table_row = static_cast<HTMLTableRowElement&>(*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)
|
||||
|
|
|
@ -97,9 +97,9 @@ void HTMLTextAreaElement::create_shadow_tree_if_needed()
|
|||
return;
|
||||
|
||||
auto shadow_root = heap().allocate<DOM::ShadowRoot>(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<DOM::Text>(realm(), document(), String {});
|
||||
m_text_node->set_always_editable(true);
|
||||
|
|
|
@ -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<DOM::Element> 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<JS::Handle<DOM::Node>> 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));
|
||||
|
|
|
@ -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<int>());
|
||||
|
||||
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<HTML::HTMLCanvasElement>(*canvas_element);
|
||||
|
||||
if (!canvas.create_bitmap(rect.width(), rect.height())) {
|
||||
|
|
|
@ -67,7 +67,7 @@ void XMLDocumentBuilder::element_start(const XML::Name& name, HashMap<XML::Name,
|
|||
return;
|
||||
}
|
||||
|
||||
auto node = DOM::create_element(m_document, MUST(FlyString::from_deprecated_fly_string(name)), m_namespace).release_value_but_fixme_should_propagate_errors();
|
||||
auto node = DOM::create_element(m_document, MUST(FlyString::from_deprecated_fly_string(name)), MUST(FlyString::from_deprecated_fly_string(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.
|
||||
|
|
Loading…
Add table
Reference in a new issue