From 41387c6b8d961e5a01ed60ab86cd3866bb8f881f Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Mon, 24 Mar 2025 11:27:27 +0000 Subject: [PATCH] LibJS+LibWeb: Remove more uses of DeprecatedFlyString --- Libraries/LibJS/Bytecode/Op.h | 2 -- Libraries/LibJS/Parser.h | 1 - Libraries/LibJS/Runtime/CommonPropertyNames.h | 1 - Libraries/LibJS/Runtime/Completion.h | 1 - Libraries/LibJS/Runtime/ExecutionContext.h | 1 - Libraries/LibJS/Runtime/PrimitiveString.cpp | 5 ----- Libraries/LibJS/Runtime/PrimitiveString.h | 1 - Libraries/LibWeb/HTML/Parser/HTMLTokenizer.cpp | 4 ++-- Libraries/LibWeb/HTML/Parser/HTMLTokenizer.h | 2 +- Libraries/LibWeb/HTML/StructuredSerialize.cpp | 4 ++-- Libraries/LibWeb/HTML/StructuredSerialize.h | 2 +- Libraries/LibWeb/XML/XMLDocumentBuilder.cpp | 8 ++++---- 12 files changed, 10 insertions(+), 22 deletions(-) diff --git a/Libraries/LibJS/Bytecode/Op.h b/Libraries/LibJS/Bytecode/Op.h index 57aca1ac1e8..79c4998a5a0 100644 --- a/Libraries/LibJS/Bytecode/Op.h +++ b/Libraries/LibJS/Bytecode/Op.h @@ -1336,8 +1336,6 @@ public: Operand base() const { return m_base; } Operand property() const { return m_property; } - Optional base_identifier(Bytecode::Interpreter const&) const; - private: Operand m_dst; Operand m_base; diff --git a/Libraries/LibJS/Parser.h b/Libraries/LibJS/Parser.h index 7129fa8fd5c..9e0f4a11769 100644 --- a/Libraries/LibJS/Parser.h +++ b/Libraries/LibJS/Parser.h @@ -338,7 +338,6 @@ private: NonnullRefPtr m_source_code; Vector m_rule_starts; ParserState m_state; - DeprecatedFlyString m_filename; Vector m_saved_state; HashMap m_token_memoizations; Program::Type m_program_type; diff --git a/Libraries/LibJS/Runtime/CommonPropertyNames.h b/Libraries/LibJS/Runtime/CommonPropertyNames.h index b03b57b111b..adc1774377f 100644 --- a/Libraries/LibJS/Runtime/CommonPropertyNames.h +++ b/Libraries/LibJS/Runtime/CommonPropertyNames.h @@ -6,7 +6,6 @@ #pragma once -#include #include #include diff --git a/Libraries/LibJS/Runtime/Completion.h b/Libraries/LibJS/Runtime/Completion.h index 81b6454fc16..974cdf353fd 100644 --- a/Libraries/LibJS/Runtime/Completion.h +++ b/Libraries/LibJS/Runtime/Completion.h @@ -7,7 +7,6 @@ #pragma once -#include #include #include #include diff --git a/Libraries/LibJS/Runtime/ExecutionContext.h b/Libraries/LibJS/Runtime/ExecutionContext.h index 7eb2ec6bf90..f6c32153045 100644 --- a/Libraries/LibJS/Runtime/ExecutionContext.h +++ b/Libraries/LibJS/Runtime/ExecutionContext.h @@ -8,7 +8,6 @@ #pragma once -#include #include #include #include diff --git a/Libraries/LibJS/Runtime/PrimitiveString.cpp b/Libraries/LibJS/Runtime/PrimitiveString.cpp index fd50a038f8f..1d11226a6f6 100644 --- a/Libraries/LibJS/Runtime/PrimitiveString.cpp +++ b/Libraries/LibJS/Runtime/PrimitiveString.cpp @@ -229,11 +229,6 @@ GC::Ref PrimitiveString::create(VM& vm, ByteString string) return *it->value; } -GC::Ref PrimitiveString::create(VM& vm, DeprecatedFlyString const& string) -{ - return create(vm, ByteString { string }); -} - GC::Ref PrimitiveString::create(VM& vm, PrimitiveString& lhs, PrimitiveString& rhs) { // We're here to concatenate two strings into a new rope string. diff --git a/Libraries/LibJS/Runtime/PrimitiveString.h b/Libraries/LibJS/Runtime/PrimitiveString.h index 9781bf5e0c9..9a227e16d77 100644 --- a/Libraries/LibJS/Runtime/PrimitiveString.h +++ b/Libraries/LibJS/Runtime/PrimitiveString.h @@ -29,7 +29,6 @@ public: [[nodiscard]] static GC::Ref create(VM&, String); [[nodiscard]] static GC::Ref create(VM&, FlyString const&); [[nodiscard]] static GC::Ref create(VM&, ByteString); - [[nodiscard]] static GC::Ref create(VM&, DeprecatedFlyString const&); [[nodiscard]] static GC::Ref create(VM&, PrimitiveString&, PrimitiveString&); [[nodiscard]] static GC::Ref create(VM&, StringView); diff --git a/Libraries/LibWeb/HTML/Parser/HTMLTokenizer.cpp b/Libraries/LibWeb/HTML/Parser/HTMLTokenizer.cpp index ec76e978340..ce5f91a7348 100644 --- a/Libraries/LibWeb/HTML/Parser/HTMLTokenizer.cpp +++ b/Libraries/LibWeb/HTML/Parser/HTMLTokenizer.cpp @@ -2923,7 +2923,7 @@ void HTMLTokenizer::switch_to(Badge, State new_state) void HTMLTokenizer::will_emit(HTMLToken& token) { if (token.is_start_tag()) - m_last_emitted_start_tag_name = token.tag_name().to_deprecated_fly_string(); + m_last_emitted_start_tag_name = token.tag_name(); auto is_start_or_end_tag = token.type() == HTMLToken::Type::StartTag || token.type() == HTMLToken::Type::EndTag; token.set_end_position({}, nth_last_position(is_start_or_end_tag ? 1 : 0)); @@ -2937,7 +2937,7 @@ bool HTMLTokenizer::current_end_tag_token_is_appropriate() const VERIFY(m_current_token.is_end_tag()); if (!m_last_emitted_start_tag_name.has_value()) return false; - return m_current_token.tag_name().to_deprecated_fly_string() == m_last_emitted_start_tag_name.value(); + return m_current_token.tag_name() == m_last_emitted_start_tag_name.value(); } bool HTMLTokenizer::consumed_as_part_of_an_attribute() const diff --git a/Libraries/LibWeb/HTML/Parser/HTMLTokenizer.h b/Libraries/LibWeb/HTML/Parser/HTMLTokenizer.h index 7d949463e17..df4eab97bbb 100644 --- a/Libraries/LibWeb/HTML/Parser/HTMLTokenizer.h +++ b/Libraries/LibWeb/HTML/Parser/HTMLTokenizer.h @@ -214,7 +214,7 @@ private: NamedCharacterReferenceMatcher m_named_character_reference_matcher; - Optional m_last_emitted_start_tag_name; + Optional m_last_emitted_start_tag_name; bool m_explicit_eof_inserted { false }; bool m_has_emitted_eof { false }; diff --git a/Libraries/LibWeb/HTML/StructuredSerialize.cpp b/Libraries/LibWeb/HTML/StructuredSerialize.cpp index edeb09ec261..cb9cce76474 100644 --- a/Libraries/LibWeb/HTML/StructuredSerialize.cpp +++ b/Libraries/LibWeb/HTML/StructuredSerialize.cpp @@ -547,9 +547,9 @@ WebIDL::ExceptionOr serialize_bytes(JS::VM& vm, Vector& vector, Reado return {}; } -WebIDL::ExceptionOr serialize_string(JS::VM& vm, Vector& vector, DeprecatedFlyString const& string) +WebIDL::ExceptionOr serialize_string(JS::VM& vm, Vector& vector, StringView string) { - return serialize_bytes(vm, vector, string.view().bytes()); + return serialize_bytes(vm, vector, string.bytes()); } WebIDL::ExceptionOr serialize_string(JS::VM& vm, Vector& vector, String const& string) diff --git a/Libraries/LibWeb/HTML/StructuredSerialize.h b/Libraries/LibWeb/HTML/StructuredSerialize.h index 981b6210e8e..0719ab4743e 100644 --- a/Libraries/LibWeb/HTML/StructuredSerialize.h +++ b/Libraries/LibWeb/HTML/StructuredSerialize.h @@ -88,7 +88,7 @@ void serialize_enum(SerializationRecord& serialized, T value) } WebIDL::ExceptionOr serialize_bytes(JS::VM& vm, Vector& vector, ReadonlyBytes bytes); -WebIDL::ExceptionOr serialize_string(JS::VM& vm, Vector& vector, DeprecatedFlyString const& string); +WebIDL::ExceptionOr serialize_string(JS::VM& vm, Vector& vector, StringView); WebIDL::ExceptionOr serialize_string(JS::VM& vm, Vector& vector, String const& string); WebIDL::ExceptionOr serialize_string(JS::VM& vm, Vector& vector, JS::PrimitiveString const& primitive_string); WebIDL::ExceptionOr serialize_array_buffer(JS::VM& vm, Vector& vector, JS::ArrayBuffer const& array_buffer, bool for_storage); diff --git a/Libraries/LibWeb/XML/XMLDocumentBuilder.cpp b/Libraries/LibWeb/XML/XMLDocumentBuilder.cpp index 21ff65bfac8..c476678e5f0 100644 --- a/Libraries/LibWeb/XML/XMLDocumentBuilder.cpp +++ b/Libraries/LibWeb/XML/XMLDocumentBuilder.cpp @@ -106,7 +106,7 @@ void XMLDocumentBuilder::element_start(const XML::Name& name, HashMaprealm(), namespace_, MUST(FlyString::from_deprecated_fly_string(name))); + auto qualified_name_or_error = DOM::validate_and_extract(m_document->realm(), namespace_, FlyString(MUST(String::from_byte_string(name)))); if (qualified_name_or_error.is_error()) { m_has_error = true; @@ -157,7 +157,7 @@ void XMLDocumentBuilder::element_start(const XML::Name& name, HashMapset_attribute_ns(Namespace::XMLNS, MUST(FlyString::from_deprecated_fly_string(name)), MUST(String::from_byte_string(attribute.value)))); + MUST(node->set_attribute_ns(Namespace::XMLNS, MUST(String::from_byte_string(name)), MUST(String::from_byte_string(attribute.value)))); } else { m_has_error = true; } @@ -166,7 +166,7 @@ void XMLDocumentBuilder::element_start(const XML::Name& name, HashMapset_attribute(MUST(FlyString::from_deprecated_fly_string(attribute.key)), MUST(String::from_byte_string(attribute.value)))); + MUST(node->set_attribute(MUST(String::from_byte_string(attribute.key)), MUST(String::from_byte_string(attribute.value)))); } m_current_node = node.ptr();