mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-03 16:16:43 +00:00
LibJS: Convert to_string() to ThrowCompletionOr
Also update get_function_name() to use ThrowCompletionOr, but this is not a standard AO and should be refactored out of existence eventually.
This commit is contained in:
parent
5d38cf4973
commit
4d8912a92b
Notes:
sideshowbarker
2024-07-18 02:47:45 +09:00
Author: https://github.com/linusg
Commit: 4d8912a92b
Pull-request: https://github.com/SerenityOS/serenity/pull/10452
Reviewed-by: https://github.com/IdanHo ✅
48 changed files with 171 additions and 415 deletions
|
@ -38,9 +38,7 @@ JS_DEFINE_NATIVE_FUNCTION(CSSNamespace::escape)
|
|||
return {};
|
||||
}
|
||||
|
||||
auto identifier = vm.argument(0).to_string(global_object);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
auto identifier = TRY_OR_DISCARD(vm.argument(0).to_string(global_object));
|
||||
|
||||
return JS::js_string(vm, Web::CSS::serialize_an_identifier(identifier));
|
||||
}
|
||||
|
@ -55,17 +53,13 @@ JS_DEFINE_NATIVE_FUNCTION(CSSNamespace::supports)
|
|||
|
||||
if (vm.argument_count() >= 2) {
|
||||
// When the supports(property, value) method is invoked with two arguments property and value:
|
||||
String property_name = vm.argument(0).to_string(global_object);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
auto property_name = TRY_OR_DISCARD(vm.argument(0).to_string(global_object));
|
||||
|
||||
// If property is an ASCII case-insensitive match for any defined CSS property that the UA supports,
|
||||
// and value successfully parses according to that property’s grammar, return true.
|
||||
auto property = CSS::property_id_from_string(property_name);
|
||||
if (property != CSS::PropertyID::Invalid) {
|
||||
auto value_string = vm.argument(1).to_string(global_object);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
auto value_string = TRY_OR_DISCARD(vm.argument(1).to_string(global_object));
|
||||
if (parse_css_value({}, value_string, property))
|
||||
return JS::Value(true);
|
||||
}
|
||||
|
@ -79,9 +73,7 @@ JS_DEFINE_NATIVE_FUNCTION(CSSNamespace::supports)
|
|||
return JS::Value(false);
|
||||
} else {
|
||||
// When the supports(conditionText) method is invoked with a single conditionText argument:
|
||||
String supports_text = vm.argument(0).to_string(global_object);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
auto supports_text = TRY_OR_DISCARD(vm.argument(0).to_string(global_object));
|
||||
|
||||
// If conditionText, parsed and evaluated as a <supports-condition>, would return true, return true.
|
||||
if (auto supports = parse_css_supports({}, supports_text); supports && supports->matches())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue