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

AK+Everywhere: Rename FlyString to DeprecatedFlyString

DeprecatedFlyString relies heavily on DeprecatedString's StringImpl, so
let's rename it to A) match the name of DeprecatedString, B) write a new
FlyString class that is tied to String.
This commit is contained in:
Timothy Flynn 2023-01-08 19:23:00 -05:00 committed by Linus Groh
parent 2eacc7aec1
commit f3db548a3d
316 changed files with 1177 additions and 1177 deletions

View file

@ -40,7 +40,7 @@ static inline void log_parse_error(SourceLocation const& location = SourceLocati
dbgln_if(HTML_PARSER_DEBUG, "Parse error! {}", location);
}
static Vector<FlyString> s_quirks_public_ids = {
static Vector<DeprecatedFlyString> s_quirks_public_ids = {
"+//Silmaril//dtd html Pro v0r11 19970101//",
"-//AS//DTD HTML 3.0 asWedit + extensions//",
"-//AdvaSoft Ltd//DTD HTML 3.0 asWedit + extensions//",
@ -616,7 +616,7 @@ HTMLParser::AdjustedInsertionLocation HTMLParser::find_appropriate_place_for_ins
return adjusted_insertion_location;
}
JS::NonnullGCPtr<DOM::Element> HTMLParser::create_element_for(HTMLToken const& token, FlyString const& namespace_, DOM::Node const& intended_parent)
JS::NonnullGCPtr<DOM::Element> HTMLParser::create_element_for(HTMLToken const& token, DeprecatedFlyString const& namespace_, DOM::Node const& intended_parent)
{
// FIXME: 1. If the active speculative HTML parser is not null, then return the result of creating a speculative mock element given given namespace, the tag name of the given token, and the attributes of the given token.
// FIXME: 2. Otherwise, optionally create a speculative mock element given given namespace, the tag name of the given token, and the attributes of the given token.
@ -681,7 +681,7 @@ JS::NonnullGCPtr<DOM::Element> HTMLParser::create_element_for(HTMLToken const& t
}
// https://html.spec.whatwg.org/multipage/parsing.html#insert-a-foreign-element
JS::NonnullGCPtr<DOM::Element> HTMLParser::insert_foreign_element(HTMLToken const& token, FlyString const& namespace_)
JS::NonnullGCPtr<DOM::Element> HTMLParser::insert_foreign_element(HTMLToken const& token, DeprecatedFlyString const& namespace_)
{
auto adjusted_insertion_location = find_appropriate_place_for_inserting_node();
@ -1041,7 +1041,7 @@ AnythingElse:
process_using_the_rules_for(m_insertion_mode, token);
}
void HTMLParser::generate_implied_end_tags(FlyString const& exception)
void HTMLParser::generate_implied_end_tags(DeprecatedFlyString const& exception)
{
while (current_node().local_name() != exception && current_node().local_name().is_one_of(HTML::TagNames::dd, HTML::TagNames::dt, HTML::TagNames::li, HTML::TagNames::optgroup, HTML::TagNames::option, HTML::TagNames::p, HTML::TagNames::rb, HTML::TagNames::rp, HTML::TagNames::rt, HTML::TagNames::rtc))
(void)m_stack_of_open_elements.pop();
@ -1365,7 +1365,7 @@ HTMLParser::AdoptionAgencyAlgorithmOutcome HTMLParser::run_the_adoption_agency_a
}
}
bool HTMLParser::is_special_tag(FlyString const& tag_name, FlyString const& namespace_)
bool HTMLParser::is_special_tag(DeprecatedFlyString const& tag_name, DeprecatedFlyString const& namespace_)
{
if (namespace_ == Namespace::HTML) {
return tag_name.is_one_of(

View file

@ -67,7 +67,7 @@ public:
InsertionMode insertion_mode() const { return m_insertion_mode; }
static bool is_special_tag(FlyString const& tag_name, FlyString const& namespace_);
static bool is_special_tag(DeprecatedFlyString const& tag_name, DeprecatedFlyString const& namespace_);
HTMLTokenizer& tokenizer() { return m_tokenizer; }
@ -117,9 +117,9 @@ private:
void stop_parsing() { m_stop_parsing = true; }
void generate_implied_end_tags(FlyString const& exception = {});
void generate_implied_end_tags(DeprecatedFlyString const& exception = {});
void generate_all_implied_end_tags_thoroughly();
JS::NonnullGCPtr<DOM::Element> create_element_for(HTMLToken const&, FlyString const& namespace_, DOM::Node const& intended_parent);
JS::NonnullGCPtr<DOM::Element> create_element_for(HTMLToken const&, DeprecatedFlyString const& namespace_, DOM::Node const& intended_parent);
struct AdjustedInsertionLocation {
JS::GCPtr<DOM::Node> parent;
@ -130,7 +130,7 @@ private:
DOM::Text* find_character_insertion_node();
void flush_character_insertions();
JS::NonnullGCPtr<DOM::Element> insert_foreign_element(HTMLToken const&, FlyString const&);
JS::NonnullGCPtr<DOM::Element> insert_foreign_element(HTMLToken const&, DeprecatedFlyString const&);
JS::NonnullGCPtr<DOM::Element> insert_html_element(HTMLToken const&);
DOM::Element& current_node();
DOM::Element& adjusted_current_node();

View file

@ -7,8 +7,8 @@
#pragma once
#include <AK/DeprecatedFlyString.h>
#include <AK/DeprecatedString.h>
#include <AK/FlyString.h>
#include <AK/Function.h>
#include <AK/OwnPtr.h>
#include <AK/Types.h>
@ -67,7 +67,7 @@ public:
return token;
}
static HTMLToken make_start_tag(FlyString const& tag_name)
static HTMLToken make_start_tag(DeprecatedFlyString const& tag_name)
{
HTMLToken token { Type::StartTag };
token.set_tag_name(tag_name);
@ -134,7 +134,7 @@ public:
m_data.get<u32>() = code_point;
}
FlyString const& comment() const
DeprecatedFlyString const& comment() const
{
VERIFY(is_comment());
return m_string_data;
@ -146,7 +146,7 @@ public:
m_string_data = move(comment);
}
FlyString const& tag_name() const
DeprecatedFlyString const& tag_name() const
{
VERIFY(is_start_tag() || is_end_tag());
return m_string_data;
@ -247,7 +247,7 @@ public:
}
}
StringView attribute(FlyString const& attribute_name)
StringView attribute(DeprecatedFlyString const& attribute_name)
{
VERIFY(is_start_tag() || is_end_tag());
@ -261,19 +261,19 @@ public:
return {};
}
bool has_attribute(FlyString const& attribute_name)
bool has_attribute(DeprecatedFlyString const& attribute_name)
{
return !attribute(attribute_name).is_null();
}
void adjust_tag_name(FlyString const& old_name, FlyString const& new_name)
void adjust_tag_name(DeprecatedFlyString const& old_name, DeprecatedFlyString const& new_name)
{
VERIFY(is_start_tag() || is_end_tag());
if (old_name == tag_name())
set_tag_name(new_name);
}
void adjust_attribute_name(FlyString const& old_name, FlyString const& new_name)
void adjust_attribute_name(DeprecatedFlyString const& old_name, DeprecatedFlyString const& new_name)
{
VERIFY(is_start_tag() || is_end_tag());
for_each_attribute([&](Attribute& attribute) {
@ -283,7 +283,7 @@ public:
});
}
void adjust_foreign_attribute(FlyString const& old_name, FlyString const& prefix, FlyString const& local_name, FlyString const& namespace_)
void adjust_foreign_attribute(DeprecatedFlyString const& old_name, DeprecatedFlyString const& prefix, DeprecatedFlyString const& local_name, DeprecatedFlyString const& namespace_)
{
VERIFY(is_start_tag() || is_end_tag());
for_each_attribute([&](Attribute& attribute) {
@ -350,7 +350,7 @@ private:
bool m_tag_self_closing_acknowledged { false };
// Type::Comment (comment data), Type::StartTag and Type::EndTag (tag name)
FlyString m_string_data;
DeprecatedFlyString m_string_data;
Variant<Empty, u32, OwnPtr<DoctypeData>, OwnPtr<Vector<Attribute>>> m_data {};

View file

@ -37,7 +37,7 @@ bool ListOfActiveFormattingElements::contains(const DOM::Element& element) const
return false;
}
DOM::Element* ListOfActiveFormattingElements::last_element_with_tag_name_before_marker(FlyString const& tag_name)
DOM::Element* ListOfActiveFormattingElements::last_element_with_tag_name_before_marker(DeprecatedFlyString const& tag_name)
{
for (ssize_t i = m_entries.size() - 1; i >= 0; --i) {
auto& entry = m_entries[i];

View file

@ -37,7 +37,7 @@ public:
Vector<Entry> const& entries() const { return m_entries; }
Vector<Entry>& entries() { return m_entries; }
DOM::Element* last_element_with_tag_name_before_marker(FlyString const& tag_name);
DOM::Element* last_element_with_tag_name_before_marker(DeprecatedFlyString const& tag_name);
void clear_up_to_the_last_marker();

View file

@ -10,7 +10,7 @@
namespace Web::HTML {
static Vector<FlyString> s_base_list { "applet", "caption", "html", "table", "td", "th", "marquee", "object", "template" };
static Vector<DeprecatedFlyString> s_base_list { "applet", "caption", "html", "table", "td", "th", "marquee", "object", "template" };
StackOfOpenElements::~StackOfOpenElements() = default;
@ -20,7 +20,7 @@ void StackOfOpenElements::visit_edges(JS::Cell::Visitor& visitor)
visitor.visit(element);
}
bool StackOfOpenElements::has_in_scope_impl(FlyString const& tag_name, Vector<FlyString> const& list) const
bool StackOfOpenElements::has_in_scope_impl(DeprecatedFlyString const& tag_name, Vector<DeprecatedFlyString> const& list) const
{
for (auto const& element : m_elements.in_reverse()) {
if (element->local_name() == tag_name)
@ -31,12 +31,12 @@ bool StackOfOpenElements::has_in_scope_impl(FlyString const& tag_name, Vector<Fl
VERIFY_NOT_REACHED();
}
bool StackOfOpenElements::has_in_scope(FlyString const& tag_name) const
bool StackOfOpenElements::has_in_scope(DeprecatedFlyString const& tag_name) const
{
return has_in_scope_impl(tag_name, s_base_list);
}
bool StackOfOpenElements::has_in_scope_impl(const DOM::Element& target_node, Vector<FlyString> const& list) const
bool StackOfOpenElements::has_in_scope_impl(const DOM::Element& target_node, Vector<DeprecatedFlyString> const& list) const
{
for (auto& element : m_elements.in_reverse()) {
if (element.ptr() == &target_node)
@ -52,19 +52,19 @@ bool StackOfOpenElements::has_in_scope(const DOM::Element& target_node) const
return has_in_scope_impl(target_node, s_base_list);
}
bool StackOfOpenElements::has_in_button_scope(FlyString const& tag_name) const
bool StackOfOpenElements::has_in_button_scope(DeprecatedFlyString const& tag_name) const
{
auto list = s_base_list;
list.append("button");
return has_in_scope_impl(tag_name, list);
}
bool StackOfOpenElements::has_in_table_scope(FlyString const& tag_name) const
bool StackOfOpenElements::has_in_table_scope(DeprecatedFlyString const& tag_name) const
{
return has_in_scope_impl(tag_name, { "html", "table", "template" });
}
bool StackOfOpenElements::has_in_list_item_scope(FlyString const& tag_name) const
bool StackOfOpenElements::has_in_list_item_scope(DeprecatedFlyString const& tag_name) const
{
auto list = s_base_list;
list.append("ol");
@ -78,7 +78,7 @@ bool StackOfOpenElements::has_in_list_item_scope(FlyString const& tag_name) cons
// - optgroup in the HTML namespace
// - option in the HTML namespace
// NOTE: In this case it's "all element types _except_"
bool StackOfOpenElements::has_in_select_scope(FlyString const& tag_name) const
bool StackOfOpenElements::has_in_select_scope(DeprecatedFlyString const& tag_name) const
{
// https://html.spec.whatwg.org/multipage/parsing.html#has-an-element-in-the-specific-scope
// 1. Initialize node to be the current node (the bottommost node of the stack).
@ -106,7 +106,7 @@ bool StackOfOpenElements::contains(const DOM::Element& element) const
return false;
}
bool StackOfOpenElements::contains(FlyString const& tag_name) const
bool StackOfOpenElements::contains(DeprecatedFlyString const& tag_name) const
{
for (auto& element_on_stack : m_elements) {
if (element_on_stack->local_name() == tag_name)
@ -115,7 +115,7 @@ bool StackOfOpenElements::contains(FlyString const& tag_name) const
return false;
}
void StackOfOpenElements::pop_until_an_element_with_tag_name_has_been_popped(FlyString const& tag_name)
void StackOfOpenElements::pop_until_an_element_with_tag_name_has_been_popped(DeprecatedFlyString const& tag_name)
{
while (m_elements.last()->local_name() != tag_name)
(void)pop();
@ -134,7 +134,7 @@ JS::GCPtr<DOM::Element> StackOfOpenElements::topmost_special_node_below(DOM::Ele
return found_element.ptr();
}
StackOfOpenElements::LastElementResult StackOfOpenElements::last_element_with_tag_name(FlyString const& tag_name)
StackOfOpenElements::LastElementResult StackOfOpenElements::last_element_with_tag_name(DeprecatedFlyString const& tag_name)
{
for (ssize_t i = m_elements.size() - 1; i >= 0; --i) {
auto& element = m_elements[i];

View file

@ -36,21 +36,21 @@ public:
const DOM::Element& current_node() const { return *m_elements.last(); }
DOM::Element& current_node() { return *m_elements.last(); }
bool has_in_scope(FlyString const& tag_name) const;
bool has_in_button_scope(FlyString const& tag_name) const;
bool has_in_table_scope(FlyString const& tag_name) const;
bool has_in_list_item_scope(FlyString const& tag_name) const;
bool has_in_select_scope(FlyString const& tag_name) const;
bool has_in_scope(DeprecatedFlyString const& tag_name) const;
bool has_in_button_scope(DeprecatedFlyString const& tag_name) const;
bool has_in_table_scope(DeprecatedFlyString const& tag_name) const;
bool has_in_list_item_scope(DeprecatedFlyString const& tag_name) const;
bool has_in_select_scope(DeprecatedFlyString const& tag_name) const;
bool has_in_scope(const DOM::Element&) const;
bool contains(const DOM::Element&) const;
bool contains(FlyString const& tag_name) const;
bool contains(DeprecatedFlyString const& tag_name) const;
auto const& elements() const { return m_elements; }
auto& elements() { return m_elements; }
void pop_until_an_element_with_tag_name_has_been_popped(FlyString const&);
void pop_until_an_element_with_tag_name_has_been_popped(DeprecatedFlyString const&);
JS::GCPtr<DOM::Element> topmost_special_node_below(DOM::Element const&);
@ -58,14 +58,14 @@ public:
JS::GCPtr<DOM::Element> element;
ssize_t index;
};
LastElementResult last_element_with_tag_name(FlyString const&);
LastElementResult last_element_with_tag_name(DeprecatedFlyString const&);
JS::GCPtr<DOM::Element> element_immediately_above(DOM::Element const&);
void visit_edges(JS::Cell::Visitor&);
private:
bool has_in_scope_impl(FlyString const& tag_name, Vector<FlyString> const&) const;
bool has_in_scope_impl(const DOM::Element& target_node, Vector<FlyString> const&) const;
bool has_in_scope_impl(DeprecatedFlyString const& tag_name, Vector<DeprecatedFlyString> const&) const;
bool has_in_scope_impl(const DOM::Element& target_node, Vector<DeprecatedFlyString> const&) const;
Vector<JS::NonnullGCPtr<DOM::Element>> m_elements;
};