mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 17:37:37 +00:00
AK+Everywhere: Rename String to DeprecatedString
We have a new, improved string type coming up in AK (OOM aware, no null state), and while it's going to use UTF-8, the name UTF8String is a mouthful - so let's free up the String name by renaming the existing class. Making the old one have an annoying name will hopefully also help with quick adoption :^)
This commit is contained in:
parent
f74251606d
commit
6e19ab2bbc
2006 changed files with 11635 additions and 11636 deletions
|
@ -35,7 +35,7 @@ bool prescan_skip_whitespace_and_slashes(ByteBuffer const& input, size_t& positi
|
|||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/urls-and-fetching.html#algorithm-for-extracting-a-character-encoding-from-a-meta-element
|
||||
Optional<StringView> extract_character_encoding_from_meta_element(String const& string)
|
||||
Optional<StringView> extract_character_encoding_from_meta_element(DeprecatedString const& string)
|
||||
{
|
||||
// Checking for "charset" is case insensitive, as is getting an encoding.
|
||||
// Therefore, stick to lowercase from the start for simplicity.
|
||||
|
@ -158,7 +158,7 @@ value:
|
|||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/parsing.html#prescan-a-byte-stream-to-determine-its-encoding
|
||||
Optional<String> run_prescan_byte_stream_algorithm(DOM::Document& document, ByteBuffer const& input)
|
||||
Optional<DeprecatedString> run_prescan_byte_stream_algorithm(DOM::Document& document, ByteBuffer const& input)
|
||||
{
|
||||
// https://html.spec.whatwg.org/multipage/parsing.html#prescan-a-byte-stream-to-determine-its-encoding
|
||||
|
||||
|
@ -188,10 +188,10 @@ Optional<String> run_prescan_byte_stream_algorithm(DOM::Document& document, Byte
|
|||
&& (input[position + 4] == 'A' || input[position + 4] == 'a')
|
||||
&& prescan_is_whitespace_or_slash(input[position + 5])) {
|
||||
position += 6;
|
||||
Vector<String> attribute_list {};
|
||||
Vector<DeprecatedString> attribute_list {};
|
||||
bool got_pragma = false;
|
||||
Optional<bool> need_pragma {};
|
||||
Optional<String> charset {};
|
||||
Optional<DeprecatedString> charset {};
|
||||
|
||||
while (true) {
|
||||
auto attribute = prescan_get_attribute(document, input, position);
|
||||
|
@ -213,7 +213,7 @@ Optional<String> run_prescan_byte_stream_algorithm(DOM::Document& document, Byte
|
|||
} else if (attribute_name == "charset") {
|
||||
auto maybe_charset = TextCodec::get_standardized_encoding(attribute->value());
|
||||
if (maybe_charset.has_value()) {
|
||||
charset = Optional<String> { maybe_charset };
|
||||
charset = Optional<DeprecatedString> { maybe_charset };
|
||||
need_pragma = { false };
|
||||
}
|
||||
}
|
||||
|
@ -247,7 +247,7 @@ Optional<String> run_prescan_byte_stream_algorithm(DOM::Document& document, Byte
|
|||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/parsing.html#determining-the-character-encoding
|
||||
String run_encoding_sniffing_algorithm(DOM::Document& document, ByteBuffer const& input)
|
||||
DeprecatedString run_encoding_sniffing_algorithm(DOM::Document& document, ByteBuffer const& input)
|
||||
{
|
||||
if (input.size() >= 2) {
|
||||
if (input[0] == 0xFE && input[1] == 0xFF) {
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/Optional.h>
|
||||
#include <AK/String.h>
|
||||
#include <LibJS/Heap/GCPtr.h>
|
||||
#include <LibWeb/Forward.h>
|
||||
|
||||
|
@ -16,9 +16,9 @@ namespace Web::HTML {
|
|||
bool prescan_should_abort(ByteBuffer const& input, size_t const& position);
|
||||
bool prescan_is_whitespace_or_slash(u8 const& byte);
|
||||
bool prescan_skip_whitespace_and_slashes(ByteBuffer const& input, size_t& position);
|
||||
Optional<StringView> extract_character_encoding_from_meta_element(String const&);
|
||||
Optional<StringView> extract_character_encoding_from_meta_element(DeprecatedString const&);
|
||||
JS::GCPtr<DOM::Attr> prescan_get_attribute(DOM::Document&, ByteBuffer const& input, size_t& position);
|
||||
Optional<String> run_prescan_byte_stream_algorithm(DOM::Document&, ByteBuffer const& input);
|
||||
String run_encoding_sniffing_algorithm(DOM::Document&, ByteBuffer const& input);
|
||||
Optional<DeprecatedString> run_prescan_byte_stream_algorithm(DOM::Document&, ByteBuffer const& input);
|
||||
DeprecatedString run_encoding_sniffing_algorithm(DOM::Document&, ByteBuffer const& input);
|
||||
|
||||
}
|
||||
|
|
|
@ -121,7 +121,7 @@ static bool is_html_integration_point(DOM::Element const& element)
|
|||
return false;
|
||||
}
|
||||
|
||||
HTMLParser::HTMLParser(DOM::Document& document, StringView input, String const& encoding)
|
||||
HTMLParser::HTMLParser(DOM::Document& document, StringView input, DeprecatedString const& encoding)
|
||||
: m_tokenizer(input, encoding)
|
||||
, m_scripting_enabled(document.is_scripting_enabled())
|
||||
, m_document(JS::make_handle(document))
|
||||
|
@ -3552,13 +3552,13 @@ JS::NonnullGCPtr<HTMLParser> HTMLParser::create_with_uncertain_encoding(DOM::Doc
|
|||
return *document.heap().allocate_without_realm<HTMLParser>(document, input, encoding);
|
||||
}
|
||||
|
||||
JS::NonnullGCPtr<HTMLParser> HTMLParser::create(DOM::Document& document, StringView input, String const& encoding)
|
||||
JS::NonnullGCPtr<HTMLParser> HTMLParser::create(DOM::Document& document, StringView input, DeprecatedString const& encoding)
|
||||
{
|
||||
return *document.heap().allocate_without_realm<HTMLParser>(document, input, encoding);
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/parsing.html#html-fragment-serialisation-algorithm
|
||||
String HTMLParser::serialize_html_fragment(DOM::Node const& node)
|
||||
DeprecatedString HTMLParser::serialize_html_fragment(DOM::Node const& node)
|
||||
{
|
||||
// The algorithm takes as input a DOM Element, Document, or DocumentFragment referred to as the node.
|
||||
VERIFY(node.is_element() || node.is_document() || node.is_document_fragment());
|
||||
|
@ -3570,7 +3570,7 @@ String HTMLParser::serialize_html_fragment(DOM::Node const& node)
|
|||
// 1. If the node serializes as void, then return the empty string.
|
||||
// (NOTE: serializes as void is defined only on elements in the spec)
|
||||
if (element.serializes_as_void())
|
||||
return String::empty();
|
||||
return DeprecatedString::empty();
|
||||
|
||||
// 3. If the node is a template element, then let the node instead be the template element's template contents (a DocumentFragment node).
|
||||
// (NOTE: This is out of order of the spec to avoid another dynamic cast. The second step just creates a string builder, so it shouldn't matter)
|
||||
|
@ -3583,7 +3583,7 @@ String HTMLParser::serialize_html_fragment(DOM::Node const& node)
|
|||
Yes,
|
||||
};
|
||||
|
||||
auto escape_string = [](StringView string, AttributeMode attribute_mode) -> String {
|
||||
auto escape_string = [](StringView string, AttributeMode attribute_mode) -> DeprecatedString {
|
||||
// https://html.spec.whatwg.org/multipage/parsing.html#escapingString
|
||||
StringBuilder builder;
|
||||
for (auto& ch : string) {
|
||||
|
@ -3622,7 +3622,7 @@ String HTMLParser::serialize_html_fragment(DOM::Node const& node)
|
|||
|
||||
// 1. If current node is an element in the HTML namespace, the MathML namespace, or the SVG namespace, then let tagname be current node's local name.
|
||||
// Otherwise, let tagname be current node's qualified name.
|
||||
String tag_name;
|
||||
DeprecatedString tag_name;
|
||||
|
||||
if (element.namespace_().is_one_of(Namespace::HTML, Namespace::MathML, Namespace::SVG))
|
||||
tag_name = element.local_name();
|
||||
|
|
|
@ -49,7 +49,7 @@ public:
|
|||
|
||||
static JS::NonnullGCPtr<HTMLParser> create_for_scripting(DOM::Document&);
|
||||
static JS::NonnullGCPtr<HTMLParser> create_with_uncertain_encoding(DOM::Document&, ByteBuffer const& input);
|
||||
static JS::NonnullGCPtr<HTMLParser> create(DOM::Document&, StringView input, String const& encoding);
|
||||
static JS::NonnullGCPtr<HTMLParser> create(DOM::Document&, StringView input, DeprecatedString const& encoding);
|
||||
|
||||
void run();
|
||||
void run(const AK::URL&);
|
||||
|
@ -57,7 +57,7 @@ public:
|
|||
DOM::Document& document();
|
||||
|
||||
static Vector<JS::Handle<DOM::Node>> parse_html_fragment(DOM::Element& context_element, StringView);
|
||||
static String serialize_html_fragment(DOM::Node const& node);
|
||||
static DeprecatedString serialize_html_fragment(DOM::Node const& node);
|
||||
|
||||
enum class InsertionMode {
|
||||
#define __ENUMERATE_INSERTION_MODE(mode) mode,
|
||||
|
@ -80,7 +80,7 @@ public:
|
|||
size_t script_nesting_level() const { return m_script_nesting_level; }
|
||||
|
||||
private:
|
||||
HTMLParser(DOM::Document&, StringView input, String const& encoding);
|
||||
HTMLParser(DOM::Document&, StringView input, DeprecatedString const& encoding);
|
||||
HTMLParser(DOM::Document&);
|
||||
|
||||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
namespace Web::HTML {
|
||||
|
||||
String HTMLToken::to_string() const
|
||||
DeprecatedString HTMLToken::to_string() const
|
||||
{
|
||||
StringBuilder builder;
|
||||
|
||||
|
|
|
@ -7,10 +7,10 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/FlyString.h>
|
||||
#include <AK/Function.h>
|
||||
#include <AK/OwnPtr.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/Types.h>
|
||||
#include <AK/Variant.h>
|
||||
#include <AK/Vector.h>
|
||||
|
@ -39,10 +39,10 @@ public:
|
|||
};
|
||||
|
||||
struct Attribute {
|
||||
String prefix;
|
||||
String local_name { "" };
|
||||
String namespace_;
|
||||
String value { "" };
|
||||
DeprecatedString prefix;
|
||||
DeprecatedString local_name { "" };
|
||||
DeprecatedString namespace_;
|
||||
DeprecatedString value { "" };
|
||||
Position name_start_position;
|
||||
Position value_start_position;
|
||||
Position name_end_position;
|
||||
|
@ -51,9 +51,9 @@ public:
|
|||
|
||||
struct DoctypeData {
|
||||
// NOTE: "Missing" is a distinct state from the empty string.
|
||||
String name;
|
||||
String public_identifier;
|
||||
String system_identifier;
|
||||
DeprecatedString name;
|
||||
DeprecatedString public_identifier;
|
||||
DeprecatedString system_identifier;
|
||||
bool missing_name { true };
|
||||
bool missing_public_identifier { true };
|
||||
bool missing_system_identifier { true };
|
||||
|
@ -140,7 +140,7 @@ public:
|
|||
return m_string_data;
|
||||
}
|
||||
|
||||
void set_comment(String comment)
|
||||
void set_comment(DeprecatedString comment)
|
||||
{
|
||||
VERIFY(is_comment());
|
||||
m_string_data = move(comment);
|
||||
|
@ -152,7 +152,7 @@ public:
|
|||
return m_string_data;
|
||||
}
|
||||
|
||||
void set_tag_name(String name)
|
||||
void set_tag_name(DeprecatedString name)
|
||||
{
|
||||
VERIFY(is_start_tag() || is_end_tag());
|
||||
m_string_data = move(name);
|
||||
|
@ -315,7 +315,7 @@ public:
|
|||
|
||||
Type type() const { return m_type; }
|
||||
|
||||
String to_string() const;
|
||||
DeprecatedString to_string() const;
|
||||
|
||||
Position const& start_position() const { return m_start_position; }
|
||||
Position const& end_position() const { return m_end_position; }
|
||||
|
|
|
@ -2796,7 +2796,7 @@ HTMLTokenizer::HTMLTokenizer()
|
|||
m_source_positions.empend(0u, 0u);
|
||||
}
|
||||
|
||||
HTMLTokenizer::HTMLTokenizer(StringView input, String const& encoding)
|
||||
HTMLTokenizer::HTMLTokenizer(StringView input, DeprecatedString const& encoding)
|
||||
{
|
||||
auto* decoder = TextCodec::decoder_for(encoding);
|
||||
VERIFY(decoder);
|
||||
|
@ -2807,7 +2807,7 @@ HTMLTokenizer::HTMLTokenizer(StringView input, String const& encoding)
|
|||
m_source_positions.empend(0u, 0u);
|
||||
}
|
||||
|
||||
void HTMLTokenizer::insert_input_at_insertion_point(String const& input)
|
||||
void HTMLTokenizer::insert_input_at_insertion_point(DeprecatedString const& input)
|
||||
{
|
||||
auto utf8_iterator_byte_offset = m_utf8_view.byte_offset_of(m_utf8_iterator);
|
||||
|
||||
|
@ -2885,7 +2885,7 @@ void HTMLTokenizer::restore_to(Utf8CodePointIterator const& new_iterator)
|
|||
m_utf8_iterator = new_iterator;
|
||||
}
|
||||
|
||||
String HTMLTokenizer::consume_current_builder()
|
||||
DeprecatedString HTMLTokenizer::consume_current_builder()
|
||||
{
|
||||
auto string = m_current_builder.to_string();
|
||||
m_current_builder.clear();
|
||||
|
|
|
@ -102,7 +102,7 @@ namespace Web::HTML {
|
|||
class HTMLTokenizer {
|
||||
public:
|
||||
explicit HTMLTokenizer();
|
||||
explicit HTMLTokenizer(StringView input, String const& encoding);
|
||||
explicit HTMLTokenizer(StringView input, DeprecatedString const& encoding);
|
||||
|
||||
enum class State {
|
||||
#define __ENUMERATE_TOKENIZER_STATE(state) state,
|
||||
|
@ -123,9 +123,9 @@ public:
|
|||
void set_blocked(bool b) { m_blocked = b; }
|
||||
bool is_blocked() const { return m_blocked; }
|
||||
|
||||
String source() const { return m_decoded_input; }
|
||||
DeprecatedString source() const { return m_decoded_input; }
|
||||
|
||||
void insert_input_at_insertion_point(String const& input);
|
||||
void insert_input_at_insertion_point(DeprecatedString const& input);
|
||||
void insert_eof();
|
||||
bool is_eof_inserted();
|
||||
|
||||
|
@ -153,7 +153,7 @@ private:
|
|||
bool consume_next_if_match(StringView, CaseSensitivity = CaseSensitivity::CaseSensitive);
|
||||
void create_new_token(HTMLToken::Type);
|
||||
bool current_end_tag_token_is_appropriate() const;
|
||||
String consume_current_builder();
|
||||
DeprecatedString consume_current_builder();
|
||||
|
||||
static char const* state_name(State state)
|
||||
{
|
||||
|
@ -183,7 +183,7 @@ private:
|
|||
|
||||
Vector<u32> m_temporary_buffer;
|
||||
|
||||
String m_decoded_input;
|
||||
DeprecatedString m_decoded_input;
|
||||
|
||||
struct InsertionPoint {
|
||||
size_t position { 0 };
|
||||
|
@ -199,7 +199,7 @@ private:
|
|||
HTMLToken m_current_token;
|
||||
StringBuilder m_current_builder;
|
||||
|
||||
Optional<String> m_last_emitted_start_tag_name;
|
||||
Optional<DeprecatedString> m_last_emitted_start_tag_name;
|
||||
|
||||
bool m_explicit_eof_inserted { false };
|
||||
bool m_has_emitted_eof { false };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue