mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 22:48:11 +00:00
Everywhere: Rename {Deprecated => Byte}String
This commit un-deprecates DeprecatedString, and repurposes it as a byte string. As the null state has already been removed, there are no other particularly hairy blockers in repurposing this type as a byte string (what it _really_ is). This commit is auto-generated: $ xs=$(ack -l \bDeprecatedString\b\|deprecated_string AK Userland \ Meta Ports Ladybird Tests Kernel) $ perl -pie 's/\bDeprecatedString\b/ByteString/g; s/deprecated_string/byte_string/g' $xs $ clang-format --style=file -i \ $(git diff --name-only | grep \.cpp\|\.h) $ gn format $(git ls-files '*.gn' '*.gni')
This commit is contained in:
parent
38d62563b3
commit
5e1499d104
1615 changed files with 10257 additions and 10257 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(DeprecatedString const& string)
|
||||
Optional<StringView> extract_character_encoding_from_meta_element(ByteString 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<DeprecatedString> run_prescan_byte_stream_algorithm(DOM::Document& document, ByteBuffer const& input)
|
||||
Optional<ByteString> 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
|
||||
|
||||
|
@ -191,7 +191,7 @@ Optional<DeprecatedString> run_prescan_byte_stream_algorithm(DOM::Document& docu
|
|||
Vector<FlyString> attribute_list {};
|
||||
bool got_pragma = false;
|
||||
Optional<bool> need_pragma {};
|
||||
Optional<DeprecatedString> charset {};
|
||||
Optional<ByteString> charset {};
|
||||
|
||||
while (true) {
|
||||
auto attribute = prescan_get_attribute(document, input, position);
|
||||
|
@ -205,7 +205,7 @@ Optional<DeprecatedString> run_prescan_byte_stream_algorithm(DOM::Document& docu
|
|||
if (attribute_name == "http-equiv") {
|
||||
got_pragma = attribute->value() == "content-type";
|
||||
} else if (attribute_name == "content") {
|
||||
auto encoding = extract_character_encoding_from_meta_element(attribute->value().to_deprecated_string());
|
||||
auto encoding = extract_character_encoding_from_meta_element(attribute->value().to_byte_string());
|
||||
if (encoding.has_value() && !charset.has_value()) {
|
||||
charset = encoding.value();
|
||||
need_pragma = true;
|
||||
|
@ -213,7 +213,7 @@ Optional<DeprecatedString> run_prescan_byte_stream_algorithm(DOM::Document& docu
|
|||
} else if (attribute_name == "charset") {
|
||||
auto maybe_charset = TextCodec::get_standardized_encoding(attribute->value());
|
||||
if (maybe_charset.has_value()) {
|
||||
charset = Optional<DeprecatedString> { maybe_charset };
|
||||
charset = Optional<ByteString> { maybe_charset };
|
||||
need_pragma = { false };
|
||||
}
|
||||
}
|
||||
|
@ -247,7 +247,7 @@ Optional<DeprecatedString> run_prescan_byte_stream_algorithm(DOM::Document& docu
|
|||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/parsing.html#determining-the-character-encoding
|
||||
DeprecatedString run_encoding_sniffing_algorithm(DOM::Document& document, ByteBuffer const& input)
|
||||
ByteString run_encoding_sniffing_algorithm(DOM::Document& document, ByteBuffer const& input)
|
||||
{
|
||||
if (input.size() >= 2) {
|
||||
if (input[0] == 0xFE && input[1] == 0xFF) {
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/Optional.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(DeprecatedString const&);
|
||||
Optional<StringView> extract_character_encoding_from_meta_element(ByteString const&);
|
||||
JS::GCPtr<DOM::Attr> prescan_get_attribute(DOM::Document&, ByteBuffer const& input, size_t& position);
|
||||
Optional<DeprecatedString> run_prescan_byte_stream_algorithm(DOM::Document&, ByteBuffer const& input);
|
||||
DeprecatedString run_encoding_sniffing_algorithm(DOM::Document&, ByteBuffer const& input);
|
||||
Optional<ByteString> run_prescan_byte_stream_algorithm(DOM::Document&, ByteBuffer const& input);
|
||||
ByteString run_encoding_sniffing_algorithm(DOM::Document&, ByteBuffer const& input);
|
||||
|
||||
}
|
||||
|
|
|
@ -132,7 +132,7 @@ static bool is_html_integration_point(DOM::Element const& element)
|
|||
return false;
|
||||
}
|
||||
|
||||
HTMLParser::HTMLParser(DOM::Document& document, StringView input, DeprecatedString const& encoding)
|
||||
HTMLParser::HTMLParser(DOM::Document& document, StringView input, ByteString const& encoding)
|
||||
: m_tokenizer(input, encoding)
|
||||
, m_scripting_enabled(document.is_scripting_enabled())
|
||||
, m_document(JS::make_handle(document))
|
||||
|
@ -219,7 +219,7 @@ void HTMLParser::run()
|
|||
void HTMLParser::run(const AK::URL& url)
|
||||
{
|
||||
m_document->set_url(url);
|
||||
m_document->set_source(MUST(String::from_deprecated_string(m_tokenizer.source())));
|
||||
m_document->set_source(MUST(String::from_byte_string(m_tokenizer.source())));
|
||||
run();
|
||||
the_end();
|
||||
m_document->detach_parser({});
|
||||
|
@ -4223,13 +4223,13 @@ JS::NonnullGCPtr<HTMLParser> HTMLParser::create_for_scripting(DOM::Document& doc
|
|||
JS::NonnullGCPtr<HTMLParser> HTMLParser::create_with_uncertain_encoding(DOM::Document& document, ByteBuffer const& input)
|
||||
{
|
||||
if (document.has_encoding())
|
||||
return document.heap().allocate_without_realm<HTMLParser>(document, input, document.encoding().value().to_deprecated_string());
|
||||
return document.heap().allocate_without_realm<HTMLParser>(document, input, document.encoding().value().to_byte_string());
|
||||
auto encoding = run_encoding_sniffing_algorithm(document, input);
|
||||
dbgln_if(HTML_PARSER_DEBUG, "The encoding sniffing algorithm returned encoding '{}'", encoding);
|
||||
return document.heap().allocate_without_realm<HTMLParser>(document, input, encoding);
|
||||
}
|
||||
|
||||
JS::NonnullGCPtr<HTMLParser> HTMLParser::create(DOM::Document& document, StringView input, DeprecatedString const& encoding)
|
||||
JS::NonnullGCPtr<HTMLParser> HTMLParser::create(DOM::Document& document, StringView input, ByteString const& encoding)
|
||||
{
|
||||
return document.heap().allocate_without_realm<HTMLParser>(document, input, encoding);
|
||||
}
|
||||
|
@ -4545,7 +4545,7 @@ RefPtr<CSS::StyleValue> parse_nonzero_dimension_value(StringView string)
|
|||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#rules-for-parsing-a-legacy-colour-value
|
||||
Optional<Color> parse_legacy_color_value(DeprecatedString input)
|
||||
Optional<Color> parse_legacy_color_value(ByteString input)
|
||||
{
|
||||
// 1. Let input be the string being parsed
|
||||
// 2. If input is the empty string, then return an error.
|
||||
|
@ -4591,7 +4591,7 @@ Optional<Color> parse_legacy_color_value(DeprecatedString input)
|
|||
}
|
||||
|
||||
// 7. Replace any code points greater than U+FFFF in input (i.e., any characters that are not in the basic multilingual plane) with the two-character string "00".
|
||||
auto replace_non_basic_multilingual_code_points = [](StringView string) -> DeprecatedString {
|
||||
auto replace_non_basic_multilingual_code_points = [](StringView string) -> ByteString {
|
||||
StringBuilder builder;
|
||||
for (auto code_point : Utf8View { string }) {
|
||||
if (code_point > 0xFFFF)
|
||||
|
@ -4599,7 +4599,7 @@ Optional<Color> parse_legacy_color_value(DeprecatedString input)
|
|||
else
|
||||
builder.append_code_point(code_point);
|
||||
}
|
||||
return builder.to_deprecated_string();
|
||||
return builder.to_byte_string();
|
||||
};
|
||||
input = replace_non_basic_multilingual_code_points(input);
|
||||
|
||||
|
@ -4612,7 +4612,7 @@ Optional<Color> parse_legacy_color_value(DeprecatedString input)
|
|||
input = input.substring(1);
|
||||
|
||||
// 10. Replace any character in input that is not an ASCII hex digit with the character U+0030 DIGIT ZERO (0).
|
||||
auto replace_non_ascii_hex = [](StringView string) -> DeprecatedString {
|
||||
auto replace_non_ascii_hex = [](StringView string) -> ByteString {
|
||||
StringBuilder builder;
|
||||
for (auto code_point : Utf8View { string }) {
|
||||
if (is_ascii_hex_digit(code_point))
|
||||
|
@ -4620,7 +4620,7 @@ Optional<Color> parse_legacy_color_value(DeprecatedString input)
|
|||
else
|
||||
builder.append_code_point('0');
|
||||
}
|
||||
return builder.to_deprecated_string();
|
||||
return builder.to_byte_string();
|
||||
};
|
||||
input = replace_non_ascii_hex(input);
|
||||
|
||||
|
@ -4629,7 +4629,7 @@ Optional<Color> parse_legacy_color_value(DeprecatedString input)
|
|||
builder.append(input);
|
||||
while (builder.length() == 0 || (builder.length() % 3 != 0))
|
||||
builder.append_code_point('0');
|
||||
input = builder.to_deprecated_string();
|
||||
input = builder.to_byte_string();
|
||||
|
||||
// 12. Split input into three strings of equal code point length, to obtain three components. Let length be the code point length that all of those components have (one third the code point length of input).
|
||||
auto length = input.length() / 3;
|
||||
|
|
|
@ -51,7 +51,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, DeprecatedString const& encoding);
|
||||
static JS::NonnullGCPtr<HTMLParser> create(DOM::Document&, StringView input, ByteString const& encoding);
|
||||
|
||||
void run();
|
||||
void run(const AK::URL&);
|
||||
|
@ -82,7 +82,7 @@ public:
|
|||
size_t script_nesting_level() const { return m_script_nesting_level; }
|
||||
|
||||
private:
|
||||
HTMLParser(DOM::Document&, StringView input, DeprecatedString const& encoding);
|
||||
HTMLParser(DOM::Document&, StringView input, ByteString const& encoding);
|
||||
HTMLParser(DOM::Document&);
|
||||
|
||||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
|
@ -202,6 +202,6 @@ private:
|
|||
|
||||
RefPtr<CSS::StyleValue> parse_dimension_value(StringView);
|
||||
RefPtr<CSS::StyleValue> parse_nonzero_dimension_value(StringView);
|
||||
Optional<Color> parse_legacy_color_value(DeprecatedString input);
|
||||
Optional<Color> parse_legacy_color_value(ByteString input);
|
||||
|
||||
}
|
||||
|
|
|
@ -2788,11 +2788,11 @@ HTMLTokenizer::HTMLTokenizer()
|
|||
m_source_positions.empend(0u, 0u);
|
||||
}
|
||||
|
||||
HTMLTokenizer::HTMLTokenizer(StringView input, DeprecatedString const& encoding)
|
||||
HTMLTokenizer::HTMLTokenizer(StringView input, ByteString const& encoding)
|
||||
{
|
||||
auto decoder = TextCodec::decoder_for(encoding);
|
||||
VERIFY(decoder.has_value());
|
||||
m_decoded_input = decoder->to_utf8(input).release_value_but_fixme_should_propagate_errors().to_deprecated_string();
|
||||
m_decoded_input = decoder->to_utf8(input).release_value_but_fixme_should_propagate_errors().to_byte_string();
|
||||
m_utf8_view = Utf8View(m_decoded_input);
|
||||
m_utf8_iterator = m_utf8_view.begin();
|
||||
m_prev_utf8_iterator = m_utf8_view.begin();
|
||||
|
@ -2808,7 +2808,7 @@ void HTMLTokenizer::insert_input_at_insertion_point(StringView input)
|
|||
builder.append(m_decoded_input.substring(0, m_insertion_point.position));
|
||||
builder.append(input);
|
||||
builder.append(m_decoded_input.substring(m_insertion_point.position));
|
||||
m_decoded_input = builder.to_deprecated_string();
|
||||
m_decoded_input = builder.to_byte_string();
|
||||
|
||||
m_utf8_view = Utf8View(m_decoded_input);
|
||||
m_utf8_iterator = m_utf8_view.iterator_at_byte_offset(utf8_iterator_byte_offset);
|
||||
|
|
|
@ -103,7 +103,7 @@ namespace Web::HTML {
|
|||
class HTMLTokenizer {
|
||||
public:
|
||||
explicit HTMLTokenizer();
|
||||
explicit HTMLTokenizer(StringView input, DeprecatedString const& encoding);
|
||||
explicit HTMLTokenizer(StringView input, ByteString const& encoding);
|
||||
|
||||
enum class State {
|
||||
#define __ENUMERATE_TOKENIZER_STATE(state) state,
|
||||
|
@ -124,7 +124,7 @@ public:
|
|||
void set_blocked(bool b) { m_blocked = b; }
|
||||
bool is_blocked() const { return m_blocked; }
|
||||
|
||||
DeprecatedString source() const { return m_decoded_input; }
|
||||
ByteString source() const { return m_decoded_input; }
|
||||
|
||||
void insert_input_at_insertion_point(StringView input);
|
||||
void insert_eof();
|
||||
|
@ -184,7 +184,7 @@ private:
|
|||
|
||||
Vector<u32> m_temporary_buffer;
|
||||
|
||||
DeprecatedString m_decoded_input;
|
||||
ByteString m_decoded_input;
|
||||
|
||||
struct InsertionPoint {
|
||||
size_t position { 0 };
|
||||
|
@ -200,7 +200,7 @@ private:
|
|||
HTMLToken m_current_token;
|
||||
StringBuilder m_current_builder;
|
||||
|
||||
Optional<DeprecatedString> m_last_emitted_start_tag_name;
|
||||
Optional<ByteString> 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