1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 20:37:34 +00:00

Everywhere: Add sv suffix to strings relying on StringView(char const*)

Each of these strings would previously rely on StringView's char const*
constructor overload, which would call __builtin_strlen on the string.
Since we now have operator ""sv, we can replace these with much simpler
versions. This opens the door to being able to remove
StringView(char const*).

No functional changes.
This commit is contained in:
sin-ack 2022-07-11 17:32:29 +00:00 committed by Andreas Kling
parent e5f09ea170
commit 3f3f45580a
762 changed files with 8315 additions and 8316 deletions

View file

@ -50,7 +50,7 @@ public:
HTML
};
static NonnullRefPtr<Document> create(const AK::URL& url = "about:blank")
static NonnullRefPtr<Document> create(const AK::URL& url = "about:blank"sv)
{
return adopt_ref(*new Document(url));
}
@ -190,7 +190,7 @@ public:
JS::Realm& realm();
JS::Interpreter& interpreter();
JS::Value run_javascript(StringView source, StringView filename = "(unknown)");
JS::Value run_javascript(StringView source, StringView filename = "(unknown)"sv);
ExceptionOr<NonnullRefPtr<Element>> create_element(String const& tag_name);
ExceptionOr<NonnullRefPtr<Element>> create_element_ns(String const& namespace_, String const& qualified_name);

View file

@ -685,10 +685,10 @@ void Element::serialize_pseudo_elements_as_json(JsonArraySerializer<StringBuilde
if (!pseudo_element_node)
continue;
auto object = MUST(children_array.add_object());
MUST(object.add("name", String::formatted("::{}", CSS::pseudo_element_name(static_cast<CSS::Selector::PseudoElement>(i)))));
MUST(object.add("type", "pseudo-element"));
MUST(object.add("parent-id", id()));
MUST(object.add("pseudo-element", i));
MUST(object.add("name"sv, String::formatted("::{}", CSS::pseudo_element_name(static_cast<CSS::Selector::PseudoElement>(i)))));
MUST(object.add("type"sv, "pseudo-element"));
MUST(object.add("parent-id"sv, id()));
MUST(object.add("pseudo-element"sv, i));
MUST(object.finish());
}
}

View file

@ -187,13 +187,13 @@ void EventDispatcher::invoke(Event::PathEntry& struct_, Event& event, Event::Pha
// 2. If events type attribute value is a match for any of the strings in the first column in the following table,
// set events type attribute value to the string in the second column on the same row as the matching string, and return otherwise.
if (event.type() == "animationend")
event.set_type("webkitAnimationEnd");
event.set_type("webkitAnimationEnd"sv);
else if (event.type() == "animationiteration")
event.set_type("webkitAnimationIteration");
event.set_type("webkitAnimationIteration"sv);
else if (event.type() == "animationstart")
event.set_type("webkitAnimationStart");
event.set_type("webkitAnimationStart"sv);
else if (event.type() == "transitionend")
event.set_type("webkitTransitionEnd");
event.set_type("webkitTransitionEnd"sv);
else
return;

View file

@ -987,16 +987,16 @@ bool Node::is_uninteresting_whitespace_node() const
void Node::serialize_tree_as_json(JsonObjectSerializer<StringBuilder>& object) const
{
MUST(object.add("name", node_name().view()));
MUST(object.add("id", id()));
MUST(object.add("name"sv, node_name().view()));
MUST(object.add("id"sv, id()));
if (is_document()) {
MUST(object.add("type", "document"));
MUST(object.add("type"sv, "document"));
} else if (is_element()) {
MUST(object.add("type", "element"));
MUST(object.add("type"sv, "element"));
auto const* element = static_cast<DOM::Element const*>(this);
if (element->has_attributes()) {
auto attributes = MUST(object.add_object("attributes"));
auto attributes = MUST(object.add_object("attributes"sv));
element->for_each_attribute([&attributes](auto& name, auto& value) {
MUST(attributes.add(name, value));
});
@ -1006,7 +1006,7 @@ void Node::serialize_tree_as_json(JsonObjectSerializer<StringBuilder>& object) c
if (element->is_browsing_context_container()) {
auto const* container = static_cast<HTML::BrowsingContextContainer const*>(element);
if (auto const* content_document = container->content_document()) {
auto children = MUST(object.add_array("children"));
auto children = MUST(object.add_array("children"sv));
JsonObjectSerializer<StringBuilder> content_document_object = MUST(children.add_object());
content_document->serialize_tree_as_json(content_document_object);
MUST(content_document_object.finish());
@ -1014,10 +1014,10 @@ void Node::serialize_tree_as_json(JsonObjectSerializer<StringBuilder>& object) c
}
}
} else if (is_text()) {
MUST(object.add("type", "text"));
MUST(object.add("type"sv, "text"));
auto text_node = static_cast<DOM::Text const*>(this);
MUST(object.add("text", text_node->data()));
MUST(object.add("text"sv, text_node->data()));
} else if (is_comment()) {
MUST(object.add("type"sv, "comment"sv));
MUST(object.add("data"sv, static_cast<DOM::Comment const&>(*this).data()));
@ -1026,7 +1026,7 @@ void Node::serialize_tree_as_json(JsonObjectSerializer<StringBuilder>& object) c
MUST((object.add("visible"sv, !!layout_node())));
if (has_child_nodes()) {
auto children = MUST(object.add_array("children"));
auto children = MUST(object.add_array("children"sv));
for_each_child([&children](DOM::Node& child) {
if (child.is_uninteresting_whitespace_node())
return;