diff --git a/AK/TypeCasts.h b/AK/TypeCasts.h index 1b0721bef18..4a2c2de6218 100644 --- a/AK/TypeCasts.h +++ b/AK/TypeCasts.h @@ -36,7 +36,7 @@ ALWAYS_INLINE bool is(NonnullRefPtr const& input) } template -ALWAYS_INLINE CopyConst* verify_cast(InputType* input) +ALWAYS_INLINE CopyConst* as(InputType* input) { static_assert(IsBaseOf); VERIFY(!input || is(*input)); @@ -44,7 +44,7 @@ ALWAYS_INLINE CopyConst* verify_cast(InputType* input) } template -ALWAYS_INLINE CopyConst& verify_cast(InputType& input) +ALWAYS_INLINE CopyConst& as(InputType& input) { static_assert(IsBaseOf); VERIFY(is(input)); @@ -70,7 +70,7 @@ ALWAYS_INLINE CopyConst* as_if(InputType* input) } #if USING_AK_GLOBALLY +using AK::as; using AK::as_if; using AK::is; -using AK::verify_cast; #endif diff --git a/Libraries/LibCore/FileWatcherMacOS.mm b/Libraries/LibCore/FileWatcherMacOS.mm index 37c0a20d4a6..81e5a33a9c6 100644 --- a/Libraries/LibCore/FileWatcherMacOS.mm +++ b/Libraries/LibCore/FileWatcherMacOS.mm @@ -284,13 +284,13 @@ FileWatcher::~FileWatcher() = default; ErrorOr FileWatcherBase::add_watch(ByteString path, FileWatcherEvent::Type event_mask) { - auto& file_watcher = verify_cast(*this); + auto& file_watcher = as(*this); return file_watcher.add_watch(move(path), event_mask); } ErrorOr FileWatcherBase::remove_watch(ByteString path) { - auto& file_watcher = verify_cast(*this); + auto& file_watcher = as(*this); return file_watcher.remove_watch(move(path)); } diff --git a/Libraries/LibGC/ForeignCell.h b/Libraries/LibGC/ForeignCell.h index 4edf9203acd..2e0adb858dd 100644 --- a/Libraries/LibGC/ForeignCell.h +++ b/Libraries/LibGC/ForeignCell.h @@ -71,11 +71,11 @@ struct ForeignRef { DeferGC const defer_gc(heap); auto* cell = T::create(&heap, forward(args)...); if constexpr (IsSame) { - return ForeignRef(*verify_cast(cell)); + return ForeignRef(*as(cell)); } else { static_assert(IsSame); auto* cast_cell = static_cast(cell); - return ForeignRef(*verify_cast(cast_cell)); + return ForeignRef(*as(cast_cell)); } } diff --git a/Libraries/LibGfx/Font/ScaledFont.cpp b/Libraries/LibGfx/Font/ScaledFont.cpp index 06f34ec04ff..2ce25e07faa 100644 --- a/Libraries/LibGfx/Font/ScaledFont.cpp +++ b/Libraries/LibGfx/Font/ScaledFont.cpp @@ -28,7 +28,7 @@ ScaledFont::ScaledFont(NonnullRefPtr typeface, float point_width, floa m_pixel_size = m_point_height * (DEFAULT_DPI / POINTS_PER_INCH); m_pixel_size_rounded_up = static_cast(ceilf(m_pixel_size)); - auto const* sk_typeface = verify_cast(*m_typeface).sk_typeface(); + auto const* sk_typeface = as(*m_typeface).sk_typeface(); SkFont const font { sk_ref_sp(sk_typeface), m_pixel_size }; SkFontMetrics skMetrics; diff --git a/Libraries/LibGfx/Font/ScaledFontSkia.cpp b/Libraries/LibGfx/Font/ScaledFontSkia.cpp index dc0ef232aec..93dfd591cd8 100644 --- a/Libraries/LibGfx/Font/ScaledFontSkia.cpp +++ b/Libraries/LibGfx/Font/ScaledFontSkia.cpp @@ -14,7 +14,7 @@ namespace Gfx { SkFont ScaledFont::skia_font(float scale) const { - auto const& sk_typeface = verify_cast(*m_typeface).sk_typeface(); + auto const& sk_typeface = as(*m_typeface).sk_typeface(); auto sk_font = SkFont { sk_ref_sp(sk_typeface), pixel_size() * scale }; sk_font.setSubpixel(true); return sk_font; diff --git a/Libraries/LibGfx/PathSkia.cpp b/Libraries/LibGfx/PathSkia.cpp index 57bdb330b6e..6b4b4c4c71f 100644 --- a/Libraries/LibGfx/PathSkia.cpp +++ b/Libraries/LibGfx/PathSkia.cpp @@ -137,11 +137,11 @@ void PathImplSkia::cubic_bezier_curve_to(FloatPoint c1, FloatPoint c2, FloatPoin void PathImplSkia::text(Utf8View string, Font const& font) { - SkTextUtils::GetPath(string.as_string().characters_without_null_termination(), string.as_string().length(), SkTextEncoding::kUTF8, last_point().x(), last_point().y(), verify_cast(font).skia_font(1), m_path.ptr()); + SkTextUtils::GetPath(string.as_string().characters_without_null_termination(), string.as_string().length(), SkTextEncoding::kUTF8, last_point().x(), last_point().y(), as(font).skia_font(1), m_path.ptr()); } NonnullOwnPtr PathImplSkia::place_text_along(Utf8View text, Font const& font) const { - auto sk_font = verify_cast(font).skia_font(1); + auto sk_font = as(font).skia_font(1); size_t const text_length = text.length(); SkScalar x = 0; SkScalar y = 0; diff --git a/Libraries/LibIDL/Types.cpp b/Libraries/LibIDL/Types.cpp index 0176977ba62..c9c58b0e3c1 100644 --- a/Libraries/LibIDL/Types.cpp +++ b/Libraries/LibIDL/Types.cpp @@ -12,22 +12,22 @@ namespace IDL { ParameterizedType const& Type::as_parameterized() const { - return verify_cast(*this); + return as(*this); } ParameterizedType& Type::as_parameterized() { - return verify_cast(*this); + return as(*this); } UnionType const& Type::as_union() const { - return verify_cast(*this); + return as(*this); } UnionType& Type::as_union() { - return verify_cast(*this); + return as(*this); } // https://webidl.spec.whatwg.org/#dfn-includes-a-nullable-type diff --git a/Libraries/LibJS/AST.cpp b/Libraries/LibJS/AST.cpp index d0de6f95904..a86937ba6a9 100644 --- a/Libraries/LibJS/AST.cpp +++ b/Libraries/LibJS/AST.cpp @@ -1217,8 +1217,8 @@ ByteString MemberExpression::to_string_approximation() const if (is_computed()) return ByteString::formatted("{}[]", object_string); if (is(*m_property)) - return ByteString::formatted("{}.{}", object_string, verify_cast(*m_property).string()); - return ByteString::formatted("{}.{}", object_string, verify_cast(*m_property).string()); + return ByteString::formatted("{}.{}", object_string, as(*m_property).string()); + return ByteString::formatted("{}.{}", object_string, as(*m_property).string()); } bool MemberExpression::ends_in_private_name() const diff --git a/Libraries/LibJS/Bytecode/ASTCodegen.cpp b/Libraries/LibJS/Bytecode/ASTCodegen.cpp index e1e74e87327..c3d925465bc 100644 --- a/Libraries/LibJS/Bytecode/ASTCodegen.cpp +++ b/Libraries/LibJS/Bytecode/ASTCodegen.cpp @@ -611,13 +611,13 @@ Bytecode::CodeGenerationErrorOr> AssignmentExpression::g else generator.emit(*base, *computed_property, *this_value, rval); } else if (expression.property().is_identifier()) { - auto identifier_table_ref = generator.intern_identifier(verify_cast(expression.property()).string()); + auto identifier_table_ref = generator.intern_identifier(as(expression.property()).string()); if (!lhs_is_super_expression) generator.emit(*base, identifier_table_ref, rval, Bytecode::Op::PropertyKind::KeyValue, generator.next_property_lookup_cache(), move(base_identifier)); else generator.emit(*base, *this_value, identifier_table_ref, rval, Bytecode::Op::PropertyKind::KeyValue, generator.next_property_lookup_cache()); } else if (expression.property().is_private_identifier()) { - auto identifier_table_ref = generator.intern_identifier(verify_cast(expression.property()).string()); + auto identifier_table_ref = generator.intern_identifier(as(expression.property()).string()); generator.emit(*base, identifier_table_ref, rval); } else { return Bytecode::CodeGenerationError { @@ -985,7 +985,7 @@ Bytecode::CodeGenerationErrorOr> ForStatement::generate_ if (m_init) { if (m_init->is_variable_declaration()) { - auto& variable_declaration = verify_cast(*m_init); + auto& variable_declaration = as(*m_init); auto has_non_local_variables = false; MUST(variable_declaration.for_each_bound_identifier([&](auto const& identifier) { @@ -1670,7 +1670,7 @@ static Bytecode::CodeGenerationErrorOr get_base_and_value_from_mem generator.emit(value, super_base, *computed_property, this_value); } else { // 3. Let propertyKey be StringValue of IdentifierName. - auto identifier_table_ref = generator.intern_identifier(verify_cast(member_expression.property()).string()); + auto identifier_table_ref = generator.intern_identifier(as(member_expression.property()).string()); generator.emit_get_by_id_with_this(value, super_base, identifier_table_ref, this_value); } @@ -1686,10 +1686,10 @@ static Bytecode::CodeGenerationErrorOr get_base_and_value_from_mem generator.emit( value, base, - generator.intern_identifier(verify_cast(member_expression.property()).string())); + generator.intern_identifier(as(member_expression.property()).string())); } else { auto base_identifier = generator.intern_identifier_for_expression(member_expression.object()); - generator.emit_get_by_id(value, base, generator.intern_identifier(verify_cast(member_expression.property()).string()), move(base_identifier)); + generator.emit_get_by_id(value, base, generator.intern_identifier(as(member_expression.property()).string()), move(base_identifier)); } return BaseAndValue { base, value }; diff --git a/Libraries/LibJS/Bytecode/Generator.cpp b/Libraries/LibJS/Bytecode/Generator.cpp index dcd7b04efa4..0f5c537cb1f 100644 --- a/Libraries/LibJS/Bytecode/Generator.cpp +++ b/Libraries/LibJS/Bytecode/Generator.cpp @@ -660,7 +660,7 @@ CodeGenerationErrorOr Generator::emit_load_from_re emit(dst, *super_reference.base, *super_reference.referenced_name, *super_reference.this_value); } else { // 3. Let propertyKey be StringValue of IdentifierName. - auto identifier_table_ref = intern_identifier(verify_cast(expression.property()).string()); + auto identifier_table_ref = intern_identifier(as(expression.property()).string()); emit_get_by_id_with_this(dst, *super_reference.base, identifier_table_ref, *super_reference.this_value); } @@ -685,7 +685,7 @@ CodeGenerationErrorOr Generator::emit_load_from_re }; } if (expression.property().is_identifier()) { - auto identifier_table_ref = intern_identifier(verify_cast(expression.property()).string()); + auto identifier_table_ref = intern_identifier(as(expression.property()).string()); auto dst = preferred_dst.has_value() ? preferred_dst.value() : allocate_register(); emit_get_by_id(dst, base, identifier_table_ref, move(base_identifier)); return ReferenceOperands { @@ -696,7 +696,7 @@ CodeGenerationErrorOr Generator::emit_load_from_re }; } if (expression.property().is_private_identifier()) { - auto identifier_table_ref = intern_identifier(verify_cast(expression.property()).string()); + auto identifier_table_ref = intern_identifier(as(expression.property()).string()); auto dst = preferred_dst.has_value() ? preferred_dst.value() : allocate_register(); emit(dst, base, identifier_table_ref); return ReferenceOperands { @@ -733,7 +733,7 @@ CodeGenerationErrorOr Generator::emit_store_to_reference(JS::ASTNode const emit(*super_reference.base, *super_reference.referenced_name, *super_reference.this_value, value); } else { // 3. Let propertyKey be StringValue of IdentifierName. - auto identifier_table_ref = intern_identifier(verify_cast(expression.property()).string()); + auto identifier_table_ref = intern_identifier(as(expression.property()).string()); emit(*super_reference.base, *super_reference.this_value, identifier_table_ref, value, Bytecode::Op::PropertyKind::KeyValue, next_property_lookup_cache()); } } else { @@ -743,10 +743,10 @@ CodeGenerationErrorOr Generator::emit_store_to_reference(JS::ASTNode const auto property = TRY(expression.property().generate_bytecode(*this)).value(); emit(object, property, value); } else if (expression.property().is_identifier()) { - auto identifier_table_ref = intern_identifier(verify_cast(expression.property()).string()); + auto identifier_table_ref = intern_identifier(as(expression.property()).string()); emit(object, identifier_table_ref, value, Bytecode::Op::PropertyKind::KeyValue, next_property_lookup_cache()); } else if (expression.property().is_private_identifier()) { - auto identifier_table_ref = intern_identifier(verify_cast(expression.property()).string()); + auto identifier_table_ref = intern_identifier(as(expression.property()).string()); emit(object, identifier_table_ref, value); } else { return CodeGenerationError { @@ -808,7 +808,7 @@ CodeGenerationErrorOr> Generator::emit_delete_reference( if (super_reference.referenced_name.has_value()) { emit(dst, *super_reference.base, *super_reference.this_value, *super_reference.referenced_name); } else { - auto identifier_table_ref = intern_identifier(verify_cast(expression.property()).string()); + auto identifier_table_ref = intern_identifier(as(expression.property()).string()); emit(dst, *super_reference.base, *super_reference.this_value, identifier_table_ref); } @@ -822,7 +822,7 @@ CodeGenerationErrorOr> Generator::emit_delete_reference( auto property = TRY(expression.property().generate_bytecode(*this)).value(); emit(dst, object, property); } else if (expression.property().is_identifier()) { - auto identifier_table_ref = intern_identifier(verify_cast(expression.property()).string()); + auto identifier_table_ref = intern_identifier(as(expression.property()).string()); emit(dst, object, identifier_table_ref); } else { // NOTE: Trying to delete a private field generates a SyntaxError in the parser. diff --git a/Libraries/LibJS/Bytecode/Interpreter.cpp b/Libraries/LibJS/Bytecode/Interpreter.cpp index 84bf2c7df2d..21d87eb0a73 100644 --- a/Libraries/LibJS/Bytecode/Interpreter.cpp +++ b/Libraries/LibJS/Bytecode/Interpreter.cpp @@ -1499,7 +1499,7 @@ inline ThrowCompletionOr create_variable(VM& vm, DeprecatedFlyString const // NOTE: CreateVariable with m_is_global set to true is expected to only be used in GlobalDeclarationInstantiation currently, which only uses "false" for "can_be_deleted". // The only area that sets "can_be_deleted" to true is EvalDeclarationInstantiation, which is currently fully implemented in C++ and not in Bytecode. - return verify_cast(vm.variable_environment())->create_global_var_binding(name, false); + return as(vm.variable_environment())->create_global_var_binding(name, false); } inline ThrowCompletionOr new_class(VM& vm, Value super_class, ClassExpression const& class_expression, Optional const& lhs_name, ReadonlySpan element_keys) @@ -1555,7 +1555,7 @@ inline ThrowCompletionOr> super_call_with_argument_array(VM& vm, auto result = TRY(construct(vm, static_cast(*func), arg_list.span(), &new_target.as_function())); // 7. Let thisER be GetThisEnvironment(). - auto& this_environment = verify_cast(*get_this_environment(vm)); + auto& this_environment = as(*get_this_environment(vm)); // 8. Perform ? thisER.BindThisValue(result). TRY(this_environment.bind_this_value(vm, result)); @@ -1575,7 +1575,7 @@ inline ThrowCompletionOr> super_call_with_argument_array(VM& vm, inline ThrowCompletionOr> iterator_to_array(VM& vm, Value iterator) { - auto& iterator_record = verify_cast(iterator.as_object()); + auto& iterator_record = as(iterator.as_object()); auto array = MUST(Array::create(*vm.current_realm(), 0)); size_t index = 0; @@ -2522,7 +2522,7 @@ ThrowCompletionOr ResolveSuperBase::execute_impl(Bytecode::Interpreter& in auto& vm = interpreter.vm(); // 1. Let env be GetThisEnvironment(). - auto& env = verify_cast(*get_this_environment(vm)); + auto& env = as(*get_this_environment(vm)); // 2. Assert: env.HasSuperBinding() is true. VERIFY(env.has_super_binding()); @@ -2870,14 +2870,14 @@ ThrowCompletionOr GetIterator::execute_impl(Bytecode::Interpreter& interpr ThrowCompletionOr GetObjectFromIteratorRecord::execute_impl(Bytecode::Interpreter& interpreter) const { - auto& iterator_record = verify_cast(interpreter.get(m_iterator_record).as_object()); + auto& iterator_record = as(interpreter.get(m_iterator_record).as_object()); interpreter.set(m_object, iterator_record.iterator); return {}; } ThrowCompletionOr GetNextMethodFromIteratorRecord::execute_impl(Bytecode::Interpreter& interpreter) const { - auto& iterator_record = verify_cast(interpreter.get(m_iterator_record).as_object()); + auto& iterator_record = as(interpreter.get(m_iterator_record).as_object()); interpreter.set(m_next_method, iterator_record.next_method); return {}; } @@ -2900,7 +2900,7 @@ ThrowCompletionOr GetObjectPropertyIterator::execute_impl(Bytecode::Interp ThrowCompletionOr IteratorClose::execute_impl(Bytecode::Interpreter& interpreter) const { auto& vm = interpreter.vm(); - auto& iterator = verify_cast(interpreter.get(m_iterator_record).as_object()); + auto& iterator = as(interpreter.get(m_iterator_record).as_object()); // FIXME: Return the value of the resulting completion. (Note that m_completion_value can be empty!) TRY(iterator_close(vm, iterator, Completion { m_completion_type, m_completion_value })); @@ -2910,7 +2910,7 @@ ThrowCompletionOr IteratorClose::execute_impl(Bytecode::Interpreter& inter ThrowCompletionOr AsyncIteratorClose::execute_impl(Bytecode::Interpreter& interpreter) const { auto& vm = interpreter.vm(); - auto& iterator = verify_cast(interpreter.get(m_iterator_record).as_object()); + auto& iterator = as(interpreter.get(m_iterator_record).as_object()); // FIXME: Return the value of the resulting completion. (Note that m_completion_value can be empty!) TRY(async_iterator_close(vm, iterator, Completion { m_completion_type, m_completion_value })); @@ -2920,7 +2920,7 @@ ThrowCompletionOr AsyncIteratorClose::execute_impl(Bytecode::Interpreter& ThrowCompletionOr IteratorNext::execute_impl(Bytecode::Interpreter& interpreter) const { auto& vm = interpreter.vm(); - auto& iterator_record = verify_cast(interpreter.get(m_iterator_record).as_object()); + auto& iterator_record = as(interpreter.get(m_iterator_record).as_object()); interpreter.set(dst(), TRY(iterator_next(vm, iterator_record))); return {}; } diff --git a/Libraries/LibJS/CyclicModule.cpp b/Libraries/LibJS/CyclicModule.cpp index e4aa0af5186..00659cb670f 100644 --- a/Libraries/LibJS/CyclicModule.cpp +++ b/Libraries/LibJS/CyclicModule.cpp @@ -334,7 +334,7 @@ ThrowCompletionOr CyclicModule::evaluate(VM& vm) // In that case we first check if this module itself has a top level capability. // See also: https://github.com/tc39/ecma262/issues/2823 . if (m_top_level_capability != nullptr) - return verify_cast(m_top_level_capability->promise().ptr()); + return as(m_top_level_capability->promise().ptr()); // 3. If module.[[Status]] is either evaluating-async or evaluated, set module to module.[[CycleRoot]]. if ((m_status == ModuleStatus::EvaluatingAsync || m_status == ModuleStatus::Evaluated) && m_cycle_root != this) { @@ -348,7 +348,7 @@ ThrowCompletionOr CyclicModule::evaluate(VM& vm) // 4. If module.[[TopLevelCapability]] is not empty, then if (m_top_level_capability != nullptr) { // a. Return module.[[TopLevelCapability]].[[Promise]]. - return verify_cast(m_top_level_capability->promise().ptr()); + return as(m_top_level_capability->promise().ptr()); } // 5. Let stack be a new empty List. @@ -414,7 +414,7 @@ ThrowCompletionOr CyclicModule::evaluate(VM& vm) } // 11. Return capability.[[Promise]]. - return verify_cast(m_top_level_capability->promise().ptr()); + return as(m_top_level_capability->promise().ptr()); } // 16.2.1.5.2.1 InnerModuleEvaluation ( module, stack, index ), https://tc39.es/ecma262/#sec-innermoduleevaluation @@ -471,7 +471,7 @@ ThrowCompletionOr CyclicModule::inner_module_evaluation(VM& vm, Vector(*required_module)) continue; - GC::Ref cyclic_module = verify_cast(*required_module); + GC::Ref cyclic_module = as(*required_module); // i. Assert: requiredModule.[[Status]] is either evaluating, evaluating-async, or evaluated. VERIFY(cyclic_module->m_status == ModuleStatus::Evaluating || cyclic_module->m_status == ModuleStatus::EvaluatingAsync || cyclic_module->m_status == ModuleStatus::Evaluated); @@ -628,7 +628,7 @@ void CyclicModule::execute_async_module(VM& vm) auto on_rejected = NativeFunction::create(realm, move(rejected_closure), 0, ""); // 8. Perform PerformPromiseThen(capability.[[Promise]], onFulfilled, onRejected). - verify_cast(capability->promise().ptr())->perform_then(on_fulfilled, on_rejected, {}); + as(capability->promise().ptr())->perform_then(on_fulfilled, on_rejected, {}); // 9. Perform ! module.ExecuteModule(capability). MUST(execute_module(vm, capability)); @@ -911,7 +911,7 @@ void continue_dynamic_import(GC::Ref promise_capability, Thro // 8. Perform PerformPromiseThen(loadPromise, linkAndEvaluate, onRejected). // FIXME: This is likely a spec bug, see load_requested_modules. - verify_cast(*load_promise.promise()).perform_then(link_and_evaluate, on_rejected, {}); + as(*load_promise.promise()).perform_then(link_and_evaluate, on_rejected, {}); // 9. Return unused. } diff --git a/Libraries/LibJS/Runtime/AbstractOperations.cpp b/Libraries/LibJS/Runtime/AbstractOperations.cpp index 607514e1b3c..4820c99e0e5 100644 --- a/Libraries/LibJS/Runtime/AbstractOperations.cpp +++ b/Libraries/LibJS/Runtime/AbstractOperations.cpp @@ -496,7 +496,7 @@ Object* get_super_constructor(VM& vm) // 2. Assert: envRec is a function Environment Record. // 3. Let activeFunction be envRec.[[FunctionObject]]. // 4. Assert: activeFunction is an ECMAScript function object. - auto& active_function = verify_cast(*env).function_object(); + auto& active_function = as(*env).function_object(); // 5. Let superConstructor be ! activeFunction.[[GetPrototypeOf]](). auto* super_constructor = MUST(active_function.internal_get_prototype_of()); @@ -1715,7 +1715,7 @@ ThrowCompletionOr perform_import_call(VM& vm, Value specifier, Value opti if (active_script_or_module.has>()) return active_script_or_module.get>(); - return GC::Ref { verify_cast(*active_script_or_module.get>()) }; + return GC::Ref { as(*active_script_or_module.get>()) }; }(); // 7. Let promiseCapability be ! NewPromiseCapability(%Promise%). diff --git a/Libraries/LibJS/Runtime/AsyncFromSyncIteratorPrototype.cpp b/Libraries/LibJS/Runtime/AsyncFromSyncIteratorPrototype.cpp index cd75136779f..4b9173d49c0 100644 --- a/Libraries/LibJS/Runtime/AsyncFromSyncIteratorPrototype.cpp +++ b/Libraries/LibJS/Runtime/AsyncFromSyncIteratorPrototype.cpp @@ -61,7 +61,7 @@ static Object* async_from_sync_iterator_continuation(VM& vm, Object& result, Pro auto on_fulfilled = NativeFunction::create(realm, move(unwrap), 1, ""); // 11. Perform PerformPromiseThen(valueWrapper, onFulfilled, undefined, promiseCapability). - verify_cast(value_wrapper)->perform_then(move(on_fulfilled), js_undefined(), &promise_capability); + as(value_wrapper)->perform_then(move(on_fulfilled), js_undefined(), &promise_capability); // 12. Return promiseCapability.[[Promise]]. return promise_capability.promise(); diff --git a/Libraries/LibJS/Runtime/AsyncFunctionDriverWrapper.cpp b/Libraries/LibJS/Runtime/AsyncFunctionDriverWrapper.cpp index 4fdde10f4f5..05a973c52ce 100644 --- a/Libraries/LibJS/Runtime/AsyncFunctionDriverWrapper.cpp +++ b/Libraries/LibJS/Runtime/AsyncFunctionDriverWrapper.cpp @@ -104,7 +104,7 @@ ThrowCompletionOr AsyncFunctionDriverWrapper::await(JS::Value value) auto on_rejected = NativeFunction::create(realm, move(rejected_closure), 1, ""); // 7. Perform PerformPromiseThen(promise, onFulfilled, onRejected). - m_current_promise = verify_cast(promise_object); + m_current_promise = as(promise_object); m_current_promise->perform_then(on_fulfilled, on_rejected, {}); // 8. Remove asyncContext from the execution context stack and restore the execution context that is at the top of the diff --git a/Libraries/LibJS/Runtime/AsyncGenerator.cpp b/Libraries/LibJS/Runtime/AsyncGenerator.cpp index f783eb643b3..513d5bf5979 100644 --- a/Libraries/LibJS/Runtime/AsyncGenerator.cpp +++ b/Libraries/LibJS/Runtime/AsyncGenerator.cpp @@ -134,7 +134,7 @@ ThrowCompletionOr AsyncGenerator::await(Value value) auto on_rejected = NativeFunction::create(realm, move(rejected_closure), 1, ""); // 7. Perform PerformPromiseThen(promise, onFulfilled, onRejected). - m_current_promise = verify_cast(promise_object); + m_current_promise = as(promise_object); m_current_promise->perform_then(on_fulfilled, on_rejected, {}); // 8. Remove asyncContext from the execution context stack and restore the execution context that is at the top of the @@ -420,7 +420,7 @@ void AsyncGenerator::await_return() // 14. Perform PerformPromiseThen(promise, onFulfilled, onRejected). // NOTE: await_return should only be called when the generator is in SuspendedStart or Completed state, // so an await shouldn't be running currently, so it should be safe to overwrite m_current_promise. - m_current_promise = verify_cast(promise); + m_current_promise = as(promise); m_current_promise->perform_then(on_fulfilled, on_rejected, {}); // 15. Return unused. diff --git a/Libraries/LibJS/Runtime/Completion.cpp b/Libraries/LibJS/Runtime/Completion.cpp index e24e363d48f..b4e99f8d59e 100644 --- a/Libraries/LibJS/Runtime/Completion.cpp +++ b/Libraries/LibJS/Runtime/Completion.cpp @@ -93,7 +93,7 @@ ThrowCompletionOr await(VM& vm, Value value) auto on_rejected = NativeFunction::create(realm, move(rejected_closure), 1, ""); // 7. Perform PerformPromiseThen(promise, onFulfilled, onRejected). - auto promise = verify_cast(promise_object); + auto promise = as(promise_object); promise->perform_then(on_fulfilled, on_rejected, {}); // FIXME: Since we don't support context suspension, we attempt to "wait" for the promise to resolve diff --git a/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp b/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp index 3e419506d8a..da4507f152c 100644 --- a/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp +++ b/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp @@ -688,7 +688,7 @@ void ECMAScriptFunctionObject::ordinary_call_bind_this(ExecutionContext& callee_ // 9. Perform ! localEnv.BindThisValue(thisValue). callee_context.this_value = this_value; if (m_function_environment_needed) - MUST(verify_cast(*local_env).bind_this_value(vm, this_value)); + MUST(as(*local_env).bind_this_value(vm, this_value)); // 10. Return unused. } diff --git a/Libraries/LibJS/Runtime/ShadowRealm.cpp b/Libraries/LibJS/Runtime/ShadowRealm.cpp index bea57bd62e5..28fdd97f47e 100644 --- a/Libraries/LibJS/Runtime/ShadowRealm.cpp +++ b/Libraries/LibJS/Runtime/ShadowRealm.cpp @@ -265,7 +265,7 @@ ThrowCompletionOr shadow_realm_import_value(VM& vm, ByteString specifier_ }); // 13. Return PerformPromiseThen(innerCapability.[[Promise]], onFulfilled, callerRealm.[[Intrinsics]].[[%ThrowTypeError%]], promiseCapability). - return verify_cast(inner_capability->promise().ptr())->perform_then(on_fulfilled, throw_type_error, promise_capability); + return as(inner_capability->promise().ptr())->perform_then(on_fulfilled, throw_type_error, promise_capability); } // 3.1.5 GetWrappedValue ( callerRealm: a Realm Record, value: unknown, ), https://tc39.es/proposal-shadowrealm/#sec-getwrappedvalue diff --git a/Libraries/LibJS/Runtime/VM.cpp b/Libraries/LibJS/Runtime/VM.cpp index 0761100a089..87e1b508558 100644 --- a/Libraries/LibJS/Runtime/VM.cpp +++ b/Libraries/LibJS/Runtime/VM.cpp @@ -352,7 +352,7 @@ Value VM::get_new_target() // 2. Assert: envRec has a [[NewTarget]] field. // 3. Return envRec.[[NewTarget]]. - return verify_cast(*env).new_target(); + return as(*env).new_target(); } // 13.3.12.1 Runtime Semantics: Evaluation, https://tc39.es/ecma262/#sec-meta-properties-runtime-semantics-evaluation @@ -363,7 +363,7 @@ Object* VM::get_import_meta() auto script_or_module = get_active_script_or_module(); // 2. Assert: module is a Source Text Module Record. - auto& module = verify_cast(*script_or_module.get>()); + auto& module = as(*script_or_module.get>()); // 3. Let importMeta be module.[[ImportMeta]]. auto* import_meta = module.import_meta(); @@ -553,7 +553,7 @@ ThrowCompletionOr VM::link_and_eval_module(CyclicModule& module) auto filename = module.filename(); auto& promise_capability = module.load_requested_modules(nullptr); - if (auto const& promise = verify_cast(*promise_capability.promise()); promise.state() == Promise::State::Rejected) + if (auto const& promise = as(*promise_capability.promise()); promise.state() == Promise::State::Rejected) return JS::throw_completion(promise.result()); dbgln_if(JS_MODULE_DEBUG, "[JS MODULE] Linking module {}", filename); diff --git a/Libraries/LibJS/SourceTextModule.cpp b/Libraries/LibJS/SourceTextModule.cpp index def620cf4fe..51558675a9f 100644 --- a/Libraries/LibJS/SourceTextModule.cpp +++ b/Libraries/LibJS/SourceTextModule.cpp @@ -732,7 +732,7 @@ ThrowCompletionOr SourceTextModule::execute_module(VM& vm, GC::Ptr(*module_context->lexical_environment); + auto& env = as(*module_context->lexical_environment); // e. Set result to Completion(DisposeResources(env.[[DisposeCapability]], result)). result = dispose_resources(vm, env.dispose_capability(), result); diff --git a/Libraries/LibRegex/RegexByteCode.h b/Libraries/LibRegex/RegexByteCode.h index fa8eff1a036..5fede59fd65 100644 --- a/Libraries/LibRegex/RegexByteCode.h +++ b/Libraries/LibRegex/RegexByteCode.h @@ -894,25 +894,25 @@ ALWAYS_INLINE bool is(OpCode const& opcode) template ALWAYS_INLINE T const& to(OpCode const& opcode) { - return verify_cast(opcode); + return as(opcode); } template ALWAYS_INLINE T* to(OpCode* opcode) { - return verify_cast(opcode); + return as(opcode); } template ALWAYS_INLINE T const* to(OpCode const* opcode) { - return verify_cast(opcode); + return as(opcode); } template ALWAYS_INLINE T& to(OpCode& opcode) { - return verify_cast(opcode); + return as(opcode); } } diff --git a/Libraries/LibUnicode/DateTimeFormat.cpp b/Libraries/LibUnicode/DateTimeFormat.cpp index ed486395b6f..64940a529a3 100644 --- a/Libraries/LibUnicode/DateTimeFormat.cpp +++ b/Libraries/LibUnicode/DateTimeFormat.cpp @@ -883,7 +883,7 @@ NonnullOwnPtr DateTimeFormat::create_for_date_and_time_style( auto locale_data = LocaleData::for_locale(locale); VERIFY(locale_data.has_value()); - auto formatter = adopt_own(*verify_cast([&]() { + auto formatter = adopt_own(*as([&]() { if (date_style.has_value() && time_style.has_value()) { return icu::DateFormat::createDateTimeInstance( icu_date_time_style(*date_style), icu_date_time_style(*time_style), locale_data->locale()); diff --git a/Libraries/LibWeb/Animations/Animatable.cpp b/Libraries/LibWeb/Animations/Animatable.cpp index 1b2ba0ff4f6..41a706c99f2 100644 --- a/Libraries/LibWeb/Animations/Animatable.cpp +++ b/Libraries/LibWeb/Animations/Animatable.cpp @@ -62,7 +62,7 @@ WebIDL::ExceptionOr> Animatable::animate(Optional>> Animatable::get_animations(Optional options) { - verify_cast(*this).document().update_style(); + as(*this).document().update_style(); return get_animations_internal(options); } @@ -103,8 +103,8 @@ WebIDL::ExceptionOr>> Animatable::get_animations_inter // The returned list is sorted using the composite order described for the associated animations of effects in // §5.4.2 The effect stack. quick_sort(relevant_animations, [](GC::Ref& a, GC::Ref& b) { - auto& a_effect = verify_cast(*a->effect()); - auto& b_effect = verify_cast(*b->effect()); + auto& a_effect = as(*a->effect()); + auto& b_effect = as(*b->effect()); return KeyframeEffect::composite_order(a_effect, b_effect) < 0; }); diff --git a/Libraries/LibWeb/Animations/Animation.cpp b/Libraries/LibWeb/Animations/Animation.cpp index 332be06960c..53e126b7315 100644 --- a/Libraries/LibWeb/Animations/Animation.cpp +++ b/Libraries/LibWeb/Animations/Animation.cpp @@ -34,7 +34,7 @@ GC::Ref Animation::create(JS::Realm& realm, GC::Ptr // a timeline argument is missing, passing the default document timeline of the Document associated with the // Window that is the current global object. if (!timeline.has_value()) { - auto& window = verify_cast(HTML::current_principal_global_object()); + auto& window = as(HTML::current_principal_global_object()); timeline = window.associated_document().timeline(); } animation->set_timeline(timeline.release_value()); @@ -1143,7 +1143,7 @@ void Animation::update_finished_state(DidSeek did_seek, SynchronouslyNotify sync // manipulation task source. else { // Manually create a task so its ID can be saved - auto& document = verify_cast(realm.global_object()).associated_document(); + auto& document = as(realm.global_object()).associated_document(); auto task = HTML::Task::create(vm(), HTML::Task::Source::DOMManipulation, &document, GC::create_function(heap(), [this, finish_event]() { dispatch_event(finish_event); @@ -1166,7 +1166,7 @@ void Animation::update_finished_state(DidSeek did_seek, SynchronouslyNotify sync // Otherwise, if synchronously notify is false, queue a microtask to run finish notification steps for // animation unless there is already a microtask queued to run those steps for animation. else if (!m_pending_finish_microtask_id.has_value()) { - auto& document = verify_cast(realm.global_object()).associated_document(); + auto& document = as(realm.global_object()).associated_document(); auto task = HTML::Task::create(vm(), HTML::Task::Source::DOMManipulation, &document, move(finish_notification_steps)); m_pending_finish_microtask_id = task->id(); HTML::main_thread_event_loop().task_queue().add(move(task)); diff --git a/Libraries/LibWeb/Animations/DocumentTimeline.cpp b/Libraries/LibWeb/Animations/DocumentTimeline.cpp index 04f2b5c086d..d20670945b2 100644 --- a/Libraries/LibWeb/Animations/DocumentTimeline.cpp +++ b/Libraries/LibWeb/Animations/DocumentTimeline.cpp @@ -36,7 +36,7 @@ WebIDL::ExceptionOr> DocumentTimeline::construct_impl( { // Creates a new DocumentTimeline. The Document with which the timeline is associated is the Document associated // with the Window that is the current global object. - auto& window = verify_cast(realm.global_object()); + auto& window = as(realm.global_object()); return create(realm, window.associated_document(), options.origin_time); } diff --git a/Libraries/LibWeb/Bindings/AudioConstructor.cpp b/Libraries/LibWeb/Bindings/AudioConstructor.cpp index 17ff217c470..5a233f76f7d 100644 --- a/Libraries/LibWeb/Bindings/AudioConstructor.cpp +++ b/Libraries/LibWeb/Bindings/AudioConstructor.cpp @@ -42,7 +42,7 @@ JS::ThrowCompletionOr> AudioConstructor::construct(FunctionO auto& vm = this->vm(); // 1. Let document be the current global object's associated Document. - auto& window = verify_cast(HTML::current_principal_global_object()); + auto& window = as(HTML::current_principal_global_object()); auto& document = window.associated_document(); // 2. Let audio be the result of creating an element given document, "audio", and the HTML namespace. diff --git a/Libraries/LibWeb/Bindings/ImageConstructor.cpp b/Libraries/LibWeb/Bindings/ImageConstructor.cpp index 12c09160cc4..91449b8435c 100644 --- a/Libraries/LibWeb/Bindings/ImageConstructor.cpp +++ b/Libraries/LibWeb/Bindings/ImageConstructor.cpp @@ -43,7 +43,7 @@ JS::ThrowCompletionOr> ImageConstructor::construct(FunctionO auto& vm = this->vm(); // 1. Let document be the current principal global object's associated Document. - auto& window = verify_cast(HTML::current_principal_global_object()); + auto& window = as(HTML::current_principal_global_object()); auto& document = window.associated_document(); // 2. Let img be the result of creating an element given document, "img", and the HTML namespace. diff --git a/Libraries/LibWeb/Bindings/Intrinsics.cpp b/Libraries/LibWeb/Bindings/Intrinsics.cpp index de2585589d2..51595543122 100644 --- a/Libraries/LibWeb/Bindings/Intrinsics.cpp +++ b/Libraries/LibWeb/Bindings/Intrinsics.cpp @@ -32,7 +32,7 @@ bool Intrinsics::is_exposed(StringView name) const Intrinsics& host_defined_intrinsics(JS::Realm& realm) { VERIFY(realm.host_defined()); - return verify_cast(*realm.host_defined()).intrinsics; + return as(*realm.host_defined()).intrinsics; } } diff --git a/Libraries/LibWeb/Bindings/MainThreadVM.cpp b/Libraries/LibWeb/Bindings/MainThreadVM.cpp index a5ce359425c..2eaa54a36a9 100644 --- a/Libraries/LibWeb/Bindings/MainThreadVM.cpp +++ b/Libraries/LibWeb/Bindings/MainThreadVM.cpp @@ -61,10 +61,10 @@ HTML::Script* active_script() // 3. Return record.[[HostDefined]]. return record.visit( [](GC::Ref& js_script) -> HTML::Script* { - return verify_cast(js_script->host_defined()); + return as(js_script->host_defined()); }, [](GC::Ref& js_module) -> HTML::Script* { - return verify_cast(js_module->host_defined()); + return as(js_module->host_defined()); }, [](Empty) -> HTML::Script* { return nullptr; @@ -77,7 +77,7 @@ ErrorOr initialize_main_thread_vm(HTML::EventLoop::Type type) s_main_thread_vm = TRY(JS::VM::create(make())); - auto& custom_data = verify_cast(*s_main_thread_vm->custom_data()); + auto& custom_data = as(*s_main_thread_vm->custom_data()); custom_data.agent.event_loop = s_main_thread_vm->heap().allocate(type); s_main_thread_vm->on_unimplemented_property_access = [](auto const& object, auto const& property_key) { @@ -110,10 +110,10 @@ ErrorOr initialize_main_thread_vm(HTML::EventLoop::Type type) HTML::Script* script { nullptr }; vm.running_execution_context().script_or_module.visit( [&script](GC::Ref& js_script) { - script = verify_cast(js_script->host_defined()); + script = as(js_script->host_defined()); }, [&script](GC::Ref& js_module) { - script = verify_cast(js_module->host_defined()); + script = as(js_module->host_defined()); }, [](Empty) { }); @@ -160,7 +160,7 @@ ErrorOr initialize_main_thread_vm(HTML::EventLoop::Type type) // with the promise attribute initialized to promise, and the reason attribute initialized to the value of promise's [[PromiseResult]] internal slot. HTML::queue_global_task(HTML::Task::Source::DOMManipulation, global, GC::create_function(s_main_thread_vm->heap(), [&global, &promise] { // FIXME: This currently assumes that global is a WindowObject. - auto& window = verify_cast(global); + auto& window = as(global); HTML::PromiseRejectionEventInit event_init { {}, // Initialize the inherited DOM::EventInit @@ -180,7 +180,7 @@ ErrorOr initialize_main_thread_vm(HTML::EventLoop::Type type) // 8.1.5.4.1 HostCallJobCallback(callback, V, argumentsList), https://html.spec.whatwg.org/multipage/webappapis.html#hostcalljobcallback // https://whatpr.org/html/9893/webappapis.html#hostcalljobcallback s_main_thread_vm->host_call_job_callback = [](JS::JobCallback& callback, JS::Value this_value, ReadonlySpan arguments_list) { - auto& callback_host_defined = verify_cast(*callback.custom_data()); + auto& callback_host_defined = as(*callback.custom_data()); // 1. Let incumbent realm be callback.[[HostDefined]].[[IncumbentRealm]]. auto& incumbent_realm = callback_host_defined.incumbent_realm; @@ -327,10 +327,10 @@ ErrorOr initialize_main_thread_vm(HTML::EventLoop::Type type) script_execution_context->function = nullptr; script_execution_context->realm = &script->realm(); if (is(script)) { - script_execution_context->script_or_module = GC::Ref(*verify_cast(script)->script_record()); + script_execution_context->script_or_module = GC::Ref(*as(script)->script_record()); } else if (is(script)) { if (is(script)) { - script_execution_context->script_or_module = GC::Ref(*verify_cast(script)->record()); + script_execution_context->script_or_module = GC::Ref(*as(script)->record()); } else { // NOTE: Handle CSS and JSON module scripts once we have those. VERIFY_NOT_REACHED(); @@ -351,7 +351,7 @@ ErrorOr initialize_main_thread_vm(HTML::EventLoop::Type type) auto& vm = realm.vm(); // 1. Let moduleScript be moduleRecord.[[HostDefined]]. - auto& module_script = *verify_cast(module_record.host_defined()); + auto& module_script = *as(module_record.host_defined()); // 2. Assert: moduleScript's base URL is not null, as moduleScript is a JavaScript module script. VERIFY(module_script.base_url().is_valid()); @@ -424,7 +424,7 @@ ErrorOr initialize_main_thread_vm(HTML::EventLoop::Type type) // 6. If referrer is a Script Record or a Cyclic Module Record, then: if (referrer.has>() || referrer.has>()) { // 1. Set referencingScript to referrer.[[HostDefined]]. - referencing_script = verify_cast(referrer.has>() ? *referrer.get>()->host_defined() : *referrer.get>()->host_defined()); + referencing_script = as(referrer.has>() ? *referrer.get>()->host_defined() : *referrer.get>()->host_defined()); // 2. Set fetchReferrer to referencingScript's base URL. fetch_referrer = referencing_script->base_url(); @@ -657,7 +657,7 @@ JS::VM& main_thread_vm() void queue_mutation_observer_microtask(DOM::Document const& document) { auto& vm = main_thread_vm(); - auto& surrounding_agent = verify_cast(*vm.custom_data()).agent; + auto& surrounding_agent = as(*vm.custom_data()).agent; // 1. If the surrounding agent’s mutation observer microtask queued is true, then return. if (surrounding_agent.mutation_observer_microtask_queued) diff --git a/Libraries/LibWeb/Bindings/OptionConstructor.cpp b/Libraries/LibWeb/Bindings/OptionConstructor.cpp index 6bc82554b32..7701432ffa5 100644 --- a/Libraries/LibWeb/Bindings/OptionConstructor.cpp +++ b/Libraries/LibWeb/Bindings/OptionConstructor.cpp @@ -52,12 +52,12 @@ JS::ThrowCompletionOr> OptionConstructor::construct(Function text_value = &vm.empty_string(); // 1. Let document be the current principal global object's associated Document. - auto& window = verify_cast(HTML::current_principal_global_object()); + auto& window = as(HTML::current_principal_global_object()); auto& document = window.associated_document(); // 2. Let option be the result of creating an element given document, "option", and the HTML namespace. auto element = TRY(Bindings::throw_dom_exception_if_needed(vm, [&]() { return DOM::create_element(document, HTML::TagNames::option, Namespace::HTML); })); - GC::Ref option_element = verify_cast(*element); + GC::Ref option_element = as(*element); // 3. If text is not the empty string, then append to option a new Text node whose data is text. auto text = TRY(text_value.to_string(vm)); diff --git a/Libraries/LibWeb/Bindings/PrincipalHostDefined.h b/Libraries/LibWeb/Bindings/PrincipalHostDefined.h index 140478309de..7819d3c3380 100644 --- a/Libraries/LibWeb/Bindings/PrincipalHostDefined.h +++ b/Libraries/LibWeb/Bindings/PrincipalHostDefined.h @@ -30,17 +30,17 @@ struct PrincipalHostDefined : public HostDefined { [[nodiscard]] inline HTML::EnvironmentSettingsObject& principal_host_defined_environment_settings_object(JS::Realm& realm) { - return *verify_cast(realm.host_defined())->environment_settings_object; + return *as(realm.host_defined())->environment_settings_object; } [[nodiscard]] inline HTML::EnvironmentSettingsObject const& principal_host_defined_environment_settings_object(JS::Realm const& realm) { - return *verify_cast(realm.host_defined())->environment_settings_object; + return *as(realm.host_defined())->environment_settings_object; } [[nodiscard]] inline Page& principal_host_defined_page(JS::Realm& realm) { - return *verify_cast(realm.host_defined())->page; + return *as(realm.host_defined())->page; } } diff --git a/Libraries/LibWeb/CSS/CSSAnimation.cpp b/Libraries/LibWeb/CSS/CSSAnimation.cpp index 6e300610d7a..3a431da28b5 100644 --- a/Libraries/LibWeb/CSS/CSSAnimation.cpp +++ b/Libraries/LibWeb/CSS/CSSAnimation.cpp @@ -22,7 +22,7 @@ GC::Ref CSSAnimation::create(JS::Realm& realm) // https://www.w3.org/TR/css-animations-2/#animation-composite-order Optional CSSAnimation::class_specific_composite_order(GC::Ref other_animation) const { - auto other = GC::Ref { verify_cast(*other_animation) }; + auto other = GC::Ref { as(*other_animation) }; // The existance of an owning element determines the animation class, so both animations should have their owning // element in the same state diff --git a/Libraries/LibWeb/CSS/CSSRuleList.cpp b/Libraries/LibWeb/CSS/CSSRuleList.cpp index 39aa50fcd20..86ba4eb2989 100644 --- a/Libraries/LibWeb/CSS/CSSRuleList.cpp +++ b/Libraries/LibWeb/CSS/CSSRuleList.cpp @@ -162,19 +162,19 @@ bool CSSRuleList::evaluate_media_queries(HTML::Window const& window) for (auto& rule : m_rules) { switch (rule->type()) { case CSSRule::Type::Import: { - auto& import_rule = verify_cast(*rule); + auto& import_rule = as(*rule); if (import_rule.loaded_style_sheet() && import_rule.loaded_style_sheet()->evaluate_media_queries(window)) any_media_queries_changed_match_state = true; break; } case CSSRule::Type::LayerBlock: { - auto& layer_rule = verify_cast(*rule); + auto& layer_rule = as(*rule); if (layer_rule.css_rules().evaluate_media_queries(window)) any_media_queries_changed_match_state = true; break; } case CSSRule::Type::Media: { - auto& media_rule = verify_cast(*rule); + auto& media_rule = as(*rule); bool did_match = media_rule.condition_matches(); bool now_matches = media_rule.evaluate(window); if (did_match != now_matches) @@ -184,13 +184,13 @@ bool CSSRuleList::evaluate_media_queries(HTML::Window const& window) break; } case CSSRule::Type::Supports: { - auto& supports_rule = verify_cast(*rule); + auto& supports_rule = as(*rule); if (supports_rule.condition_matches() && supports_rule.css_rules().evaluate_media_queries(window)) any_media_queries_changed_match_state = true; break; } case CSSRule::Type::Style: { - auto& style_rule = verify_cast(*rule); + auto& style_rule = as(*rule); if (style_rule.css_rules().evaluate_media_queries(window)) any_media_queries_changed_match_state = true; break; diff --git a/Libraries/LibWeb/CSS/CSSStyleSheet.cpp b/Libraries/LibWeb/CSS/CSSStyleSheet.cpp index e0989c8ca8b..d7b80975933 100644 --- a/Libraries/LibWeb/CSS/CSSStyleSheet.cpp +++ b/Libraries/LibWeb/CSS/CSSStyleSheet.cpp @@ -35,7 +35,7 @@ WebIDL::ExceptionOr> CSSStyleSheet::construct_impl(JS::Re auto sheet = create(realm, CSSRuleList::create_empty(realm), CSS::MediaList::create(realm, {}), {}); // 2. Set sheet’s location to the base URL of the associated Document for the current principal global object. - auto associated_document = verify_cast(HTML::current_principal_global_object()).document(); + auto associated_document = as(HTML::current_principal_global_object()).document(); sheet->set_location(associated_document->base_url().to_string()); // 3. Set sheet’s stylesheet base URL to the baseURL attribute value from options. @@ -387,11 +387,11 @@ void CSSStyleSheet::recalculate_rule_caches() // @import rules must appear before @namespace rules, so skip this if we've seen @namespace. if (!m_namespace_rules.is_empty()) continue; - m_import_rules.append(verify_cast(*rule)); + m_import_rules.append(as(*rule)); break; } case CSSRule::Type::Namespace: { - auto& namespace_rule = verify_cast(*rule); + auto& namespace_rule = as(*rule); if (!namespace_rule.namespace_uri().is_empty() && namespace_rule.prefix().is_empty()) m_default_namespace_rule = namespace_rule; diff --git a/Libraries/LibWeb/CSS/CSSTransition.cpp b/Libraries/LibWeb/CSS/CSSTransition.cpp index 4f80cb11b95..3e36c09cdf4 100644 --- a/Libraries/LibWeb/CSS/CSSTransition.cpp +++ b/Libraries/LibWeb/CSS/CSSTransition.cpp @@ -34,7 +34,7 @@ Animations::AnimationClass CSSTransition::animation_class() const Optional CSSTransition::class_specific_composite_order(GC::Ref other_animation) const { - auto other = GC::Ref { verify_cast(*other_animation) }; + auto other = GC::Ref { as(*other_animation) }; // Within the set of CSS Transitions, two animations A and B are sorted in composite order (first to last) as // follows: diff --git a/Libraries/LibWeb/CSS/ComputedProperties.cpp b/Libraries/LibWeb/CSS/ComputedProperties.cpp index 66a73bb432d..f7ef0e19030 100644 --- a/Libraries/LibWeb/CSS/ComputedProperties.cpp +++ b/Libraries/LibWeb/CSS/ComputedProperties.cpp @@ -1060,7 +1060,7 @@ Vector ComputedProperties::shadow(PropertyID property_id, Layout::No maybe_offset_y.release_value(), maybe_blur_radius.release_value(), maybe_spread_distance.release_value(), - value.color()->to_color(verify_cast(layout_node)), + value.color()->to_color(as(layout_node)), value.placement() }; }; diff --git a/Libraries/LibWeb/CSS/CountersSet.cpp b/Libraries/LibWeb/CSS/CountersSet.cpp index ff5241ff26e..ff238f250bc 100644 --- a/Libraries/LibWeb/CSS/CountersSet.cpp +++ b/Libraries/LibWeb/CSS/CountersSet.cpp @@ -23,7 +23,7 @@ Counter& CountersSet::instantiate_a_counter(FlyString name, UniqueNodeID origina if (innermost_counter.has_value()) { auto* originating_node = DOM::Node::from_unique_id(innermost_counter->originating_element_id); VERIFY(originating_node); - auto& innermost_element = verify_cast(*originating_node); + auto& innermost_element = as(*originating_node); if (&innermost_element == element || (innermost_element.parent() == element->parent() && innermost_element.is_before(*element))) { diff --git a/Libraries/LibWeb/CSS/FontFace.cpp b/Libraries/LibWeb/CSS/FontFace.cpp index ac4e994b3b1..6ec07b9e0fe 100644 --- a/Libraries/LibWeb/CSS/FontFace.cpp +++ b/Libraries/LibWeb/CSS/FontFace.cpp @@ -178,7 +178,7 @@ FontFace::FontFace(JS::Realm& realm, GC::Ref font_status_promis // FIXME: Have gettter reflect this member instead of the string m_unicode_ranges.empend(0x0u, 0x10FFFFu); - if (verify_cast(*m_font_status_promise->promise()).state() == JS::Promise::State::Rejected) + if (as(*m_font_status_promise->promise()).state() == JS::Promise::State::Rejected) m_status = Bindings::FontFaceLoadStatus::Error; } diff --git a/Libraries/LibWeb/CSS/FontFaceSet.cpp b/Libraries/LibWeb/CSS/FontFaceSet.cpp index d904de11602..4bf25662d65 100644 --- a/Libraries/LibWeb/CSS/FontFaceSet.cpp +++ b/Libraries/LibWeb/CSS/FontFaceSet.cpp @@ -209,7 +209,7 @@ static WebIDL::ExceptionOr> find_matching_font_faces(JS::Realm& auto const& font_family_name = font_family->as_string().string_value(); for (auto font_face_value : *available_font_faces) { - auto& font_face = verify_cast(font_face_value.key.as_object()); + auto& font_face = as(font_face_value.key.as_object()); if (font_face.family() != font_family_name) continue; @@ -253,7 +253,7 @@ JS::ThrowCompletionOr> FontFaceSet::load(String const& // 1. For all of the font faces in the font face list, call their load() method. for (auto font_face_value : *matched_font_faces) { - auto& font_face = verify_cast(font_face_value.key.as_object()); + auto& font_face = as(font_face_value.key.as_object()); font_face.load(); promises.append(font_face.font_status_promise()); diff --git a/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp b/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp index 6a42fb4fc23..d84a491087b 100644 --- a/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp +++ b/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp @@ -366,7 +366,7 @@ RefPtr ResolvedCSSStyleDeclaration::style_value_for_propert // 2. Post-multiply all s in to transform. VERIFY(layout_node.first_paintable()); - auto const& paintable_box = verify_cast(*layout_node.first_paintable()); + auto const& paintable_box = as(*layout_node.first_paintable()); for (auto transformation : transformations) { transform = transform * transformation.to_matrix(paintable_box).release_value(); } @@ -497,14 +497,14 @@ RefPtr ResolvedCSSStyleDeclaration::style_value_for_propert // https://www.w3.org/TR/css-grid-2/#resolved-track-list-standalone if (property_id == PropertyID::GridTemplateColumns) { if (layout_node.first_paintable() && layout_node.first_paintable()->is_paintable_box()) { - auto const& paintable_box = verify_cast(*layout_node.first_paintable()); + auto const& paintable_box = as(*layout_node.first_paintable()); if (auto used_values_for_grid_template_columns = paintable_box.used_values_for_grid_template_columns()) { return used_values_for_grid_template_columns; } } } else if (property_id == PropertyID::GridTemplateRows) { if (layout_node.first_paintable() && layout_node.first_paintable()->is_paintable_box()) { - auto const& paintable_box = verify_cast(*layout_node.first_paintable()); + auto const& paintable_box = as(*layout_node.first_paintable()); if (auto used_values_for_grid_template_rows = paintable_box.used_values_for_grid_template_rows()) { return used_values_for_grid_template_rows; } diff --git a/Libraries/LibWeb/CSS/StyleComputer.cpp b/Libraries/LibWeb/CSS/StyleComputer.cpp index 146b9a6b7f5..9c7b1a4c83e 100644 --- a/Libraries/LibWeb/CSS/StyleComputer.cpp +++ b/Libraries/LibWeb/CSS/StyleComputer.cpp @@ -1177,7 +1177,7 @@ static void apply_animation_properties(DOM::Document& document, CascadedProperti if (!animation.effect()) return; - auto& effect = verify_cast(*animation.effect()); + auto& effect = as(*animation.effect()); Optional duration; if (auto duration_value = cascaded_properties.property(PropertyID::AnimationDuration); duration_value) { @@ -2339,7 +2339,7 @@ GC::Ptr StyleComputer::compute_style_impl(DOM::Element& elem // Special path for elements that use pseudo element as style selector if (element.use_pseudo_element().has_value()) { - auto& parent_element = verify_cast(*element.root().parent_or_shadow_host()); + auto& parent_element = as(*element.root().parent_or_shadow_host()); auto style = compute_style(parent_element, *element.use_pseudo_element()); // Merge back inline styles @@ -2772,7 +2772,7 @@ NonnullOwnPtr StyleComputer::make_rule_cache_for_casca // Forwards pass, resolve all the user-specified keyframe properties. for (auto const& keyframe_rule : *rule.css_rules()) { - auto const& keyframe = verify_cast(*keyframe_rule); + auto const& keyframe = as(*keyframe_rule); Animations::KeyframeEffect::KeyFrameSet::ResolvedKeyFrame resolved_keyframe; auto key = static_cast(keyframe.key().value() * Animations::KeyframeEffect::AnimationKeyFrameKeyScaleFactor); diff --git a/Libraries/LibWeb/CSS/StyleValues/CSSColor.cpp b/Libraries/LibWeb/CSS/StyleValues/CSSColor.cpp index 8dd78795192..ebcf252765b 100644 --- a/Libraries/LibWeb/CSS/StyleValues/CSSColor.cpp +++ b/Libraries/LibWeb/CSS/StyleValues/CSSColor.cpp @@ -77,7 +77,7 @@ bool CSSColor::equals(CSSStyleValue const& other) const auto const& other_color = other.as_color(); if (color_type() != other_color.color_type()) return false; - auto const& other_lab_like = verify_cast(other_color); + auto const& other_lab_like = as(other_color); return m_properties == other_lab_like.m_properties; } diff --git a/Libraries/LibWeb/CSS/StyleValues/CSSHSL.cpp b/Libraries/LibWeb/CSS/StyleValues/CSSHSL.cpp index 9c91ae6a6f5..a2685cb8d39 100644 --- a/Libraries/LibWeb/CSS/StyleValues/CSSHSL.cpp +++ b/Libraries/LibWeb/CSS/StyleValues/CSSHSL.cpp @@ -27,7 +27,7 @@ bool CSSHSL::equals(CSSStyleValue const& other) const auto const& other_color = other.as_color(); if (color_type() != other_color.color_type()) return false; - auto const& other_hsl = verify_cast(other_color); + auto const& other_hsl = as(other_color); return m_properties == other_hsl.m_properties; } diff --git a/Libraries/LibWeb/CSS/StyleValues/CSSHWB.cpp b/Libraries/LibWeb/CSS/StyleValues/CSSHWB.cpp index 0dfdecd668e..ab99d9522f0 100644 --- a/Libraries/LibWeb/CSS/StyleValues/CSSHWB.cpp +++ b/Libraries/LibWeb/CSS/StyleValues/CSSHWB.cpp @@ -37,7 +37,7 @@ bool CSSHWB::equals(CSSStyleValue const& other) const auto const& other_color = other.as_color(); if (color_type() != other_color.color_type()) return false; - auto const& other_hwb = verify_cast(other_color); + auto const& other_hwb = as(other_color); return m_properties == other_hwb.m_properties; } diff --git a/Libraries/LibWeb/CSS/StyleValues/CSSLCHLike.cpp b/Libraries/LibWeb/CSS/StyleValues/CSSLCHLike.cpp index 23288ba4822..c6ef26fecd9 100644 --- a/Libraries/LibWeb/CSS/StyleValues/CSSLCHLike.cpp +++ b/Libraries/LibWeb/CSS/StyleValues/CSSLCHLike.cpp @@ -21,7 +21,7 @@ bool CSSLCHLike::equals(CSSStyleValue const& other) const auto const& other_color = other.as_color(); if (color_type() != other_color.color_type()) return false; - auto const& other_oklch_like = verify_cast(other_color); + auto const& other_oklch_like = as(other_color); return m_properties == other_oklch_like.m_properties; } diff --git a/Libraries/LibWeb/CSS/StyleValues/CSSLabLike.cpp b/Libraries/LibWeb/CSS/StyleValues/CSSLabLike.cpp index 2cf2c606d0d..9c55ed098ce 100644 --- a/Libraries/LibWeb/CSS/StyleValues/CSSLabLike.cpp +++ b/Libraries/LibWeb/CSS/StyleValues/CSSLabLike.cpp @@ -20,7 +20,7 @@ bool CSSLabLike::equals(CSSStyleValue const& other) const auto const& other_color = other.as_color(); if (color_type() != other_color.color_type()) return false; - auto const& other_lab_like = verify_cast(other_color); + auto const& other_lab_like = as(other_color); return m_properties == other_lab_like.m_properties; } diff --git a/Libraries/LibWeb/CSS/StyleValues/CSSLightDark.cpp b/Libraries/LibWeb/CSS/StyleValues/CSSLightDark.cpp index ed171eef8d4..ad4bfec42bb 100644 --- a/Libraries/LibWeb/CSS/StyleValues/CSSLightDark.cpp +++ b/Libraries/LibWeb/CSS/StyleValues/CSSLightDark.cpp @@ -24,7 +24,7 @@ bool CSSLightDark::equals(CSSStyleValue const& other) const auto const& other_color = other.as_color(); if (color_type() != other_color.color_type()) return false; - auto const& other_light_dark = verify_cast(other_color); + auto const& other_light_dark = as(other_color); return m_properties == other_light_dark.m_properties; } diff --git a/Libraries/LibWeb/CSS/StyleValues/CSSRGB.cpp b/Libraries/LibWeb/CSS/StyleValues/CSSRGB.cpp index 55d189f2bc5..6ba63f5e902 100644 --- a/Libraries/LibWeb/CSS/StyleValues/CSSRGB.cpp +++ b/Libraries/LibWeb/CSS/StyleValues/CSSRGB.cpp @@ -65,7 +65,7 @@ bool CSSRGB::equals(CSSStyleValue const& other) const auto const& other_color = other.as_color(); if (color_type() != other_color.color_type()) return false; - auto const& other_rgb = verify_cast(other_color); + auto const& other_rgb = as(other_color); return m_properties == other_rgb.m_properties; } diff --git a/Libraries/LibWeb/Clipboard/Clipboard.cpp b/Libraries/LibWeb/Clipboard/Clipboard.cpp index 44b12ee5c44..fbe0b932cb2 100644 --- a/Libraries/LibWeb/Clipboard/Clipboard.cpp +++ b/Libraries/LibWeb/Clipboard/Clipboard.cpp @@ -86,7 +86,7 @@ static String os_specific_well_known_format(StringView mime_type_string) // https://w3c.github.io/clipboard-apis/#write-blobs-and-option-to-the-clipboard static void write_blobs_and_option_to_clipboard(JS::Realm& realm, ReadonlySpan> items, String presentation_style) { - auto& window = verify_cast(realm.global_object()); + auto& window = as(realm.global_object()); // FIXME: 1. Let webCustomFormats be a sequence. @@ -127,7 +127,7 @@ static bool check_clipboard_write_permission(JS::Realm& realm) // https://pr-preview.s3.amazonaws.com/w3c/clipboard-apis/pull/164.html#write-permission // 1. Let hasGesture be true if the relevant global object of this has transient activation, false otherwise. - auto has_gesture = verify_cast(realm.global_object()).has_transient_activation(); + auto has_gesture = as(realm.global_object()).has_transient_activation(); // 2. If hasGesture then, if (has_gesture) { diff --git a/Libraries/LibWeb/Crypto/CryptoAlgorithms.cpp b/Libraries/LibWeb/Crypto/CryptoAlgorithms.cpp index 5c2f47e53a9..8b07fddc0bf 100644 --- a/Libraries/LibWeb/Crypto/CryptoAlgorithms.cpp +++ b/Libraries/LibWeb/Crypto/CryptoAlgorithms.cpp @@ -586,7 +586,7 @@ JS::ThrowCompletionOr> EcdhKeyDeriveParams::from_ return vm.throw_completion(JS::ErrorType::NotAnObjectOfType, "CryptoKey"); } - auto& key = verify_cast(*key_object); + auto& key = as(*key_object); return adopt_own(*new EcdhKeyDeriveParams { key }); } @@ -672,7 +672,7 @@ WebIDL::ExceptionOr> RSAOAEP::encrypt(AlgorithmParams c auto const& handle = key->handle(); auto public_key = handle.get<::Crypto::PK::RSAPublicKey<>>(); - auto hash = TRY(verify_cast(*key->algorithm()).hash().name(vm)); + auto hash = TRY(as(*key->algorithm()).hash().name(vm)); // 3. Perform the encryption operation defined in Section 7.1 of [RFC3447] with the key represented by key as the recipient's RSA public key, // the contents of plaintext as the message to be encrypted, M and label as the label, L, and with the hash function specified by the hash attribute @@ -721,7 +721,7 @@ WebIDL::ExceptionOr> RSAOAEP::decrypt(AlgorithmParams c auto const& handle = key->handle(); auto private_key = handle.get<::Crypto::PK::RSAPrivateKey<>>(); - auto hash = TRY(verify_cast(*key->algorithm()).hash().name(vm)); + auto hash = TRY(as(*key->algorithm()).hash().name(vm)); // 3. Perform the decryption operation defined in Section 7.1 of [RFC3447] with the key represented by key as the recipient's RSA private key, // the contents of ciphertext as the ciphertext to be decrypted, C, and label as the label, L, and with the hash function specified by the hash attribute @@ -1158,7 +1158,7 @@ WebIDL::ExceptionOr> RSAOAEP::export_key(Bindings::KeyFormat jwk.kty = "RSA"_string; // 4. Let hash be the name attribute of the hash attribute of the [[algorithm]] internal slot of key. - auto hash = TRY(verify_cast(*key->algorithm()).hash().name(vm)); + auto hash = TRY(as(*key->algorithm()).hash().name(vm)); // 4. If hash is "SHA-1": // - Set the alg attribute of jwk to the string "RSA-OAEP". @@ -1325,7 +1325,7 @@ WebIDL::ExceptionOr> RSAPSS::sign(AlgorithmParams const auto const& private_key = key->handle().get<::Crypto::PK::RSAPrivateKey<>>(); auto pss_params = static_cast(params); - auto hash = TRY(verify_cast(*key->algorithm()).hash().name(vm)); + auto hash = TRY(as(*key->algorithm()).hash().name(vm)); // 3. Perform the signature generation operation defined in Section 8.1 of [RFC3447] with the key represented by the [[handle]] internal slot // of key as the signer's private key, K, and the contents of message as the message to be signed, M, and using the hash function specified @@ -1371,7 +1371,7 @@ WebIDL::ExceptionOr RSAPSS::verify(AlgorithmParams const& params, GC: auto const& public_key = key->handle().get<::Crypto::PK::RSAPublicKey<>>(); auto pss_params = static_cast(params); - auto hash = TRY(verify_cast(*key->algorithm()).hash().name(vm)); + auto hash = TRY(as(*key->algorithm()).hash().name(vm)); // 2. Perform the signature verification operation defined in Section 8.1 of [RFC3447] with the key represented by the [[handle]] internal slot // of key as the signer's RSA public key and the contents of message as M and the contents of signature as S and using the hash function specified @@ -1736,7 +1736,7 @@ WebIDL::ExceptionOr> RSAPSS::export_key(Bindings::KeyFormat jwk.kty = "RSA"_string; // 3. Let hash be the name attribute of the hash attribute of the [[algorithm]] internal slot of key. - auto hash = TRY(verify_cast(*key->algorithm()).hash().name(vm)); + auto hash = TRY(as(*key->algorithm()).hash().name(vm)); // 4. If hash is "SHA-1": // - Set the alg attribute of jwk to the string "PS1". @@ -1903,7 +1903,7 @@ WebIDL::ExceptionOr> RSASSAPKCS1::sign(AlgorithmParams return WebIDL::InvalidAccessError::create(realm, "Key is not a private key"_string); auto const& private_key = key->handle().get<::Crypto::PK::RSAPrivateKey<>>(); - auto hash = TRY(verify_cast(*key->algorithm()).hash().name(vm)); + auto hash = TRY(as(*key->algorithm()).hash().name(vm)); // 3. Perform the signature generation operation defined in Section 8.2 of [RFC3447] with the key represented by the [[handle]] internal slot // of key as the signer's private key and the contents of message as M and using the hash function specified in the hash attribute @@ -1946,7 +1946,7 @@ WebIDL::ExceptionOr RSASSAPKCS1::verify(AlgorithmParams const&, GC::R return WebIDL::InvalidAccessError::create(realm, "Key is not a public key"_string); auto const& public_key = key->handle().get<::Crypto::PK::RSAPublicKey<>>(); - auto hash = TRY(verify_cast(*key->algorithm()).hash().name(vm)); + auto hash = TRY(as(*key->algorithm()).hash().name(vm)); // 2. Perform the signature verification operation defined in Section 8.2 of [RFC3447] with the key represented by the [[handle]] internal slot // of key as the signer's RSA public key and the contents of message as M and the contents of signature as S and using the hash function specified @@ -2307,7 +2307,7 @@ WebIDL::ExceptionOr> RSASSAPKCS1::export_key(Bindings::KeyFo jwk.kty = "RSA"_string; // 3. Let hash be the name attribute of the hash attribute of the [[algorithm]] internal slot of key. - auto hash = TRY(verify_cast(*key->algorithm()).hash().name(vm)); + auto hash = TRY(as(*key->algorithm()).hash().name(vm)); // 4. If hash is "SHA-1": // - Set the alg attribute of jwk to the string "RS1". @@ -7810,7 +7810,7 @@ WebIDL::ExceptionOr> HMAC::sign(AlgorithmParams const&, // function identified by the hash attribute of the [[algorithm]] internal slot of key and // message as the input data text. auto const& key_data = key->handle().get(); - auto const& algorithm = verify_cast(*key->algorithm()); + auto const& algorithm = as(*key->algorithm()); auto mac = TRY(hmac_calculate_message_digest(m_realm, algorithm.hash(), key_data.bytes(), message.bytes())); // 2. Return the result of creating an ArrayBuffer containing mac. @@ -7825,7 +7825,7 @@ WebIDL::ExceptionOr HMAC::verify(AlgorithmParams const&, GC::Refhandle().get(); - auto const& algorithm = verify_cast(*key->algorithm()); + auto const& algorithm = as(*key->algorithm()); auto mac = TRY(hmac_calculate_message_digest(m_realm, algorithm.hash(), key_data.bytes(), message.bytes())); // 2. Return true if mac is equal to signature and false otherwise. @@ -8098,7 +8098,7 @@ WebIDL::ExceptionOr> HMAC::export_key(Bindings::KeyFormat fo jwk.k = MUST(encode_base64url(data, AK::OmitPadding::Yes)); // Let algorithm be the [[algorithm]] internal slot of key. - auto const& algorithm = verify_cast(*key->algorithm()); + auto const& algorithm = as(*key->algorithm()); // Let hash be the hash attribute of algorithm. auto hash = algorithm.hash(); diff --git a/Libraries/LibWeb/Crypto/SubtleCrypto.cpp b/Libraries/LibWeb/Crypto/SubtleCrypto.cpp index f848808a45a..3dedf811fa0 100644 --- a/Libraries/LibWeb/Crypto/SubtleCrypto.cpp +++ b/Libraries/LibWeb/Crypto/SubtleCrypto.cpp @@ -447,7 +447,7 @@ JS::ThrowCompletionOr> SubtleCrypto::export_key(Binding // 5. If the name member of the [[algorithm]] internal slot of key does not identify a registered algorithm that supports the export key operation, // then throw a NotSupportedError. // Note: Handled by the base AlgorithmMethods implementation - auto& algorithm = verify_cast(*key->algorithm()); + auto& algorithm = as(*key->algorithm()); // FIXME: Stash the AlgorithmMethods on the KeyAlgorithm auto normalized_algorithm_or_error = normalize_an_algorithm(realm, algorithm.name(), "exportKey"_string); if (normalized_algorithm_or_error.is_error()) { @@ -808,7 +808,7 @@ JS::ThrowCompletionOr> SubtleCrypto::wrap_key(Bindings: // 12. Let key be the result of performing the export key operation specified the [[algorithm]] internal slot of key using key and format. // NOTE: The spec does not mention we need to normalize this, but it's the only way we have to get to export_key. - auto& key_algorithm = verify_cast(*key->algorithm()); + auto& key_algorithm = as(*key->algorithm()); auto normalized_key_algorithm = normalize_an_algorithm(realm, key_algorithm.name(), "exportKey"_string); if (normalized_key_algorithm.is_error()) { WebIDL::reject_promise(realm, promise, Bindings::exception_to_throw_completion(realm.vm(), normalized_key_algorithm.release_error()).release_value().value()); @@ -827,7 +827,7 @@ JS::ThrowCompletionOr> SubtleCrypto::wrap_key(Bindings: // 13. If format is equal to the strings "raw", "pkcs8", or "spki": if (format == Bindings::KeyFormat::Raw || format == Bindings::KeyFormat::Pkcs8 || format == Bindings::KeyFormat::Spki) { // Set bytes be set to key. - bytes = verify_cast(*key_data).buffer(); + bytes = as(*key_data).buffer(); } // If format is equal to the string "jwk": diff --git a/Libraries/LibWeb/DOM/Comment.cpp b/Libraries/LibWeb/DOM/Comment.cpp index 85f299f4bd3..04919cad9c8 100644 --- a/Libraries/LibWeb/DOM/Comment.cpp +++ b/Libraries/LibWeb/DOM/Comment.cpp @@ -21,7 +21,7 @@ Comment::Comment(Document& document, String const& data) // https://dom.spec.whatwg.org/#dom-comment-comment WebIDL::ExceptionOr> Comment::construct_impl(JS::Realm& realm, String const& data) { - auto& window = verify_cast(realm.global_object()); + auto& window = as(realm.global_object()); return realm.create(window.associated_document(), data); } diff --git a/Libraries/LibWeb/DOM/Document.cpp b/Libraries/LibWeb/DOM/Document.cpp index 0454e073bad..8c933b81e22 100644 --- a/Libraries/LibWeb/DOM/Document.cpp +++ b/Libraries/LibWeb/DOM/Document.cpp @@ -268,7 +268,7 @@ WebIDL::ExceptionOr> Document::create_and_initialize(Type type }); // 6. Set window to the global object of realmExecutionContext's Realm component. - window = verify_cast(realm_execution_context->realm->global_object()); + window = as(realm_execution_context->realm->global_object()); // 7. Let topLevelCreationURL be creationURL. auto top_level_creation_url = creation_url; @@ -824,7 +824,7 @@ HTML::HTMLHtmlElement* Document::html_element() // The html element of a document is its document element, if it's an html element, and null otherwise. auto* html = document_element(); if (is(html)) - return verify_cast(html); + return as(html); return nullptr; } @@ -1221,7 +1221,7 @@ void Document::update_layout() if (!m_layout_root || needs_layout_tree_update() || child_needs_layout_tree_update() || needs_full_layout_tree_update()) { Layout::TreeBuilder tree_builder; - m_layout_root = verify_cast(*tree_builder.build(*this)); + m_layout_root = as(*tree_builder.build(*this)); if (document_element && document_element->layout_node()) { propagate_overflow_to_viewport(*document_element, *m_layout_root); @@ -1266,7 +1266,7 @@ void Document::update_layout() viewport_state.set_content_height(viewport_rect.height()); if (document_element && document_element->layout_node()) { - auto& icb_state = layout_state.get_mutable(verify_cast(*document_element->layout_node())); + auto& icb_state = layout_state.get_mutable(as(*document_element->layout_node())); icb_state.set_content_width(viewport_rect.width()); } @@ -1747,7 +1747,7 @@ GC::Ref Document::get_elements_by_name(FlyString const& name) return LiveNodeList::create(realm(), *this, LiveNodeList::Scope::Descendants, [name](auto const& node) { if (!is(node)) return false; - return verify_cast(node).name() == name; + return as(node).name() == name; }); } @@ -2208,7 +2208,7 @@ WebIDL::ExceptionOr> Document::adopt_node_binding(GC::Ref no if (is(*node)) return WebIDL::HierarchyRequestError::create(realm(), "Cannot adopt a shadow root into a document"_string); - if (is(*node) && verify_cast(*node).host()) + if (is(*node) && as(*node).host()) return node; adopt_node(*node); @@ -2239,7 +2239,7 @@ void Document::update_active_element() Node* candidate = focused_element(); // 2. Set candidate to the result of retargeting candidate against this DocumentOrShadowRoot. - candidate = verify_cast(retarget(candidate, this)); + candidate = as(retarget(candidate, this)); // 3. If candidate's root is not this DocumentOrShadowRoot, then return null. if (&candidate->root() != this) { @@ -2249,7 +2249,7 @@ void Document::update_active_element() // 4. If candidate is not a Document object, then return candidate. if (!is(candidate)) { - set_active_element(verify_cast(candidate)); + set_active_element(as(candidate)); return; } @@ -2530,7 +2530,7 @@ void Document::dispatch_events_for_transition(GC::Ref transi void Document::dispatch_events_for_animation_if_necessary(GC::Ref animation) { if (animation->is_css_transition()) { - dispatch_events_for_transition(verify_cast(*animation)); + dispatch_events_for_transition(as(*animation)); return; } @@ -2541,7 +2541,7 @@ void Document::dispatch_events_for_animation_if_necessary(GC::Refis_keyframe_effect() || !animation->is_css_animation() || animation->pending()) return; - auto& css_animation = verify_cast(*animation); + auto& css_animation = as(*animation); GC::Ptr target = effect->target(); if (!target) @@ -3496,7 +3496,7 @@ GC::Ptr Document::lookup_custom_element_definitio return nullptr; // 3. Let registry be document's relevant global object's custom element registry. - auto registry = verify_cast(relevant_global_object(*this)).custom_elements(); + auto registry = as(relevant_global_object(*this)).custom_elements(); // 4. If registry's custom element definition set contains an item with name and local name both equal to localName, then return that item. auto converted_local_name = local_name.to_string(); @@ -3604,7 +3604,7 @@ HTML::SourceSnapshotParams Document::snapshot_source_snapshot_params() const // sourceDocument's policy container return HTML::SourceSnapshotParams { - .has_transient_activation = verify_cast(HTML::relevant_global_object(*this)).has_transient_activation(), + .has_transient_activation = as(HTML::relevant_global_object(*this)).has_transient_activation(), .sandboxing_flags = m_active_sandboxing_flag_set, .allows_downloading = !has_flag(m_active_sandboxing_flag_set, HTML::SandboxingFlagSet::SandboxedDownloads), .fetch_client = relevant_settings_object(), @@ -3972,7 +3972,7 @@ void Document::unload(GC::Ptr) m_page_showing = false; // 2. Fire a page transition event named pagehide at oldDocument's relevant global object with oldDocument's salvageable state. - verify_cast(relevant_global_object(*this)).fire_a_page_transition_event(HTML::EventNames::pagehide, m_salvageable); + as(relevant_global_object(*this)).fire_a_page_transition_event(HTML::EventNames::pagehide, m_salvageable); // 3. Update the visibility state of oldDocument to "hidden". update_the_visibility_state(HTML::VisibilityState::Hidden); @@ -3987,7 +3987,7 @@ void Document::unload(GC::Ptr) // FIXME: The legacy target override flag is currently set by a virtual override of dispatch_event() // We should reorganize this so that the flag appears explicitly here instead. auto event = DOM::Event::create(realm(), HTML::EventNames::unload); - verify_cast(relevant_global_object(*this)).dispatch_event(event); + as(relevant_global_object(*this)).dispatch_event(event); } // FIXME: 13. If unloadTimingInfo is not null, then set unloadTimingInfo's unload event end time to the current high resolution time given newDocument's relevant global object, coarsened @@ -4193,7 +4193,7 @@ WebIDL::ExceptionOr> Document::create_attribute_ns(Optional(HTML::relevant_global_object(*this)); + auto& window = as(HTML::relevant_global_object(*this)); set_window(window); @@ -4520,12 +4520,12 @@ void Document::start_intersection_observing_a_lazy_loading_element(Element& elem // - The callback is these steps, with arguments entries and observer: auto callback = JS::NativeFunction::create(realm, "", [this](JS::VM& vm) -> JS::ThrowCompletionOr { // For each entry in entries using a method of iteration which does not trigger developer-modifiable array accessors or iteration hooks: - auto& entries = verify_cast(vm.argument(0).as_object()); + auto& entries = as(vm.argument(0).as_object()); auto entries_length = MUST(MUST(entries.get(vm.names.length)).to_length(vm)); for (size_t i = 0; i < entries_length; ++i) { auto property_key = JS::PropertyKey { i }; - auto& entry = verify_cast(entries.get_without_side_effects(property_key).as_object()); + auto& entry = as(entries.get_without_side_effects(property_key).as_object()); // 1. Let resumptionSteps be null. GC::Ptr> resumption_steps; @@ -4784,7 +4784,7 @@ void Document::update_for_history_step_application(GC::Refm_length = script_history_length; // 5. Let navigation be history's relevant global object's navigation API. - auto navigation = verify_cast(HTML::relevant_global_object(*this)).navigation(); + auto navigation = as(HTML::relevant_global_object(*this)).navigation(); // 6. If documentsEntryChanged is true, then: // NOTE: documentsEntryChanged can be false for one of two reasons: either we are restoring from bfcache, @@ -4820,7 +4820,7 @@ void Document::update_for_history_step_application(GC::Refunsafe_state(); - auto& relevant_global_object = verify_cast(HTML::relevant_global_object(*this)); + auto& relevant_global_object = as(HTML::relevant_global_object(*this)); auto pop_state_event = HTML::PopStateEvent::create(realm(), "popstate"_fly_string, popstate_event_init); relevant_global_object.dispatch_event(pop_state_event); @@ -4951,8 +4951,8 @@ void Document::update_animations_and_send_events(Optional const& timesta return true; if (!b.animation->effect()) return false; - auto& a_effect = verify_cast(*a.animation->effect()); - auto& b_effect = verify_cast(*b.animation->effect()); + auto& a_effect = as(*a.animation->effect()); + auto& b_effect = as(*b.animation->effect()); return Animations::KeyframeEffect::composite_order(a_effect, b_effect) < 0; }; @@ -5655,11 +5655,11 @@ Optional Document::get_style_sheet_source(CSS::StyleSheetIdentifier cons if (identifier.dom_element_unique_id.has_value()) { if (auto* node = Node::from_unique_id(*identifier.dom_element_unique_id)) { if (node->is_html_style_element()) { - if (auto* sheet = verify_cast(*node).sheet()) + if (auto* sheet = as(*node).sheet()) return sheet->source_text({}); } if (node->is_svg_style_element()) { - if (auto* sheet = verify_cast(*node).sheet()) + if (auto* sheet = as(*node).sheet()) return sheet->source_text({}); } } @@ -5876,7 +5876,7 @@ void Document::parse_html_from_a_string(StringView html) auto parser = HTML::HTMLParser::create(*this, html, "UTF-8"sv); // 4. Start parser and let it run until it has consumed all the characters just inserted into the input stream. - parser->run(verify_cast(HTML::relevant_global_object(*this)).associated_document().url()); + parser->run(as(HTML::relevant_global_object(*this)).associated_document().url()); } // https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-parsehtmlunsafe @@ -6106,7 +6106,7 @@ Document::StepsToFireBeforeunloadResult Document::steps_to_fire_beforeunload(boo // 4. Let eventFiringResult be the result of firing an event named beforeunload at document's relevant global object, // using BeforeUnloadEvent, with the cancelable attribute initialized to true. auto& global_object = HTML::relevant_global_object(*this); - auto& window = verify_cast(global_object); + auto& window = as(global_object); auto beforeunload_event = HTML::BeforeUnloadEvent::create(realm(), HTML::EventNames::beforeunload); beforeunload_event->set_cancelable(true); auto event_firing_result = window.dispatch_event(*beforeunload_event); diff --git a/Libraries/LibWeb/DOM/DocumentFragment.cpp b/Libraries/LibWeb/DOM/DocumentFragment.cpp index dfca5b2e535..d10701ca2c6 100644 --- a/Libraries/LibWeb/DOM/DocumentFragment.cpp +++ b/Libraries/LibWeb/DOM/DocumentFragment.cpp @@ -37,7 +37,7 @@ void DocumentFragment::set_host(Web::DOM::Element* element) // https://dom.spec.whatwg.org/#dom-documentfragment-documentfragment WebIDL::ExceptionOr> DocumentFragment::construct_impl(JS::Realm& realm) { - auto& window = verify_cast(realm.global_object()); + auto& window = as(realm.global_object()); return realm.create(window.associated_document()); } diff --git a/Libraries/LibWeb/DOM/Element.cpp b/Libraries/LibWeb/DOM/Element.cpp index 4cfb4581c9b..36ca42019a2 100644 --- a/Libraries/LibWeb/DOM/Element.cpp +++ b/Libraries/LibWeb/DOM/Element.cpp @@ -793,11 +793,11 @@ WebIDL::ExceptionOr Element::set_inner_html(StringView value) DOM::Node* context = this; // 3. Let fragment be the result of invoking the fragment parsing algorithm steps with context and compliantString. FIXME: Use compliantString. - auto fragment = TRY(verify_cast(*context).parse_fragment(value)); + auto fragment = TRY(as(*context).parse_fragment(value)); // 4. If context is a template element, then set context to the template element's template contents (a DocumentFragment). if (is(*context)) - context = verify_cast(*context).content(); + context = as(*context).content(); // 5. Replace all with fragment within context. context->replace_all(fragment); @@ -1627,7 +1627,7 @@ WebIDL::ExceptionOr Element::set_outer_html(String const& value) parent = TRY(create_element(document(), HTML::TagNames::body, Namespace::HTML)); // 6. Let fragment be the result of invoking the fragment parsing algorithm steps given parent and compliantString. FIXME: Use compliantString. - auto fragment = TRY(verify_cast(*parent).parse_fragment(value)); + auto fragment = TRY(as(*parent).parse_fragment(value)); // 6. Replace this with fragment within this's parent. TRY(parent->replace_child(fragment, *this)); @@ -1678,7 +1678,7 @@ WebIDL::ExceptionOr Element::insert_adjacent_html(String const& position, } // 4. Let fragment be the result of invoking the fragment parsing algorithm steps with context and string. - auto fragment = TRY(verify_cast(*context).parse_fragment(string)); + auto fragment = TRY(as(*context).parse_fragment(string)); // 5. Use the first matching item from this list: @@ -1756,7 +1756,7 @@ WebIDL::ExceptionOr> Element::insert_adjacent_element(String co auto returned_node = TRY(insert_adjacent(where, element)); if (!returned_node) return GC::Ptr { nullptr }; - return GC::Ptr { verify_cast(*returned_node) }; + return GC::Ptr { as(*returned_node) }; } // https://dom.spec.whatwg.org/#dom-element-insertadjacenttext @@ -3101,7 +3101,7 @@ WebIDL::ExceptionOr Element::set_html_unsafe(StringView html) // 2. Let target be this's template contents if this is a template element; otherwise this. DOM::Node* target = this; if (is(*this)) - target = verify_cast(*this).content().ptr(); + target = as(*this).content().ptr(); // 3. Unsafe set HTML given target, this, and compliantHTML. FIXME: Use compliantHTML. TRY(target->unsafely_set_html(*this, html)); diff --git a/Libraries/LibWeb/DOM/ElementFactory.cpp b/Libraries/LibWeb/DOM/ElementFactory.cpp index 4f73431e445..4efb8a60c6f 100644 --- a/Libraries/LibWeb/DOM/ElementFactory.cpp +++ b/Libraries/LibWeb/DOM/ElementFactory.cpp @@ -578,7 +578,7 @@ WebIDL::ExceptionOr> create_element(Document& document, FlyStri if (!result.has_value() || !result->is_object() || !is(result->as_object())) return JS::throw_completion(JS::TypeError::create(realm, "Custom element constructor must return an object that implements HTMLElement"_string)); - GC::Ref element = verify_cast(result->as_object()); + GC::Ref element = as(result->as_object()); // FIXME: 3. Assert: result’s custom element state and custom element definition are initialized. diff --git a/Libraries/LibWeb/DOM/Event.cpp b/Libraries/LibWeb/DOM/Event.cpp index 27767e17d1b..91450729153 100644 --- a/Libraries/LibWeb/DOM/Event.cpp +++ b/Libraries/LibWeb/DOM/Event.cpp @@ -85,11 +85,11 @@ void Event::append_to_path(EventTarget& invocation_target, GC::Ptr // 2. If invocationTarget is a node and its root is a shadow root, then set invocationTargetInShadowTree to true. if (is(invocation_target)) { - auto& invocation_target_node = verify_cast(invocation_target); + auto& invocation_target_node = as(invocation_target); if (is(invocation_target_node.root())) invocation_target_in_shadow_tree = true; if (is(invocation_target_node)) { - auto& invocation_target_shadow_root = verify_cast(invocation_target_node); + auto& invocation_target_shadow_root = as(invocation_target_node); // 4. If invocationTarget is a shadow root whose mode is "closed", then set root-of-closed-tree to true. root_of_closed_tree = invocation_target_shadow_root.mode() == Bindings::ShadowRootMode::Closed; } diff --git a/Libraries/LibWeb/DOM/EventDispatcher.cpp b/Libraries/LibWeb/DOM/EventDispatcher.cpp index 4d7a1064b06..2cb9d57cc9a 100644 --- a/Libraries/LibWeb/DOM/EventDispatcher.cpp +++ b/Libraries/LibWeb/DOM/EventDispatcher.cpp @@ -71,7 +71,7 @@ bool EventDispatcher::inner_invoke(Event& event, Vector(global)) { - auto& window = verify_cast(global); + auto& window = as(global); // 1. Set currentEvent to global’s current event. current_event = window.current_event(); @@ -109,7 +109,7 @@ bool EventDispatcher::inner_invoke(Event& event, Vector(global)) { - auto& window = verify_cast(global); + auto& window = as(global); window.set_current_event(current_event); } @@ -203,7 +203,7 @@ bool EventDispatcher::dispatch(GC::Ref target, Event& event, bool l if (!legacy_target_override) { target_override = target; } else { - target_override = &verify_cast(*target).associated_document(); + target_override = &as(*target).associated_document(); } // 3. Let activationTarget be null. @@ -279,7 +279,7 @@ bool EventDispatcher::dispatch(GC::Ref target, Event& event, bool l // 6. If parent is a Window object, or parent is a node and target’s root is a shadow-including inclusive ancestor of parent, then: if (is(parent) - || (is(parent) && verify_cast(*target).root().is_shadow_including_inclusive_ancestor_of(verify_cast(*parent)))) { + || (is(parent) && as(*target).root().is_shadow_including_inclusive_ancestor_of(as(*parent)))) { // 1. If isActivationEvent is true, event’s bubbles attribute is true, activationTarget is null, and parent has activation behavior, then set activationTarget to parent. if (is_activation_event && event.bubbles() && !activation_target && parent->has_activation_behavior()) activation_target = parent; @@ -323,13 +323,13 @@ bool EventDispatcher::dispatch(GC::Ref target, Event& event, bool l // 11. Let clearTargets be true if clearTargetsStruct’s shadow-adjusted target, clearTargetsStruct’s relatedTarget, // or an EventTarget object in clearTargetsStruct’s touch target list is a node and its root is a shadow root; otherwise false. if (is(clear_targets_struct.value().shadow_adjusted_target.ptr())) { - auto& shadow_adjusted_target_node = verify_cast(*clear_targets_struct.value().shadow_adjusted_target); + auto& shadow_adjusted_target_node = as(*clear_targets_struct.value().shadow_adjusted_target); if (is(shadow_adjusted_target_node.root())) clear_targets = true; } if (!clear_targets && is(clear_targets_struct.value().related_target.ptr())) { - auto& related_target_node = verify_cast(*clear_targets_struct.value().related_target); + auto& related_target_node = as(*clear_targets_struct.value().related_target); if (is(related_target_node.root())) clear_targets = true; } @@ -337,7 +337,7 @@ bool EventDispatcher::dispatch(GC::Ref target, Event& event, bool l if (!clear_targets) { for (auto touch_target : clear_targets_struct.value().touch_target_list) { if (is(*touch_target.ptr())) { - auto& touch_target_node = verify_cast(*touch_target.ptr()); + auto& touch_target_node = as(*touch_target.ptr()); if (is(touch_target_node.root())) { clear_targets = true; break; diff --git a/Libraries/LibWeb/DOM/EventTarget.cpp b/Libraries/LibWeb/DOM/EventTarget.cpp index ef635ae9542..260ca7bd57e 100644 --- a/Libraries/LibWeb/DOM/EventTarget.cpp +++ b/Libraries/LibWeb/DOM/EventTarget.cpp @@ -161,7 +161,7 @@ static bool default_passive_value(FlyString const& type, EventTarget* event_targ return true; if (is(event_target)) { - auto* node = verify_cast(event_target); + auto* node = as(event_target); if (&node->document() == event_target || node->document().document_element() == event_target || node->document().body() == event_target) return true; } @@ -353,7 +353,7 @@ static EventTarget* determine_target_of_event_handler(EventTarget& event_target, return nullptr; // 4. Return eventTarget's node document's relevant global object. - return &verify_cast(HTML::relevant_global_object(event_target_element.document())); + return &as(HTML::relevant_global_object(event_target_element.document())); } // https://html.spec.whatwg.org/multipage/webappapis.html#event-handler-attributes:event-handler-idl-attributes-2 @@ -397,12 +397,12 @@ WebIDL::CallbackType* EventTarget::get_current_value_of_event_handler(FlyString GC::Ptr document; if (is(this)) { - auto* element_event_target = verify_cast(this); + auto* element_event_target = as(this); element = element_event_target; document = &element_event_target->document(); } else { VERIFY(is(this)); - auto* window_event_target = verify_cast(this); + auto* window_event_target = as(this); document = &window_event_target->associated_document(); } @@ -608,7 +608,7 @@ void EventTarget::activate_event_handler(FlyString const& name, HTML::EventHandl // The argument must be an object and it must be an Event. auto event_wrapper_argument = vm.argument(0); VERIFY(event_wrapper_argument.is_object()); - auto& event = verify_cast(event_wrapper_argument.as_object()); + auto& event = as(event_wrapper_argument.as_object()); TRY(event_target->process_event_handler_for_event(name, event)); return JS::js_undefined(); @@ -682,7 +682,7 @@ JS::ThrowCompletionOr EventTarget::process_event_handler_for_event(FlyStri // Invoke callback with five arguments, the first one having the value of event's message attribute, the second having the value of event's filename attribute, the third having the value of event's lineno attribute, // the fourth having the value of event's colno attribute, the fifth having the value of event's error attribute, and with the callback this value set to event's currentTarget. // Let return value be the callback's return value. [WEBIDL] - auto& error_event = verify_cast(event); + auto& error_event = as(event); auto wrapped_message = JS::PrimitiveString::create(vm(), error_event.message()); auto wrapped_filename = JS::PrimitiveString::create(vm(), error_event.filename()); auto wrapped_lineno = JS::Value(error_event.lineno()); diff --git a/Libraries/LibWeb/DOM/MutationObserver.cpp b/Libraries/LibWeb/DOM/MutationObserver.cpp index 5393670ea59..63b6cf30da0 100644 --- a/Libraries/LibWeb/DOM/MutationObserver.cpp +++ b/Libraries/LibWeb/DOM/MutationObserver.cpp @@ -100,7 +100,7 @@ WebIDL::ExceptionOr MutationObserver::observe(Node& target, MutationObserv if (node->registered_observer_list()) { node->registered_observer_list()->remove_all_matching([®istered_observer](RegisteredObserver& observer) { - return is(observer) && verify_cast(observer).source().ptr() == registered_observer; + return is(observer) && as(observer).source().ptr() == registered_observer; }); } } diff --git a/Libraries/LibWeb/DOM/Node.cpp b/Libraries/LibWeb/DOM/Node.cpp index f19188b5e06..5796ac3b88b 100644 --- a/Libraries/LibWeb/DOM/Node.cpp +++ b/Libraries/LibWeb/DOM/Node.cpp @@ -150,8 +150,8 @@ const HTML::HTMLElement* Node::enclosing_html_element() const const HTML::HTMLElement* Node::enclosing_html_element_with_attribute(FlyString const& attribute) const { for (auto* node = this; node; node = node->parent()) { - if (is(*node) && verify_cast(*node).has_attribute(attribute)) - return verify_cast(node); + if (is(*node) && as(*node).has_attribute(attribute)) + return as(node); } return nullptr; } @@ -212,7 +212,7 @@ void Node::set_text_content(Optional const& maybe_content) // If CharacterData, replace data with node this, offset 0, count this’s length, and data the given value. else if (is(this)) { - auto* character_data_node = verify_cast(this); + auto* character_data_node = as(this); character_data_node->set_data(content); // FIXME: CharacterData::set_data is not spec compliant. Make this match the spec when set_data becomes spec compliant. @@ -343,12 +343,12 @@ Optional Node::node_value() const // If Attr, return this’s value. if (is(this)) { - return verify_cast(this)->value(); + return as(this)->value(); } // If CharacterData, return this’s data. if (is(this)) { - return verify_cast(this)->data(); + return as(this)->data(); } // Otherwise, return null. @@ -364,10 +364,10 @@ void Node::set_node_value(Optional const& maybe_value) // If Attr, set an existing attribute value with this and the given value. if (is(this)) { - verify_cast(this)->set_value(move(value)); + as(this)->set_value(move(value)); } else if (is(this)) { // If CharacterData, replace data with node this, offset 0, count this’s length, and data the given value. - verify_cast(this)->set_data(value); + as(this)->set_data(value); } // Otherwise, do nothing. @@ -536,9 +536,9 @@ String Node::child_text_content() const return String {}; StringBuilder builder; - verify_cast(*this).for_each_child([&](auto& child) { + as(*this).for_each_child([&](auto& child) { if (is(child)) { - auto maybe_content = verify_cast(child).text_content(); + auto maybe_content = as(child).text_content(); if (maybe_content.has_value()) builder.append(maybe_content.value()); } @@ -615,7 +615,7 @@ WebIDL::ExceptionOr Node::ensure_pre_insertion_validity(GC::Ref node if (is(*node)) { // If node has more than one element child or has a Text node child. // Otherwise, if node has one element child and either parent has an element child, child is a doctype, or child is non-null and a doctype is following child. - auto node_element_child_count = verify_cast(*node).child_element_count(); + auto node_element_child_count = as(*node).child_element_count(); if ((node_element_child_count > 1 || node->has_child_of_type()) || (node_element_child_count == 1 && (has_child_of_type() || is(child.ptr()) || (child && child->has_following_node_of_type_in_tree_order())))) { return WebIDL::HierarchyRequestError::create(realm(), "Invalid node type for insertion"_string); @@ -1025,7 +1025,7 @@ WebIDL::ExceptionOr> Node::replace_child(GC::Ref node, GC::R if (is(*node)) { // If node has more than one element child or has a Text node child. // Otherwise, if node has one element child and either parent has an element child that is not child or a doctype is following child. - auto node_element_child_count = verify_cast(*node).child_element_count(); + auto node_element_child_count = as(*node).child_element_count(); if ((node_element_child_count > 1 || node->has_child_of_type()) || (node_element_child_count == 1 && (first_child_of_type() != child || child->has_following_node_of_type_in_tree_order()))) { return WebIDL::HierarchyRequestError::create(realm(), "Invalid node type for insertion"_string); @@ -1119,10 +1119,10 @@ WebIDL::ExceptionOr> Node::clone_node(Document* document, bool sub // 6. If node is an element, node is a shadow host, and node’s shadow root’s clonable is true: if (is_element()) { - auto& node_element = verify_cast(*this); + auto& node_element = as(*this); if (node_element.is_shadow_host() && node_element.shadow_root()->clonable()) { // 1. Assert: copy is not a shadow host. - auto& copy_element = verify_cast(*copy); + auto& copy_element = as(*copy); VERIFY(!copy_element.is_shadow_host()); // 2. Attach a shadow root with copy, node’s shadow root’s mode, true, node’s shadow root’s serializable, node’s shadow root’s delegates focus, and node’s shadow root’s slot assignment. @@ -1154,7 +1154,7 @@ WebIDL::ExceptionOr> Node::clone_single_node(Document& document) c // 2. If node is an element: if (is_element()) { // 1. Set copy to the result of creating an element, given document, node’s local name, node’s namespace, node’s namespace prefix, and node’s is value. - auto& element = *verify_cast(this); + auto& element = *as(this); auto element_copy = TRY(DOM::create_element(document, element.local_name(), element.namespace_uri(), element.prefix(), element.is_value())); // 2. For each attribute of node’s attribute list: @@ -1170,7 +1170,7 @@ WebIDL::ExceptionOr> Node::clone_single_node(Document& document) c auto copy_attribute = copy_attribute_or_error.release_value(); // 2. Append copyAttribute to copy. - element_copy->append_attribute(verify_cast(*copy_attribute)); + element_copy->append_attribute(as(*copy_attribute)); }); if (maybe_exception.has_value()) @@ -1183,7 +1183,7 @@ WebIDL::ExceptionOr> Node::clone_single_node(Document& document) c else { if (is_document()) { // -> Document - auto& document_ = verify_cast(*this); + auto& document_ = as(*this); auto document_copy = [&] -> GC::Ref { switch (document_.document_type()) { case Document::Type::XML: @@ -1205,7 +1205,7 @@ WebIDL::ExceptionOr> Node::clone_single_node(Document& document) c copy = move(document_copy); } else if (is_document_type()) { // -> DocumentType - auto& document_type = verify_cast(*this); + auto& document_type = as(*this); auto document_type_copy = realm().create(document); // Set copy’s name, public ID, and system ID to those of node. @@ -1216,11 +1216,11 @@ WebIDL::ExceptionOr> Node::clone_single_node(Document& document) c } else if (is_attribute()) { // -> Attr // Set copy’s namespace, namespace prefix, local name, and value to those of node. - auto& attr = verify_cast(*this); + auto& attr = as(*this); copy = attr.clone(document); } else if (is_text()) { // -> Text - auto& text = verify_cast(*this); + auto& text = as(*this); // Set copy’s data to that of node. copy = [&]() -> GC::Ref { @@ -1235,14 +1235,14 @@ WebIDL::ExceptionOr> Node::clone_single_node(Document& document) c }(); } else if (is_comment()) { // -> Comment - auto& comment = verify_cast(*this); + auto& comment = as(*this); // Set copy’s data to that of node. auto comment_copy = realm().create(document, comment.data()); copy = move(comment_copy); } else if (is(this)) { // -> ProcessingInstruction - auto& processing_instruction = verify_cast(*this); + auto& processing_instruction = as(*this); // Set copy’s target and data to those of node. auto processing_instruction_copy = realm().create(document, processing_instruction.data(), processing_instruction.target()); @@ -1443,7 +1443,7 @@ ParentNode* Node::parent_or_shadow_host() { if (is(*this)) return static_cast(*this).host(); - return verify_cast(parent()); + return as(parent()); } Element* Node::parent_or_shadow_host_element() @@ -1513,14 +1513,14 @@ u16 Node::compare_document_position(GC::Ptr other) // 4. If node1 is an attribute, then set attr1 to node1 and node1 to attr1’s element. if (is(node1)) { - attr1 = verify_cast(node1); + attr1 = as(node1); node1 = const_cast(attr1->owner_element()); } // 5. If node2 is an attribute, then: if (is(node2)) { // 1. Set attr2 to node2 and node2 to attr2’s element. - attr2 = verify_cast(node2); + attr2 = as(node2); node2 = const_cast(attr2->owner_element()); // 2. If attr1 and node1 are non-null, and node2 is node1, then: @@ -1750,7 +1750,7 @@ bool Node::is_shadow_including_descendant_of(Node const& other) const return false; // and A’s root’s host is a shadow-including inclusive descendant of B. - auto& shadow_root = verify_cast(root()); + auto& shadow_root = as(root()); return shadow_root.host() && shadow_root.host()->is_shadow_including_inclusive_descendant_of(other); } @@ -1892,8 +1892,8 @@ bool Node::is_equal_node(Node const* other_node) const switch (node_type()) { case (u16)NodeType::DOCUMENT_TYPE_NODE: { // Its name, public ID, and system ID. - auto& this_doctype = verify_cast(*this); - auto& other_doctype = verify_cast(*other_node); + auto& this_doctype = as(*this); + auto& other_doctype = as(*other_node); if (this_doctype.name() != other_doctype.name() || this_doctype.public_id() != other_doctype.public_id() || this_doctype.system_id() != other_doctype.system_id()) @@ -1902,8 +1902,8 @@ bool Node::is_equal_node(Node const* other_node) const } case (u16)NodeType::ELEMENT_NODE: { // Its namespace, namespace prefix, local name, and its attribute list’s size. - auto& this_element = verify_cast(*this); - auto& other_element = verify_cast(*other_node); + auto& this_element = as(*this); + auto& other_element = as(*other_node); if (this_element.namespace_uri() != other_element.namespace_uri() || this_element.prefix() != other_element.prefix() || this_element.local_name() != other_element.local_name() @@ -1922,16 +1922,16 @@ bool Node::is_equal_node(Node const* other_node) const case (u16)NodeType::COMMENT_NODE: case (u16)NodeType::TEXT_NODE: { // Its data. - auto& this_cdata = verify_cast(*this); - auto& other_cdata = verify_cast(*other_node); + auto& this_cdata = as(*this); + auto& other_cdata = as(*other_node); if (this_cdata.data() != other_cdata.data()) return false; break; } case (u16)NodeType::ATTRIBUTE_NODE: { // Its namespace, local name, and value. - auto& this_attr = verify_cast(*this); - auto& other_attr = verify_cast(*other_node); + auto& this_attr = as(*this); + auto& other_attr = as(*other_node); if (this_attr.namespace_uri() != other_attr.namespace_uri()) return false; if (this_attr.local_name() != other_attr.local_name()) @@ -1942,8 +1942,8 @@ bool Node::is_equal_node(Node const* other_node) const } case (u16)NodeType::PROCESSING_INSTRUCTION_NODE: { // Its target and data. - auto& this_processing_instruction = verify_cast(*this); - auto& other_processing_instruction = verify_cast(*other_node); + auto& this_processing_instruction = as(*this); + auto& other_processing_instruction = as(*other_node); if (this_processing_instruction.target() != other_processing_instruction.target()) return false; if (this_processing_instruction.data() != other_processing_instruction.data()) @@ -1989,7 +1989,7 @@ Optional Node::locate_a_namespace(Optional const& prefix) const return Web::Namespace::XMLNS.to_string(); // 3. If its namespace is non-null and its namespace prefix is prefix, then return namespace. - auto& element = verify_cast(*this); + auto& element = as(*this); if (element.namespace_uri().has_value() && element.prefix() == prefix) return element.namespace_uri()->to_string(); @@ -2023,7 +2023,7 @@ Optional Node::locate_a_namespace(Optional const& prefix) const // Document if (is(*this)) { // 1. If its document element is null, then return null. - auto* document_element = verify_cast(*this).document_element(); + auto* document_element = as(*this).document_element(); if (!document_element) return {}; @@ -2041,7 +2041,7 @@ Optional Node::locate_a_namespace(Optional const& prefix) const // Attr if (is(*this)) { // 1. If its element is null, then return null. - auto* element = verify_cast(*this).owner_element(); + auto* element = as(*this).owner_element(); if (!element) return {}; @@ -2082,14 +2082,14 @@ Optional Node::lookup_prefix(Optional namespace_) const // Element if (is(*this)) { // Return the result of locating a namespace prefix for it using namespace. - auto& element = verify_cast(*this); + auto& element = as(*this); return element.locate_a_namespace_prefix(namespace_); } // Document if (is(*this)) { // Return the result of locating a namespace prefix for its document element, if its document element is non-null; otherwise null. - auto* document_element = verify_cast(*this).document_element(); + auto* document_element = as(*this).document_element(); if (!document_element) return {}; @@ -2105,7 +2105,7 @@ Optional Node::lookup_prefix(Optional namespace_) const // Attr if (is(*this)) { // Return the result of locating a namespace prefix for its element, if its element is non-null; otherwise null. - auto* element = verify_cast(*this).owner_element(); + auto* element = as(*this).owner_element(); if (!element) return {}; @@ -2176,7 +2176,7 @@ size_t Node::length() const // 2. If node is a CharacterData node, then return node’s data’s length. if (is_character_data()) - return verify_cast(*this).length_in_utf16_code_units(); + return as(*this).length_in_utf16_code_units(); // 3. Return the number of node’s children. return child_count(); @@ -2826,7 +2826,7 @@ ErrorOr Node::name_or_description(NameOrDescription target, Document con // aria-labelledby or aria-describedby and/or un-hidden. See the comment for substep A above. if (is_text() && (!parent_element() || (parent_element()->is_referenced() || !parent_element()->is_hidden() || !parent_element()->has_hidden_ancestor() || parent_element()->has_referenced_and_hidden_ancestor()))) { if (layout_node() && layout_node()->is_text_node()) - return verify_cast(layout_node())->text_for_rendering(); + return as(layout_node())->text_for_rendering(); return text_content().release_value(); } diff --git a/Libraries/LibWeb/DOM/Node.h b/Libraries/LibWeb/DOM/Node.h index b2c76200445..27c57cae837 100644 --- a/Libraries/LibWeb/DOM/Node.h +++ b/Libraries/LibWeb/DOM/Node.h @@ -652,7 +652,7 @@ public: { for (auto* node = first_child(); node; node = node->next_sibling()) { if (is(node)) { - if (callback(verify_cast(*node)) == IterationDecision::Break) + if (callback(as(*node)) == IterationDecision::Break) return; } } @@ -669,7 +669,7 @@ public: { for (auto* node = first_child(); node; node = node->next_sibling()) { if (is(node)) { - if (TRY(callback(verify_cast(*node))) == IterationDecision::Break) + if (TRY(callback(as(*node))) == IterationDecision::Break) return {}; } } @@ -687,7 +687,7 @@ public: { for (auto* sibling = next_sibling(); sibling; sibling = sibling->next_sibling()) { if (is(*sibling)) - return &verify_cast(*sibling); + return &as(*sibling); } return nullptr; } @@ -703,7 +703,7 @@ public: { for (auto* sibling = previous_sibling(); sibling; sibling = sibling->previous_sibling()) { if (is(*sibling)) - return &verify_cast(*sibling); + return &as(*sibling); } return nullptr; } @@ -725,7 +725,7 @@ public: { for (auto* child = first_child(); child; child = child->next_sibling()) { if (is(*child)) - return &verify_cast(*child); + return &as(*child); } return nullptr; } @@ -735,7 +735,7 @@ public: { for (auto* child = last_child(); child; child = child->previous_sibling()) { if (is(*child)) - return &verify_cast(*child); + return &as(*child); } return nullptr; } @@ -757,7 +757,7 @@ public: { for (auto* ancestor = parent(); ancestor; ancestor = ancestor->parent()) { if (is(*ancestor)) - return &verify_cast(*ancestor); + return &as(*ancestor); } return nullptr; } diff --git a/Libraries/LibWeb/DOM/NonDocumentTypeChildNode.h b/Libraries/LibWeb/DOM/NonDocumentTypeChildNode.h index cbe756a2ccb..638ef94c558 100644 --- a/Libraries/LibWeb/DOM/NonDocumentTypeChildNode.h +++ b/Libraries/LibWeb/DOM/NonDocumentTypeChildNode.h @@ -19,7 +19,7 @@ public: { for (auto* sibling = static_cast(this)->previous_sibling(); sibling; sibling = sibling->previous_sibling()) { if (is(*sibling)) - return verify_cast(sibling); + return as(sibling); } return nullptr; } @@ -28,7 +28,7 @@ public: { for (auto* node = static_cast(this)->previous_in_pre_order(); node; node = node->previous_in_pre_order()) { if (is(*node)) - return verify_cast(node); + return as(node); } return nullptr; } @@ -37,7 +37,7 @@ public: { for (auto* sibling = static_cast(this)->next_sibling(); sibling; sibling = sibling->next_sibling()) { if (is(*sibling)) - return verify_cast(sibling); + return as(sibling); } return nullptr; } @@ -46,7 +46,7 @@ public: { for (auto* node = static_cast(this)->next_in_pre_order(); node; node = node->next_in_pre_order()) { if (is(*node)) - return verify_cast(node); + return as(node); } return nullptr; } diff --git a/Libraries/LibWeb/DOM/ParentNode.h b/Libraries/LibWeb/DOM/ParentNode.h index e0e2199d865..6b1e9b70d45 100644 --- a/Libraries/LibWeb/DOM/ParentNode.h +++ b/Libraries/LibWeb/DOM/ParentNode.h @@ -63,7 +63,7 @@ inline U* Node::shadow_including_first_ancestor_of_type() { for (auto* ancestor = parent_or_shadow_host(); ancestor; ancestor = ancestor->parent_or_shadow_host()) { if (is(*ancestor)) - return &verify_cast(*ancestor); + return &as(*ancestor); } return nullptr; } diff --git a/Libraries/LibWeb/DOM/Range.cpp b/Libraries/LibWeb/DOM/Range.cpp index 850e0b48763..0a0f24b3ea0 100644 --- a/Libraries/LibWeb/DOM/Range.cpp +++ b/Libraries/LibWeb/DOM/Range.cpp @@ -56,7 +56,7 @@ GC::Ref Range::create(GC::Ref start_container, WebIDL::UnsignedLong WebIDL::ExceptionOr> Range::construct_impl(JS::Realm& realm) { - auto& window = verify_cast(realm.global_object()); + auto& window = as(realm.global_object()); return Range::create(window); } @@ -625,7 +625,7 @@ WebIDL::ExceptionOr> Range::extract() // 2. Set the data of clone to the result of substringing data with node original start node, // offset original start offset, and count original end offset minus original start offset. auto result = TRY(static_cast(*original_start_node).substring_data(original_start_offset, original_end_offset - original_start_offset)); - verify_cast(*clone).set_data(move(result)); + as(*clone).set_data(move(result)); // 3. Append clone to fragment. TRY(fragment->append_child(clone)); @@ -715,7 +715,7 @@ WebIDL::ExceptionOr> Range::extract() // 2. Set the data of clone to the result of substringing data with node original start node, offset original start offset, // and count original start node’s length minus original start offset. auto result = TRY(static_cast(*original_start_node).substring_data(original_start_offset, original_start_node->length() - original_start_offset)); - verify_cast(*clone).set_data(move(result)); + as(*clone).set_data(move(result)); // 3. Append clone to fragment. TRY(fragment->append_child(clone)); @@ -753,13 +753,13 @@ WebIDL::ExceptionOr> Range::extract() // 2. Set the data of clone to the result of substringing data with node original end node, offset 0, and count original end offset. auto result = TRY(static_cast(*original_end_node).substring_data(0, original_end_offset)); - verify_cast(*clone).set_data(move(result)); + as(*clone).set_data(move(result)); // 3. Append clone to fragment. TRY(fragment->append_child(clone)); // 4. Replace data with node original end node, offset 0, count original end offset, and data the empty string. - TRY(verify_cast(*original_end_node).replace_data(0, original_end_offset, String {})); + TRY(as(*original_end_node).replace_data(0, original_end_offset, String {})); } // 19. Otherwise, if last partially contained child is not null: else if (last_partially_contained_child) { @@ -951,7 +951,7 @@ WebIDL::ExceptionOr> Range::clone_the_contents() // 2. Set the data of clone to the result of substringing data with node original start node, // offset original start offset, and count original end offset minus original start offset. auto result = TRY(static_cast(*original_start_node).substring_data(original_start_offset, original_end_offset - original_start_offset)); - verify_cast(*clone).set_data(move(result)); + as(*clone).set_data(move(result)); // 3. Append clone to fragment. TRY(fragment->append_child(clone)); @@ -1016,7 +1016,7 @@ WebIDL::ExceptionOr> Range::clone_the_contents() // 2. Set the data of clone to the result of substringing data with node original start node, offset original start offset, // and count original start node’s length minus original start offset. auto result = TRY(static_cast(*original_start_node).substring_data(original_start_offset, original_start_node->length() - original_start_offset)); - verify_cast(*clone).set_data(move(result)); + as(*clone).set_data(move(result)); // 3. Append clone to fragment. TRY(fragment->append_child(clone)); @@ -1055,7 +1055,7 @@ WebIDL::ExceptionOr> Range::clone_the_contents() // 2. Set the data of clone to the result of substringing data with node original end node, offset 0, and count original end offset. auto result = TRY(static_cast(*original_end_node).substring_data(0, original_end_offset)); - verify_cast(*clone).set_data(move(result)); + as(*clone).set_data(move(result)); // 3. Append clone to fragment. TRY(fragment->append_child(clone)); diff --git a/Libraries/LibWeb/DOM/ShadowRoot.cpp b/Libraries/LibWeb/DOM/ShadowRoot.cpp index c7d3efb3e17..102e72956a6 100644 --- a/Libraries/LibWeb/DOM/ShadowRoot.cpp +++ b/Libraries/LibWeb/DOM/ShadowRoot.cpp @@ -53,7 +53,7 @@ WebIDL::CallbackType* ShadowRoot::onslotchange() EventTarget* ShadowRoot::get_parent(Event const& event) { if (!event.composed()) { - auto& events_first_invocation_target = verify_cast(*event.path().first().invocation_target); + auto& events_first_invocation_target = as(*event.path().first().invocation_target); if (&events_first_invocation_target.root() == this) return nullptr; } diff --git a/Libraries/LibWeb/DOM/Text.cpp b/Libraries/LibWeb/DOM/Text.cpp index 33b0ea0f56c..66affd6ad76 100644 --- a/Libraries/LibWeb/DOM/Text.cpp +++ b/Libraries/LibWeb/DOM/Text.cpp @@ -43,7 +43,7 @@ void Text::visit_edges(Cell::Visitor& visitor) WebIDL::ExceptionOr> Text::construct_impl(JS::Realm& realm, String const& data) { // The new Text(data) constructor steps are to set this’s data to data and this’s node document to current global object’s associated Document. - auto& window = verify_cast(HTML::current_principal_global_object()); + auto& window = as(HTML::current_principal_global_object()); return realm.create(window.associated_document(), data); } diff --git a/Libraries/LibWeb/DOM/Utils.cpp b/Libraries/LibWeb/DOM/Utils.cpp index 5cf5f011a28..dbef56886f3 100644 --- a/Libraries/LibWeb/DOM/Utils.cpp +++ b/Libraries/LibWeb/DOM/Utils.cpp @@ -23,17 +23,17 @@ EventTarget* retarget(EventTarget* a, EventTarget* b) return a; // - A’s root is not a shadow root - auto* a_node = verify_cast(a); + auto* a_node = as(a); auto& a_root = a_node->root(); if (!is(a_root)) return a; // - B is a node and A’s root is a shadow-including inclusive ancestor of B - if (is(b) && a_root.is_shadow_including_inclusive_ancestor_of(verify_cast(*b))) + if (is(b) && a_root.is_shadow_including_inclusive_ancestor_of(as(*b))) return a; // 2. Set A to A’s root’s host. - auto& a_shadow_root = verify_cast(a_root); + auto& a_shadow_root = as(a_root); a = a_shadow_root.host(); } } diff --git a/Libraries/LibWeb/DOMParsing/XMLSerializer.cpp b/Libraries/LibWeb/DOMParsing/XMLSerializer.cpp index bf81ec9f1f8..7b9a9c7100c 100644 --- a/Libraries/LibWeb/DOMParsing/XMLSerializer.cpp +++ b/Libraries/LibWeb/DOMParsing/XMLSerializer.cpp @@ -700,7 +700,7 @@ static WebIDL::ExceptionOr serialize_element(DOM::Element const& element // 18. If ns is the HTML namespace, and the node's localName matches the string "template", then this is a template element. if (ns == Namespace::HTML && element.local_name() == HTML::TagNames::template_) { // Append to markup the result of XML serializing a DocumentFragment node given the template element's template contents (a DocumentFragment), providing inherited ns, map, prefix index, and the require well-formed flag. - auto const& template_element = verify_cast(element); + auto const& template_element = as(element); markup.append(TRY(serialize_document_fragment(template_element.content(), inherited_ns, map, prefix_index, require_well_formed))); } diff --git a/Libraries/LibWeb/Dump.cpp b/Libraries/LibWeb/Dump.cpp index aa9d5f08663..ead3512da24 100644 --- a/Libraries/LibWeb/Dump.cpp +++ b/Libraries/LibWeb/Dump.cpp @@ -88,19 +88,19 @@ void dump_tree(StringBuilder& builder, DOM::Node const& node) for (int i = 0; i < indent; ++i) builder.append(" "sv); if (is(node)) { - builder.appendff("<{}", verify_cast(node).local_name()); - verify_cast(node).for_each_attribute([&](auto& name, auto& value) { + builder.appendff("<{}", as(node).local_name()); + as(node).for_each_attribute([&](auto& name, auto& value) { builder.appendff(" {}={}", name, value); }); builder.append(">\n"sv); - auto& element = verify_cast(node); + auto& element = as(node); if (element.use_pseudo_element().has_value()) { for (int i = 0; i < indent; ++i) builder.append(" "sv); builder.appendff(" (pseudo-element: {})\n", CSS::Selector::PseudoElement::name(element.use_pseudo_element().value())); } } else if (is(node)) { - builder.appendff("\"{}\"\n", verify_cast(node).data()); + builder.appendff("\"{}\"\n", as(node).data()); } else { builder.appendff("{}\n", node.node_name()); } @@ -117,7 +117,7 @@ void dump_tree(StringBuilder& builder, DOM::Node const& node) for (int i = 0; i < indent; ++i) builder.append(" "sv); builder.append("(SVG-as-image isolated context)\n"sv); - auto& svg_data = verify_cast(*image_data); + auto& svg_data = as(*image_data); dump_tree(builder, svg_data.svg_document()); --indent; } @@ -130,7 +130,7 @@ void dump_tree(StringBuilder& builder, DOM::Node const& node) return IterationDecision::Continue; }); } else { - auto& template_element = verify_cast(node); + auto& template_element = as(node); dump_tree(builder, template_element.content()); } } @@ -154,13 +154,13 @@ void dump_tree(StringBuilder& builder, Layout::Node const& layout_node, bool sho if (layout_node.is_anonymous()) tag_name = "(anonymous)"_fly_string; else if (is(layout_node.dom_node())) - tag_name = verify_cast(*layout_node.dom_node()).local_name(); + tag_name = as(*layout_node.dom_node()).local_name(); else tag_name = layout_node.dom_node()->node_name(); String identifier; if (layout_node.dom_node() && is(*layout_node.dom_node())) { - auto& element = verify_cast(*layout_node.dom_node()); + auto& element = as(*layout_node.dom_node()); StringBuilder builder; if (element.id().has_value() && !element.id()->is_empty()) { builder.append('#'); @@ -212,7 +212,7 @@ void dump_tree(StringBuilder& builder, Layout::Node const& layout_node, bool sho color_off); builder.append("\n"sv); } else { - auto& box = verify_cast(layout_node); + auto& box = as(layout_node); StringView color_on = is(box) ? svg_box_color_on : box_color_on; builder.appendff("{}{}{} <{}{}{}{}> ", @@ -341,7 +341,7 @@ void dump_tree(StringBuilder& builder, Layout::Node const& layout_node, bool sho if (layout_node.dom_node() && is(*layout_node.dom_node())) { if (auto image_data = static_cast(*layout_node.dom_node()).current_request().image_data()) { if (is(*image_data)) { - auto& svg_data = verify_cast(*image_data); + auto& svg_data = as(*image_data); if (svg_data.svg_document().layout_node()) { ++indent; for (size_t i = 0; i < indent; ++i) @@ -397,13 +397,13 @@ void dump_tree(StringBuilder& builder, Layout::Node const& layout_node, bool sho } } - if (show_cascaded_properties && layout_node.dom_node() && layout_node.dom_node()->is_element() && verify_cast(layout_node.dom_node())->computed_properties()) { + if (show_cascaded_properties && layout_node.dom_node() && layout_node.dom_node()->is_element() && as(layout_node.dom_node())->computed_properties()) { struct NameAndValue { FlyString name; String value; }; Vector properties; - verify_cast(*layout_node.dom_node()).computed_properties()->for_each_property([&](auto property_id, auto& value) { + as(*layout_node.dom_node()).computed_properties()->for_each_property([&](auto property_id, auto& value) { properties.append({ CSS::string_from_property_id(property_id), value.to_string(CSS::CSSStyleValue::SerializationMode::Normal) }); }); quick_sort(properties, [](auto& a, auto& b) { return a.name < b.name; }); @@ -637,38 +637,38 @@ void dump_rule(StringBuilder& builder, CSS::CSSRule const& rule, int indent_leve switch (rule.type()) { case CSS::CSSRule::Type::FontFace: - dump_font_face_rule(builder, verify_cast(rule), indent_levels); + dump_font_face_rule(builder, as(rule), indent_levels); break; case CSS::CSSRule::Type::Import: - dump_import_rule(builder, verify_cast(rule), indent_levels); + dump_import_rule(builder, as(rule), indent_levels); break; case CSS::CSSRule::Type::Keyframe: case CSS::CSSRule::Type::Keyframes: // TODO: Dump them! break; case CSS::CSSRule::Type::LayerBlock: - dump_layer_block_rule(builder, verify_cast(rule), indent_levels); + dump_layer_block_rule(builder, as(rule), indent_levels); break; case CSS::CSSRule::Type::LayerStatement: - dump_layer_statement_rule(builder, verify_cast(rule), indent_levels); + dump_layer_statement_rule(builder, as(rule), indent_levels); break; case CSS::CSSRule::Type::Media: - dump_media_rule(builder, verify_cast(rule), indent_levels); + dump_media_rule(builder, as(rule), indent_levels); break; case CSS::CSSRule::Type::Namespace: - dump_namespace_rule(builder, verify_cast(rule), indent_levels); + dump_namespace_rule(builder, as(rule), indent_levels); break; case CSS::CSSRule::Type::NestedDeclarations: - dump_nested_declarations(builder, verify_cast(rule), indent_levels); + dump_nested_declarations(builder, as(rule), indent_levels); break; case CSS::CSSRule::Type::Style: - dump_style_rule(builder, verify_cast(rule), indent_levels); + dump_style_rule(builder, as(rule), indent_levels); break; case CSS::CSSRule::Type::Supports: - dump_supports_rule(builder, verify_cast(rule), indent_levels); + dump_supports_rule(builder, as(rule), indent_levels); break; case CSS::CSSRule::Type::Property: - dump_property_rule(builder, verify_cast(rule), indent_levels); + dump_property_rule(builder, as(rule), indent_levels); break; } } @@ -863,7 +863,7 @@ void dump_sheet(CSS::StyleSheet const& sheet) void dump_sheet(StringBuilder& builder, CSS::StyleSheet const& sheet) { - auto& css_stylesheet = verify_cast(sheet); + auto& css_stylesheet = as(sheet); builder.appendff("CSSStyleSheet{{{}}}: {} rule(s)\n", &sheet, css_stylesheet.rules().length()); diff --git a/Libraries/LibWeb/Editing/Commands.cpp b/Libraries/LibWeb/Editing/Commands.cpp index 504062509de..680f90f905f 100644 --- a/Libraries/LibWeb/Editing/Commands.cpp +++ b/Libraries/LibWeb/Editing/Commands.cpp @@ -1645,7 +1645,7 @@ bool command_insert_paragraph_action(DOM::Document& document, String const&) || ((new_line_range->start_container() == new_line_range->end_container() && new_line_range->start_offset() == new_line_range->end_offset() - 1) && is(*new_line_range->start_container())); - auto& container_element = verify_cast(*container); + auto& container_element = as(*container); auto new_container_name = [&] -> FlyString { // 18. If the local name of container is "h1", "h2", "h3", "h4", "h5", or "h6", and end of line is true, let new // container name be the default single-line container name. diff --git a/Libraries/LibWeb/FileAPI/FileReader.cpp b/Libraries/LibWeb/FileAPI/FileReader.cpp index 376f29df4dd..e66b3dfd11e 100644 --- a/Libraries/LibWeb/FileAPI/FileReader.cpp +++ b/Libraries/LibWeb/FileAPI/FileReader.cpp @@ -153,7 +153,7 @@ WebIDL::ExceptionOr FileReader::read_operation(Blob& blob, Type type, Opti while (true) { auto& vm = realm.vm(); // FIXME: Try harder to not reach into the [[Promise]] slot of chunkPromise - auto promise = GC::Ref { verify_cast(*chunk_promise->promise()) }; + auto promise = GC::Ref { as(*chunk_promise->promise()) }; // 1. Wait for chunkPromise to be fulfilled or rejected. // FIXME: Create spec issue to use WebIDL react to promise steps here instead of this custom logic @@ -181,7 +181,7 @@ WebIDL::ExceptionOr FileReader::read_operation(Blob& blob, Type type, Opti // 4. If chunkPromise is fulfilled with an object whose done property is false and whose value property is a Uint8Array object, run these steps: if (promise->state() == JS::Promise::State::Fulfilled && !done.as_bool() && is(value.as_object())) { // 1. Let bs be the byte sequence represented by the Uint8Array object. - auto const& byte_sequence = verify_cast(value.as_object()); + auto const& byte_sequence = as(value.as_object()); // 2. Append bs to bytes. bytes.append(byte_sequence.data()); diff --git a/Libraries/LibWeb/HTML/BrowsingContext.cpp b/Libraries/LibWeb/HTML/BrowsingContext.cpp index fe0b0b4729a..7a6ff4cd6a5 100644 --- a/Libraries/LibWeb/HTML/BrowsingContext.cpp +++ b/Libraries/LibWeb/HTML/BrowsingContext.cpp @@ -211,7 +211,7 @@ WebIDL::ExceptionOr BrowsingContext auto load_timing_info = DOM::DocumentLoadTimingInfo(); load_timing_info.navigation_start_time = HighResolutionTime::coarsen_time( unsafe_context_creation_time, - verify_cast(Bindings::principal_host_defined_environment_settings_object(window->realm())).cross_origin_isolated_capability() == CanUseCrossOriginIsolatedAPIs::Yes); + as(Bindings::principal_host_defined_environment_settings_object(window->realm())).cross_origin_isolated_capability() == CanUseCrossOriginIsolatedAPIs::Yes); // 15. Let document be a new Document, with: auto document = HTML::HTMLDocument::create(window->realm()); diff --git a/Libraries/LibWeb/HTML/CloseWatcher.cpp b/Libraries/LibWeb/HTML/CloseWatcher.cpp index 9e42ce5ea41..d48f15d6493 100644 --- a/Libraries/LibWeb/HTML/CloseWatcher.cpp +++ b/Libraries/LibWeb/HTML/CloseWatcher.cpp @@ -43,7 +43,7 @@ GC::Ref CloseWatcher::establish(HTML::Window& window) // https://html.spec.whatwg.org/multipage/interaction.html#dom-closewatcher WebIDL::ExceptionOr> CloseWatcher::construct_impl(JS::Realm& realm, CloseWatcherOptions const& options) { - auto& window = verify_cast(realm.global_object()); + auto& window = as(realm.global_object()); // NOTE: Not in spec explicitly, but this should account for detached iframes too. See /close-watcher/frame-removal.html WPT. auto navigable = window.navigable(); @@ -91,7 +91,7 @@ bool CloseWatcher::request_close() return true; // 3. Let window be closeWatcher's window. - auto& window = verify_cast(realm().global_object()); + auto& window = as(realm().global_object()); // 4. If window's associated Document is not fully active, then return true. if (!window.associated_document().is_fully_active()) @@ -131,7 +131,7 @@ void CloseWatcher::close() return; // 2. If closeWatcher's window's associated Document is not fully active, then return. - if (!verify_cast(realm().global_object()).associated_document().is_fully_active()) + if (!as(realm().global_object()).associated_document().is_fully_active()) return; // 3. Destroy closeWatcher. @@ -145,7 +145,7 @@ void CloseWatcher::close() void CloseWatcher::destroy() { // 1. Let manager be closeWatcher's window's close watcher manager. - auto manager = verify_cast(realm().global_object()).close_watcher_manager(); + auto manager = as(realm().global_object()).close_watcher_manager(); // 2-3. Moved to CloseWatcherManager::remove manager->remove(*this); diff --git a/Libraries/LibWeb/HTML/CustomElements/CustomElementRegistry.cpp b/Libraries/LibWeb/HTML/CustomElements/CustomElementRegistry.cpp index 20a552439ad..8623d4a8f8f 100644 --- a/Libraries/LibWeb/HTML/CustomElements/CustomElementRegistry.cpp +++ b/Libraries/LibWeb/HTML/CustomElements/CustomElementRegistry.cpp @@ -289,7 +289,7 @@ JS::ThrowCompletionOr CustomElementRegistry::define(String const& name, We m_custom_element_definitions.append(definition); // 17. Let document be this's relevant global object's associated Document. - auto& document = verify_cast(relevant_global_object(*this)).associated_document(); + auto& document = as(relevant_global_object(*this)).associated_document(); // 18. Let upgradeCandidates be all elements that are shadow-including descendants of document, whose namespace is the HTML namespace // and whose local name is localName, in shadow-including tree order. diff --git a/Libraries/LibWeb/HTML/DOMParser.cpp b/Libraries/LibWeb/HTML/DOMParser.cpp index 83f502e0b2e..8caf623ff29 100644 --- a/Libraries/LibWeb/HTML/DOMParser.cpp +++ b/Libraries/LibWeb/HTML/DOMParser.cpp @@ -47,14 +47,14 @@ GC::Ref DOMParser::parse_from_string(StringView string, Bindings: // 3. Switch on type: if (type == Bindings::DOMParserSupportedType::Text_Html) { // -> "text/html" - document = HTML::HTMLDocument::create(realm(), verify_cast(relevant_global_object(*this)).associated_document().url()); + document = HTML::HTMLDocument::create(realm(), as(relevant_global_object(*this)).associated_document().url()); document->set_content_type(Bindings::idl_enum_to_string(type)); // 1. Parse HTML from a string given document and compliantString. FIXME: Use compliantString. document->parse_html_from_a_string(string); } else { // -> Otherwise - document = DOM::XMLDocument::create(realm(), verify_cast(relevant_global_object(*this)).associated_document().url()); + document = DOM::XMLDocument::create(realm(), as(relevant_global_object(*this)).associated_document().url()); document->set_content_type(Bindings::idl_enum_to_string(type)); document->set_document_type(DOM::Document::Type::XML); diff --git a/Libraries/LibWeb/HTML/EventLoop/EventLoop.cpp b/Libraries/LibWeb/HTML/EventLoop/EventLoop.cpp index 4e981fad1f0..cb3090682e7 100644 --- a/Libraries/LibWeb/HTML/EventLoop/EventLoop.cpp +++ b/Libraries/LibWeb/HTML/EventLoop/EventLoop.cpp @@ -466,7 +466,7 @@ TaskID queue_global_task(HTML::Task::Source source, JS::Object& global_object, G // 2. Let document be global's associated Document, if global is a Window object; otherwise null. DOM::Document* document { nullptr }; if (is(global_object)) { - auto& window_object = verify_cast(global_object); + auto& window_object = as(global_object); document = &window_object.associated_document(); } diff --git a/Libraries/LibWeb/HTML/Focus.cpp b/Libraries/LibWeb/HTML/Focus.cpp index 5512eb25df0..0fbc17e6965 100644 --- a/Libraries/LibWeb/HTML/Focus.cpp +++ b/Libraries/LibWeb/HTML/Focus.cpp @@ -27,7 +27,7 @@ static void fire_a_focus_event(GC::Ptr focus_event_target, GC: // object, and the composed flag set. UIEvents::FocusEventInit focus_event_init {}; focus_event_init.related_target = related_focus_target; - focus_event_init.view = verify_cast(focus_event_target->realm().global_object()).window(); + focus_event_init.view = as(focus_event_target->realm().global_object()).window(); auto focus_event = UIEvents::FocusEvent::create(focus_event_target->realm(), event_name, focus_event_init); // AD-HOC: support bubbling focus events, used for focusin & focusout. @@ -283,7 +283,7 @@ void run_unfocusing_steps(DOM::Node* old_focus_target) return; // 7. Let topDocument be old chain's last entry. - auto* top_document = verify_cast(old_chain.last().ptr()); + auto* top_document = as(old_chain.last().ptr()); // 8. If topDocument's node navigable has system focus, then run the focusing steps for topDocument's viewport. if (top_document->navigable()->traversable_navigable()->system_visibility_state() == HTML::VisibilityState::Visible) { diff --git a/Libraries/LibWeb/HTML/FormControlInfrastructure.cpp b/Libraries/LibWeb/HTML/FormControlInfrastructure.cpp index ddbd17b00b6..9a80d793c2f 100644 --- a/Libraries/LibWeb/HTML/FormControlInfrastructure.cpp +++ b/Libraries/LibWeb/HTML/FormControlInfrastructure.cpp @@ -51,7 +51,7 @@ WebIDL::ExceptionOr create_entry(JS::Realm& realm, String co blob = TRY(FileAPI::File::create(realm, { GC::make_root(*blob) }, *filename, move(options))); } - return GC::make_root(verify_cast(*blob)); + return GC::make_root(as(*blob)); })); // 4. Return an entry whose name is name and whose value is value. diff --git a/Libraries/LibWeb/HTML/HTMLDialogElement.cpp b/Libraries/LibWeb/HTML/HTMLDialogElement.cpp index 83067ec9d34..79476d61a62 100644 --- a/Libraries/LibWeb/HTML/HTMLDialogElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLDialogElement.cpp @@ -211,7 +211,7 @@ WebIDL::ExceptionOr HTMLDialogElement::show_modal() // - cancelAction given canPreventClose being to return the result of firing an event named cancel at this, with the cancelable attribute initialized to canPreventClose. auto cancel_callback_function = JS::NativeFunction::create( realm(), [this](JS::VM& vm) { - auto& event = verify_cast(vm.argument(0).as_object()); + auto& event = as(vm.argument(0).as_object()); bool can_prevent_close = event.cancelable(); auto should_continue = dispatch_event(DOM::Event::create(realm(), HTML::EventNames::cancel, { .cancelable = can_prevent_close })); if (!should_continue) diff --git a/Libraries/LibWeb/HTML/HTMLElement.cpp b/Libraries/LibWeb/HTML/HTMLElement.cpp index 579797f5653..23e791548a3 100644 --- a/Libraries/LibWeb/HTML/HTMLElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLElement.cpp @@ -294,7 +294,7 @@ static Vector> rendered_text_collection_ // or it ends with a br element. Soft hyphens should be preserved. [CSSTEXT] if (is(node)) { - auto const* layout_text_node = verify_cast(layout_node); + auto const* layout_text_node = as(layout_node); items.append(layout_text_node->text_for_rendering()); return items; } @@ -667,7 +667,7 @@ GC::Ptr HTMLElement::labels() if (!m_labels) { m_labels = DOM::LiveNodeList::create(realm(), root(), DOM::LiveNodeList::Scope::Descendants, [&](auto& node) { - return is(node) && verify_cast(node).control() == this; + return is(node) && as(node).control() == this; }); } @@ -962,7 +962,7 @@ WebIDL::ExceptionOr HTMLElement::check_popover_validity(ExpectedToBeShowin // then: // 3.1 If throwExceptions is true, then throw an "InvalidStateError" DOMException. // 3.2 Return false. - if (!is_connected() || !document().is_fully_active() || (expected_document && &document() != expected_document) || (is(*this) && verify_cast(*this).is_modal())) { + if (!is_connected() || !document().is_fully_active() || (expected_document && &document() != expected_document) || (is(*this) && as(*this).is_modal())) { if (throw_exceptions == ThrowExceptions::Yes) return WebIDL::InvalidStateError::create(realm(), "Element is not in a valid state to show a popover"_string); return false; diff --git a/Libraries/LibWeb/HTML/HTMLFormControlsCollection.cpp b/Libraries/LibWeb/HTML/HTMLFormControlsCollection.cpp index 6f87d3ed4db..1fe841c6e4c 100644 --- a/Libraries/LibWeb/HTML/HTMLFormControlsCollection.cpp +++ b/Libraries/LibWeb/HTML/HTMLFormControlsCollection.cpp @@ -72,7 +72,7 @@ Variant> HTMLFormControlsCollectio if (!is(node)) return false; - auto const& element = verify_cast(node); + auto const& element = as(node); return element.id() == name || element.name() == name; })); } diff --git a/Libraries/LibWeb/HTML/HTMLFormElement.cpp b/Libraries/LibWeb/HTML/HTMLFormElement.cpp index 26e0c67d105..389cebedf49 100644 --- a/Libraries/LibWeb/HTML/HTMLFormElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLFormElement.cpp @@ -521,7 +521,7 @@ static bool is_form_control(DOM::Element const& element, HTMLFormElement const& GC::Ref HTMLFormElement::elements() const { if (!m_elements) { - auto& root = verify_cast(const_cast(this)->root()); + auto& root = as(const_cast(this)->root()); m_elements = HTMLFormControlsCollection::create(root, DOM::HTMLCollection::Scope::Descendants, [this](Element const& element) { return is_form_control(element, *this); }); @@ -1017,7 +1017,7 @@ Vector HTMLFormElement::supported_property_names() const JS::Value HTMLFormElement::named_item_value(FlyString const& name) const { auto& realm = this->realm(); - auto& root = verify_cast(this->root()); + auto& root = as(this->root()); // To determine the value of a named property name for a form element, the user agent must run the following steps: diff --git a/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp b/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp index 96c509180db..7876298efd3 100644 --- a/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp @@ -70,7 +70,7 @@ void HTMLIFrameElement::attribute_changed(FlyString const& name, Optional(shadow_including_root()); + DOM::Document& document = as(shadow_including_root()); // NOTE: The check for "not fully active" is to prevent a crash on the dom/nodes/node-appendchild-crash.html WPT test. if (!document.browsing_context() || !document.is_fully_active()) diff --git a/Libraries/LibWeb/HTML/HTMLImageElement.cpp b/Libraries/LibWeb/HTML/HTMLImageElement.cpp index 5295b1bdb63..e265630f4a8 100644 --- a/Libraries/LibWeb/HTML/HTMLImageElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLImageElement.cpp @@ -136,7 +136,7 @@ void HTMLImageElement::form_associated_element_attribute_changed(FlyString const if (name == HTML::AttributeNames::alt) { if (layout_node()) - did_update_alt_text(verify_cast(*layout_node())); + did_update_alt_text(as(*layout_node())); } if (name == HTML::AttributeNames::decoding) { diff --git a/Libraries/LibWeb/HTML/HTMLInputElement.cpp b/Libraries/LibWeb/HTML/HTMLInputElement.cpp index 6d32f8dfea9..3c6456857bb 100644 --- a/Libraries/LibWeb/HTML/HTMLInputElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLInputElement.cpp @@ -1309,7 +1309,7 @@ void HTMLInputElement::form_associated_element_attribute_changed(FlyString const handle_src_attribute(value.value_or({})).release_value_but_fixme_should_propagate_errors(); } else if (name == HTML::AttributeNames::alt) { if (layout_node() && type_state() == TypeAttributeState::ImageButton) - did_update_alt_text(verify_cast(*layout_node())); + did_update_alt_text(as(*layout_node())); } else if (name == HTML::AttributeNames::maxlength) { handle_maxlength_attribute(); } else if (name == HTML::AttributeNames::multiple) { @@ -1728,7 +1728,7 @@ WebIDL::ExceptionOr HTMLInputElement::cloned(DOM::Node& copy, bool subtree TRY(Base::cloned(copy, subtree)); // The cloning steps for input elements given node, copy, and subtree are to propagate the value, dirty value flag, checkedness, and dirty checkedness flag from node to copy. - auto& input_clone = verify_cast(copy); + auto& input_clone = as(copy); input_clone.m_value = m_value; input_clone.m_dirty_value = m_dirty_value; input_clone.m_checked = m_checked; diff --git a/Libraries/LibWeb/HTML/HTMLLegendElement.cpp b/Libraries/LibWeb/HTML/HTMLLegendElement.cpp index 5a77eef7830..c2a2185a768 100644 --- a/Libraries/LibWeb/HTML/HTMLLegendElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLLegendElement.cpp @@ -33,7 +33,7 @@ HTMLFormElement* HTMLLegendElement::form() // The form IDL attribute's behavior depends on whether the legend element is in a fieldset element or not. // If the legend has a fieldset element as its parent, then the form IDL attribute must return the same value as the form IDL attribute on that fieldset element. if (is(parent_element())) { - return verify_cast(parent_element())->form(); + return as(parent_element())->form(); } // Otherwise, it must return null. diff --git a/Libraries/LibWeb/HTML/HTMLMediaElement.cpp b/Libraries/LibWeb/HTML/HTMLMediaElement.cpp index 11c59712e7d..70fef36f5f6 100644 --- a/Libraries/LibWeb/HTML/HTMLMediaElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLMediaElement.cpp @@ -1202,7 +1202,7 @@ WebIDL::ExceptionOr HTMLMediaElement::process_media_data(Functionduration() : audio_track->duration(); set_duration(static_cast(duration.to_milliseconds()) / 1000.0); - auto& video_element = verify_cast(*this); + auto& video_element = as(*this); video_element.set_video_width(video_track->pixel_width()); video_element.set_video_height(video_track->pixel_height()); diff --git a/Libraries/LibWeb/HTML/HTMLOptionElement.cpp b/Libraries/LibWeb/HTML/HTMLOptionElement.cpp index 876e2ca15cc..7bdd3b973aa 100644 --- a/Libraries/LibWeb/HTML/HTMLOptionElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLOptionElement.cpp @@ -107,7 +107,7 @@ static void concatenate_descendants_text_content(DOM::Node const* node, StringBu if (is(node) || is(node)) return; if (is(node)) - builder.append(verify_cast(node)->data()); + builder.append(as(node)->data()); node->for_each_child([&](auto const& node) { concatenate_descendants_text_content(&node, builder); return IterationDecision::Continue; @@ -202,7 +202,7 @@ GC::Ptr HTMLOptionElement::form() const parent = parent->parent_element(); if (is(parent)) { - auto const* select_element = verify_cast(parent); + auto const* select_element = as(parent); return const_cast(select_element->form()); } diff --git a/Libraries/LibWeb/HTML/HTMLOptionsCollection.cpp b/Libraries/LibWeb/HTML/HTMLOptionsCollection.cpp index 111a424b6d4..26d63cafa98 100644 --- a/Libraries/LibWeb/HTML/HTMLOptionsCollection.cpp +++ b/Libraries/LibWeb/HTML/HTMLOptionsCollection.cpp @@ -183,12 +183,12 @@ WebIDL::Long HTMLOptionsCollection::selected_index() const { // The selectedIndex IDL attribute must act like the identically named attribute // on the select element on which the HTMLOptionsCollection is rooted. - return verify_cast(*root()).selected_index(); + return as(*root()).selected_index(); } void HTMLOptionsCollection::set_selected_index(WebIDL::Long index) { - verify_cast(*root()).set_selected_index(index); + as(*root()).set_selected_index(index); } } diff --git a/Libraries/LibWeb/HTML/HTMLScriptElement.cpp b/Libraries/LibWeb/HTML/HTMLScriptElement.cpp index 19370937d6f..f442326d4a5 100644 --- a/Libraries/LibWeb/HTML/HTMLScriptElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLScriptElement.cpp @@ -130,7 +130,7 @@ void HTMLScriptElement::execute_script() dbgln_if(HTML_SCRIPT_DEBUG, "HTMLScriptElement: Running inline script"); // 3. Run the classic script given by el's result. - (void)verify_cast(*m_result.get>()).run(); + (void)as(*m_result.get>()).run(); // 4. Set document's currentScript attribute to oldCurrentScript. document->set_current_script({}, old_current_script); @@ -141,12 +141,12 @@ void HTMLScriptElement::execute_script() VERIFY(document->current_script() == nullptr); // 2. Run the module script given by el's result. - (void)verify_cast(*m_result.get>()).run(); + (void)as(*m_result.get>()).run(); } // -> "importmap" else if (m_script_type == ScriptType::ImportMap) { // 1. Register an import map given el's relevant global object and el's result. - m_result.get>()->register_import_map(verify_cast(relevant_global_object(*this))); + m_result.get>()->register_import_map(as(relevant_global_object(*this))); } // 7. Decrement the ignore-destructive-writes counter of document, if it was incremented in the earlier step. @@ -656,7 +656,7 @@ WebIDL::ExceptionOr HTMLScriptElement::cloned(Node& copy, bool subtree) co TRY(Base::cloned(copy, subtree)); // The cloning steps for script elements given node, copy, and subtree are to set copy's already started to node's already started. - auto& script_copy = verify_cast(copy); + auto& script_copy = as(copy); script_copy.m_already_started = m_already_started; return {}; diff --git a/Libraries/LibWeb/HTML/HTMLSelectElement.cpp b/Libraries/LibWeb/HTML/HTMLSelectElement.cpp index 4141e0abde5..aad95f9c03a 100644 --- a/Libraries/LibWeb/HTML/HTMLSelectElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLSelectElement.cpp @@ -145,14 +145,14 @@ WebIDL::ExceptionOr HTMLSelectElement::set_length(WebIDL::UnsignedLong len HTMLOptionElement* HTMLSelectElement::item(WebIDL::UnsignedLong index) { // The item(index) method must return the value returned by the method of the same name on the options collection, when invoked with the same argument. - return verify_cast(const_cast(*options()).item(index)); + return as(const_cast(*options()).item(index)); } // https://html.spec.whatwg.org/multipage/form-elements.html#dom-select-nameditem HTMLOptionElement* HTMLSelectElement::named_item(FlyString const& name) { // The namedItem(name) method must return the value returned by the method of the same name on the options collection, when invoked with the same argument. - return verify_cast(const_cast(*options()).named_item(name)); + return as(const_cast(*options()).named_item(name)); } // https://html.spec.whatwg.org/multipage/form-elements.html#dom-select-add @@ -187,7 +187,7 @@ GC::Ref HTMLSelectElement::selected_options() if (!m_selected_options) { m_selected_options = DOM::HTMLCollection::create(*this, DOM::HTMLCollection::Scope::Descendants, [](Element const& element) { if (is(element)) { - auto const& option_element = verify_cast(element); + auto const& option_element = as(element); return option_element.selected(); } return false; @@ -408,11 +408,11 @@ void HTMLSelectElement::show_the_picker_if_applicable() u32 id_counter = 1; for (auto const& child : children_as_vector()) { if (is(*child)) { - auto& opt_group_element = verify_cast(*child); + auto& opt_group_element = as(*child); Vector option_group_items; for (auto const& child : opt_group_element.children_as_vector()) { if (is(*child)) { - auto& option_element = verify_cast(*child); + auto& option_element = as(*child); option_group_items.append(SelectItemOption { id_counter++, option_element.selected(), option_element.disabled(), option_element, strip_newlines(option_element.label()), option_element.value() }); } } @@ -420,7 +420,7 @@ void HTMLSelectElement::show_the_picker_if_applicable() } if (is(*child)) { - auto& option_element = verify_cast(*child); + auto& option_element = as(*child); m_select_items.append(SelectItemOption { id_counter++, option_element.selected(), option_element.disabled(), option_element, strip_newlines(option_element.label()), option_element.value() }); } diff --git a/Libraries/LibWeb/HTML/HTMLTableElement.cpp b/Libraries/LibWeb/HTML/HTMLTableElement.cpp index 8fbffcad5d7..190f6bd1a8b 100644 --- a/Libraries/LibWeb/HTML/HTMLTableElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLTableElement.cpp @@ -189,7 +189,7 @@ GC::Ptr HTMLTableElement::t_head() // if any, or null otherwise. for (auto* child = first_child(); child; child = child->next_sibling()) { if (is(*child)) { - auto table_section_element = &verify_cast(*child); + auto table_section_element = &as(*child); if (table_section_element->local_name() == TagNames::thead) return table_section_element; } @@ -224,7 +224,7 @@ WebIDL::ExceptionOr HTMLTableElement::set_t_head(HTMLTableSectionElement* if (is(*child)) continue; if (is(*child)) { - auto table_col_element = &verify_cast(*child); + auto table_col_element = &as(*child); if (table_col_element->local_name() == TagNames::colgroup) continue; } @@ -256,7 +256,7 @@ GC::Ref HTMLTableElement::create_t_head() if (is(*child)) continue; if (is(*child)) { - auto table_col_element = &verify_cast(*child); + auto table_col_element = &as(*child); if (table_col_element->local_name() == TagNames::colgroup) continue; } @@ -287,7 +287,7 @@ GC::Ptr HTMLTableElement::t_foot() // if any, or null otherwise. for (auto* child = first_child(); child; child = child->next_sibling()) { if (is(*child)) { - auto table_section_element = &verify_cast(*child); + auto table_section_element = &as(*child); if (table_section_element->local_name() == TagNames::tfoot) return table_section_element; } @@ -360,7 +360,7 @@ GC::Ref HTMLTableElement::create_t_body() if (!is(*child)) continue; if (is(*child)) { - auto table_section_element = &verify_cast(*child); + auto table_section_element = &as(*child); if (table_section_element->local_name() == TagNames::tbody) { // We have found an element which is a we'll insert after this child_to_insert_before = child->next_sibling(); diff --git a/Libraries/LibWeb/HTML/HTMLTemplateElement.cpp b/Libraries/LibWeb/HTML/HTMLTemplateElement.cpp index 58154fcf664..d38d1e6387c 100644 --- a/Libraries/LibWeb/HTML/HTMLTemplateElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLTemplateElement.cpp @@ -59,7 +59,7 @@ WebIDL::ExceptionOr HTMLTemplateElement::cloned(Node& copy, bool subtree) // 2. For each child of node's template contents's children, in tree order: // clone a node given child with document set to copy's template contents's node document, // subtree set to true, and parent set to copy's template contents. - auto& template_copy = verify_cast(copy); + auto& template_copy = as(copy); for (auto child = content()->first_child(); child; child = child->next_sibling()) { TRY(child->clone_node(&template_copy.content()->document(), true, template_copy.content())); } diff --git a/Libraries/LibWeb/HTML/HTMLTextAreaElement.cpp b/Libraries/LibWeb/HTML/HTMLTextAreaElement.cpp index fba9ac2a322..31de5ebec4d 100644 --- a/Libraries/LibWeb/HTML/HTMLTextAreaElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLTextAreaElement.cpp @@ -141,7 +141,7 @@ WebIDL::ExceptionOr HTMLTextAreaElement::cloned(DOM::Node& copy, bool subt TRY(Base::cloned(copy, subtree)); // The cloning steps for textarea elements given node, copy, and subtree are to propagate the raw value and dirty value flag from node to copy. - auto& textarea_copy = verify_cast(copy); + auto& textarea_copy = as(copy); textarea_copy.m_raw_value = m_raw_value; textarea_copy.m_dirty_value = m_dirty_value; diff --git a/Libraries/LibWeb/HTML/HTMLTrackElement.cpp b/Libraries/LibWeb/HTML/HTMLTrackElement.cpp index c977bf62ca9..9b484d5c82b 100644 --- a/Libraries/LibWeb/HTML/HTMLTrackElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLTrackElement.cpp @@ -175,7 +175,7 @@ void HTMLTrackElement::start_the_track_processing_model_parallel_steps(JS::Realm // parent media element's crossorigin content attribute. Otherwise, let corsAttributeState be No CORS. auto cors_attribute_state = CORSSettingAttribute::NoCORS; if (is(parent())) { - cors_attribute_state = verify_cast(parent())->crossorigin(); + cors_attribute_state = as(parent())->crossorigin(); } // 9. End the synchronous section, continuing the remaining steps in parallel. diff --git a/Libraries/LibWeb/HTML/History.cpp b/Libraries/LibWeb/HTML/History.cpp index e9b4e759db8..5c9a5cfd360 100644 --- a/Libraries/LibWeb/HTML/History.cpp +++ b/Libraries/LibWeb/HTML/History.cpp @@ -211,7 +211,7 @@ WebIDL::ExceptionOr History::shared_history_push_replace_state(JS::Value d } // 7. Let navigation be history's relevant global object's navigation API. - auto navigation = verify_cast(relevant_global_object(*this)).navigation(); + auto navigation = as(relevant_global_object(*this)).navigation(); // 8. Let continue be the result of firing a push/replace/reload navigate event at navigation // with navigationType set to historyHandling, isSameDocument set to true, destinationURL set to newURL, diff --git a/Libraries/LibWeb/HTML/Location.cpp b/Libraries/LibWeb/HTML/Location.cpp index 75c7dd8873d..4913c2d5c71 100644 --- a/Libraries/LibWeb/HTML/Location.cpp +++ b/Libraries/LibWeb/HTML/Location.cpp @@ -79,7 +79,7 @@ GC::Ptr Location::relevant_document() const // A Location object has an associated relevant Document, which is this Location object's // relevant global object's browsing context's active document, if this Location object's // relevant global object's browsing context is non-null, and null otherwise. - auto* browsing_context = verify_cast(HTML::relevant_global_object(*this)).browsing_context(); + auto* browsing_context = as(HTML::relevant_global_object(*this)).browsing_context(); return browsing_context ? browsing_context->active_document() : nullptr; } @@ -87,13 +87,13 @@ GC::Ptr Location::relevant_document() const WebIDL::ExceptionOr Location::navigate(URL::URL url, Bindings::NavigationHistoryBehavior history_handling) { // 1. Let navigable be location's relevant global object's navigable. - auto navigable = verify_cast(HTML::relevant_global_object(*this)).navigable(); + auto navigable = as(HTML::relevant_global_object(*this)).navigable(); // 2. Let sourceDocument be the incumbent global object's associated Document. - auto& source_document = verify_cast(incumbent_global_object()).associated_document(); + auto& source_document = as(incumbent_global_object()).associated_document(); // 3. If location's relevant Document is not yet completely loaded, and the incumbent global object does not have transient activation, then set historyHandling to "replace". - if (!relevant_document()->is_completely_loaded() && !verify_cast(incumbent_global_object()).has_transient_activation()) { + if (!relevant_document()->is_completely_loaded() && !as(incumbent_global_object()).has_transient_activation()) { history_handling = Bindings::NavigationHistoryBehavior::Replace; } diff --git a/Libraries/LibWeb/HTML/MessagePort.cpp b/Libraries/LibWeb/HTML/MessagePort.cpp index fecaee14b52..b16309d69ef 100644 --- a/Libraries/LibWeb/HTML/MessagePort.cpp +++ b/Libraries/LibWeb/HTML/MessagePort.cpp @@ -403,7 +403,7 @@ void MessagePort::post_message_task_steps(SerializedTransferRecord& serialize_wi Vector> new_ports; for (auto const& object : deserialize_record.transferred_values) { if (is(*object)) { - new_ports.append(verify_cast(*object)); + new_ports.append(as(*object)); } } diff --git a/Libraries/LibWeb/HTML/MimeType.cpp b/Libraries/LibWeb/HTML/MimeType.cpp index 3cb28e21134..6f67a9ec995 100644 --- a/Libraries/LibWeb/HTML/MimeType.cpp +++ b/Libraries/LibWeb/HTML/MimeType.cpp @@ -55,7 +55,7 @@ String const& MimeType::suffixes() const GC::Ref MimeType::enabled_plugin() const { // The MimeType interface's enabledPlugin getter steps are to return this's relevant global object's PDF viewer plugin objects[0] (i.e., the generic "PDF Viewer" one). - auto& window = verify_cast(HTML::relevant_global_object(*this)); + auto& window = as(HTML::relevant_global_object(*this)); auto plugin_objects = window.pdf_viewer_plugin_objects(); // NOTE: If a MimeType object was created, that means PDF viewer support is enabled, meaning there will be Plugin objects. diff --git a/Libraries/LibWeb/HTML/MimeTypeArray.cpp b/Libraries/LibWeb/HTML/MimeTypeArray.cpp index 961a16096b0..b41b857c6a1 100644 --- a/Libraries/LibWeb/HTML/MimeTypeArray.cpp +++ b/Libraries/LibWeb/HTML/MimeTypeArray.cpp @@ -37,7 +37,7 @@ void MimeTypeArray::initialize(JS::Realm& realm) Vector MimeTypeArray::supported_property_names() const { // The MimeTypeArray interface supports named properties. If the user agent's PDF viewer supported is true, then they are the PDF viewer mime types. Otherwise, they are the empty list. - auto const& window = verify_cast(HTML::relevant_global_object(*this)); + auto const& window = as(HTML::relevant_global_object(*this)); if (!window.page().pdf_viewer_supported()) return {}; @@ -54,7 +54,7 @@ Vector MimeTypeArray::supported_property_names() const size_t MimeTypeArray::length() const { // The MimeTypeArray interface's length getter steps are to return this's relevant global object's PDF viewer mime type objects's size. - auto& window = verify_cast(HTML::relevant_global_object(*this)); + auto& window = as(HTML::relevant_global_object(*this)); return window.pdf_viewer_mime_type_objects().size(); } @@ -62,7 +62,7 @@ size_t MimeTypeArray::length() const GC::Ptr MimeTypeArray::item(u32 index) const { // 1. Let mimeTypes be this's relevant global object's PDF viewer mime type objects. - auto& window = verify_cast(HTML::relevant_global_object(*this)); + auto& window = as(HTML::relevant_global_object(*this)); auto mime_types = window.pdf_viewer_mime_type_objects(); // 2. If index < mimeType's size, then return mimeTypes[index]. @@ -77,7 +77,7 @@ GC::Ptr MimeTypeArray::item(u32 index) const GC::Ptr MimeTypeArray::named_item(FlyString const& name) const { // 1. For each MimeType mimeType of this's relevant global object's PDF viewer mime type objects: if mimeType's type is name, then return mimeType. - auto& window = verify_cast(HTML::relevant_global_object(*this)); + auto& window = as(HTML::relevant_global_object(*this)); auto mime_types = window.pdf_viewer_mime_type_objects(); for (auto& mime_type : mime_types) { diff --git a/Libraries/LibWeb/HTML/Navigable.cpp b/Libraries/LibWeb/HTML/Navigable.cpp index 3d81830f1f0..9ff34b194d1 100644 --- a/Libraries/LibWeb/HTML/Navigable.cpp +++ b/Libraries/LibWeb/HTML/Navigable.cpp @@ -331,7 +331,7 @@ GC::Ptr Navigable::top_level_traversable() navigable = navigable->parent(); // 3. Return navigable. - return verify_cast(navigable); + return as(navigable); } // https://html.spec.whatwg.org/multipage/browsing-the-web.html#set-the-ongoing-navigation @@ -2044,7 +2044,7 @@ void perform_url_and_history_update_steps(DOM::Document& document, URL::URL new_ navigable->set_active_session_history_entry(new_entry); // 11. Update the navigation API entries for a same-document navigation given document's relevant global object's navigation API, newEntry, and historyHandling. - auto& relevant_global_object = verify_cast(HTML::relevant_global_object(document)); + auto& relevant_global_object = as(HTML::relevant_global_object(document)); auto navigation_type = history_handling == HistoryHandlingBehavior::Push ? Bindings::NavigationType::Push : Bindings::NavigationType::Replace; relevant_global_object.navigation()->update_the_navigation_api_entries_for_a_same_document_navigation(new_entry, navigation_type); diff --git a/Libraries/LibWeb/HTML/NavigateEvent.cpp b/Libraries/LibWeb/HTML/NavigateEvent.cpp index ef1cc889fc0..05f9ee1b524 100644 --- a/Libraries/LibWeb/HTML/NavigateEvent.cpp +++ b/Libraries/LibWeb/HTML/NavigateEvent.cpp @@ -149,7 +149,7 @@ WebIDL::ExceptionOr NavigateEvent::perform_shared_checks() // 1. If event's relevant global object's associated Document is not fully active, // then throw an "InvalidStateError" DOMException. - auto& associated_document = verify_cast(relevant_global_object(*this)).associated_document(); + auto& associated_document = as(relevant_global_object(*this)).associated_document(); if (!associated_document.is_fully_active()) return WebIDL::InvalidStateError::create(realm(), "Document is not fully active"_string); @@ -184,7 +184,7 @@ void NavigateEvent::process_scroll_behavior() // 4. Otherwise: else { // 1. Let document be event's relevant global object's associated Document. - auto& document = verify_cast(relevant_global_object(*this)).associated_document(); + auto& document = as(relevant_global_object(*this)).associated_document(); // 2. If document's indicated part is null, then scroll to the beginning of the document given document. [CSSOMVIEW] auto indicated_part = document.determine_the_indicated_part(); @@ -226,7 +226,7 @@ void NavigateEvent::potentially_reset_the_focus() VERIFY(m_interception_state == InterceptionState::Committed || m_interception_state == InterceptionState::Scrolled); // 2. Let navigation be event's relevant global object's navigation API. - auto& relevant_global_object = verify_cast(HTML::relevant_global_object(*this)); + auto& relevant_global_object = as(HTML::relevant_global_object(*this)); auto navigation = relevant_global_object.navigation(); // 3. Let focusChanged be navigation's focus changed during ongoing navigation. diff --git a/Libraries/LibWeb/HTML/Navigation.cpp b/Libraries/LibWeb/HTML/Navigation.cpp index eb9d821362b..38822ac9624 100644 --- a/Libraries/LibWeb/HTML/Navigation.cpp +++ b/Libraries/LibWeb/HTML/Navigation.cpp @@ -233,7 +233,7 @@ WebIDL::ExceptionOr Navigation::navigate(String url, Navigatio return early_error_result(WebIDL::SyntaxError::create(realm, "Cannot navigate to Invalid URL"_string)); // 2. Let document be this's relevant global object's associated Document. - auto& document = verify_cast(relevant_global_object(*this)).associated_document(); + auto& document = as(relevant_global_object(*this)).associated_document(); // 3. If options["history"] is "push", and the navigation must be a replace given urlRecord and document, // then return an early error result for a "NotSupportedError" DOMException. @@ -301,7 +301,7 @@ WebIDL::ExceptionOr Navigation::reload(NavigationReloadOptions // The reload(options) method steps are: // 1. Let document be this's relevant global object's associated Document. - auto& document = verify_cast(relevant_global_object(*this)).associated_document(); + auto& document = as(relevant_global_object(*this)).associated_document(); // 2. Let serializedState be StructuredSerializeForStorage(undefined). auto serialized_state = MUST(structured_serialize_for_storage(vm, JS::js_undefined())); @@ -451,7 +451,7 @@ bool Navigation::has_entries_and_events_disabled() const // A Navigation navigation has entries and events disabled if the following steps return true: // 1. Let document be navigation's relevant global object's associated Document. - auto const& document = verify_cast(relevant_global_object(*this)).associated_document(); + auto const& document = as(relevant_global_object(*this)).associated_document(); // 2. If document is not fully active, then return true. if (!document.is_fully_active()) @@ -620,7 +620,7 @@ WebIDL::ExceptionOr Navigation::perform_a_navigation_api_trave // To perform a navigation API traversal given a Navigation navigation, a string key, and a NavigationOptions options: // 1. Let document be this's relevant global object's associated Document. - auto& document = verify_cast(relevant_global_object(*this)).associated_document(); + auto& document = as(relevant_global_object(*this)).associated_document(); // 2. If document is not fully active, then return an early error result for an "InvalidStateError" DOMException. if (!document.is_fully_active()) @@ -957,7 +957,7 @@ bool Navigation::inner_navigate_event_firing_algorithm( auto api_method_tracker = m_ongoing_api_method_tracker; // 7. Let navigable be navigation's relevant global object's navigable. - auto& relevant_global_object = verify_cast(Web::HTML::relevant_global_object(*this)); + auto& relevant_global_object = as(Web::HTML::relevant_global_object(*this)); auto navigable = relevant_global_object.navigable(); // 8. Let document be navigation's relevant global object's associated Document. @@ -1157,7 +1157,7 @@ bool Navigation::inner_navigate_event_firing_algorithm( // FIXME: Spec issue: Event's relevant global objects' *associated document* // 1. If event's relevant global object is not fully active, then abort these steps. - auto& relevant_global_object = verify_cast(HTML::relevant_global_object(*event)); + auto& relevant_global_object = as(HTML::relevant_global_object(*event)); auto& realm = event->realm(); if (!relevant_global_object.associated_document().is_fully_active()) return; @@ -1193,7 +1193,7 @@ bool Navigation::inner_navigate_event_firing_algorithm( [event, this, api_method_tracker](JS::Value rejection_reason) -> void { // FIXME: Spec issue: Event's relevant global objects' *associated document* // 1. If event's relevant global object is not fully active, then abort these steps. - auto& relevant_global_object = verify_cast(HTML::relevant_global_object(*event)); + auto& relevant_global_object = as(HTML::relevant_global_object(*event)); auto& realm = event->realm(); if (!relevant_global_object.associated_document().is_fully_active()) return; @@ -1291,7 +1291,7 @@ bool Navigation::fire_a_traverse_navigate_event(GC::Ref des // 8. Set destination's is same document to true if destinationSHE's document is equal to // navigation's relevant global object's associated Document; otherwise false. - destination->set_is_same_document(destination_she->document() == &verify_cast(relevant_global_object(*this)).associated_document()); + destination->set_is_same_document(destination_she->document() == &as(relevant_global_object(*this)).associated_document()); // 9. Return the result of performing the inner navigate event firing algorithm given navigation, "traverse", event, destination, userInvolvement, null, and null. // AD-HOC: We don't pass the event, but we do pass the classic_history_api state at the end to be set later diff --git a/Libraries/LibWeb/HTML/NavigationHistoryEntry.cpp b/Libraries/LibWeb/HTML/NavigationHistoryEntry.cpp index cb3dda64865..986fe8c2ad0 100644 --- a/Libraries/LibWeb/HTML/NavigationHistoryEntry.cpp +++ b/Libraries/LibWeb/HTML/NavigationHistoryEntry.cpp @@ -48,7 +48,7 @@ Optional NavigationHistoryEntry::url() const { // The url getter steps are: // 1. Let document be this's relevant global object's associated Document. - auto& document = verify_cast(relevant_global_object(*this)).associated_document(); + auto& document = as(relevant_global_object(*this)).associated_document(); // 2. If document is not fully active, then return the empty string. if (!document.is_fully_active()) @@ -73,7 +73,7 @@ String NavigationHistoryEntry::key() const { // The key of a NavigationHistoryEntry nhe is given by the return value of the following algorithm: // 1. If nhe's relevant global object's associated Document is not fully active, then return the empty string. - auto& associated_document = verify_cast(relevant_global_object(*this)).associated_document(); + auto& associated_document = as(relevant_global_object(*this)).associated_document(); if (!associated_document.is_fully_active()) return {}; @@ -86,7 +86,7 @@ String NavigationHistoryEntry::id() const { // The ID of a NavigationHistoryEntry nhe is given by the return value of the following algorithm: // 1. If nhe's relevant global object's associated Document is not fully active, then return the empty string. - auto& associated_document = verify_cast(relevant_global_object(*this)).associated_document(); + auto& associated_document = as(relevant_global_object(*this)).associated_document(); if (!associated_document.is_fully_active()) return {}; @@ -99,7 +99,7 @@ i64 NavigationHistoryEntry::index() const { // The index of a NavigationHistoryEntry nhe is given by the return value of the following algorithm: // 1. If nhe's relevant global object's associated Document is not fully active, then return −1. - auto& this_relevant_global_object = verify_cast(relevant_global_object(*this)); + auto& this_relevant_global_object = as(relevant_global_object(*this)); if (!this_relevant_global_object.associated_document().is_fully_active()) return -1; @@ -113,7 +113,7 @@ bool NavigationHistoryEntry::same_document() const { // The sameDocument getter steps are: // 1. Let document be this's relevant global object's associated Document. - auto& document = verify_cast(relevant_global_object(*this)).associated_document(); + auto& document = as(relevant_global_object(*this)).associated_document(); // 2. If document is not fully active, then return false. if (!document.is_fully_active()) @@ -128,7 +128,7 @@ WebIDL::ExceptionOr NavigationHistoryEntry::get_state() { // The getState() method steps are: // 1. If this's relevant global object's associated Document is not fully active, then return undefined. - auto& associated_document = verify_cast(relevant_global_object(*this)).associated_document(); + auto& associated_document = as(relevant_global_object(*this)).associated_document(); if (!associated_document.is_fully_active()) return JS::js_undefined(); diff --git a/Libraries/LibWeb/HTML/Navigator.cpp b/Libraries/LibWeb/HTML/Navigator.cpp index eaef3f45130..a418e3c59c1 100644 --- a/Libraries/LibWeb/HTML/Navigator.cpp +++ b/Libraries/LibWeb/HTML/Navigator.cpp @@ -45,7 +45,7 @@ bool Navigator::pdf_viewer_enabled() const { // The NavigatorPlugins mixin's pdfViewerEnabled getter steps are to return the user agent's PDF viewer supported. // NOTE: The NavigatorPlugins mixin should only be exposed on the Window object. - auto const& window = verify_cast(HTML::current_principal_global_object()); + auto const& window = as(HTML::current_principal_global_object()); return window.page().pdf_viewer_supported(); } @@ -55,7 +55,7 @@ bool Navigator::webdriver() const // Returns true if webdriver-active flag is set, false otherwise. // NOTE: The NavigatorAutomationInformation interface should not be exposed on WorkerNavigator. - auto const& window = verify_cast(HTML::current_principal_global_object()); + auto const& window = as(HTML::current_principal_global_object()); return window.page().is_webdriver_active(); } diff --git a/Libraries/LibWeb/HTML/NavigatorBeacon.cpp b/Libraries/LibWeb/HTML/NavigatorBeacon.cpp index 44442f993b5..b5059a6e6c0 100644 --- a/Libraries/LibWeb/HTML/NavigatorBeacon.cpp +++ b/Libraries/LibWeb/HTML/NavigatorBeacon.cpp @@ -19,7 +19,7 @@ namespace Web::HTML { // https://w3c.github.io/beacon/#sendbeacon-method WebIDL::ExceptionOr NavigatorBeaconMixin::send_beacon(String const& url, Optional const& data) { - auto& navigator = verify_cast(*this); + auto& navigator = as(*this); auto& realm = navigator.realm(); auto& vm = realm.vm(); auto& relevant_settings_object = HTML::relevant_settings_object(navigator); diff --git a/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp b/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp index 7b00353e93f..ac0c598cace 100644 --- a/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp +++ b/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp @@ -355,7 +355,7 @@ void HTMLParser::the_end(GC::Ref document, GC::Ptr pa return; // 3. Let window be the Document's relevant global object. - auto& window = verify_cast(relevant_global_object(*document)); + auto& window = as(relevant_global_object(*document)); // 4. Set the Document's load timing info's load event start time to the current high resolution time given window. document->load_timing_info().load_event_start_time = HighResolutionTime::current_high_resolution_time(window); @@ -689,7 +689,7 @@ HTMLParser::AdjustedInsertionLocation HTMLParser::find_appropriate_place_for_ins // then: let adjusted insertion location be inside last template's template contents, after its last child (if any), and abort these steps. // NOTE: This returns the template content, so no need to check the parent is a template. - return { verify_cast(*last_template.element).content().ptr(), nullptr }; + return { as(*last_template.element).content().ptr(), nullptr }; } // 4. If there is no last table, then let adjusted insertion location be inside the first element in the stack of open elements (the html element), // after its last child (if any), and abort these steps. (fragment case) @@ -861,7 +861,7 @@ void HTMLParser::handle_before_head(HTMLToken& token) if (token.is_start_tag() && token.tag_name() == HTML::TagNames::head) { auto element = insert_html_element(token); - m_head_element = verify_cast(*element); + m_head_element = as(*element); m_insertion_mode = InsertionMode::InHead; return; } @@ -876,7 +876,7 @@ void HTMLParser::handle_before_head(HTMLToken& token) } AnythingElse: - m_head_element = verify_cast(*insert_html_element(HTMLToken::make_start_tag(HTML::TagNames::head))); + m_head_element = as(*insert_html_element(HTMLToken::make_start_tag(HTML::TagNames::head))); m_insertion_mode = InsertionMode::InHead; process_using_the_rules_for(InsertionMode::InHead, token); return; @@ -947,7 +947,7 @@ void HTMLParser::handle_in_head(HTMLToken& token) if (token.is_start_tag() && token.tag_name() == HTML::TagNames::script) { auto adjusted_insertion_location = find_appropriate_place_for_inserting_node(); auto element = create_element_for(token, Namespace::HTML, *adjusted_insertion_location.parent); - auto& script_element = verify_cast(*element); + auto& script_element = as(*element); script_element.set_parser_document(Badge {}, document()); script_element.set_force_async(Badge {}, false); script_element.set_source_line_number({}, token.start_position().line + 1); // FIXME: This +1 is incorrect for script tags whose script does not start on a new line @@ -1072,7 +1072,7 @@ void HTMLParser::handle_in_head(HTMLToken& token) shadow.set_declarative(true); // 4. Set template's template contents property to shadow. - verify_cast(*template_).set_template_contents(shadow); + as(*template_).set_template_contents(shadow); // 5. Set shadow's available to element internals to true. shadow.set_available_to_element_internals(true); @@ -2032,7 +2032,7 @@ void HTMLParser::handle_in_body(HTMLToken& token) // Insert an HTML element for the token, and, if there is no template element on the stack of open elements, set the form element pointer to point to the element created. auto element = insert_html_element(token); if (!m_stack_of_open_elements.contains_template_element()) - m_form_element = verify_cast(*element); + m_form_element = as(*element); return; } @@ -2959,7 +2959,7 @@ void HTMLParser::handle_text(HTMLToken& token) if (token.is_end_of_file()) { log_parse_error(); if (current_node()->local_name() == HTML::TagNames::script) - verify_cast(*current_node()).set_already_started(Badge {}, true); + as(*current_node()).set_already_started(Badge {}, true); (void)m_stack_of_open_elements.pop(); m_insertion_mode = m_original_insertion_mode; process_using_the_rules_for(m_insertion_mode, token); @@ -2980,7 +2980,7 @@ void HTMLParser::handle_text(HTMLToken& token) perform_a_microtask_checkpoint(); // Let script be the current node (which will be a script element). - GC::Ref script = verify_cast(*current_node()); + GC::Ref script = as(*current_node()); // Pop the current node off the stack of open elements. (void)m_stack_of_open_elements.pop(); @@ -3566,7 +3566,7 @@ void HTMLParser::handle_in_table(HTMLToken& token) // Otherwise: // Insert an HTML element for the token, and set the form element pointer to point to the element created. - m_form_element = verify_cast(*insert_html_element(token)); + m_form_element = as(*insert_html_element(token)); // Pop that form element off the stack of open elements. (void)m_stack_of_open_elements.pop(); @@ -4257,7 +4257,7 @@ void HTMLParser::process_using_the_rules_for_foreign_content(HTMLToken& token) // -> If the token's tag name is "script", and the new current node is in the SVG namespace if (token.tag_name() == SVG::TagNames::script && current_node()->namespace_uri() == Namespace::SVG) { - auto& script_element = verify_cast(*current_node()); + auto& script_element = as(*current_node()); script_element.set_source_line_number({}, token.start_position().line + 1); // FIXME: This +1 is incorrect for script tags whose script does not start on a new line // Acknowledge the token's self-closing flag, and then act as described in the steps for a "script" end tag below. @@ -4279,7 +4279,7 @@ void HTMLParser::process_using_the_rules_for_foreign_content(HTMLToken& token) if (token.is_end_tag() && current_node()->namespace_uri() == Namespace::SVG && current_node()->local_name() == SVG::TagNames::script) { ScriptEndTag: // Pop the current node off the stack of open elements. - auto& script_element = verify_cast(*m_stack_of_open_elements.pop()); + auto& script_element = as(*m_stack_of_open_elements.pop()); // Let the old insertion point have the same value as the current insertion point. m_tokenizer.store_insertion_point(); // Let the insertion point be just before the next input character. @@ -4709,7 +4709,7 @@ String HTMLParser::serialize_html_fragment(DOM::Node const& node, SerializableSh }; if (fragment_serialization_mode == DOM::FragmentSerializationMode::Outer) { - serialize_element(verify_cast(node)); + serialize_element(as(node)); return builder.to_string_without_validation(); } @@ -4718,7 +4718,7 @@ String HTMLParser::serialize_html_fragment(DOM::Node const& node, SerializableSh GC::Ref actual_node = node; if (is(node)) { - auto const& element = verify_cast(node); + auto const& element = as(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) @@ -4728,7 +4728,7 @@ String HTMLParser::serialize_html_fragment(DOM::Node const& node, SerializableSh // 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) if (is(element)) - actual_node = verify_cast(element).content(); + actual_node = as(element).content(); // 4. If current node is a shadow host, then: if (element.is_shadow_host()) { @@ -4783,18 +4783,18 @@ String HTMLParser::serialize_html_fragment(DOM::Node const& node, SerializableSh if (is(current_node)) { // -> If current node is an Element - auto& element = verify_cast(current_node); + auto& element = as(current_node); serialize_element(element); return IterationDecision::Continue; } if (is(current_node)) { // -> If current node is a Text node - auto& text_node = verify_cast(current_node); + auto& text_node = as(current_node); auto* parent = current_node.parent(); if (is(parent)) { - auto& parent_element = verify_cast(*parent); + auto& parent_element = as(*parent); // If the parent of current node is a style, script, xmp, iframe, noembed, noframes, or plaintext element, // or if the parent of current node is a noscript element and scripting is enabled for the node, then append the value of current node's data IDL attribute literally. @@ -4811,7 +4811,7 @@ String HTMLParser::serialize_html_fragment(DOM::Node const& node, SerializableSh if (is(current_node)) { // -> If current node is a Comment - auto& comment_node = verify_cast(current_node); + auto& comment_node = as(current_node); // Append the literal string "" (U+002D HYPHEN-MINUS, U+002D HYPHEN-MINUS, U+003E GREATER-THAN SIGN). @@ -4823,7 +4823,7 @@ String HTMLParser::serialize_html_fragment(DOM::Node const& node, SerializableSh if (is(current_node)) { // -> If current node is a ProcessingInstruction - auto& processing_instruction_node = verify_cast(current_node); + auto& processing_instruction_node = as(current_node); // Append the literal string "). @@ -4837,7 +4837,7 @@ String HTMLParser::serialize_html_fragment(DOM::Node const& node, SerializableSh if (is(current_node)) { // -> If current node is a DocumentType - auto& document_type_node = verify_cast(current_node); + auto& document_type_node = as(current_node); // Append the literal string " Plugin::supported_property_names() const { // The Plugin interface supports named properties. If the user agent's PDF viewer supported is true, then they are the PDF viewer mime types. Otherwise, they are the empty list. - auto const& window = verify_cast(HTML::relevant_global_object(*this)); + auto const& window = as(HTML::relevant_global_object(*this)); if (!window.page().pdf_viewer_supported()) return {}; @@ -78,7 +78,7 @@ Vector Plugin::supported_property_names() const size_t Plugin::length() const { // The Plugin interface's length getter steps are to return this's relevant global object's PDF viewer mime type objects's size. - auto& window = verify_cast(HTML::relevant_global_object(*this)); + auto& window = as(HTML::relevant_global_object(*this)); return window.pdf_viewer_mime_type_objects().size(); } @@ -86,7 +86,7 @@ size_t Plugin::length() const GC::Ptr Plugin::item(u32 index) const { // 1. Let mimeTypes be this's relevant global object's PDF viewer mime type objects. - auto& window = verify_cast(HTML::relevant_global_object(*this)); + auto& window = as(HTML::relevant_global_object(*this)); auto mime_types = window.pdf_viewer_mime_type_objects(); // 2. If index < mimeType's size, then return mimeTypes[index]. @@ -100,7 +100,7 @@ GC::Ptr Plugin::item(u32 index) const GC::Ptr Plugin::named_item(FlyString const& name) const { // 1. For each MimeType mimeType of this's relevant global object's PDF viewer mime type objects: if mimeType's type is name, then return mimeType. - auto& window = verify_cast(HTML::relevant_global_object(*this)); + auto& window = as(HTML::relevant_global_object(*this)); auto mime_types = window.pdf_viewer_mime_type_objects(); for (auto& mime_type : mime_types) { diff --git a/Libraries/LibWeb/HTML/PluginArray.cpp b/Libraries/LibWeb/HTML/PluginArray.cpp index 133d2c69711..5479bbb4582 100644 --- a/Libraries/LibWeb/HTML/PluginArray.cpp +++ b/Libraries/LibWeb/HTML/PluginArray.cpp @@ -43,7 +43,7 @@ void PluginArray::refresh() const Vector PluginArray::supported_property_names() const { // The PluginArray interface supports named properties. If the user agent's PDF viewer supported is true, then they are the PDF viewer plugin names. Otherwise, they are the empty list. - auto const& window = verify_cast(HTML::relevant_global_object(*this)); + auto const& window = as(HTML::relevant_global_object(*this)); if (!window.page().pdf_viewer_supported()) return {}; @@ -63,7 +63,7 @@ Vector PluginArray::supported_property_names() const size_t PluginArray::length() const { // The PluginArray interface's length getter steps are to return this's relevant global object's PDF viewer plugin objects's size. - auto& window = verify_cast(HTML::relevant_global_object(*this)); + auto& window = as(HTML::relevant_global_object(*this)); return window.pdf_viewer_plugin_objects().size(); } @@ -71,7 +71,7 @@ size_t PluginArray::length() const GC::Ptr PluginArray::item(u32 index) const { // 1. Let plugins be this's relevant global object's PDF viewer plugin objects. - auto& window = verify_cast(HTML::relevant_global_object(*this)); + auto& window = as(HTML::relevant_global_object(*this)); auto plugins = window.pdf_viewer_plugin_objects(); // 2. If index < plugins's size, then return plugins[index]. @@ -86,7 +86,7 @@ GC::Ptr PluginArray::item(u32 index) const GC::Ptr PluginArray::named_item(FlyString const& name) const { // 1. For each Plugin plugin of this's relevant global object's PDF viewer plugin objects: if plugin's name is name, then return plugin. - auto& window = verify_cast(HTML::relevant_global_object(*this)); + auto& window = as(HTML::relevant_global_object(*this)); auto plugins = window.pdf_viewer_plugin_objects(); for (auto& plugin : plugins) { diff --git a/Libraries/LibWeb/HTML/RadioNodeList.cpp b/Libraries/LibWeb/HTML/RadioNodeList.cpp index 4459cac6117..23f16f855b8 100644 --- a/Libraries/LibWeb/HTML/RadioNodeList.cpp +++ b/Libraries/LibWeb/HTML/RadioNodeList.cpp @@ -37,7 +37,7 @@ static HTMLInputElement const* radio_button(DOM::Node const& node) if (!is(node)) return nullptr; - auto const& input_element = verify_cast(node); + auto const& input_element = as(node); if (input_element.type_state() != HTMLInputElement::TypeAttributeState::RadioButton) return nullptr; @@ -49,7 +49,7 @@ FlyString RadioNodeList::value() const { // 1. Let element be the first element in tree order represented by the RadioNodeList object that is an input element whose type // attribute is in the Radio Button state and whose checkedness is true. Otherwise, let it be null. - auto* element = verify_cast(first_matching([](DOM::Node const& node) -> bool { + auto* element = as(first_matching([](DOM::Node const& node) -> bool { auto const* button = radio_button(node); if (!button) return false; @@ -74,7 +74,7 @@ void RadioNodeList::set_value(FlyString const& value) // that is an input element whose type attribute is in the Radio Button state and whose value content attribute is either absent, // or present and equal to the new value, if any. If no such element exists, then instead let element be null. if (value == "on"sv) { - element = verify_cast(first_matching([&value](auto const& node) { + element = as(first_matching([&value](auto const& node) { auto const* button = radio_button(node); if (!button) return false; @@ -87,7 +87,7 @@ void RadioNodeList::set_value(FlyString const& value) // type attribute is in the Radio Button state and whose value content attribute is present and equal to the new value, if any. If // no such element exists, then instead let element be null. else { - element = verify_cast(first_matching([&value](auto const& node) { + element = as(first_matching([&value](auto const& node) { auto const* button = radio_button(node); if (!button) return false; diff --git a/Libraries/LibWeb/HTML/Scripting/Agent.cpp b/Libraries/LibWeb/HTML/Scripting/Agent.cpp index d148f7ff718..a08c961f749 100644 --- a/Libraries/LibWeb/HTML/Scripting/Agent.cpp +++ b/Libraries/LibWeb/HTML/Scripting/Agent.cpp @@ -15,7 +15,7 @@ Agent& relevant_agent(JS::Object const& object) { // The relevant agent for a platform object platformObject is platformObject's relevant Realm's agent. // Spec Note: This pointer is not yet defined in the JavaScript specification; see tc39/ecma262#1357. - return verify_cast(relevant_realm(object).vm().custom_data())->agent; + return as(relevant_realm(object).vm().custom_data())->agent; } } diff --git a/Libraries/LibWeb/HTML/Scripting/Environments.cpp b/Libraries/LibWeb/HTML/Scripting/Environments.cpp index 06634c6de90..6f7a0c8784a 100644 --- a/Libraries/LibWeb/HTML/Scripting/Environments.cpp +++ b/Libraries/LibWeb/HTML/Scripting/Environments.cpp @@ -112,7 +112,7 @@ EventLoop& EnvironmentSettingsObject::responsible_event_loop() RunScriptDecision can_run_script(JS::Realm const& realm) { // 1. If the global object specified by realm is a Window object whose Document object is not fully active, then return "do not run". - if (is(realm.global_object()) && !verify_cast(realm.global_object()).associated_document().is_fully_active()) + if (is(realm.global_object()) && !as(realm.global_object()).associated_document().is_fully_active()) return RunScriptDecision::DoNotRun; // 2. If scripting is disabled for realm, then return "do not run". @@ -146,7 +146,7 @@ JS::ExecutionContext const& execution_context_of_realm(JS::Realm const& realm) // 2. Assert: realm is a synthetic realm. // 3. Return the execution context of the synthetic realm settings object of realm. - return *verify_cast(*realm.host_defined()).synthetic_realm_settings.execution_context; + return *as(*realm.host_defined()).synthetic_realm_settings.execution_context; } // https://html.spec.whatwg.org/multipage/webappapis.html#clean-up-after-running-script @@ -276,7 +276,7 @@ bool is_scripting_enabled(JS::Realm const& realm) return true; // The user has not disabled scripting for realm at this time. (User agents may provide users with the option to disable scripting globally, or in a finer-grained manner, e.g., on a per-origin basis, down to the level of individual realms.) - auto const& document = verify_cast(realm.global_object()).associated_document(); + auto const& document = as(realm.global_object()).associated_document(); if (!document.page().is_scripting_enabled()) return false; @@ -328,7 +328,7 @@ void add_module_to_resolved_module_set(JS::Realm& realm, String const& serialize }; // 4. Append record to global's resolved module set. - return verify_cast(global).append_resolved_module(move(resolution)); + return as(global).append_resolved_module(move(resolution)); } // https://whatpr.org/html/9893/webappapis.html#concept-realm-module-map @@ -342,7 +342,7 @@ ModuleMap& module_map_of_realm(JS::Realm& realm) // 2. Assert: realm is a synthetic realm. // 3. Return the module map of the synthetic realm settings object of realm. - return *verify_cast(*realm.host_defined()).synthetic_realm_settings.module_map; + return *as(*realm.host_defined()).synthetic_realm_settings.module_map; } // https://html.spec.whatwg.org/multipage/webappapis.html#concept-incumbent-realm diff --git a/Libraries/LibWeb/HTML/Scripting/Fetching.cpp b/Libraries/LibWeb/HTML/Scripting/Fetching.cpp index deecf0de04b..a9456a57836 100644 --- a/Libraries/LibWeb/HTML/Scripting/Fetching.cpp +++ b/Libraries/LibWeb/HTML/Scripting/Fetching.cpp @@ -118,7 +118,7 @@ WebIDL::ExceptionOr resolve_module_specifier(Optional referri // 5. If realm's global object implements Window, then set importMap to settingsObject's global object's import map. if (is(realm->global_object())) - import_map = verify_cast(realm->global_object()).import_map(); + import_map = as(realm->global_object()).import_map(); // 6. Let serializedBaseURL be baseURL, serialized. auto serialized_base_url = base_url->serialize(); @@ -321,7 +321,7 @@ ScriptFetchOptions get_descendant_script_fetch_options(ScriptFetchOptions const& String resolve_a_module_integrity_metadata(const URL::URL& url, EnvironmentSettingsObject& settings_object) { // 1. Let map be settingsObject's global object's import map. - auto map = verify_cast(settings_object.global_object()).import_map(); + auto map = as(settings_object.global_object()).import_map(); // 2. If map's integrity[url] does not exist, then return the empty string. // 3. Return map's integrity[url]. @@ -587,7 +587,7 @@ WebIDL::ExceptionOr fetch_worklet_module_worker_script_graph(URL::URL cons } // 2. Fetch the descendants of and link result given fetchClient, destination, and onComplete. If performFetch was given, pass it along as well. - fetch_descendants_of_and_link_a_module_script(realm, verify_cast(*result), fetch_client, destination, move(perform_fetch), on_complete); + fetch_descendants_of_and_link_a_module_script(realm, as(*result), fetch_client, destination, move(perform_fetch), on_complete); }); // 2. Fetch a single module script given url, fetchClient, destination, options, settingsObject's realm, "client", true, @@ -621,7 +621,7 @@ void fetch_internal_module_script_graph(JS::Realm& realm, JS::ModuleRequest cons } // 2. Fetch the descendants of result given fetch client settings object, destination, visited set, and with onComplete. If performFetch was given, pass it along as well. - auto& module_script = verify_cast(*result); + auto& module_script = as(*result); fetch_descendants_of_a_module_script(realm, module_script, fetch_client_settings_object, destination, visited_set, perform_fetch, on_complete); }); @@ -873,7 +873,7 @@ void fetch_external_module_script_graph(JS::Realm& realm, URL::URL const& url, E } // 2. Fetch the descendants of and link result given settingsObject, "script", and onComplete. - auto& module_script = verify_cast(*result); + auto& module_script = as(*result); fetch_descendants_of_and_link_a_module_script(realm, module_script, settings_object, Fetch::Infrastructure::Request::Destination::Script, nullptr, on_complete); }); diff --git a/Libraries/LibWeb/HTML/Scripting/WindowEnvironmentSettingsObject.cpp b/Libraries/LibWeb/HTML/Scripting/WindowEnvironmentSettingsObject.cpp index ee6ad2f327a..58de96d361e 100644 --- a/Libraries/LibWeb/HTML/Scripting/WindowEnvironmentSettingsObject.cpp +++ b/Libraries/LibWeb/HTML/Scripting/WindowEnvironmentSettingsObject.cpp @@ -36,7 +36,7 @@ void WindowEnvironmentSettingsObject::setup(Page& page, URL::URL const& creation VERIFY(realm); // 2. Let window be realm's global object. - auto& window = verify_cast(realm->global_object()); + auto& window = as(realm->global_object()); // 3. Let settings object be a new environment settings object whose algorithms are defined as follows: // NOTE: See the functions defined for this class. diff --git a/Libraries/LibWeb/HTML/Scripting/WorkerEnvironmentSettingsObject.cpp b/Libraries/LibWeb/HTML/Scripting/WorkerEnvironmentSettingsObject.cpp index d438b70a20f..b23596ed527 100644 --- a/Libraries/LibWeb/HTML/Scripting/WorkerEnvironmentSettingsObject.cpp +++ b/Libraries/LibWeb/HTML/Scripting/WorkerEnvironmentSettingsObject.cpp @@ -28,7 +28,7 @@ GC::Ref WorkerEnvironmentSettingsObject::setup( VERIFY(realm); // 3. Let worker global scope be realm's global object. - auto& worker = verify_cast(realm->global_object()); + auto& worker = as(realm->global_object()); // 4. Let settings object be a new environment settings object whose algorithms are defined as follows: // NOTE: See the functions defined for this class. diff --git a/Libraries/LibWeb/HTML/Storage.cpp b/Libraries/LibWeb/HTML/Storage.cpp index 126755f6a53..6eb9e63352b 100644 --- a/Libraries/LibWeb/HTML/Storage.cpp +++ b/Libraries/LibWeb/HTML/Storage.cpp @@ -187,7 +187,7 @@ void Storage::broadcast(Optional const& key, Optional const& old // 1. Let thisDocument be storage's relevant global object's associated Document. auto& relevant_global = relevant_global_object(*this); - auto const& this_document = verify_cast(relevant_global).associated_document(); + auto const& this_document = as(relevant_global).associated_document(); // 2. Let url be the serialization of thisDocument's URL. auto url = this_document.url().serialize(); @@ -235,7 +235,7 @@ void Storage::broadcast(Optional const& key, Optional const& old init.new_value = move(new_value); init.url = move(url); init.storage_area = remote_storage; - verify_cast(relevant_global_object(remote_storage)).dispatch_event(StorageEvent::create(realm, EventNames::storage, init)); + as(relevant_global_object(remote_storage)).dispatch_event(StorageEvent::create(realm, EventNames::storage, init)); })); } } diff --git a/Libraries/LibWeb/HTML/StructuredSerialize.cpp b/Libraries/LibWeb/HTML/StructuredSerialize.cpp index e0c6d6f634d..ba2eefb5c53 100644 --- a/Libraries/LibWeb/HTML/StructuredSerialize.cpp +++ b/Libraries/LibWeb/HTML/StructuredSerialize.cpp @@ -854,7 +854,7 @@ public: case ValueTag::ArrayBufferView: { auto* realm = m_vm.current_realm(); auto array_buffer_value = TRY(deserialize()); - auto& array_buffer = verify_cast(array_buffer_value.as_object()); + auto& array_buffer = as(array_buffer_value.as_object()); auto constructor_name = TRY(deserialize_string(m_vm, m_serialized, m_position)); u32 byte_length = deserialize_primitive_type(m_serialized, m_position); u32 byte_offset = deserialize_primitive_type(m_serialized, m_position); diff --git a/Libraries/LibWeb/HTML/UserActivation.cpp b/Libraries/LibWeb/HTML/UserActivation.cpp index 83cf2d87cbd..6f96a6bf350 100644 --- a/Libraries/LibWeb/HTML/UserActivation.cpp +++ b/Libraries/LibWeb/HTML/UserActivation.cpp @@ -33,14 +33,14 @@ void UserActivation::initialize(JS::Realm& realm) bool UserActivation::has_been_active() const { // The hasBeenActive getter steps are to return true if this's relevant global object has sticky activation, and false otherwise. - return verify_cast(relevant_global_object(*this)).has_sticky_activation(); + return as(relevant_global_object(*this)).has_sticky_activation(); } // https://html.spec.whatwg.org/multipage/interaction.html#dom-useractivation-isactive bool UserActivation::is_active() const { // The isActive getter steps are to return true if this's relevant global object has transient activation, and false otherwise. - return verify_cast(relevant_global_object(*this)).has_transient_activation(); + return as(relevant_global_object(*this)).has_transient_activation(); } } diff --git a/Libraries/LibWeb/HTML/VideoTrack.cpp b/Libraries/LibWeb/HTML/VideoTrack.cpp index dcea273efd3..cd128ee0555 100644 --- a/Libraries/LibWeb/HTML/VideoTrack.cpp +++ b/Libraries/LibWeb/HTML/VideoTrack.cpp @@ -35,7 +35,7 @@ VideoTrack::VideoTrack(JS::Realm& realm, GC::Ref media_element auto playback_position = static_cast(position().to_milliseconds()) / 1000.0; if (is(*m_media_element)) - verify_cast(*m_media_element).set_current_frame({}, move(frame), playback_position); + as(*m_media_element).set_current_frame({}, move(frame), playback_position); m_media_element->set_current_playback_position(playback_position); }; @@ -169,7 +169,7 @@ void VideoTrack::set_selected(bool selected) // AD-HOC: Inform the video element node that we have (un)selected a video track for layout. if (is(*m_media_element)) { - auto& video_element = verify_cast(*m_media_element); + auto& video_element = as(*m_media_element); video_element.set_video_track(m_selected ? this : nullptr); } } diff --git a/Libraries/LibWeb/HTML/Window.cpp b/Libraries/LibWeb/HTML/Window.cpp index 839d8f72453..46852537be4 100644 --- a/Libraries/LibWeb/HTML/Window.cpp +++ b/Libraries/LibWeb/HTML/Window.cpp @@ -191,7 +191,7 @@ WebIDL::ExceptionOr Window::window_open_steps_internal(Str return OpenedWindow {}; // 2. Let sourceDocument be the entry global object's associated Document. - auto& source_document = verify_cast(entry_global_object()).associated_document(); + auto& source_document = as(entry_global_object()).associated_document(); // 3. Let urlRecord be null. Optional url_record; @@ -758,14 +758,14 @@ JS::ThrowCompletionOr Window::internal_set_prototype_of(JS::Object* protot GC::Ref Window::window() const { // The window, frames, and self getter steps are to return this's relevant realm.[[GlobalEnv]].[[GlobalThisValue]]. - return verify_cast(relevant_realm(*this).global_environment().global_this_value()); + return as(relevant_realm(*this).global_environment().global_this_value()); } // https://html.spec.whatwg.org/multipage/window-object.html#dom-self GC::Ref Window::self() const { // The window, frames, and self getter steps are to return this's relevant realm.[[GlobalEnv]].[[GlobalThisValue]]. - return verify_cast(relevant_realm(*this).global_environment().global_this_value()); + return as(relevant_realm(*this).global_environment().global_this_value()); } // https://html.spec.whatwg.org/multipage/nav-history-apis.html#dom-document-2 @@ -824,7 +824,7 @@ void Window::close() // 5. Let sourceSnapshotParams be the result of snapshotting source snapshot params given thisTraversable's active document. auto source_snapshot_params = traversable->active_document()->snapshot_source_snapshot_params(); - auto& incumbent_global_object = verify_cast(HTML::incumbent_global_object()); + auto& incumbent_global_object = as(HTML::incumbent_global_object()); // 6. If all the following are true: if ( @@ -843,7 +843,7 @@ void Window::close() // 2. Queue a task on the DOM manipulation task source to definitely close thisTraversable. HTML::queue_global_task(HTML::Task::Source::DOMManipulation, incumbent_global_object, GC::create_function(heap(), [traversable] { - verify_cast(*traversable).definitely_close_top_level_traversable(); + as(*traversable).definitely_close_top_level_traversable(); })); } } @@ -929,7 +929,7 @@ void Window::blur() GC::Ref Window::frames() const { // The window, frames, and self getter steps are to return this's relevant realm.[[GlobalEnv]].[[GlobalThisValue]]. - return verify_cast(relevant_realm(*this).global_environment().global_this_value()); + return as(relevant_realm(*this).global_environment().global_this_value()); } // https://html.spec.whatwg.org/multipage/window-object.html#dom-length @@ -1133,7 +1133,7 @@ WebIDL::ExceptionOr Window::window_post_message_steps(JS::Value message, W auto origin = incumbent_settings.origin().serialize(); // 3. Let source be the WindowProxy object corresponding to incumbentSettings's global object (a Window object). - auto& source = verify_cast(incumbent_settings.realm().global_environment().global_this_value()); + auto& source = as(incumbent_settings.realm().global_environment().global_this_value()); // 4. Let deserializeRecord be StructuredDeserializeWithTransfer(serializeWithTransferResult, targetRealm). auto temporary_execution_context = TemporaryExecutionContext { target_realm, TemporaryExecutionContext::CallbacksEnabled::Yes }; @@ -1161,7 +1161,7 @@ WebIDL::ExceptionOr Window::window_post_message_steps(JS::Value message, W Vector> new_ports; for (auto const& object : deserialize_record.transferred_values) { if (is(*object)) { - new_ports.append(verify_cast(*object)); + new_ports.append(as(*object)); } } diff --git a/Libraries/LibWeb/HTML/WindowOrWorkerGlobalScope.cpp b/Libraries/LibWeb/HTML/WindowOrWorkerGlobalScope.cpp index 868536230e6..3da4e18f926 100644 --- a/Libraries/LibWeb/HTML/WindowOrWorkerGlobalScope.cpp +++ b/Libraries/LibWeb/HTML/WindowOrWorkerGlobalScope.cpp @@ -807,7 +807,7 @@ void WindowOrWorkerGlobalScopeMixin::report_an_exception(JS::Value exception, Om // 0, and errorInfo[colno] to 0. script_or_module.visit( [&](GC::Ref const& js_script) { - if (verify_cast(js_script->host_defined())->muted_errors() == ClassicScript::MutedErrors::Yes) { + if (as(js_script->host_defined())->muted_errors() == ClassicScript::MutedErrors::Yes) { error_info.error = JS::js_null(); error_info.message = "Script error."_string; error_info.filename = String {}; diff --git a/Libraries/LibWeb/HTML/WindowProxy.cpp b/Libraries/LibWeb/HTML/WindowProxy.cpp index b8b21df704c..104d4da0997 100644 --- a/Libraries/LibWeb/HTML/WindowProxy.cpp +++ b/Libraries/LibWeb/HTML/WindowProxy.cpp @@ -161,7 +161,7 @@ JS::ThrowCompletionOr WindowProxy::internal_get(JS::PropertyKey const // 1. Let W be the value of the [[Window]] internal slot of this. // 2. Check if an access between two browsing contexts should be reported, given the current principal global object's browsing context, W's browsing context, P, and the current principal settings object. - check_if_access_between_two_browsing_contexts_should_be_reported(*verify_cast(current_principal_global_object()).browsing_context(), m_window->browsing_context(), property_key, current_principal_settings_object()); + check_if_access_between_two_browsing_contexts_should_be_reported(*as(current_principal_global_object()).browsing_context(), m_window->browsing_context(), property_key, current_principal_settings_object()); // 3. If IsPlatformObjectSameOrigin(W) is true, then return ? OrdinaryGet(this, P, Receiver). // NOTE: this is passed rather than W as OrdinaryGet and CrossOriginGet will invoke the [[GetOwnProperty]] internal method. @@ -182,7 +182,7 @@ JS::ThrowCompletionOr WindowProxy::internal_set(JS::PropertyKey const& pro // 1. Let W be the value of the [[Window]] internal slot of this. // 2. Check if an access between two browsing contexts should be reported, given the current principal global object's browsing context, W's browsing context, P, and the current principal settings object. - check_if_access_between_two_browsing_contexts_should_be_reported(*verify_cast(current_principal_global_object()).browsing_context(), m_window->browsing_context(), property_key, current_principal_settings_object()); + check_if_access_between_two_browsing_contexts_should_be_reported(*as(current_principal_global_object()).browsing_context(), m_window->browsing_context(), property_key, current_principal_settings_object()); // 3. If IsPlatformObjectSameOrigin(W) is true, then: if (is_platform_object_same_origin(*m_window)) { diff --git a/Libraries/LibWeb/HTML/Worker.h b/Libraries/LibWeb/HTML/Worker.h index d54ec2860b5..3470a48c7c0 100644 --- a/Libraries/LibWeb/HTML/Worker.h +++ b/Libraries/LibWeb/HTML/Worker.h @@ -29,7 +29,7 @@ public: static WebIDL::ExceptionOr> create(String const& script_url, WorkerOptions const& options, DOM::Document& document); static WebIDL::ExceptionOr> construct_impl(JS::Realm& realm, String const& script_url, WorkerOptions const& options) { - auto& window = verify_cast(realm.global_object()); + auto& window = as(realm.global_object()); return Worker::create(script_url, options, window.associated_document()); } diff --git a/Libraries/LibWeb/Internals/Inspector.cpp b/Libraries/LibWeb/Internals/Inspector.cpp index 7406b94612a..f29e6e09672 100644 --- a/Libraries/LibWeb/Internals/Inspector.cpp +++ b/Libraries/LibWeb/Internals/Inspector.cpp @@ -33,7 +33,7 @@ void Inspector::initialize(JS::Realm& realm) PageClient& Inspector::inspector_page_client() const { - return verify_cast(HTML::relevant_global_object(*this)).page().client(); + return as(HTML::relevant_global_object(*this)).page().client(); } void Inspector::inspector_loaded() diff --git a/Libraries/LibWeb/Internals/InternalAnimationTimeline.cpp b/Libraries/LibWeb/Internals/InternalAnimationTimeline.cpp index 47eb4a994af..676d4187d1b 100644 --- a/Libraries/LibWeb/Internals/InternalAnimationTimeline.cpp +++ b/Libraries/LibWeb/Internals/InternalAnimationTimeline.cpp @@ -30,7 +30,7 @@ InternalAnimationTimeline::InternalAnimationTimeline(JS::Realm& realm) { m_current_time = 0.0; - auto& document = verify_cast(HTML::relevant_global_object(*this)).associated_document(); + auto& document = as(HTML::relevant_global_object(*this)).associated_document(); document.associate_with_timeline(*this); } diff --git a/Libraries/LibWeb/Internals/Internals.cpp b/Libraries/LibWeb/Internals/Internals.cpp index 70c23046372..bf9ccc83193 100644 --- a/Libraries/LibWeb/Internals/Internals.cpp +++ b/Libraries/LibWeb/Internals/Internals.cpp @@ -40,7 +40,7 @@ void Internals::initialize(JS::Realm& realm) HTML::Window& Internals::internals_window() const { - return verify_cast(HTML::relevant_global_object(*this)); + return as(HTML::relevant_global_object(*this)); } Page& Internals::internals_page() const diff --git a/Libraries/LibWeb/IntersectionObserver/IntersectionObserver.cpp b/Libraries/LibWeb/IntersectionObserver/IntersectionObserver.cpp index 5fa8cdc7484..1b24c2fc362 100644 --- a/Libraries/LibWeb/IntersectionObserver/IntersectionObserver.cpp +++ b/Libraries/LibWeb/IntersectionObserver/IntersectionObserver.cpp @@ -251,7 +251,7 @@ Variant, GC::Root> IntersectionObserver::i } // otherwise, it is the top-level browsing context’s document node, referred to as the implicit root. - return GC::make_root(verify_cast(HTML::relevant_global_object(*this)).page().top_level_browsing_context().active_document()); + return GC::make_root(as(HTML::relevant_global_object(*this)).page().top_level_browsing_context().active_document()); } // https://www.w3.org/TR/intersection-observer/#intersectionobserver-root-intersection-rectangle diff --git a/Libraries/LibWeb/Layout/BlockFormattingContext.cpp b/Libraries/LibWeb/Layout/BlockFormattingContext.cpp index df2d00cf747..6500be890a7 100644 --- a/Libraries/LibWeb/Layout/BlockFormattingContext.cpp +++ b/Libraries/LibWeb/Layout/BlockFormattingContext.cpp @@ -81,7 +81,7 @@ void BlockFormattingContext::run(AvailableSpace const& available_space) else layout_block_level_children(root(), available_space); - auto const& fieldset_box = verify_cast(root()); + auto const& fieldset_box = as(root()); if (!(fieldset_box.has_rendered_legend())) { return; } @@ -145,7 +145,7 @@ void BlockFormattingContext::parent_context_did_dimension_child_root_box() if (m_layout_mode == LayoutMode::Normal) { // We can also layout absolutely positioned boxes within this BFC. for (auto& child : root().contained_abspos_children()) { - auto& box = verify_cast(*child); + auto& box = as(*child); auto& cb_state = m_state.get(*box.containing_block()); auto available_width = AvailableSize::make_definite(cb_state.content_width() + cb_state.padding_left + cb_state.padding_right); auto available_height = AvailableSize::make_definite(cb_state.content_height() + cb_state.padding_top + cb_state.padding_bottom); @@ -189,7 +189,7 @@ void BlockFormattingContext::compute_width(Box const& box, AvailableSpace const& if (box_is_sized_as_replaced_element(box)) { // FIXME: This should not be done *by* ReplacedBox if (is(box)) { - auto& replaced = verify_cast(box); + auto& replaced = as(box); // FIXME: This const_cast is gross. const_cast(replaced).prepare_for_replaced_layout(); } @@ -792,7 +792,7 @@ void BlockFormattingContext::layout_block_level_box(Box const& box, BlockContain } else { // This box participates in the current block container's flow. if (box.children_are_inline()) { - layout_inline_children(verify_cast(box), box_state.available_inner_space_or_constraints_from(available_space)); + layout_inline_children(as(box), box_state.available_inner_space_or_constraints_from(available_space)); } else { if (box_state.border_top > 0 || box_state.padding_top > 0) { // margin-top of block container can't collapse with it's children if it has non zero border or padding @@ -806,7 +806,7 @@ void BlockFormattingContext::layout_block_level_box(Box const& box, BlockContain }); } - layout_block_level_children(verify_cast(box), box_state.available_inner_space_or_constraints_from(available_space)); + layout_block_level_children(as(box), box_state.available_inner_space_or_constraints_from(available_space)); } } @@ -1005,7 +1005,7 @@ void BlockFormattingContext::layout_viewport(AvailableSpace const& available_spa // The root container gets the same size as the viewport, // and we call directly into the SVG layout code from here. if (root().first_child() && root().first_child()->is_svg_svg_box()) { - auto const& svg_root = verify_cast(*root().first_child()); + auto const& svg_root = as(*root().first_child()); auto content_height = m_state.get(*svg_root.containing_block()).content_height(); m_state.get_mutable(svg_root).set_content_height(content_height); auto svg_formatting_context = create_independent_formatting_context_if_needed(m_state, m_layout_mode, svg_root); @@ -1312,7 +1312,7 @@ CSSPixels BlockFormattingContext::greatest_child_width(Box const& box) const // but this one takes floats into account! CSSPixels max_width = m_left_floats.max_width + m_right_floats.max_width; if (box.children_are_inline()) { - for (auto const& line_box : m_state.get(verify_cast(box)).line_boxes) { + for (auto const& line_box : m_state.get(as(box)).line_boxes) { CSSPixels width_here = line_box.width(); CSSPixels extra_width_from_left_floats = 0; for (auto& left_float : m_left_floats.all_boxes) { diff --git a/Libraries/LibWeb/Layout/BreakNode.h b/Libraries/LibWeb/Layout/BreakNode.h index 6b7c24cfd83..a3a69225eb0 100644 --- a/Libraries/LibWeb/Layout/BreakNode.h +++ b/Libraries/LibWeb/Layout/BreakNode.h @@ -19,7 +19,7 @@ public: BreakNode(DOM::Document&, HTML::HTMLBRElement&, GC::Ref); virtual ~BreakNode() override; - const HTML::HTMLBRElement& dom_node() const { return verify_cast(*Node::dom_node()); } + const HTML::HTMLBRElement& dom_node() const { return as(*Node::dom_node()); } private: virtual bool is_break_node() const final { return true; } diff --git a/Libraries/LibWeb/Layout/FlexFormattingContext.cpp b/Libraries/LibWeb/Layout/FlexFormattingContext.cpp index ae4b3e8299c..67e31b46a4c 100644 --- a/Libraries/LibWeb/Layout/FlexFormattingContext.cpp +++ b/Libraries/LibWeb/Layout/FlexFormattingContext.cpp @@ -194,7 +194,7 @@ void FlexFormattingContext::parent_context_did_dimension_child_root_box() }); for (auto& child : flex_container().contained_abspos_children()) { - auto& box = verify_cast(*child); + auto& box = as(*child); auto& cb_state = m_state.get(*box.containing_block()); auto available_width = AvailableSize::make_definite(cb_state.content_width() + cb_state.padding_left + cb_state.padding_right); auto available_height = AvailableSize::make_definite(cb_state.content_height() + cb_state.padding_top + cb_state.padding_bottom); diff --git a/Libraries/LibWeb/Layout/FormattingContext.cpp b/Libraries/LibWeb/Layout/FormattingContext.cpp index 0df0c517882..8e35f6fc6c6 100644 --- a/Libraries/LibWeb/Layout/FormattingContext.cpp +++ b/Libraries/LibWeb/Layout/FormattingContext.cpp @@ -196,7 +196,7 @@ OwnPtr FormattingContext::create_independent_formatting_conte switch (type.value()) { case Type::Block: - return make(state, layout_mode, verify_cast(child_box), this); + return make(state, layout_mode, as(child_box), this); case Type::SVG: return make(state, layout_mode, child_box, this); case Type::Flex: @@ -1440,7 +1440,7 @@ CSSPixels FormattingContext::calculate_min_content_width(Layout::Box const& box) auto context = const_cast(this)->create_independent_formatting_context_if_needed(throwaway_state, LayoutMode::IntrinsicSizing, box); if (!context) { - context = make(throwaway_state, LayoutMode::IntrinsicSizing, verify_cast(box), nullptr); + context = make(throwaway_state, LayoutMode::IntrinsicSizing, as(box), nullptr); } auto available_width = AvailableSize::make_min_content(); @@ -1480,7 +1480,7 @@ CSSPixels FormattingContext::calculate_max_content_width(Layout::Box const& box) auto context = const_cast(this)->create_independent_formatting_context_if_needed(throwaway_state, LayoutMode::IntrinsicSizing, box); if (!context) { - context = make(throwaway_state, LayoutMode::IntrinsicSizing, verify_cast(box), nullptr); + context = make(throwaway_state, LayoutMode::IntrinsicSizing, as(box), nullptr); } auto available_width = AvailableSize::make_max_content(); @@ -1529,7 +1529,7 @@ CSSPixels FormattingContext::calculate_min_content_height(Layout::Box const& box auto context = const_cast(this)->create_independent_formatting_context_if_needed(throwaway_state, LayoutMode::IntrinsicSizing, box); if (!context) { - context = make(throwaway_state, LayoutMode::IntrinsicSizing, verify_cast(box), nullptr); + context = make(throwaway_state, LayoutMode::IntrinsicSizing, as(box), nullptr); } context->run(AvailableSpace(AvailableSize::make_definite(width), AvailableSize::make_min_content())); @@ -1573,7 +1573,7 @@ CSSPixels FormattingContext::calculate_max_content_height(Layout::Box const& box auto context = const_cast(this)->create_independent_formatting_context_if_needed(throwaway_state, LayoutMode::IntrinsicSizing, box); if (!context) { - context = make(throwaway_state, LayoutMode::IntrinsicSizing, verify_cast(box), nullptr); + context = make(throwaway_state, LayoutMode::IntrinsicSizing, as(box), nullptr); } context->run(AvailableSpace(AvailableSize::make_definite(width), AvailableSize::make_max_content())); diff --git a/Libraries/LibWeb/Layout/GridFormattingContext.cpp b/Libraries/LibWeb/Layout/GridFormattingContext.cpp index f6621cc33b5..4bbd28f707b 100644 --- a/Libraries/LibWeb/Layout/GridFormattingContext.cpp +++ b/Libraries/LibWeb/Layout/GridFormattingContext.cpp @@ -2212,7 +2212,7 @@ void GridFormattingContext::parent_context_did_dimension_child_root_box() }); for (auto const& child : grid_container().contained_abspos_children()) { - auto const& box = verify_cast(*child); + auto const& box = as(*child); layout_absolutely_positioned_element(box); } } diff --git a/Libraries/LibWeb/Layout/ImageBox.cpp b/Libraries/LibWeb/Layout/ImageBox.cpp index bea4872b9c4..591f34b2e51 100644 --- a/Libraries/LibWeb/Layout/ImageBox.cpp +++ b/Libraries/LibWeb/Layout/ImageBox.cpp @@ -36,7 +36,7 @@ void ImageBox::prepare_for_replaced_layout() set_natural_aspect_ratio(m_image_provider.intrinsic_aspect_ratio()); if (renders_as_alt_text()) { - auto const& element = verify_cast(dom_node()); + auto const& element = as(dom_node()); auto alt = element.get_attribute_value(HTML::AttributeNames::alt); if (alt.is_empty()) { diff --git a/Libraries/LibWeb/Layout/InlineFormattingContext.cpp b/Libraries/LibWeb/Layout/InlineFormattingContext.cpp index 368691b080c..28f2b8fe732 100644 --- a/Libraries/LibWeb/Layout/InlineFormattingContext.cpp +++ b/Libraries/LibWeb/Layout/InlineFormattingContext.cpp @@ -291,7 +291,7 @@ void InlineFormattingContext::generate_line_boxes() break; } case InlineLevelIterator::Item::Type::Element: { - auto& box = verify_cast(*item.node); + auto& box = as(*item.node); compute_inset(box, content_box_rect(m_containing_block_used_values).size()); if (containing_block().computed_values().white_space() != CSS::WhiteSpace::Nowrap) { auto minimum_space_needed_on_line = item.border_box_width(); @@ -324,7 +324,7 @@ void InlineFormattingContext::generate_line_boxes() break; case InlineLevelIterator::Item::Type::Text: { - auto& text_node = verify_cast(*item.node); + auto& text_node = as(*item.node); if (text_node.computed_values().white_space() != CSS::WhiteSpace::Nowrap) { bool is_whitespace = false; diff --git a/Libraries/LibWeb/Layout/InlineLevelIterator.cpp b/Libraries/LibWeb/Layout/InlineLevelIterator.cpp index 8031f21af71..25a83484f8b 100644 --- a/Libraries/LibWeb/Layout/InlineLevelIterator.cpp +++ b/Libraries/LibWeb/Layout/InlineLevelIterator.cpp @@ -158,7 +158,7 @@ CSSPixels InlineLevelIterator::next_non_whitespace_sequence_width() break; if (next_item.is_collapsible_whitespace) break; - auto& next_text_node = verify_cast(*(next_item.node)); + auto& next_text_node = as(*(next_item.node)); auto next_view = next_text_node.text_for_rendering().bytes_as_string_view().substring_view(next_item.offset_in_node, next_item.length_in_node); if (next_view.is_whitespace()) break; @@ -614,7 +614,7 @@ Optional InlineLevelIterator::next_without_lookahead( const_cast(replaced_box).prepare_for_replaced_layout(); } - auto& box = verify_cast(*m_current_node); + auto& box = as(*m_current_node); auto& box_state = m_layout_state.get(box); m_inline_formatting_context.dimension_box_on_line(box, m_layout_mode); diff --git a/Libraries/LibWeb/Layout/Label.cpp b/Libraries/LibWeb/Layout/Label.cpp index 11fdfe5facf..a50993a80b5 100644 --- a/Libraries/LibWeb/Layout/Label.cpp +++ b/Libraries/LibWeb/Layout/Label.cpp @@ -30,7 +30,7 @@ void Label::handle_mousedown_on_label(Badge, CSSPixelPo return; if (auto control = dom_node().control(); control && is(control->paintable())) { - auto& labelable_paintable = verify_cast(*control->paintable()); + auto& labelable_paintable = as(*control->paintable()); labelable_paintable.handle_associated_label_mousedown({}); } @@ -46,7 +46,7 @@ void Label::handle_mouseup_on_label(Badge, CSSPixelPoin bool is_inside_control = control->paintable_box()->absolute_rect().contains(position); bool is_inside_label = paintable_box()->absolute_rect().contains(position); if (is_inside_control || is_inside_label) { - auto& labelable_paintable = verify_cast(*control->paintable()); + auto& labelable_paintable = as(*control->paintable()); labelable_paintable.handle_associated_label_mouseup({}); } } @@ -62,7 +62,7 @@ void Label::handle_mousemove_on_label(Badge, CSSPixelPo if (auto control = dom_node().control(); control && is(control->paintable())) { bool is_inside_control = control->paintable_box()->absolute_rect().contains(position); bool is_inside_label = paintable_box()->absolute_rect().contains(position); - auto& labelable_paintable = verify_cast(*control->paintable()); + auto& labelable_paintable = as(*control->paintable()); labelable_paintable.handle_associated_label_mousemove({}, is_inside_control || is_inside_label); } } diff --git a/Libraries/LibWeb/Layout/LineBoxFragment.cpp b/Libraries/LibWeb/Layout/LineBoxFragment.cpp index fe9c2213d0a..3a01c65193b 100644 --- a/Libraries/LibWeb/Layout/LineBoxFragment.cpp +++ b/Libraries/LibWeb/Layout/LineBoxFragment.cpp @@ -62,7 +62,7 @@ StringView LineBoxFragment::text() const { if (!is(layout_node())) return {}; - return verify_cast(layout_node()).text_for_rendering().bytes_as_string_view().substring_view(m_start, m_length); + return as(layout_node()).text_for_rendering().bytes_as_string_view().substring_view(m_start, m_length); } bool LineBoxFragment::is_atomic_inline() const diff --git a/Libraries/LibWeb/Layout/LineBuilder.cpp b/Libraries/LibWeb/Layout/LineBuilder.cpp index bfc301cb7f4..5ec7c3d6ee1 100644 --- a/Libraries/LibWeb/Layout/LineBuilder.cpp +++ b/Libraries/LibWeb/Layout/LineBuilder.cpp @@ -238,7 +238,7 @@ void LineBuilder::update_last_line() if (fragment.layout_node().is_text_node()) { fragment_baseline = CSSPixels::nearest_value_for(font_metrics.ascent) + half_leading; } else { - auto const& box = verify_cast(fragment.layout_node()); + auto const& box = as(fragment.layout_node()); fragment_baseline = m_context.box_baseline(box); } diff --git a/Libraries/LibWeb/Layout/NavigableContainerViewport.h b/Libraries/LibWeb/Layout/NavigableContainerViewport.h index 616e63d578f..e548c0f52a0 100644 --- a/Libraries/LibWeb/Layout/NavigableContainerViewport.h +++ b/Libraries/LibWeb/Layout/NavigableContainerViewport.h @@ -21,8 +21,8 @@ public: virtual void prepare_for_replaced_layout() override; - [[nodiscard]] HTML::NavigableContainer const& dom_node() const { return verify_cast(ReplacedBox::dom_node()); } - [[nodiscard]] HTML::NavigableContainer& dom_node() { return verify_cast(ReplacedBox::dom_node()); } + [[nodiscard]] HTML::NavigableContainer const& dom_node() const { return as(ReplacedBox::dom_node()); } + [[nodiscard]] HTML::NavigableContainer& dom_node() { return as(ReplacedBox::dom_node()); } virtual GC::Ptr create_paintable() const override; diff --git a/Libraries/LibWeb/Layout/Node.cpp b/Libraries/LibWeb/Layout/Node.cpp index 2fb0063f79d..a9c272fd201 100644 --- a/Libraries/LibWeb/Layout/Node.cpp +++ b/Libraries/LibWeb/Layout/Node.cpp @@ -100,7 +100,7 @@ static Box const* nearest_ancestor_capable_of_forming_a_containing_block(Node co || ancestor->display().is_flex_inside() || ancestor->display().is_grid_inside() || ancestor->is_svg_svg_box()) { - return verify_cast(ancestor); + return as(ancestor); } } return nullptr; diff --git a/Libraries/LibWeb/Layout/ReplacedBox.h b/Libraries/LibWeb/Layout/ReplacedBox.h index 9572462a0cd..87d93ae2197 100644 --- a/Libraries/LibWeb/Layout/ReplacedBox.h +++ b/Libraries/LibWeb/Layout/ReplacedBox.h @@ -18,8 +18,8 @@ public: ReplacedBox(DOM::Document&, DOM::Element&, GC::Ref); virtual ~ReplacedBox() override; - DOM::Element const& dom_node() const { return verify_cast(*Node::dom_node()); } - DOM::Element& dom_node() { return verify_cast(*Node::dom_node()); } + DOM::Element const& dom_node() const { return as(*Node::dom_node()); } + DOM::Element& dom_node() { return as(*Node::dom_node()); } virtual void prepare_for_replaced_layout() { } diff --git a/Libraries/LibWeb/Layout/SVGBox.h b/Libraries/LibWeb/Layout/SVGBox.h index 4a01aac1be5..968c9b50553 100644 --- a/Libraries/LibWeb/Layout/SVGBox.h +++ b/Libraries/LibWeb/Layout/SVGBox.h @@ -19,8 +19,8 @@ public: SVGBox(DOM::Document&, SVG::SVGElement&, GC::Ref); virtual ~SVGBox() override = default; - SVG::SVGElement& dom_node() { return verify_cast(*Box::dom_node()); } - SVG::SVGElement const& dom_node() const { return verify_cast(*Box::dom_node()); } + SVG::SVGElement& dom_node() { return as(*Box::dom_node()); } + SVG::SVGElement const& dom_node() const { return as(*Box::dom_node()); } private: virtual bool is_svg_box() const final { return true; } diff --git a/Libraries/LibWeb/Layout/SVGClipBox.h b/Libraries/LibWeb/Layout/SVGClipBox.h index 6ca5ad15284..babb6b6908e 100644 --- a/Libraries/LibWeb/Layout/SVGClipBox.h +++ b/Libraries/LibWeb/Layout/SVGClipBox.h @@ -20,8 +20,8 @@ public: SVGClipBox(DOM::Document&, SVG::SVGClipPathElement&, GC::Ref); virtual ~SVGClipBox() override = default; - SVG::SVGClipPathElement& dom_node() { return verify_cast(SVGBox::dom_node()); } - SVG::SVGClipPathElement const& dom_node() const { return verify_cast(SVGBox::dom_node()); } + SVG::SVGClipPathElement& dom_node() { return as(SVGBox::dom_node()); } + SVG::SVGClipPathElement const& dom_node() const { return as(SVGBox::dom_node()); } virtual GC::Ptr create_paintable() const override; }; diff --git a/Libraries/LibWeb/Layout/SVGGraphicsBox.h b/Libraries/LibWeb/Layout/SVGGraphicsBox.h index 024f302bfac..a915fce6672 100644 --- a/Libraries/LibWeb/Layout/SVGGraphicsBox.h +++ b/Libraries/LibWeb/Layout/SVGGraphicsBox.h @@ -19,8 +19,8 @@ public: SVGGraphicsBox(DOM::Document&, SVG::SVGGraphicsElement&, GC::Ref); virtual ~SVGGraphicsBox() override = default; - SVG::SVGGraphicsElement& dom_node() { return verify_cast(SVGBox::dom_node()); } - SVG::SVGGraphicsElement const& dom_node() const { return verify_cast(SVGBox::dom_node()); } + SVG::SVGGraphicsElement& dom_node() { return as(SVGBox::dom_node()); } + SVG::SVGGraphicsElement const& dom_node() const { return as(SVGBox::dom_node()); } virtual GC::Ptr create_paintable() const override; }; diff --git a/Libraries/LibWeb/Layout/SVGMaskBox.h b/Libraries/LibWeb/Layout/SVGMaskBox.h index 8f50fefb8d8..fe0ad027289 100644 --- a/Libraries/LibWeb/Layout/SVGMaskBox.h +++ b/Libraries/LibWeb/Layout/SVGMaskBox.h @@ -22,8 +22,8 @@ public: virtual bool is_svg_mask_box() const override { return true; } - SVG::SVGMaskElement& dom_node() { return verify_cast(SVGGraphicsBox::dom_node()); } - SVG::SVGMaskElement const& dom_node() const { return verify_cast(SVGGraphicsBox::dom_node()); } + SVG::SVGMaskElement& dom_node() { return as(SVGGraphicsBox::dom_node()); } + SVG::SVGMaskElement const& dom_node() const { return as(SVGGraphicsBox::dom_node()); } virtual GC::Ptr create_paintable() const override; }; diff --git a/Libraries/LibWeb/Layout/SVGSVGBox.h b/Libraries/LibWeb/Layout/SVGSVGBox.h index 3eb664fb906..d7b5472cebb 100644 --- a/Libraries/LibWeb/Layout/SVGSVGBox.h +++ b/Libraries/LibWeb/Layout/SVGSVGBox.h @@ -19,8 +19,8 @@ public: SVGSVGBox(DOM::Document&, SVG::SVGSVGElement&, GC::Ref); virtual ~SVGSVGBox() override = default; - SVG::SVGSVGElement& dom_node() { return verify_cast(ReplacedBox::dom_node()); } - SVG::SVGSVGElement const& dom_node() const { return verify_cast(ReplacedBox::dom_node()); } + SVG::SVGSVGElement& dom_node() { return as(ReplacedBox::dom_node()); } + SVG::SVGSVGElement const& dom_node() const { return as(ReplacedBox::dom_node()); } virtual bool can_have_children() const override { return true; } diff --git a/Libraries/LibWeb/Layout/TableFormattingContext.cpp b/Libraries/LibWeb/Layout/TableFormattingContext.cpp index e2bedea6c16..43611e759cc 100644 --- a/Libraries/LibWeb/Layout/TableFormattingContext.cpp +++ b/Libraries/LibWeb/Layout/TableFormattingContext.cpp @@ -40,7 +40,7 @@ CSSPixels TableFormattingContext::run_caption_layout(CSS::CaptionSide phase) } // The caption boxes are principal block-level boxes that retain their own content, padding, margin, and border areas, // and are rendered as normal block boxes inside the table wrapper box, as described in https://www.w3.org/TR/CSS22/tables.html#model - auto caption_context = make(m_state, m_layout_mode, *verify_cast(child), this); + auto caption_context = make(m_state, m_layout_mode, *as(child), this); caption_context->run(*m_available_space); VERIFY(child->is_box()); auto const& child_box = static_cast(*child); @@ -1632,7 +1632,7 @@ void TableFormattingContext::parent_context_did_dimension_child_root_box() }); for (auto& child : context_box().contained_abspos_children()) { - auto& box = verify_cast(*child); + auto& box = as(*child); auto& cb_state = m_state.get(*box.containing_block()); auto available_width = AvailableSize::make_definite(cb_state.content_width() + cb_state.padding_left + cb_state.padding_right); auto available_height = AvailableSize::make_definite(cb_state.content_height() + cb_state.padding_top + cb_state.padding_bottom); diff --git a/Libraries/LibWeb/Layout/TableFormattingContext.h b/Libraries/LibWeb/Layout/TableFormattingContext.h index f38bdab9201..b91de915db1 100644 --- a/Libraries/LibWeb/Layout/TableFormattingContext.h +++ b/Libraries/LibWeb/Layout/TableFormattingContext.h @@ -33,7 +33,7 @@ public: Box const& table_box() const { return context_box(); } TableWrapper const& table_wrapper() const { - return verify_cast(*table_box().containing_block()); + return as(*table_box().containing_block()); } static bool border_is_less_specific(const CSS::BorderData& a, const CSS::BorderData& b); diff --git a/Libraries/LibWeb/Layout/TreeBuilder.cpp b/Libraries/LibWeb/Layout/TreeBuilder.cpp index b0f46cf8537..b4a8d7d7c05 100644 --- a/Libraries/LibWeb/Layout/TreeBuilder.cpp +++ b/Libraries/LibWeb/Layout/TreeBuilder.cpp @@ -419,7 +419,7 @@ void TreeBuilder::update_layout_tree(DOM::Node& dom_node, TreeBuilder::Context& } } - auto shadow_root = is(dom_node) ? verify_cast(dom_node).shadow_root() : nullptr; + auto shadow_root = is(dom_node) ? as(dom_node).shadow_root() : nullptr; auto element_has_content_visibility_hidden = [&dom_node]() { if (is(dom_node)) { @@ -434,7 +434,7 @@ void TreeBuilder::update_layout_tree(DOM::Node& dom_node, TreeBuilder::Context& if (should_create_layout_node || dom_node.child_needs_layout_tree_update()) { if ((dom_node.has_children() || shadow_root) && layout_node->can_have_children() && !element_has_content_visibility_hidden) { - push_parent(verify_cast(*layout_node)); + push_parent(as(*layout_node)); if (shadow_root) { for (auto* node = shadow_root->first_child(); node; node = node->next_sibling()) { update_layout_tree(*node, context, should_create_layout_node ? MustCreateSubtree::Yes : MustCreateSubtree::No); @@ -442,8 +442,8 @@ void TreeBuilder::update_layout_tree(DOM::Node& dom_node, TreeBuilder::Context& shadow_root->set_child_needs_layout_tree_update(false); shadow_root->set_needs_layout_tree_update(false); } else { - // This is the same as verify_cast(dom_node).for_each_child - for (auto* node = verify_cast(dom_node).first_child(); node; node = node->next_sibling()) + // This is the same as as(dom_node).for_each_child + for (auto* node = as(dom_node).first_child(); node; node = node->next_sibling()) update_layout_tree(*node, context, should_create_layout_node ? MustCreateSubtree::Yes : MustCreateSubtree::No); } @@ -470,7 +470,7 @@ void TreeBuilder::update_layout_tree_before_children(DOM::Node& dom_node, GC::Re // Add node for the ::before pseudo-element. if (is(dom_node) && layout_node->can_have_children() && !element_has_content_visibility_hidden) { auto& element = static_cast(dom_node); - push_parent(verify_cast(*layout_node)); + push_parent(as(*layout_node)); create_pseudo_element_if_needed(element, CSS::Selector::PseudoElement::Type::Before, AppendOrPrepend::Prepend); pop_parent(); } @@ -498,7 +498,7 @@ void TreeBuilder::update_layout_tree_after_children(DOM::Node& dom_node, GC::Ref return; auto slottables = slot_element.assigned_nodes_internal(); - push_parent(verify_cast(*layout_node)); + push_parent(as(*layout_node)); for (auto const& slottable : slottables) slottable.visit([&](auto& node) { update_layout_tree(node, context, MustCreateSubtree::Yes); }); @@ -514,7 +514,7 @@ void TreeBuilder::update_layout_tree_after_children(DOM::Node& dom_node, GC::Ref // duplication is necessary. auto layout_mask_or_clip_path = [&](GC::Ptr mask_or_clip_path) { TemporaryChange layout_mask(context.layout_svg_mask_or_clip_path, true); - push_parent(verify_cast(*layout_node)); + push_parent(as(*layout_node)); update_layout_tree(const_cast(*mask_or_clip_path), context, MustCreateSubtree::Yes); pop_parent(); }; @@ -540,7 +540,7 @@ void TreeBuilder::update_layout_tree_after_children(DOM::Node& dom_node, GC::Ref // https://html.spec.whatwg.org/multipage/rendering.html#button-layout // If the computed value of 'inline-size' is 'auto', then the used value is the fit-content inline size. if (is_button_layout && dom_node.layout_node()->computed_values().width().is_auto()) { - auto& computed_values = verify_cast(*dom_node.layout_node()).mutable_computed_values(); + auto& computed_values = as(*dom_node.layout_node()).mutable_computed_values(); computed_values.set_width(CSS::Size::make_fit_content()); } @@ -587,7 +587,7 @@ void TreeBuilder::update_layout_tree_after_children(DOM::Node& dom_node, GC::Ref // Add nodes for the ::after pseudo-element. if (is(dom_node) && layout_node->can_have_children() && !element_has_content_visibility_hidden) { auto& element = static_cast(dom_node); - push_parent(verify_cast(*layout_node)); + push_parent(as(*layout_node)); create_pseudo_element_if_needed(element, CSS::Selector::PseudoElement::Type::After, AppendOrPrepend::Append); pop_parent(); } diff --git a/Libraries/LibWeb/Layout/Viewport.cpp b/Libraries/LibWeb/Layout/Viewport.cpp index d1386f43362..6d5404e6a5f 100644 --- a/Libraries/LibWeb/Layout/Viewport.cpp +++ b/Libraries/LibWeb/Layout/Viewport.cpp @@ -69,7 +69,7 @@ void Viewport::update_text_blocks() } if (layout_node.is_text_node()) { - auto const& text_node = verify_cast(layout_node); + auto const& text_node = as(layout_node); auto& dom_node = const_cast(text_node.dom_node()); if (text_positions.is_empty()) { text_positions.empend(dom_node); diff --git a/Libraries/LibWeb/MixedContent/AbstractOperations.cpp b/Libraries/LibWeb/MixedContent/AbstractOperations.cpp index 17dd0ddf381..81c8fc4f5f7 100644 --- a/Libraries/LibWeb/MixedContent/AbstractOperations.cpp +++ b/Libraries/LibWeb/MixedContent/AbstractOperations.cpp @@ -51,7 +51,7 @@ ProhibitsMixedSecurityContexts does_settings_prohibit_mixed_security_contexts(GC // 2. If settings’ global object is a window, then: if (is(settings->global_object())) { // 1. Set document to settings’ global object's associated Document. - auto document = verify_cast(settings->global_object()).document(); + auto document = as(settings->global_object()).document(); // 2. For each navigable navigable in document’s ancestor navigables: for (auto const& navigable : document->ancestor_navigables()) { diff --git a/Libraries/LibWeb/Page/EventHandler.cpp b/Libraries/LibWeb/Page/EventHandler.cpp index 710276f3dd1..a7a1797678d 100644 --- a/Libraries/LibWeb/Page/EventHandler.cpp +++ b/Libraries/LibWeb/Page/EventHandler.cpp @@ -56,7 +56,7 @@ static GC::Ptr dom_node_for_event_dispatch(Painting::Paintable& paint static DOM::Node* input_control_associated_with_ancestor_label_element(Painting::Paintable& paintable) { if (is(paintable.layout_node())) { - auto const& label = verify_cast(paintable.layout_node()); + auto const& label = as(paintable.layout_node()); return label.dom_node().control().ptr(); } if (auto const* label = paintable.layout_node().first_ancestor_of_type()) @@ -506,7 +506,7 @@ EventResult EventHandler::handle_mouseup(CSSPixelPoint viewport_position, CSSPix } } else if (button == UIEvents::MouseButton::Secondary) { if (is(*node)) { - auto& image_element = verify_cast(*node); + auto& image_element = as(*node); auto image_url = image_element.document().encoding_parse_url(image_element.src()); Optional bitmap; if (image_element.immutable_bitmap()) @@ -514,7 +514,7 @@ EventResult EventHandler::handle_mouseup(CSSPixelPoint viewport_position, CSSPix m_navigable->page().client().page_did_request_image_context_menu(viewport_position, image_url, "", modifiers, bitmap); } else if (is(*node)) { - auto& media_element = verify_cast(*node); + auto& media_element = as(*node); Page::MediaContextMenu menu { .media_url = media_element.document().encoding_parse_url(media_element.current_src()), @@ -885,7 +885,7 @@ EventResult EventHandler::handle_doubleclick(CSSPixelPoint viewport_position, CS return EventResult::Accepted; auto& hit_paintable = static_cast(*result->paintable); - auto& hit_dom_node = const_cast(verify_cast(*hit_paintable.dom_node())); + auto& hit_dom_node = const_cast(as(*hit_paintable.dom_node())); auto previous_boundary = hit_dom_node.word_segmenter().previous_boundary(result->index_in_node, Unicode::Segmenter::Inclusive::Yes).value_or(0); auto next_boundary = hit_dom_node.word_segmenter().next_boundary(result->index_in_node).value_or(hit_dom_node.length()); @@ -1036,7 +1036,7 @@ EventResult EventHandler::fire_keyboard_event(FlyString const& event_name, HTML: if (GC::Ptr focused_element = document->focused_element()) { if (is(*focused_element)) { - auto& navigable_container = verify_cast(*focused_element); + auto& navigable_container = as(*focused_element); if (navigable_container.content_navigable()) return fire_keyboard_event(event_name, *navigable_container.content_navigable(), key, modifiers, code_point, repeat); } @@ -1080,7 +1080,7 @@ EventResult EventHandler::input_event(FlyString const& event_name, FlyString con if (auto* focused_element = document->focused_element()) { if (is(*focused_element)) { - auto& navigable_container = verify_cast(*focused_element); + auto& navigable_container = as(*focused_element); if (navigable_container.content_navigable()) return input_event(event_name, input_type, *navigable_container.content_navigable(), code_point); } diff --git a/Libraries/LibWeb/Page/Page.cpp b/Libraries/LibWeb/Page/Page.cpp index b9ab5dd6444..0b5744d924c 100644 --- a/Libraries/LibWeb/Page/Page.cpp +++ b/Libraries/LibWeb/Page/Page.cpp @@ -395,7 +395,7 @@ void Page::color_picker_update(Optional picked_color, HTML::ColorPickerUp m_pending_non_blocking_dialog = PendingNonBlockingDialog::None; if (m_pending_non_blocking_dialog_target) { - auto& input_element = verify_cast(*m_pending_non_blocking_dialog_target); + auto& input_element = as(*m_pending_non_blocking_dialog_target); input_element.did_pick_color(move(picked_color), state); if (state == HTML::ColorPickerUpdateState::Closed) m_pending_non_blocking_dialog_target.clear(); @@ -419,7 +419,7 @@ void Page::file_picker_closed(Span selected_files) m_pending_non_blocking_dialog = PendingNonBlockingDialog::None; if (m_pending_non_blocking_dialog_target) { - auto& input_element = verify_cast(*m_pending_non_blocking_dialog_target); + auto& input_element = as(*m_pending_non_blocking_dialog_target); input_element.did_select_files(selected_files); m_pending_non_blocking_dialog_target.clear(); @@ -442,7 +442,7 @@ void Page::select_dropdown_closed(Optional const& selected_item_id) m_pending_non_blocking_dialog = PendingNonBlockingDialog::None; if (m_pending_non_blocking_dialog_target) { - auto& select_element = verify_cast(*m_pending_non_blocking_dialog_target); + auto& select_element = as(*m_pending_non_blocking_dialog_target); select_element.did_select_item(selected_item_id); m_pending_non_blocking_dialog_target.clear(); } @@ -535,7 +535,7 @@ void Page::toggle_page_mute_state() for (auto media_id : m_media_elements) { if (auto* node = DOM::Node::from_unique_id(media_id)) { - auto& media_element = verify_cast(*node); + auto& media_element = as(*node); media_element.page_mute_state_changed({}); } } diff --git a/Libraries/LibWeb/Painting/MediaPaintable.cpp b/Libraries/LibWeb/Painting/MediaPaintable.cpp index 1af98271e52..ab3f3c3459d 100644 --- a/Libraries/LibWeb/Painting/MediaPaintable.cpp +++ b/Libraries/LibWeb/Painting/MediaPaintable.cpp @@ -280,7 +280,7 @@ MediaPaintable::DispatchEventOfSameName MediaPaintable::handle_mousedown(Badge(layout_node_with_style_and_box_metrics().dom_node()); + auto& media_element = *as(layout_node_with_style_and_box_metrics().dom_node()); auto const& cached_layout_boxes = media_element.cached_layout_boxes({}); auto position_adjusted_by_scroll_offset = position; @@ -302,7 +302,7 @@ MediaPaintable::DispatchEventOfSameName MediaPaintable::handle_mousedown(Badge, CSSPixelPoint position, unsigned button, unsigned) { - auto& media_element = *verify_cast(layout_node_with_style_and_box_metrics().dom_node()); + auto& media_element = *as(layout_node_with_style_and_box_metrics().dom_node()); auto const& cached_layout_boxes = media_element.cached_layout_boxes({}); auto position_adjusted_by_scroll_offset = position; @@ -350,7 +350,7 @@ MediaPaintable::DispatchEventOfSameName MediaPaintable::handle_mouseup(Badge, CSSPixelPoint position, unsigned, unsigned) { - auto& media_element = *verify_cast(layout_node_with_style_and_box_metrics().dom_node()); + auto& media_element = *as(layout_node_with_style_and_box_metrics().dom_node()); auto const& cached_layout_boxes = media_element.cached_layout_boxes({}); auto position_adjusted_by_scroll_offset = position; diff --git a/Libraries/LibWeb/Painting/SVGMaskable.cpp b/Libraries/LibWeb/Painting/SVGMaskable.cpp index 22e781ff170..68d13b57baf 100644 --- a/Libraries/LibWeb/Painting/SVGMaskable.cpp +++ b/Libraries/LibWeb/Painting/SVGMaskable.cpp @@ -35,7 +35,7 @@ static auto get_clip_box(SVG::SVGGraphicsElement const& graphics_element) Optional SVGMaskable::get_masking_area_of_svg() const { - auto const& graphics_element = verify_cast(*dom_node_of_svg()); + auto const& graphics_element = as(*dom_node_of_svg()); Optional masking_area = {}; if (auto* mask_box = get_mask_box(graphics_element)) { masking_area = mask_box->dom_node().resolve_masking_area(mask_box->paintable_box()->absolute_border_box_rect()); @@ -65,7 +65,7 @@ static Gfx::Bitmap::MaskKind mask_type_to_gfx_mask_kind(CSS::MaskType mask_type) Optional SVGMaskable::get_mask_type_of_svg() const { - auto const& graphics_element = verify_cast(*dom_node_of_svg()); + auto const& graphics_element = as(*dom_node_of_svg()); if (auto* mask_box = get_mask_box(graphics_element)) return mask_type_to_gfx_mask_kind(mask_box->computed_values().mask_type()); if (get_clip_box(graphics_element)) @@ -75,7 +75,7 @@ Optional SVGMaskable::get_mask_type_of_svg() const RefPtr SVGMaskable::calculate_mask_of_svg(PaintContext& context, CSSPixelRect const& masking_area) const { - auto const& graphics_element = verify_cast(*dom_node_of_svg()); + auto const& graphics_element = as(*dom_node_of_svg()); auto mask_rect = context.enclosing_device_rect(masking_area); auto paint_mask_or_clip = [&](PaintableBox const& paintable) -> RefPtr { auto mask_bitmap_or_error = Gfx::Bitmap::create(Gfx::BitmapFormat::BGRA8888, mask_rect.size().to_type()); diff --git a/Libraries/LibWeb/Painting/StackingContext.cpp b/Libraries/LibWeb/Painting/StackingContext.cpp index 901c2883b9b..ba6be7f3a48 100644 --- a/Libraries/LibWeb/Painting/StackingContext.cpp +++ b/Libraries/LibWeb/Painting/StackingContext.cpp @@ -426,7 +426,7 @@ TraversalDecision StackingContext::hit_test(CSSPixelPoint position, HitTestType if (!child->is_paintable_box()) continue; - auto const& paintable_box = verify_cast(*child); + auto const& paintable_box = as(*child); if (!paintable_box.is_absolutely_positioned() && !paintable_box.is_floating() && !paintable_box.stacking_context()) { if (paintable_box.hit_test(transformed_position, type, callback) == TraversalDecision::Break) return TraversalDecision::Break; diff --git a/Libraries/LibWeb/ResizeObserver/ResizeObserver.cpp b/Libraries/LibWeb/ResizeObserver/ResizeObserver.cpp index 6100cfd1db9..8e6f8567db5 100644 --- a/Libraries/LibWeb/ResizeObserver/ResizeObserver.cpp +++ b/Libraries/LibWeb/ResizeObserver/ResizeObserver.cpp @@ -27,7 +27,7 @@ ResizeObserver::ResizeObserver(JS::Realm& realm, WebIDL::CallbackType* callback) : PlatformObject(realm) , m_callback(callback) { - auto navigable = verify_cast(HTML::relevant_global_object(*this)).navigable(); + auto navigable = as(HTML::relevant_global_object(*this)).navigable(); m_document = navigable->active_document().ptr(); m_document->register_resize_observer({}, *this); } diff --git a/Libraries/LibWeb/SVG/SVGDecodedImageData.cpp b/Libraries/LibWeb/SVG/SVGDecodedImageData.cpp index ba63721aef5..66f3a2e9919 100644 --- a/Libraries/LibWeb/SVG/SVGDecodedImageData.cpp +++ b/Libraries/LibWeb/SVG/SVGDecodedImageData.cpp @@ -50,7 +50,7 @@ ErrorOr> SVGDecodedImageData::create(JS::Realm& rea navigable->set_ongoing_navigation({}); navigable->active_document()->destroy(); navigable->active_session_history_entry()->document_state()->set_document(document); - auto& window = verify_cast(HTML::relevant_global_object(document)); + auto& window = as(HTML::relevant_global_object(document)); document->browsing_context()->window_proxy()->set_window(window); auto parser = HTML::HTMLParser::create_with_uncertain_encoding(document, data); diff --git a/Libraries/LibWeb/SVG/SVGGradientElement.cpp b/Libraries/LibWeb/SVG/SVGGradientElement.cpp index 2fd2441b929..c333f87c2e1 100644 --- a/Libraries/LibWeb/SVG/SVGGradientElement.cpp +++ b/Libraries/LibWeb/SVG/SVGGradientElement.cpp @@ -139,9 +139,9 @@ GC::Ptr SVGGradientElement::linked_gradient(HashTable< return {}; if (!is(*element)) return {}; - if (seen_gradients.set(&verify_cast(*element)) != AK::HashSetResult::InsertedNewEntry) + if (seen_gradients.set(&as(*element)) != AK::HashSetResult::InsertedNewEntry) return {}; - return &verify_cast(*element); + return &as(*element); } return {}; } diff --git a/Libraries/LibWeb/SVG/SVGLinearGradientElement.h b/Libraries/LibWeb/SVG/SVGLinearGradientElement.h index 4f346c6d138..86f5a10cc72 100644 --- a/Libraries/LibWeb/SVG/SVGLinearGradientElement.h +++ b/Libraries/LibWeb/SVG/SVGLinearGradientElement.h @@ -37,7 +37,7 @@ private: GC::Ptr linked_linear_gradient(HashTable& seen_gradients) const { if (auto gradient = linked_gradient(seen_gradients); gradient && is(*gradient)) - return &verify_cast(*gradient); + return &as(*gradient); return {}; } diff --git a/Libraries/LibWeb/SVG/SVGRadialGradientElement.h b/Libraries/LibWeb/SVG/SVGRadialGradientElement.h index 3c7db7599e0..d27fa393c5c 100644 --- a/Libraries/LibWeb/SVG/SVGRadialGradientElement.h +++ b/Libraries/LibWeb/SVG/SVGRadialGradientElement.h @@ -39,7 +39,7 @@ private: GC::Ptr linked_radial_gradient(HashTable& seen_gradients) const { if (auto gradient = linked_gradient(seen_gradients); gradient && is(*gradient)) - return &verify_cast(*gradient); + return &as(*gradient); return {}; } diff --git a/Libraries/LibWeb/SVG/SVGUseElement.cpp b/Libraries/LibWeb/SVG/SVGUseElement.cpp index 1acc235033c..2cb4344529b 100644 --- a/Libraries/LibWeb/SVG/SVGUseElement.cpp +++ b/Libraries/LibWeb/SVG/SVGUseElement.cpp @@ -149,7 +149,7 @@ GC::Ptr SVGUseElement::referenced_element() if (!data || !is(*data)) return nullptr; - return verify_cast(*data).svg_document().get_element_by_id(*m_href.fragment()); + return as(*data).svg_document().get_element_by_id(*m_href.fragment()); } // https://svgwg.org/svg2-draft/linking.html#processingURL-fetch diff --git a/Libraries/LibWeb/ServiceWorker/Job.cpp b/Libraries/LibWeb/ServiceWorker/Job.cpp index f9b6e26acb8..329b5ffcb9a 100644 --- a/Libraries/LibWeb/ServiceWorker/Job.cpp +++ b/Libraries/LibWeb/ServiceWorker/Job.cpp @@ -591,7 +591,7 @@ void schedule_job(JS::VM& vm, GC::Ref job) // 2. If job is equivalent to lastJob and lastJob’s job promise has not settled, append job to lastJob’s list of equivalent jobs. // FIXME: There's no WebIDL AO that corresponds to checking if an ECMAScript promise has settled - if (job == last_job && !verify_cast(*job->job_promise->promise()).is_handled()) { + if (job == last_job && !as(*job->job_promise->promise()).is_handled()) { last_job->list_of_equivalent_jobs.append(job); } // 3. Else, set job’s containing job queue to jobQueue, and enqueue job to jobQueue. diff --git a/Libraries/LibWeb/StorageAPI/StorageBottle.cpp b/Libraries/LibWeb/StorageAPI/StorageBottle.cpp index 5abdd0b3239..6136d9893a5 100644 --- a/Libraries/LibWeb/StorageAPI/StorageBottle.cpp +++ b/Libraries/LibWeb/StorageAPI/StorageBottle.cpp @@ -46,7 +46,7 @@ RefPtr obtain_a_storage_bottle_map(StorageType type, HTML::Enviro VERIFY(type == StorageType::Session); // 2. Set shed to environment’s global object’s associated Document’s node navigable’s traversable navigable’s storage shed. - shed = &verify_cast(environment.global_object()).associated_document().navigable()->traversable_navigable()->storage_shed(); + shed = &as(environment.global_object()).associated_document().navigable()->traversable_navigable()->storage_shed(); } // 4. Let shelf be the result of running obtain a storage shelf, with shed, environment, and type. diff --git a/Libraries/LibWeb/Streams/AbstractOperations.cpp b/Libraries/LibWeb/Streams/AbstractOperations.cpp index f341986c9fb..ec44d475aa6 100644 --- a/Libraries/LibWeb/Streams/AbstractOperations.cpp +++ b/Libraries/LibWeb/Streams/AbstractOperations.cpp @@ -4098,7 +4098,7 @@ void writable_stream_default_writer_ensure_closed_promise_rejected(WritableStrea auto& realm = writer.realm(); // 1. If writer.[[closedPromise]].[[PromiseState]] is "pending", reject writer.[[closedPromise]] with error. - auto& closed_promise = verify_cast(*writer.closed_promise()->promise()); + auto& closed_promise = as(*writer.closed_promise()->promise()); if (closed_promise.state() == JS::Promise::State::Pending) { WebIDL::reject_promise(realm, *writer.closed_promise(), error); } @@ -4117,7 +4117,7 @@ void writable_stream_default_writer_ensure_ready_promise_rejected(WritableStream auto& realm = writer.realm(); // 1. If writer.[[readyPromise]].[[PromiseState]] is "pending", reject writer.[[readyPromise]] with error. - auto& ready_promise = verify_cast(*writer.ready_promise()->promise()); + auto& ready_promise = as(*writer.ready_promise()->promise()); if (ready_promise.state() == JS::Promise::State::Pending) { WebIDL::reject_promise(realm, *writer.ready_promise(), error); } diff --git a/Libraries/LibWeb/TreeNode.h b/Libraries/LibWeb/TreeNode.h index c54a7e67b04..f57641316cc 100644 --- a/Libraries/LibWeb/TreeNode.h +++ b/Libraries/LibWeb/TreeNode.h @@ -220,7 +220,7 @@ public: { for (auto* node = first_child(); node; node = node->next_sibling()) { if (is(node)) { - if (callback(verify_cast(*node)) == IterationDecision::Break) + if (callback(as(*node)) == IterationDecision::Break) return; } } @@ -243,7 +243,7 @@ public: { for (auto* sibling = next_sibling(); sibling; sibling = sibling->next_sibling()) { if (is(*sibling)) - return &verify_cast(*sibling); + return &as(*sibling); } return nullptr; } @@ -259,7 +259,7 @@ public: { for (auto* sibling = previous_sibling(); sibling; sibling = sibling->previous_sibling()) { if (is(*sibling)) - return &verify_cast(*sibling); + return &as(*sibling); } return nullptr; } @@ -281,7 +281,7 @@ public: { for (auto* child = first_child(); child; child = child->next_sibling()) { if (is(*child)) - return &verify_cast(*child); + return &as(*child); } return nullptr; } @@ -291,7 +291,7 @@ public: { for (auto* child = last_child(); child; child = child->previous_sibling()) { if (is(*child)) - return &verify_cast(*child); + return &as(*child); } return nullptr; } @@ -307,7 +307,7 @@ public: { for (auto* ancestor = parent(); ancestor; ancestor = ancestor->parent()) { if (is(*ancestor)) - return &verify_cast(*ancestor); + return &as(*ancestor); } return nullptr; } diff --git a/Libraries/LibWeb/WebAudio/AudioContext.cpp b/Libraries/LibWeb/WebAudio/AudioContext.cpp index b91bb771475..c215cd9c3b7 100644 --- a/Libraries/LibWeb/WebAudio/AudioContext.cpp +++ b/Libraries/LibWeb/WebAudio/AudioContext.cpp @@ -136,7 +136,7 @@ WebIDL::ExceptionOr> AudioContext::resume() auto& realm = this->realm(); // 1. If this's relevant global object's associated Document is not fully active then return a promise rejected with "InvalidStateError" DOMException. - auto const& associated_document = verify_cast(HTML::relevant_global_object(*this)).associated_document(); + auto const& associated_document = as(HTML::relevant_global_object(*this)).associated_document(); if (!associated_document.is_fully_active()) return WebIDL::InvalidStateError::create(realm, "Document is not fully active"_string); @@ -228,7 +228,7 @@ WebIDL::ExceptionOr> AudioContext::suspend() auto& realm = this->realm(); // 1. If this's relevant global object's associated Document is not fully active then return a promise rejected with "InvalidStateError" DOMException. - auto const& associated_document = verify_cast(HTML::relevant_global_object(*this)).associated_document(); + auto const& associated_document = as(HTML::relevant_global_object(*this)).associated_document(); if (!associated_document.is_fully_active()) return WebIDL::InvalidStateError::create(realm, "Document is not fully active"_string); @@ -287,7 +287,7 @@ WebIDL::ExceptionOr> AudioContext::close() auto& realm = this->realm(); // 1. If this's relevant global object's associated Document is not fully active then return a promise rejected with "InvalidStateError" DOMException. - auto const& associated_document = verify_cast(HTML::relevant_global_object(*this)).associated_document(); + auto const& associated_document = as(HTML::relevant_global_object(*this)).associated_document(); if (!associated_document.is_fully_active()) return WebIDL::InvalidStateError::create(realm, "Document is not fully active"_string); diff --git a/Libraries/LibWeb/WebAudio/BaseAudioContext.cpp b/Libraries/LibWeb/WebAudio/BaseAudioContext.cpp index f4606ed4dec..e2592601f16 100644 --- a/Libraries/LibWeb/WebAudio/BaseAudioContext.cpp +++ b/Libraries/LibWeb/WebAudio/BaseAudioContext.cpp @@ -209,7 +209,7 @@ GC::Ref BaseAudioContext::decode_audio_data(GC::Root(HTML::relevant_global_object(*this)).associated_document(); + auto const& associated_document = as(HTML::relevant_global_object(*this)).associated_document(); if (!associated_document.is_fully_active()) { auto error = WebIDL::InvalidStateError::create(realm, "The document is not fully active."_string); return WebIDL::create_rejected_promise_from_exception(realm, error); diff --git a/Libraries/LibWeb/WebDriver/ExecuteScript.cpp b/Libraries/LibWeb/WebDriver/ExecuteScript.cpp index 6db760332a6..95b39c0986a 100644 --- a/Libraries/LibWeb/WebDriver/ExecuteScript.cpp +++ b/Libraries/LibWeb/WebDriver/ExecuteScript.cpp @@ -132,7 +132,7 @@ void execute_script(HTML::BrowsingContext const& browsing_context, ByteString bo return JS::js_undefined(); timer->stop(); - auto promise_promise = GC::Ref { verify_cast(*promise->promise()) }; + auto promise_promise = GC::Ref { as(*promise->promise()) }; on_complete->function()({ promise_promise->state(), promise_promise->result() }); return JS::js_undefined(); @@ -164,7 +164,7 @@ void execute_async_script(HTML::BrowsingContext const& browsing_context, ByteStr // 7. Let promise be a new Promise. auto promise_capability = WebIDL::create_promise(realm); - GC::Ref promise { verify_cast(*promise_capability->promise()) }; + GC::Ref promise { as(*promise_capability->promise()) }; // 8. Run the following substeps in parallel: Platform::EventLoopPlugin::the().deferred_invoke(GC::create_function(realm.heap(), [&vm, &realm, &browsing_context, timer, promise_capability, promise, body = move(body), arguments = move(arguments)]() mutable { diff --git a/Libraries/LibWeb/WebDriver/Screenshot.cpp b/Libraries/LibWeb/WebDriver/Screenshot.cpp index ccdaa34db46..0e11c9d2edf 100644 --- a/Libraries/LibWeb/WebDriver/Screenshot.cpp +++ b/Libraries/LibWeb/WebDriver/Screenshot.cpp @@ -35,7 +35,7 @@ ErrorOr, WebDriver::Error> draw_bounding_box_fr // 4. Let canvas be a new canvas element, and set its width and height to paint width and paint height, respectively. auto canvas_element = DOM::create_element(element.document(), HTML::TagNames::canvas, Namespace::HTML).release_value_but_fixme_should_propagate_errors(); - auto& canvas = verify_cast(*canvas_element); + auto& canvas = as(*canvas_element); // FIXME: Handle DevicePixelRatio in HiDPI mode. MUST(canvas.set_width(paint_width)); diff --git a/Libraries/LibWeb/WebIDL/AbstractOperations.cpp b/Libraries/LibWeb/WebIDL/AbstractOperations.cpp index 9e645f6c8c4..c4688e4a116 100644 --- a/Libraries/LibWeb/WebIDL/AbstractOperations.cpp +++ b/Libraries/LibWeb/WebIDL/AbstractOperations.cpp @@ -211,7 +211,7 @@ JS::Completion call_user_object_operation(WebIDL::CallbackType& callback, String // 11. Let callResult be Call(X, thisArg, esArgs). VERIFY(actual_function_object); auto& vm = object->vm(); - auto call_result = JS::call(vm, verify_cast(*actual_function_object), this_argument.value(), args.span()); + auto call_result = JS::call(vm, as(*actual_function_object), this_argument.value(), args.span()); // 12. If callResult is an abrupt completion, set completion to callResult and jump to the step labeled return. if (call_result.is_throw_completion()) { @@ -301,7 +301,7 @@ JS::Completion invoke_callback(WebIDL::CallbackType& callback, Optionalvm(); - auto call_result = JS::call(vm, verify_cast(*function_object), this_argument.value(), args.span()); + auto call_result = JS::call(vm, as(*function_object), this_argument.value(), args.span()); auto return_steps = [&](JS::Completion completion) -> JS::Completion { // 1. Clean up after running a callback with stored realm. @@ -393,7 +393,7 @@ JS::Completion construct(WebIDL::CallbackType& callback, GC::RootVectorvm(); - auto call_result = JS::construct(vm, verify_cast(*function_object), args.span()); + auto call_result = JS::construct(vm, as(*function_object), args.span()); // 9. If callResult is an abrupt completion, set completion to callResult and jump to the step labeled return. if (call_result.is_throw_completion()) { diff --git a/Libraries/LibWeb/WebIDL/ObservableArray.h b/Libraries/LibWeb/WebIDL/ObservableArray.h index f07b9c41bcb..59b31999ec2 100644 --- a/Libraries/LibWeb/WebIDL/ObservableArray.h +++ b/Libraries/LibWeb/WebIDL/ObservableArray.h @@ -37,7 +37,7 @@ public: for (auto& entry : indexed_properties()) { auto value_and_attributes = indexed_properties().storage()->get(entry.index()); if (value_and_attributes.has_value()) { - auto& style_sheet = verify_cast(value_and_attributes->value.as_object()); + auto& style_sheet = as(value_and_attributes->value.as_object()); callback(style_sheet); } } diff --git a/Libraries/LibWeb/WebIDL/Promise.cpp b/Libraries/LibWeb/WebIDL/Promise.cpp index c7eff45aad6..be2143637d9 100644 --- a/Libraries/LibWeb/WebIDL/Promise.cpp +++ b/Libraries/LibWeb/WebIDL/Promise.cpp @@ -141,7 +141,7 @@ GC::Ref react_to_promise(Promise const& promise, GC::Ptr // 7. Return PerformPromiseThen(promise.[[Promise]], onFulfilled, onRejected, newCapability). // FIXME: https://github.com/whatwg/webidl/issues/1443 // Returning newCapability instead of newCapability.[[Promise]. - auto promise_object = verify_cast(promise.promise().ptr()); + auto promise_object = as(promise.promise().ptr()); auto value = promise_object->perform_then(on_fulfilled, on_rejected, new_capability); VERIFY(value == new_capability->promise()); @@ -173,7 +173,7 @@ GC::Ref upon_rejection(Promise const& promise, GC::Ref s void mark_promise_as_handled(Promise const& promise) { // To mark as handled a Promise promise, set promise.[[Promise]].[[PromiseIsHandled]] to true. - auto promise_object = verify_cast(promise.promise().ptr()); + auto promise_object = as(promise.promise().ptr()); promise_object->set_is_handled(); } diff --git a/Libraries/LibWeb/XHR/XMLHttpRequest.cpp b/Libraries/LibWeb/XHR/XMLHttpRequest.cpp index ee96d0ba472..5d0cd39a858 100644 --- a/Libraries/LibWeb/XHR/XMLHttpRequest.cpp +++ b/Libraries/LibWeb/XHR/XMLHttpRequest.cpp @@ -144,7 +144,7 @@ WebIDL::ExceptionOr> XMLHttpRequest::response_xml() // 4. If this’s response object is non-null, then return it. if (!m_response_object.has()) - return &verify_cast(*m_response_object.get>()); + return &as(*m_response_object.get>()); // 5. Set a document response for this. set_document_response(); @@ -152,7 +152,7 @@ WebIDL::ExceptionOr> XMLHttpRequest::response_xml() // 6. Return this’s response object. if (m_response_object.has()) return nullptr; - return &verify_cast(*m_response_object.get>()); + return &as(*m_response_object.get>()); } // https://xhr.spec.whatwg.org/#dom-xmlhttprequest-responsetype diff --git a/Libraries/LibWeb/XML/XMLDocumentBuilder.cpp b/Libraries/LibWeb/XML/XMLDocumentBuilder.cpp index 7ae73a40e4f..4146345e996 100644 --- a/Libraries/LibWeb/XML/XMLDocumentBuilder.cpp +++ b/Libraries/LibWeb/XML/XMLDocumentBuilder.cpp @@ -301,7 +301,7 @@ void XMLDocumentBuilder::document_end() return; // Let window be the Document's relevant global object. - GC::Ref window = verify_cast(relevant_global_object(*document)); + GC::Ref window = as(relevant_global_object(*document)); // Set the Document's load timing info's load event start time to the current high resolution time given window. document->load_timing_info().load_event_start_time = HighResolutionTime::current_high_resolution_time(window); diff --git a/Libraries/LibWebView/Process.h b/Libraries/LibWebView/Process.h index cfbca5edb69..3f6010057a4 100644 --- a/Libraries/LibWebView/Process.h +++ b/Libraries/LibWebView/Process.h @@ -37,7 +37,7 @@ public: Optional client() { if (auto strong_connection = m_connection.strong_ref()) - return verify_cast(*strong_connection); + return as(*strong_connection); return {}; } diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp index 3f04e2e6759..57f5751f6e5 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp @@ -260,7 +260,7 @@ CppType idl_type_name_to_cpp_type(Type const& type, Interface const& interface) return { .name = "GC::Root", .sequence_storage_type = SequenceStorageType::RootVector }; if (type.name() == "sequence") { - auto& parameterized_type = verify_cast(type); + auto& parameterized_type = as(type); auto& sequence_type = parameterized_type.parameters().first(); auto sequence_cpp_type = idl_type_name_to_cpp_type(sequence_type, interface); auto storage_type_name = sequence_storage_type_to_cpp_storage_type_name(sequence_cpp_type.sequence_storage_type); @@ -272,7 +272,7 @@ CppType idl_type_name_to_cpp_type(Type const& type, Interface const& interface) } if (type.name() == "record") { - auto& parameterized_type = verify_cast(type); + auto& parameterized_type = as(type); auto& record_key_type = parameterized_type.parameters()[0]; auto& record_value_type = parameterized_type.parameters()[1]; auto record_key_cpp_type = idl_type_name_to_cpp_type(record_key_type, interface); @@ -282,7 +282,7 @@ CppType idl_type_name_to_cpp_type(Type const& type, Interface const& interface) } if (is(type)) { - auto& union_type = verify_cast(type); + auto& union_type = as(type); return { .name = union_type_to_variant(union_type, interface), .sequence_storage_type = SequenceStorageType::Vector }; } @@ -989,7 +989,7 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter // https://webidl.spec.whatwg.org/#es-sequence auto sequence_generator = scoped_generator.fork(); - auto& parameterized_type = verify_cast(*parameter.type); + auto& parameterized_type = as(*parameter.type); sequence_generator.set("recursion_depth", ByteString::number(recursion_depth)); // An ECMAScript value V is converted to an IDL sequence value as follows: @@ -1054,7 +1054,7 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter // https://webidl.spec.whatwg.org/#es-record auto record_generator = scoped_generator.fork(); - auto& parameterized_type = verify_cast(*parameter.type); + auto& parameterized_type = as(*parameter.type); record_generator.set("recursion_depth", ByteString::number(recursion_depth)); // A record can only have two types: key type and value type. @@ -1124,7 +1124,7 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter auto union_generator = scoped_generator.fork(); - auto& union_type = verify_cast(*parameter.type); + auto& union_type = as(*parameter.type); union_generator.set("union_type", union_type_to_variant(union_type, interface)); union_generator.set("recursion_depth", ByteString::number(recursion_depth)); @@ -1348,7 +1348,7 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter RefPtr sequence_type; for (auto& type : types) { if (type->name() == "sequence") { - sequence_type = verify_cast(*type); + sequence_type = as(*type); break; } } @@ -1388,7 +1388,7 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter RefPtr record_type; for (auto& type : types) { if (type->name() == "record") { - record_type = verify_cast(*type); + record_type = as(*type); break; } } @@ -1810,7 +1810,7 @@ static void generate_wrap_statement(SourceGenerator& generator, ByteString const } } else if (type.name() == "sequence") { // https://webidl.spec.whatwg.org/#es-sequence - auto& sequence_generic_type = verify_cast(type); + auto& sequence_generic_type = as(type); scoped_generator.append(R"~~~( auto new_array@recursion_depth@ = MUST(JS::Array::create(realm, 0)); @@ -1865,14 +1865,14 @@ static void generate_wrap_statement(SourceGenerator& generator, ByteString const )~~~"); } else if (type.name() == "Promise") { scoped_generator.append(R"~~~( - @result_expression@ GC::Ref { verify_cast(*@value@->promise()) }; + @result_expression@ GC::Ref { as(*@value@->promise()) }; )~~~"); } else if (type.name() == "ArrayBufferView" || type.name() == "BufferSource") { scoped_generator.append(R"~~~( @result_expression@ JS::Value(@value@->raw_object()); )~~~"); } else if (is(type)) { - auto& union_type = verify_cast(type); + auto& union_type = as(type); auto union_types = union_type.flattened_member_types(); auto union_generator = scoped_generator.fork(); @@ -2531,7 +2531,7 @@ static void generate_html_constructor(SourceGenerator& generator, IDL::Construct } constructor_generator.append(R"~~~( - auto& window = verify_cast(HTML::current_principal_global_object()); + auto& window = as(HTML::current_principal_global_object()); // 1. Let registry be current global object's custom element registry. auto registry = TRY(throw_dom_exception_if_needed(vm, [&] { return window.custom_elements(); })); @@ -3178,7 +3178,7 @@ JS::ThrowCompletionOr> @named_properties_class@ // 2. Let object be O.[[Realm]]'s global object. // 3. Assert: object implements A. - auto& object = verify_cast(realm.global_object()); + auto& object = as(realm.global_object()); // 4. If the result of running the named property visibility algorithm with property name P and object object is true, then: if (TRY(object.is_named_property_exposed_on_object(property_name))) { @@ -3810,7 +3810,7 @@ JS_DEFINE_NATIVE_FUNCTION(@class_name@::@attribute.getter_callback@) else if (attribute.type->is_nullable() && attribute.type->name() == "Element") { // The getter steps are to return the result of running this's get the attr-associated element. attribute_generator.append(R"~~~( - auto retval = GC::Ptr {}; + auto retval = GC::Ptr {}; )~~~"); // 1. Let element be the result of running reflectedTarget's get the element. diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateWebGLRenderingContext.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateWebGLRenderingContext.cpp index 3542f490833..7aa31284d4e 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateWebGLRenderingContext.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateWebGLRenderingContext.cpp @@ -1110,7 +1110,7 @@ public: count = vector_data.size() / matrix_size; } else { auto& typed_array_base = static_cast(*@array_argument_name@.get>()->raw_object()); - auto& float32_array = verify_cast(typed_array_base); + auto& float32_array = as(typed_array_base); raw_data = float32_array.data().data(); count = float32_array.array_length().length() / matrix_size; } @@ -1162,7 +1162,7 @@ public: count = vector.size(); } else if (v.has>()) { auto& typed_array_base = static_cast(*v.get>()->raw_object()); - auto& typed_array = verify_cast(typed_array_base); + auto& typed_array = as(typed_array_base); data = typed_array.data().data(); count = typed_array.array_length().length(); } else { @@ -1203,7 +1203,7 @@ public: } auto& typed_array_base = static_cast(*values.get>()->raw_object()); - auto& float32_array = verify_cast(typed_array_base); + auto& float32_array = as(typed_array_base); float const* data = float32_array.data().data(); glVertexAttrib@number_of_vector_elements@fv(index, data); )~~~"); @@ -1544,7 +1544,7 @@ public: count = vector.size(); } else if (values.has>()) { auto& typed_array_base = static_cast(*values.get>()->raw_object()); - auto& typed_array = verify_cast(typed_array_base); + auto& typed_array = as(typed_array_base); data = typed_array.data().data(); count = typed_array.array_length().length(); } else { diff --git a/Services/WebContent/ConnectionFromClient.cpp b/Services/WebContent/ConnectionFromClient.cpp index 006665efa5e..325664aee16 100644 --- a/Services/WebContent/ConnectionFromClient.cpp +++ b/Services/WebContent/ConnectionFromClient.cpp @@ -505,7 +505,7 @@ void ConnectionFromClient::inspect_dom_node(u64 page_id, Web::UniqueNodeID const node->document().set_inspected_node(node, pseudo_element); if (node->is_element()) { - auto& element = verify_cast(*node); + auto& element = as(*node); if (!element.computed_properties()) { async_did_inspect_dom_node(page_id, false, {}, {}, {}, {}, {}, {}); return; diff --git a/Services/WebContent/PageClient.cpp b/Services/WebContent/PageClient.cpp index 1b8adf3733d..8a6f3d02649 100644 --- a/Services/WebContent/PageClient.cpp +++ b/Services/WebContent/PageClient.cpp @@ -349,7 +349,7 @@ void PageClient::page_did_change_active_document_in_top_level_browsing_context(W auto& realm = document.realm(); if (auto console_client = document.console_client()) { - auto& web_content_console_client = verify_cast(*console_client); + auto& web_content_console_client = as(*console_client); m_top_level_document_console_client = web_content_console_client; auto console_object = realm.intrinsics().console_object(); diff --git a/Services/WebContent/WebContentConsoleClient.cpp b/Services/WebContent/WebContentConsoleClient.cpp index b23a3737a61..1376c3c4a0e 100644 --- a/Services/WebContent/WebContentConsoleClient.cpp +++ b/Services/WebContent/WebContentConsoleClient.cpp @@ -30,7 +30,7 @@ WebContentConsoleClient::WebContentConsoleClient(JS::Console& console, JS::Realm : ConsoleClient(console) , m_client(client) { - auto& window = verify_cast(realm.global_object()); + auto& window = as(realm.global_object()); m_console_global_environment_extensions = realm.create(realm, window); } diff --git a/Services/WebWorker/DedicatedWorkerHost.cpp b/Services/WebWorker/DedicatedWorkerHost.cpp index 74ae018161f..0a28c47d33a 100644 --- a/Services/WebWorker/DedicatedWorkerHost.cpp +++ b/Services/WebWorker/DedicatedWorkerHost.cpp @@ -55,7 +55,7 @@ void DedicatedWorkerHost::run(GC::Ref page, Web::HTML::TransferDataHo // 8. Let worker global scope be the global object of realm execution context's Realm component. // NOTE: This is the DedicatedWorkerGlobalScope or SharedWorkerGlobalScope object created in the previous step. - GC::Ref worker_global_scope = verify_cast(realm_execution_context->realm->global_object()); + GC::Ref worker_global_scope = as(realm_execution_context->realm->global_object()); // 9. Set up a worker environment settings object with realm execution context, // outside settings, and unsafeWorkerCreationTime, and let inside settings be the result. @@ -187,7 +187,7 @@ void DedicatedWorkerHost::run(GC::Ref page, Web::HTML::TransferDataHo if (is(*script)) (void)static_cast(*script).run(); else - (void)verify_cast(*script).run(); + (void)as(*script).run(); // FIXME: 11. Enable outside port's port message queue. diff --git a/Tests/AK/TestVariant.cpp b/Tests/AK/TestVariant.cpp index 63d61b7f6f3..d97f58019a5 100644 --- a/Tests/AK/TestVariant.cpp +++ b/Tests/AK/TestVariant.cpp @@ -110,7 +110,7 @@ TEST_CASE(move_moves) EXPECT(second_variant.has()); } -TEST_CASE(verify_cast) +TEST_CASE(as) { Variant one_integer_to_rule_them_all { static_cast(42) }; auto fake_integer = one_integer_to_rule_them_all.downcast(); diff --git a/UI/Android/src/main/cpp/ALooperEventLoopImplementation.cpp b/UI/Android/src/main/cpp/ALooperEventLoopImplementation.cpp index 40311bcefe0..344eea042ac 100644 --- a/UI/Android/src/main/cpp/ALooperEventLoopImplementation.cpp +++ b/UI/Android/src/main/cpp/ALooperEventLoopImplementation.cpp @@ -24,7 +24,7 @@ EventLoopThreadData& EventLoopThreadData::the() static ALooperEventLoopImplementation& current_impl() { - return verify_cast(Core::EventLoop::current().impl()); + return as(Core::EventLoop::current().impl()); } static int looper_callback(int fd, int events, void* data); diff --git a/UI/AppKit/Interface/Event.mm b/UI/AppKit/Interface/Event.mm index 1f5dfc7368b..ce627469801 100644 --- a/UI/AppKit/Interface/Event.mm +++ b/UI/AppKit/Interface/Event.mm @@ -131,7 +131,7 @@ Web::DragEvent ns_event_to_drag_event(Web::DragEvent::Type type, id drag_event_url_list(Web::DragEvent const& event) { - auto& chrome_data = verify_cast(*event.chrome_data); + auto& chrome_data = as(*event.chrome_data); return move(chrome_data.urls); } @@ -322,7 +322,7 @@ Web::KeyEvent ns_event_to_key_event(Web::KeyEvent::Type type, NSEvent* event) NSEvent* key_event_to_ns_event(Web::KeyEvent const& event) { - auto& chrome_data = verify_cast(*event.chrome_data); + auto& chrome_data = as(*event.chrome_data); return chrome_data.take_event(); } diff --git a/UI/Qt/BrowserWindow.cpp b/UI/Qt/BrowserWindow.cpp index aaa3f0e2c50..878da0b0cdc 100644 --- a/UI/Qt/BrowserWindow.cpp +++ b/UI/Qt/BrowserWindow.cpp @@ -59,7 +59,7 @@ public: { if (!isVisible()) return; - auto* browser_window = verify_cast(parentWidget()); + auto* browser_window = as(parentWidget()); if (!browser_window) return; auto* current_tab = browser_window->current_tab(); @@ -626,7 +626,7 @@ BrowserWindow::BrowserWindow(Vector const& initial_urls, IsPopupWindow m_settings_dialog->setFocus(); }); QObject::connect(m_tabs_container, &QTabWidget::currentChanged, [this](int index) { - auto* tab = verify_cast(m_tabs_container->widget(index)); + auto* tab = as(m_tabs_container->widget(index)); if (tab) setWindowTitle(QString("%1 - Ladybird").arg(tab->title())); @@ -915,7 +915,7 @@ void BrowserWindow::create_close_button_for_tab(Tab* tab) void BrowserWindow::tab_audio_play_state_changed(int index, Web::HTML::AudioPlayState play_state) { - auto* tab = verify_cast(m_tabs_container->widget(index)); + auto* tab = as(m_tabs_container->widget(index)); auto position = audio_button_position_for_tab(index); switch (play_state) { @@ -939,7 +939,7 @@ void BrowserWindow::tab_audio_play_state_changed(int index, Web::HTML::AudioPlay break; case Web::HTML::AudioPlayState::Playing: auto* button = m_tabs_container->tabBar()->tabButton(index, position); - verify_cast(button)->setIcon(icon_for_page_mute_state(*tab)); + as(button)->setIcon(icon_for_page_mute_state(*tab)); button->setToolTip(tool_tip_for_page_mute_state(*tab)); break; } @@ -952,7 +952,7 @@ void BrowserWindow::tab_audio_play_state_changed(int index, Web::HTML::AudioPlay void BrowserWindow::tab_navigation_buttons_state_changed(int index) { - auto* tab = verify_cast(m_tabs_container->widget(index)); + auto* tab = as(m_tabs_container->widget(index)); tab->update_navigation_buttons_state(); } diff --git a/UI/Qt/BrowserWindow.h b/UI/Qt/BrowserWindow.h index eafe0ca3cc5..dcad36a4eb6 100644 --- a/UI/Qt/BrowserWindow.h +++ b/UI/Qt/BrowserWindow.h @@ -160,7 +160,7 @@ private: void for_each_tab(Callback&& callback) { for (int i = 0; i < m_tabs_container->count(); ++i) { - auto& tab = verify_cast(*m_tabs_container->widget(i)); + auto& tab = as(*m_tabs_container->widget(i)); callback(tab); } } diff --git a/UI/Qt/TabBar.cpp b/UI/Qt/TabBar.cpp index 744327bfb8e..5abde4b1854 100644 --- a/UI/Qt/TabBar.cpp +++ b/UI/Qt/TabBar.cpp @@ -40,8 +40,8 @@ QSize TabBar::tabSizeHint(int index) const void TabBar::contextMenuEvent(QContextMenuEvent* event) { - auto* tab_widget = verify_cast(this->parent()); - auto* tab = verify_cast(tab_widget->widget(tabAt(event->pos()))); + auto* tab_widget = as(this->parent()); + auto* tab = as(tab_widget->widget(tabAt(event->pos()))); if (tab) tab->context_menu()->exec(event->globalPos()); } @@ -147,7 +147,7 @@ QRect TabStyle::subElementRect(QStyle::SubElement sub_element, QStyleOption cons { // Place our add-tab button (set as the top-right corner widget) directly after the last tab if (sub_element == QStyle::SE_TabWidgetRightCorner) { - auto* tab_widget = verify_cast(widget); + auto* tab_widget = as(widget); auto tab_bar_size = tab_widget->tabBar()->sizeHint(); auto new_tab_button_size = tab_bar_size.height(); return QRect { diff --git a/UI/Qt/WebContentView.cpp b/UI/Qt/WebContentView.cpp index ae98bd594c9..265507bc146 100644 --- a/UI/Qt/WebContentView.cpp +++ b/UI/Qt/WebContentView.cpp @@ -827,7 +827,7 @@ void WebContentView::finish_handling_drag_event(Web::DragEvent const& event) if (event.type != Web::DragEvent::Type::Drop) return; - auto const& chrome_data = verify_cast(*event.chrome_data); + auto const& chrome_data = as(*event.chrome_data); emit urls_dropped(chrome_data.urls); } @@ -867,7 +867,7 @@ void WebContentView::enqueue_native_event(Web::KeyEvent::Type type, QKeyEvent co void WebContentView::finish_handling_key_event(Web::KeyEvent const& key_event) { - auto& chrome_data = verify_cast(*key_event.chrome_data); + auto& chrome_data = as(*key_event.chrome_data); auto& event = *chrome_data.event; switch (key_event.type) {