From dd419b5a8df3b9a32478c4a8f0ea9f70334214cd Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Mon, 14 Oct 2024 10:05:01 +0200 Subject: [PATCH] AK: Make String::number() infallible This API will always succeed in creating a String representing the provided number in base-10. --- AK/String.h | 4 ++-- .../LibTextCodec/GenerateEncodingIndexes.cpp | 14 +++++++------- .../LibWeb/BindingsGenerator/IDLGenerators.cpp | 2 +- .../CodeGenerators/LibWeb/GenerateAriaRoles.cpp | 2 +- .../LibWeb/GenerateCSSMathFunctions.cpp | 8 ++++---- Tests/AK/TestJSON.cpp | 8 ++++---- Userland/Libraries/LibJS/Bytecode/Generator.h | 2 +- Userland/Libraries/LibJS/Bytecode/Interpreter.cpp | 2 +- Userland/Libraries/LibJS/MarkupGenerator.cpp | 2 +- Userland/Libraries/LibJS/Runtime/StringObject.cpp | 4 ++-- Userland/Libraries/LibJS/Runtime/TypedArray.h | 2 +- Userland/Libraries/LibJS/Runtime/Value.cpp | 4 ++-- .../Libraries/LibWeb/Bindings/PlatformObject.cpp | 2 +- Userland/Libraries/LibWeb/CSS/MediaQuery.cpp | 2 +- Userland/Libraries/LibWeb/CSS/Number.h | 2 +- Userland/Libraries/LibWeb/CSS/Parser/Token.cpp | 2 +- Userland/Libraries/LibWeb/CSS/Selector.h | 2 +- .../LibWeb/CSS/StyleValues/IntegerStyleValue.cpp | 2 +- .../LibWeb/CSS/StyleValues/NumberStyleValue.cpp | 2 +- .../CSS/StyleValues/TransformationStyleValue.cpp | 2 +- Userland/Libraries/LibWeb/DOM/Element.cpp | 2 +- .../Libraries/LibWeb/Fetch/Fetching/Fetching.cpp | 4 ++-- .../LibWeb/Fetch/Infrastructure/HTTP/Requests.cpp | 4 ++-- Userland/Libraries/LibWeb/HTML/AudioTrack.cpp | 2 +- .../LibWeb/HTML/FormControlInfrastructure.cpp | 4 ++-- .../Libraries/LibWeb/HTML/HTMLCanvasElement.cpp | 4 ++-- .../LibWeb/HTML/HTMLHyperlinkElementUtils.cpp | 2 +- .../Libraries/LibWeb/HTML/HTMLImageElement.cpp | 4 ++-- .../Libraries/LibWeb/HTML/HTMLInputElement.cpp | 6 +++--- Userland/Libraries/LibWeb/HTML/HTMLLIElement.h | 2 +- .../Libraries/LibWeb/HTML/HTMLMarqueeElement.cpp | 4 ++-- .../Libraries/LibWeb/HTML/HTMLMeterElement.cpp | 12 ++++++------ Userland/Libraries/LibWeb/HTML/HTMLOListElement.h | 2 +- .../Libraries/LibWeb/HTML/HTMLProgressElement.cpp | 4 ++-- .../Libraries/LibWeb/HTML/HTMLSelectElement.cpp | 2 +- .../Libraries/LibWeb/HTML/HTMLTableCellElement.cpp | 4 ++-- .../Libraries/LibWeb/HTML/HTMLTableColElement.cpp | 2 +- .../Libraries/LibWeb/HTML/HTMLTextAreaElement.cpp | 4 ++-- Userland/Libraries/LibWeb/HTML/Location.cpp | 4 +--- Userland/Libraries/LibWeb/HTML/Navigable.cpp | 2 +- Userland/Libraries/LibWeb/HTML/Numbers.cpp | 2 +- .../Scripting/WindowEnvironmentSettingsObject.cpp | 2 +- Userland/Libraries/LibWeb/HTML/VideoTrack.cpp | 2 +- Userland/Libraries/LibWeb/HTML/WorkerLocation.cpp | 4 +--- Userland/Libraries/LibWebView/InspectorClient.cpp | 2 +- Userland/Libraries/LibWebView/ProcessManager.cpp | 2 +- 46 files changed, 77 insertions(+), 81 deletions(-) diff --git a/AK/String.h b/AK/String.h index 27738e712af..13e31401a32 100644 --- a/AK/String.h +++ b/AK/String.h @@ -170,9 +170,9 @@ public: [[nodiscard]] u32 ascii_case_insensitive_hash() const; template - static ErrorOr number(T value) + [[nodiscard]] static String number(T value) { - return formatted("{}", value); + return MUST(formatted("{}", value)); } template diff --git a/Meta/Lagom/Tools/CodeGenerators/LibTextCodec/GenerateEncodingIndexes.cpp b/Meta/Lagom/Tools/CodeGenerators/LibTextCodec/GenerateEncodingIndexes.cpp index cb8bbfea3ee..f1f7a0dc209 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibTextCodec/GenerateEncodingIndexes.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibTextCodec/GenerateEncodingIndexes.cpp @@ -71,8 +71,8 @@ void generate_table(SourceGenerator generator, StringView name, LookupTable& tab { generator.set("name", name); generator.set("value_type", table.max_code_point > NumericLimits::max() ? "u32" : "u16"); - generator.set("first_pointer", MUST(String::number(table.first_pointer))); - generator.set("size", MUST(String::number(table.code_points.size()))); + generator.set("first_pointer", String::number(table.first_pointer)); + generator.set("size", String::number(table.code_points.size())); if (table.first_pointer > 0) { generator.appendln("static constexpr u32 s_@name@_index_first_pointer = @first_pointer@;"); @@ -96,7 +96,7 @@ ErrorOr generate_header_file(LookupTables& tables, Core::File& file) StringBuilder builder; SourceGenerator generator { builder }; - generator.set("gb18030_ranges_size", MUST(String::number(tables.gb18030_ranges.size()))); + generator.set("gb18030_ranges_size", String::number(tables.gb18030_ranges.size())); generator.append(R"~~~( #pragma once @@ -133,8 +133,8 @@ static constexpr Array s_gb18030_range void generate_table_accessor(SourceGenerator generator, StringView name, LookupTable& table) { generator.set("name", name); - generator.set("first_pointer", MUST(String::number(table.first_pointer))); - generator.set("size", MUST(String::number(table.code_points.size()))); + generator.set("first_pointer", String::number(table.first_pointer)); + generator.set("size", String::number(table.code_points.size())); if (table.first_pointer > 0) { generator.append(R"~~~( @@ -166,8 +166,8 @@ Optional index_@name@_code_point(u32 pointer) void generate_inverse_table_accessor(SourceGenerator generator, StringView name, LookupTable& table) { generator.set("name", name); - generator.set("first_pointer", MUST(String::number(table.first_pointer))); - generator.set("size", MUST(String::number(table.code_points.size()))); + generator.set("first_pointer", String::number(table.first_pointer)); + generator.set("size", String::number(table.code_points.size())); // FIXME - Doing a linear search here is really slow, should be generating // some kind of reverse lookup table. diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp index abbb39da659..81754e7020e 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp @@ -3762,7 +3762,7 @@ JS_DEFINE_NATIVE_FUNCTION(@class_name@::@attribute.setter_callback@) )~~~"); } else if (attribute.type->is_integer() && !attribute.type->is_nullable()) { attribute_generator.append(R"~~~( - MUST(impl->set_attribute(HTML::AttributeNames::@attribute.reflect_name@, MUST(String::number(cpp_value)))); + MUST(impl->set_attribute(HTML::AttributeNames::@attribute.reflect_name@, String::number(cpp_value))); )~~~"); } else if (attribute.type->is_nullable()) { attribute_generator.append(R"~~~( diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateAriaRoles.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateAriaRoles.cpp index ed4ba65f67f..7c7b354551e 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateAriaRoles.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateAriaRoles.cpp @@ -103,7 +103,7 @@ void generate_hash_table_member(SourceGenerator& generator, StringView member_na member_generator.set("member_name"sv, member_name); member_generator.set("hash_table_name"sv, hash_table_name); member_generator.set("enum_class"sv, enum_class); - member_generator.set("hash_table_size"sv, MUST(String::number(values.size()))); + member_generator.set("hash_table_size"sv, String::number(values.size())); if (values.size() == 0) { member_generator.append(R"~~~( diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSMathFunctions.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSMathFunctions.cpp index b324d278494..4111fd4a6ca 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSMathFunctions.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSMathFunctions.cpp @@ -188,8 +188,8 @@ OwnPtr Parser::parse_math_function(PropertyID property_id, Func if (parameter.get_bool("required"sv) == true) min_argument_count++; }); - function_generator.set("min_argument_count", MUST(String::number(min_argument_count))); - function_generator.set("max_argument_count", MUST(String::number(max_argument_count))); + function_generator.set("min_argument_count", String::number(min_argument_count)); + function_generator.set("max_argument_count", String::number(max_argument_count)); function_generator.append(R"~~~( if (arguments.size() < @min_argument_count@ || arguments.size() > @max_argument_count@) { @@ -209,7 +209,7 @@ OwnPtr Parser::parse_math_function(PropertyID property_id, Func auto parameter_generator = function_generator.fork(); parameter_generator.set("parameter_name", parameter.get_byte_string("name"sv).value()); - parameter_generator.set("parameter_index", MUST(String::number(parameter_index))); + parameter_generator.set("parameter_index", String::number(parameter_index)); bool parameter_is_calculation; if (parameter_type_string == "") { @@ -319,7 +319,7 @@ OwnPtr Parser::parse_math_function(PropertyID property_id, Func auto parameter_type_string = parameter.get_byte_string("type"sv).value(); auto parameter_generator = function_generator.fork(); - parameter_generator.set("parameter_index"sv, MUST(String::number(parameter_index))); + parameter_generator.set("parameter_index"sv, String::number(parameter_index)); if (parameter_type_string == ""sv) { parameter_generator.set("release_value"sv, ""_string); diff --git a/Tests/AK/TestJSON.cpp b/Tests/AK/TestJSON.cpp index f84652d045a..3178f2dd64c 100644 --- a/Tests/AK/TestJSON.cpp +++ b/Tests/AK/TestJSON.cpp @@ -134,11 +134,11 @@ TEST_CASE(json_64_bit_value_coerced_to_32_bit) auto min = NumericLimits::min(); auto max = NumericLimits::max(); - auto json = TRY_OR_FAIL(JsonValue::from_string(MUST(String::number(min)))); + auto json = TRY_OR_FAIL(JsonValue::from_string(String::number(min))); EXPECT_EQ(json.get_integer(), min); EXPECT(!json.is_integer()); - json = TRY_OR_FAIL(JsonValue::from_string(MUST(String::number(max)))); + json = TRY_OR_FAIL(JsonValue::from_string(String::number(max))); EXPECT_EQ(json.get_integer(), max); EXPECT(!json.is_integer()); } @@ -146,11 +146,11 @@ TEST_CASE(json_64_bit_value_coerced_to_32_bit) auto min = NumericLimits::min(); auto max = NumericLimits::max(); - auto json = TRY_OR_FAIL(JsonValue::from_string(MUST(String::number(min)))); + auto json = TRY_OR_FAIL(JsonValue::from_string(String::number(min))); EXPECT_EQ(json.get_integer(), min); EXPECT_EQ(json.get_integer(), min); - json = TRY_OR_FAIL(JsonValue::from_string(MUST(String::number(max)))); + json = TRY_OR_FAIL(JsonValue::from_string(String::number(max))); EXPECT_EQ(json.get_integer(), max); EXPECT(!json.is_integer()); } diff --git a/Userland/Libraries/LibJS/Bytecode/Generator.h b/Userland/Libraries/LibJS/Bytecode/Generator.h index ae965452a5e..c934a42d364 100644 --- a/Userland/Libraries/LibJS/Bytecode/Generator.h +++ b/Userland/Libraries/LibJS/Bytecode/Generator.h @@ -171,7 +171,7 @@ public: BasicBlock& make_block(String name = {}) { if (name.is_empty()) - name = MUST(String::number(m_next_block++)); + name = String::number(m_next_block++); auto block = BasicBlock::create(m_root_basic_blocks.size(), name); if (auto const* context = m_current_unwind_context) { if (context->handler().has_value()) diff --git a/Userland/Libraries/LibJS/Bytecode/Interpreter.cpp b/Userland/Libraries/LibJS/Bytecode/Interpreter.cpp index 981539914bf..a5a68820600 100644 --- a/Userland/Libraries/LibJS/Bytecode/Interpreter.cpp +++ b/Userland/Libraries/LibJS/Bytecode/Interpreter.cpp @@ -1720,7 +1720,7 @@ inline ThrowCompletionOr get_object_property_iterator(VM& vm, Value val result_object->define_direct_property(vm.names.done, JS::Value(false), default_attributes); if (key.is_number()) - result_object->define_direct_property(vm.names.value, PrimitiveString::create(vm, TRY_OR_THROW_OOM(vm, String::number(key.as_number()))), default_attributes); + result_object->define_direct_property(vm.names.value, PrimitiveString::create(vm, String::number(key.as_number())), default_attributes); else if (key.is_string()) result_object->define_direct_property(vm.names.value, PrimitiveString::create(vm, key.as_string()), default_attributes); else diff --git a/Userland/Libraries/LibJS/MarkupGenerator.cpp b/Userland/Libraries/LibJS/MarkupGenerator.cpp index b5b3d97ff10..e018d7dd532 100644 --- a/Userland/Libraries/LibJS/MarkupGenerator.cpp +++ b/Userland/Libraries/LibJS/MarkupGenerator.cpp @@ -113,7 +113,7 @@ ErrorOr MarkupGenerator::object_to_html(Object const& object, StringBuilde if (!first) TRY(html_output.try_append(TRY(wrap_string_in_style(", "sv, StyleType::Punctuation)))); first = false; - TRY(html_output.try_append(TRY(wrap_string_in_style(TRY(String::number(entry.index())), StyleType::Number)))); + TRY(html_output.try_append(TRY(wrap_string_in_style(String::number(entry.index()), StyleType::Number)))); TRY(html_output.try_append(TRY(wrap_string_in_style(": "sv, StyleType::Punctuation)))); // FIXME: Exception check TRY(value_to_html(object.get(entry.index()).release_value(), html_output, seen_objects)); diff --git a/Userland/Libraries/LibJS/Runtime/StringObject.cpp b/Userland/Libraries/LibJS/Runtime/StringObject.cpp index d03e897d68a..3600ac5953f 100644 --- a/Userland/Libraries/LibJS/Runtime/StringObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/StringObject.cpp @@ -152,14 +152,14 @@ ThrowCompletionOr> StringObject::internal_own_property_keys( // 5. For each integer i starting with 0 such that i < len, in ascending order, do for (size_t i = 0; i < length; ++i) { // a. Add ! ToString(𝔽(i)) as the last element of keys. - keys.append(PrimitiveString::create(vm, MUST(String::number(i)))); + keys.append(PrimitiveString::create(vm, String::number(i))); } // 6. For each own property key P of O such that P is an array index and ! ToIntegerOrInfinity(P) ≥ len, in ascending numeric index order, do for (auto& entry : indexed_properties()) { if (entry.index() >= length) { // a. Add P as the last element of keys. - keys.append(PrimitiveString::create(vm, MUST(String::number(entry.index())))); + keys.append(PrimitiveString::create(vm, String::number(entry.index()))); } } diff --git a/Userland/Libraries/LibJS/Runtime/TypedArray.h b/Userland/Libraries/LibJS/Runtime/TypedArray.h index f7a07c1ca03..10195b73425 100644 --- a/Userland/Libraries/LibJS/Runtime/TypedArray.h +++ b/Userland/Libraries/LibJS/Runtime/TypedArray.h @@ -425,7 +425,7 @@ public: // b. For each integer i such that 0 ≤ i < length, in ascending order, do for (size_t i = 0; i < length; ++i) { // i. Append ! ToString(𝔽(i)) to keys. - keys.append(PrimitiveString::create(vm, MUST(String::number(i)))); + keys.append(PrimitiveString::create(vm, String::number(i))); } } diff --git a/Userland/Libraries/LibJS/Runtime/Value.cpp b/Userland/Libraries/LibJS/Runtime/Value.cpp index b43325d3706..84bbf904af7 100644 --- a/Userland/Libraries/LibJS/Runtime/Value.cpp +++ b/Userland/Libraries/LibJS/Runtime/Value.cpp @@ -367,7 +367,7 @@ String Value::to_string_without_side_effects() const case BOOLEAN_TAG: return as_bool() ? "true"_string : "false"_string; case INT32_TAG: - return String::number(as_i32()).release_value(); + return String::number(as_i32()); case STRING_TAG: return as_string().utf8_string(); case SYMBOL_TAG: @@ -418,7 +418,7 @@ ThrowCompletionOr Value::to_string(VM& vm) const return as_bool() ? "true"_string : "false"_string; // 7. If argument is a Number, return Number::toString(argument, 10). case INT32_TAG: - return TRY_OR_THROW_OOM(vm, String::number(as_i32())); + return String::number(as_i32()); // 8. If argument is a BigInt, return BigInt::toString(argument, 10). case BIGINT_TAG: return TRY_OR_THROW_OOM(vm, as_bigint().big_integer().to_base(10)); diff --git a/Userland/Libraries/LibWeb/Bindings/PlatformObject.cpp b/Userland/Libraries/LibWeb/Bindings/PlatformObject.cpp index de7ef720249..e98a67a4a70 100644 --- a/Userland/Libraries/LibWeb/Bindings/PlatformObject.cpp +++ b/Userland/Libraries/LibWeb/Bindings/PlatformObject.cpp @@ -405,7 +405,7 @@ JS::ThrowCompletionOr> PlatformObject::internal_own_ if (m_legacy_platform_object_flags->supports_indexed_properties) { for (u64 index = 0; index <= NumericLimits::max(); ++index) { if (is_supported_property_index(index)) - keys.append(JS::PrimitiveString::create(vm, MUST(String::number(index)))); + keys.append(JS::PrimitiveString::create(vm, String::number(index))); else break; } diff --git a/Userland/Libraries/LibWeb/CSS/MediaQuery.cpp b/Userland/Libraries/LibWeb/CSS/MediaQuery.cpp index ca7d10a226d..841d8d35621 100644 --- a/Userland/Libraries/LibWeb/CSS/MediaQuery.cpp +++ b/Userland/Libraries/LibWeb/CSS/MediaQuery.cpp @@ -29,7 +29,7 @@ String MediaFeatureValue::to_string() const [](Length const& length) { return length.to_string(); }, [](Ratio const& ratio) { return ratio.to_string(); }, [](Resolution const& resolution) { return resolution.to_string(); }, - [](float number) { return MUST(String::number(number)); }); + [](float number) { return String::number(number); }); } bool MediaFeatureValue::is_same_type(MediaFeatureValue const& other) const diff --git a/Userland/Libraries/LibWeb/CSS/Number.h b/Userland/Libraries/LibWeb/CSS/Number.h index 84c37793a62..d5e728efc1f 100644 --- a/Userland/Libraries/LibWeb/CSS/Number.h +++ b/Userland/Libraries/LibWeb/CSS/Number.h @@ -74,7 +74,7 @@ public: { if (m_type == Type::IntegerWithExplicitSign) return MUST(String::formatted("{:+}", m_value)); - return MUST(String::number(m_value)); + return String::number(m_value); } bool operator==(Number const& other) const diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Token.cpp b/Userland/Libraries/LibWeb/CSS/Parser/Token.cpp index d0f5d6b4f3c..69b10582e46 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/Token.cpp +++ b/Userland/Libraries/LibWeb/CSS/Parser/Token.cpp @@ -43,7 +43,7 @@ String Token::to_string() const case Type::Delim: return String { m_value }; case Type::Number: - return MUST(String::number(m_number_value.value())); + return String::number(m_number_value.value()); case Type::Percentage: return MUST(String::formatted("{}%", m_number_value.value())); case Type::Dimension: diff --git a/Userland/Libraries/LibWeb/CSS/Selector.h b/Userland/Libraries/LibWeb/CSS/Selector.h index 7b1d59518cd..2aab0bd35c1 100644 --- a/Userland/Libraries/LibWeb/CSS/Selector.h +++ b/Userland/Libraries/LibWeb/CSS/Selector.h @@ -102,7 +102,7 @@ public: { // 1. If A is zero, return the serialization of B. if (step_size == 0) { - return MUST(String::number(offset)); + return String::number(offset); } // 2. Otherwise, let result initially be an empty string. diff --git a/Userland/Libraries/LibWeb/CSS/StyleValues/IntegerStyleValue.cpp b/Userland/Libraries/LibWeb/CSS/StyleValues/IntegerStyleValue.cpp index c0f761d27db..e0d9c037b50 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleValues/IntegerStyleValue.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleValues/IntegerStyleValue.cpp @@ -10,7 +10,7 @@ namespace Web::CSS { String IntegerStyleValue::to_string() const { - return MUST(String::number(m_value)); + return String::number(m_value); } } diff --git a/Userland/Libraries/LibWeb/CSS/StyleValues/NumberStyleValue.cpp b/Userland/Libraries/LibWeb/CSS/StyleValues/NumberStyleValue.cpp index d9b7028dcab..9dd16ec7976 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleValues/NumberStyleValue.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleValues/NumberStyleValue.cpp @@ -13,7 +13,7 @@ namespace Web::CSS { String NumberStyleValue::to_string() const { - return MUST(String::number(m_value)); + return String::number(m_value); } } diff --git a/Userland/Libraries/LibWeb/CSS/StyleValues/TransformationStyleValue.cpp b/Userland/Libraries/LibWeb/CSS/StyleValues/TransformationStyleValue.cpp index fc51885d6bd..cc78077aef4 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleValues/TransformationStyleValue.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleValues/TransformationStyleValue.cpp @@ -30,7 +30,7 @@ String TransformationStyleValue::to_string() const || m_properties.transform_function == CSS::TransformFunction::ScaleY || m_properties.transform_function == CSS::TransformFunction::ScaleZ) && value->is_percentage()) { - builder.append(MUST(String::number(value->as_percentage().percentage().as_fraction()))); + builder.append(String::number(value->as_percentage().percentage().as_fraction())); } else { builder.append(value->to_string()); } diff --git a/Userland/Libraries/LibWeb/DOM/Element.cpp b/Userland/Libraries/LibWeb/DOM/Element.cpp index 60a9d9f834d..606bfcd89ff 100644 --- a/Userland/Libraries/LibWeb/DOM/Element.cpp +++ b/Userland/Libraries/LibWeb/DOM/Element.cpp @@ -1208,7 +1208,7 @@ i32 Element::tab_index() const // https://html.spec.whatwg.org/multipage/interaction.html#dom-tabindex void Element::set_tab_index(i32 tab_index) { - MUST(set_attribute(HTML::AttributeNames::tabindex, MUST(String::number(tab_index)))); + MUST(set_attribute(HTML::AttributeNames::tabindex, String::number(tab_index))); } // https://drafts.csswg.org/cssom-view/#potentially-scrollable diff --git a/Userland/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp b/Userland/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp index 6027857b6f1..196e67be8b7 100644 --- a/Userland/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp +++ b/Userland/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp @@ -836,7 +836,7 @@ WebIDL::ExceptionOr> scheme_fetch(JS::Realm& r auto full_length = blob->size(); // 6. Let serializedFullLength be fullLength, serialized and isomorphic encoded. - auto serialized_full_length = TRY_OR_THROW_OOM(vm, String::number(full_length)); + auto serialized_full_length = String::number(full_length); // 7. Let type be blob’s type. auto const& type = blob->type(); @@ -1627,7 +1627,7 @@ WebIDL::ExceptionOr> http_network_or_cache_fet // 8. If contentLength is non-null, then set contentLengthHeaderValue to contentLength, serialized and // isomorphic encoded. if (content_length.has_value()) - content_length_header_value = MUST(ByteBuffer::copy(TRY_OR_THROW_OOM(vm, String::number(*content_length)).bytes())); + content_length_header_value = MUST(ByteBuffer::copy(String::number(*content_length).bytes())); // 9. If contentLengthHeaderValue is non-null, then append (`Content-Length`, contentLengthHeaderValue) to // httpRequest’s header list. diff --git a/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Requests.cpp b/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Requests.cpp index 95274ca2c29..6ac68a1470d 100644 --- a/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Requests.cpp +++ b/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Requests.cpp @@ -272,14 +272,14 @@ void Request::add_range_header(u64 first, Optional const& last) auto range_value = MUST(ByteBuffer::copy("bytes"sv.bytes())); // 3. Serialize and isomorphic encode first, and append the result to rangeValue. - range_value.append(MUST(String::number(first)).bytes()); + range_value.append(String::number(first).bytes()); // 4. Append 0x2D (-) to rangeValue. range_value.append('-'); // 5. If last is given, then serialize and isomorphic encode it, and append the result to rangeValue. if (last.has_value()) - range_value.append(MUST(String::number(*last)).bytes()); + range_value.append(String::number(*last).bytes()); // 6. Append (`Range`, rangeValue) to request’s header list. auto header = Header { diff --git a/Userland/Libraries/LibWeb/HTML/AudioTrack.cpp b/Userland/Libraries/LibWeb/HTML/AudioTrack.cpp index a6bd4bbb3cd..1d62566a618 100644 --- a/Userland/Libraries/LibWeb/HTML/AudioTrack.cpp +++ b/Userland/Libraries/LibWeb/HTML/AudioTrack.cpp @@ -57,7 +57,7 @@ void AudioTrack::initialize(JS::Realm& realm) WEB_SET_PROTOTYPE_FOR_INTERFACE(AudioTrack); auto id = s_audio_track_id_allocator.allocate(); - m_id = MUST(String::number(id)); + m_id = String::number(id); } void AudioTrack::play(Badge) diff --git a/Userland/Libraries/LibWeb/HTML/FormControlInfrastructure.cpp b/Userland/Libraries/LibWeb/HTML/FormControlInfrastructure.cpp index ed3b6f1289a..25b520ca8da 100644 --- a/Userland/Libraries/LibWeb/HTML/FormControlInfrastructure.cpp +++ b/Userland/Libraries/LibWeb/HTML/FormControlInfrastructure.cpp @@ -121,10 +121,10 @@ WebIDL::ExceptionOr>> construct_entry_list(J auto [x, y] = input_element->selected_coordinate(); // 6. Create an entry with namex and x, and append it to entry list. - entry_list.append(XHR::FormDataEntry { .name = move(name_x), .value = MUST(String::number(x)) }); + entry_list.append(XHR::FormDataEntry { .name = move(name_x), .value = String::number(x) }); // 7. Create an entry with namey and y, and append it to entry list. - entry_list.append(XHR::FormDataEntry { .name = move(name_y), .value = MUST(String::number(y)) }); + entry_list.append(XHR::FormDataEntry { .name = move(name_y), .value = String::number(y) }); // 8. Continue. continue; diff --git a/Userland/Libraries/LibWeb/HTML/HTMLCanvasElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLCanvasElement.cpp index e8f6bd8e6e1..3bd716495b7 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLCanvasElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLCanvasElement.cpp @@ -114,7 +114,7 @@ void HTMLCanvasElement::reset_context_to_default_state() WebIDL::ExceptionOr HTMLCanvasElement::set_width(unsigned value) { - TRY(set_attribute(HTML::AttributeNames::width, MUST(String::number(value)))); + TRY(set_attribute(HTML::AttributeNames::width, String::number(value))); m_bitmap = nullptr; reset_context_to_default_state(); return {}; @@ -122,7 +122,7 @@ WebIDL::ExceptionOr HTMLCanvasElement::set_width(unsigned value) WebIDL::ExceptionOr HTMLCanvasElement::set_height(unsigned value) { - TRY(set_attribute(HTML::AttributeNames::height, MUST(String::number(value)))); + TRY(set_attribute(HTML::AttributeNames::height, String::number(value))); m_bitmap = nullptr; reset_context_to_default_state(); return {}; diff --git a/Userland/Libraries/LibWeb/HTML/HTMLHyperlinkElementUtils.cpp b/Userland/Libraries/LibWeb/HTML/HTMLHyperlinkElementUtils.cpp index 67d1e82317b..8023d077736 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLHyperlinkElementUtils.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLHyperlinkElementUtils.cpp @@ -244,7 +244,7 @@ String HTMLHyperlinkElementUtils::port() const return String {}; // 4. Return url's port, serialized. - return MUST(String::number(url->port().value())); + return String::number(url->port().value()); } // https://html.spec.whatwg.org/multipage/links.html#dom-hyperlink-port diff --git a/Userland/Libraries/LibWeb/HTML/HTMLImageElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLImageElement.cpp index 66a9b86b16a..1dcbc1ec183 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLImageElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLImageElement.cpp @@ -191,7 +191,7 @@ unsigned HTMLImageElement::width() const WebIDL::ExceptionOr HTMLImageElement::set_width(unsigned width) { - return set_attribute(HTML::AttributeNames::width, MUST(String::number(width))); + return set_attribute(HTML::AttributeNames::width, String::number(width)); } // https://html.spec.whatwg.org/multipage/embedded-content.html#dom-img-height @@ -220,7 +220,7 @@ unsigned HTMLImageElement::height() const WebIDL::ExceptionOr HTMLImageElement::set_height(unsigned height) { - return set_attribute(HTML::AttributeNames::height, MUST(String::number(height))); + return set_attribute(HTML::AttributeNames::height, String::number(height)); } // https://html.spec.whatwg.org/multipage/embedded-content.html#dom-img-naturalwidth diff --git a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp index a3e357eef30..5bb926de880 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp @@ -1866,7 +1866,7 @@ unsigned HTMLInputElement::size() const WebIDL::ExceptionOr HTMLInputElement::set_size(unsigned value) { - return set_attribute(HTML::AttributeNames::size, MUST(String::number(value))); + return set_attribute(HTML::AttributeNames::size, String::number(value)); } // https://html.spec.whatwg.org/multipage/input.html#concept-input-value-string-number @@ -1889,11 +1889,11 @@ String HTMLInputElement::convert_number_to_string(double input) const { // https://html.spec.whatwg.org/multipage/input.html#number-state-(type=number):concept-input-value-number-string if (type_state() == TypeAttributeState::Number) - return MUST(String::number(input)); + return String::number(input); // https://html.spec.whatwg.org/multipage/input.html#range-state-(type=range):concept-input-value-number-string if (type_state() == TypeAttributeState::Range) - return MUST(String::number(input)); + return String::number(input); dbgln("HTMLInputElement::convert_number_to_string() not implemented for input type {}", type()); return {}; diff --git a/Userland/Libraries/LibWeb/HTML/HTMLLIElement.h b/Userland/Libraries/LibWeb/HTML/HTMLLIElement.h index a18db4aa56c..e12879c39e8 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLLIElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLLIElement.h @@ -24,7 +24,7 @@ public: i32 value() { return get_attribute(AttributeNames::value).value_or("0"_string).to_number().value_or(0); } void set_value(i32 value) { - set_attribute(AttributeNames::value, MUST(String::number(value))).release_value_but_fixme_should_propagate_errors(); + set_attribute(AttributeNames::value, String::number(value)).release_value_but_fixme_should_propagate_errors(); } private: diff --git a/Userland/Libraries/LibWeb/HTML/HTMLMarqueeElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLMarqueeElement.cpp index 8243b377432..9aaab2bda73 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLMarqueeElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLMarqueeElement.cpp @@ -76,7 +76,7 @@ WebIDL::UnsignedLong HTMLMarqueeElement::scroll_amount() // https://html.spec.whatwg.org/multipage/obsolete.html#dom-marquee-scrollamount WebIDL::ExceptionOr HTMLMarqueeElement::set_scroll_amount(WebIDL::UnsignedLong value) { - return set_attribute(HTML::AttributeNames::scrollamount, MUST(String::number(value))); + return set_attribute(HTML::AttributeNames::scrollamount, String::number(value)); } // https://html.spec.whatwg.org/multipage/obsolete.html#dom-marquee-scrolldelay @@ -93,7 +93,7 @@ WebIDL::UnsignedLong HTMLMarqueeElement::scroll_delay() // https://html.spec.whatwg.org/multipage/obsolete.html#dom-marquee-scrolldelay WebIDL::ExceptionOr HTMLMarqueeElement::set_scroll_delay(WebIDL::UnsignedLong value) { - return set_attribute(HTML::AttributeNames::scrolldelay, MUST(String::number(value))); + return set_attribute(HTML::AttributeNames::scrolldelay, String::number(value)); } } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLMeterElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLMeterElement.cpp index c0a86868f9f..541bb16336b 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLMeterElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLMeterElement.cpp @@ -54,7 +54,7 @@ double HTMLMeterElement::value() const WebIDL::ExceptionOr HTMLMeterElement::set_value(double value) { - TRY(set_attribute(HTML::AttributeNames::value, MUST(String::number(value)))); + TRY(set_attribute(HTML::AttributeNames::value, String::number(value))); update_meter_value_element(); return {}; } @@ -72,7 +72,7 @@ double HTMLMeterElement::min() const WebIDL::ExceptionOr HTMLMeterElement::set_min(double value) { - TRY(set_attribute(HTML::AttributeNames::min, MUST(String::number(value)))); + TRY(set_attribute(HTML::AttributeNames::min, String::number(value))); update_meter_value_element(); return {}; } @@ -93,7 +93,7 @@ double HTMLMeterElement::max() const WebIDL::ExceptionOr HTMLMeterElement::set_max(double value) { - TRY(set_attribute(HTML::AttributeNames::max, MUST(String::number(value)))); + TRY(set_attribute(HTML::AttributeNames::max, String::number(value))); update_meter_value_element(); return {}; } @@ -116,7 +116,7 @@ double HTMLMeterElement::low() const WebIDL::ExceptionOr HTMLMeterElement::set_low(double value) { - TRY(set_attribute(HTML::AttributeNames::low, MUST(String::number(value)))); + TRY(set_attribute(HTML::AttributeNames::low, String::number(value))); update_meter_value_element(); return {}; } @@ -139,7 +139,7 @@ double HTMLMeterElement::high() const WebIDL::ExceptionOr HTMLMeterElement::set_high(double value) { - TRY(set_attribute(HTML::AttributeNames::high, MUST(String::number(value)))); + TRY(set_attribute(HTML::AttributeNames::high, String::number(value))); update_meter_value_element(); return {}; } @@ -162,7 +162,7 @@ double HTMLMeterElement::optimum() const WebIDL::ExceptionOr HTMLMeterElement::set_optimum(double value) { - TRY(set_attribute(HTML::AttributeNames::optimum, MUST(String::number(value)))); + TRY(set_attribute(HTML::AttributeNames::optimum, String::number(value))); update_meter_value_element(); return {}; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLOListElement.h b/Userland/Libraries/LibWeb/HTML/HTMLOListElement.h index 7f1bb32b3a2..051ae0638be 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLOListElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLOListElement.h @@ -24,7 +24,7 @@ public: i32 start() { return get_attribute(AttributeNames::start).value_or("1"_string).to_number().value_or(1); } void set_start(i32 start) { - set_attribute(AttributeNames::start, MUST(String::number(start))).release_value_but_fixme_should_propagate_errors(); + set_attribute(AttributeNames::start, String::number(start)).release_value_but_fixme_should_propagate_errors(); } private: diff --git a/Userland/Libraries/LibWeb/HTML/HTMLProgressElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLProgressElement.cpp index 8ecfac9c7fa..30ce11c780b 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLProgressElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLProgressElement.cpp @@ -54,7 +54,7 @@ WebIDL::ExceptionOr HTMLProgressElement::set_value(double value) if (value < 0) value = 0; - TRY(set_attribute(HTML::AttributeNames::value, MUST(String::number(value)))); + TRY(set_attribute(HTML::AttributeNames::value, String::number(value))); update_progress_value_element(); return {}; } @@ -75,7 +75,7 @@ WebIDL::ExceptionOr HTMLProgressElement::set_max(double value) if (value <= 0) value = 1; - TRY(set_attribute(HTML::AttributeNames::max, MUST(String::number(value)))); + TRY(set_attribute(HTML::AttributeNames::max, String::number(value))); update_progress_value_element(); return {}; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.cpp index 1d6a56e7658..8e130016999 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.cpp @@ -92,7 +92,7 @@ WebIDL::UnsignedLong HTMLSelectElement::size() const WebIDL::ExceptionOr HTMLSelectElement::set_size(WebIDL::UnsignedLong size) { - return set_attribute(HTML::AttributeNames::size, MUST(String::number(size))); + return set_attribute(HTML::AttributeNames::size, String::number(size)); } // https://html.spec.whatwg.org/multipage/form-elements.html#dom-select-options diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTableCellElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLTableCellElement.cpp index 80502054579..fbbe0e9a5fd 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLTableCellElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLTableCellElement.cpp @@ -129,7 +129,7 @@ unsigned int HTMLTableCellElement::col_span() const WebIDL::ExceptionOr HTMLTableCellElement::set_col_span(unsigned int value) { - return set_attribute(HTML::AttributeNames::colspan, MUST(String::number(value))); + return set_attribute(HTML::AttributeNames::colspan, String::number(value)); } // This implements step 9 in the spec here: @@ -149,7 +149,7 @@ unsigned int HTMLTableCellElement::row_span() const WebIDL::ExceptionOr HTMLTableCellElement::set_row_span(unsigned int value) { - return set_attribute(HTML::AttributeNames::rowspan, MUST(String::number(value))); + return set_attribute(HTML::AttributeNames::rowspan, String::number(value)); } // https://html.spec.whatwg.org/multipage/tables.html#dom-tdth-cellindex diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTableColElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLTableColElement.cpp index b9ea4a6feb1..fd0eafe79ff 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLTableColElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLTableColElement.cpp @@ -41,7 +41,7 @@ unsigned int HTMLTableColElement::span() const WebIDL::ExceptionOr HTMLTableColElement::set_span(unsigned int value) { - return set_attribute(HTML::AttributeNames::span, MUST(String::number(value))); + return set_attribute(HTML::AttributeNames::span, String::number(value)); } void HTMLTableColElement::apply_presentational_hints(CSS::StyleProperties& style) const diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTextAreaElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLTextAreaElement.cpp index eb8062c6972..60f8e53912c 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLTextAreaElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLTextAreaElement.cpp @@ -299,7 +299,7 @@ unsigned HTMLTextAreaElement::cols() const WebIDL::ExceptionOr HTMLTextAreaElement::set_cols(unsigned cols) { - return set_attribute(HTML::AttributeNames::cols, MUST(String::number(cols))); + return set_attribute(HTML::AttributeNames::cols, String::number(cols)); } // https://html.spec.whatwg.org/multipage/form-elements.html#dom-textarea-rows @@ -315,7 +315,7 @@ unsigned HTMLTextAreaElement::rows() const WebIDL::ExceptionOr HTMLTextAreaElement::set_rows(unsigned rows) { - return set_attribute(HTML::AttributeNames::rows, MUST(String::number(rows))); + return set_attribute(HTML::AttributeNames::rows, String::number(rows)); } WebIDL::UnsignedLong HTMLTextAreaElement::selection_start_binding() const diff --git a/Userland/Libraries/LibWeb/HTML/Location.cpp b/Userland/Libraries/LibWeb/HTML/Location.cpp index bc97fd969d8..86350eabcd2 100644 --- a/Userland/Libraries/LibWeb/HTML/Location.cpp +++ b/Userland/Libraries/LibWeb/HTML/Location.cpp @@ -251,8 +251,6 @@ WebIDL::ExceptionOr Location::set_hostname(String const&) // https://html.spec.whatwg.org/multipage/history.html#dom-location-port WebIDL::ExceptionOr Location::port() const { - auto& vm = this->vm(); - // 1. If this's relevant Document is non-null and its origin is not same origin-domain with the entry settings object's origin, then throw a "SecurityError" DOMException. auto const relevant_document = this->relevant_document(); if (relevant_document && !relevant_document->origin().is_same_origin_domain(entry_settings_object().origin())) @@ -265,7 +263,7 @@ WebIDL::ExceptionOr Location::port() const return String {}; // 3. Return this's url's port, serialized. - return TRY_OR_THROW_OOM(vm, String::number(*url.port())); + return String::number(*url.port()); } WebIDL::ExceptionOr Location::set_port(String const&) diff --git a/Userland/Libraries/LibWeb/HTML/Navigable.cpp b/Userland/Libraries/LibWeb/HTML/Navigable.cpp index e6f00bd5358..4bd2e6337aa 100644 --- a/Userland/Libraries/LibWeb/HTML/Navigable.cpp +++ b/Userland/Libraries/LibWeb/HTML/Navigable.cpp @@ -167,7 +167,7 @@ JS::GCPtr Navigable::navigable_with_active_document(JS::NonnullGCPtr< ErrorOr Navigable::initialize_navigable(JS::NonnullGCPtr document_state, JS::GCPtr parent) { static int next_id = 0; - m_id = TRY(String::number(next_id++)); + m_id = String::number(next_id++); // 1. Assert: documentState's document is non-null. VERIFY(document_state->document()); diff --git a/Userland/Libraries/LibWeb/HTML/Numbers.cpp b/Userland/Libraries/LibWeb/HTML/Numbers.cpp index 42690f7eefa..111969da50a 100644 --- a/Userland/Libraries/LibWeb/HTML/Numbers.cpp +++ b/Userland/Libraries/LibWeb/HTML/Numbers.cpp @@ -129,7 +129,7 @@ WebIDL::ExceptionOr convert_non_negative_integer_to_string(JS::Realm& re { if (value < 0) return WebIDL::IndexSizeError::create(realm, "The attribute is limited to only non-negative numbers"_string); - return MUST(String::number(value)); + return String::number(value); } } diff --git a/Userland/Libraries/LibWeb/HTML/Scripting/WindowEnvironmentSettingsObject.cpp b/Userland/Libraries/LibWeb/HTML/Scripting/WindowEnvironmentSettingsObject.cpp index d8299782125..14aed00a936 100644 --- a/Userland/Libraries/LibWeb/HTML/Scripting/WindowEnvironmentSettingsObject.cpp +++ b/Userland/Libraries/LibWeb/HTML/Scripting/WindowEnvironmentSettingsObject.cpp @@ -60,7 +60,7 @@ void WindowEnvironmentSettingsObject::setup(Page& page, URL::URL const& creation // settings object's target browsing context to null, // and settings object's active service worker to null. static i64 next_id = 1; - settings_object->id = MUST(String::number(next_id++)); + settings_object->id = String::number(next_id++); settings_object->target_browsing_context = nullptr; } diff --git a/Userland/Libraries/LibWeb/HTML/VideoTrack.cpp b/Userland/Libraries/LibWeb/HTML/VideoTrack.cpp index 751fc90b65a..dcee7b26b2d 100644 --- a/Userland/Libraries/LibWeb/HTML/VideoTrack.cpp +++ b/Userland/Libraries/LibWeb/HTML/VideoTrack.cpp @@ -78,7 +78,7 @@ void VideoTrack::initialize(JS::Realm& realm) WEB_SET_PROTOTYPE_FOR_INTERFACE(VideoTrack); auto id = s_video_track_id_allocator.allocate(); - m_id = MUST(String::number(id)); + m_id = String::number(id); } void VideoTrack::visit_edges(Cell::Visitor& visitor) diff --git a/Userland/Libraries/LibWeb/HTML/WorkerLocation.cpp b/Userland/Libraries/LibWeb/HTML/WorkerLocation.cpp index 6b3e9c57bca..82e68f5228d 100644 --- a/Userland/Libraries/LibWeb/HTML/WorkerLocation.cpp +++ b/Userland/Libraries/LibWeb/HTML/WorkerLocation.cpp @@ -78,8 +78,6 @@ WebIDL::ExceptionOr WorkerLocation::hostname() const // https://html.spec.whatwg.org/multipage/workers.html#dom-workerlocation-port WebIDL::ExceptionOr WorkerLocation::port() const { - auto& vm = realm().vm(); - // The port getter steps are: // 1. Let port be this's WorkerGlobalScope object's url's port. auto const& port = m_global_scope->url().port(); @@ -88,7 +86,7 @@ WebIDL::ExceptionOr WorkerLocation::port() const if (!port.has_value()) return String {}; // 3. Return port, serialized. - return TRY_OR_THROW_OOM(vm, String::number(port.value())); + return String::number(port.value()); } // https://html.spec.whatwg.org/multipage/workers.html#dom-workerlocation-pathname diff --git a/Userland/Libraries/LibWebView/InspectorClient.cpp b/Userland/Libraries/LibWebView/InspectorClient.cpp index 7a174690f72..622833a6488 100644 --- a/Userland/Libraries/LibWebView/InspectorClient.cpp +++ b/Userland/Libraries/LibWebView/InspectorClient.cpp @@ -40,7 +40,7 @@ static String style_sheet_identifier_to_json(Web::CSS::StyleSheetIdentifier cons { return MUST(String::formatted("{{ type: '{}', domNodeId: {}, url: '{}' }}"sv, Web::CSS::style_sheet_identifier_type_to_string(identifier.type), - identifier.dom_element_unique_id.map([](auto& it) { return MUST(String::number(it)); }).value_or("undefined"_string), + identifier.dom_element_unique_id.map([](auto& it) { return String::number(it); }).value_or("undefined"_string), identifier.url.value_or("undefined"_string))); } diff --git a/Userland/Libraries/LibWebView/ProcessManager.cpp b/Userland/Libraries/LibWebView/ProcessManager.cpp index 492b18a0066..c0b2e29bedd 100644 --- a/Userland/Libraries/LibWebView/ProcessManager.cpp +++ b/Userland/Libraries/LibWebView/ProcessManager.cpp @@ -183,7 +183,7 @@ String ProcessManager::generate_html() builder.appendff(" - {}", escape_html_entities(*process_handle.title())); builder.append(""sv); builder.append(""sv); - builder.append(MUST(String::number(process.pid))); + builder.append(String::number(process.pid)); builder.append(""sv); builder.append(""sv); builder.append(human_readable_size(process.memory_usage_bytes));