mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-22 09:12:13 -05:00
parent
a0b44ff5e7
commit
85b424464a
Notes:
github-actions[bot]
2025-01-21 16:49:39 +00:00
Author: https://github.com/trflynn89 Commit: https://github.com/LadybirdBrowser/ladybird/commit/85b424464a1 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3335
191 changed files with 574 additions and 574 deletions
|
@ -36,7 +36,7 @@ ALWAYS_INLINE bool is(NonnullRefPtr<InputType> const& input)
|
|||
}
|
||||
|
||||
template<typename OutputType, typename InputType>
|
||||
ALWAYS_INLINE CopyConst<InputType, OutputType>* verify_cast(InputType* input)
|
||||
ALWAYS_INLINE CopyConst<InputType, OutputType>* as(InputType* input)
|
||||
{
|
||||
static_assert(IsBaseOf<InputType, OutputType>);
|
||||
VERIFY(!input || is<OutputType>(*input));
|
||||
|
@ -44,7 +44,7 @@ ALWAYS_INLINE CopyConst<InputType, OutputType>* verify_cast(InputType* input)
|
|||
}
|
||||
|
||||
template<typename OutputType, typename InputType>
|
||||
ALWAYS_INLINE CopyConst<InputType, OutputType>& verify_cast(InputType& input)
|
||||
ALWAYS_INLINE CopyConst<InputType, OutputType>& as(InputType& input)
|
||||
{
|
||||
static_assert(IsBaseOf<InputType, OutputType>);
|
||||
VERIFY(is<OutputType>(input));
|
||||
|
@ -70,7 +70,7 @@ ALWAYS_INLINE CopyConst<InputType, OutputType>* as_if(InputType* input)
|
|||
}
|
||||
|
||||
#if USING_AK_GLOBALLY
|
||||
using AK::as;
|
||||
using AK::as_if;
|
||||
using AK::is;
|
||||
using AK::verify_cast;
|
||||
#endif
|
||||
|
|
|
@ -284,13 +284,13 @@ FileWatcher::~FileWatcher() = default;
|
|||
|
||||
ErrorOr<bool> FileWatcherBase::add_watch(ByteString path, FileWatcherEvent::Type event_mask)
|
||||
{
|
||||
auto& file_watcher = verify_cast<FileWatcherMacOS>(*this);
|
||||
auto& file_watcher = as<FileWatcherMacOS>(*this);
|
||||
return file_watcher.add_watch(move(path), event_mask);
|
||||
}
|
||||
|
||||
ErrorOr<bool> FileWatcherBase::remove_watch(ByteString path)
|
||||
{
|
||||
auto& file_watcher = verify_cast<FileWatcherMacOS>(*this);
|
||||
auto& file_watcher = as<FileWatcherMacOS>(*this);
|
||||
return file_watcher.remove_watch(move(path));
|
||||
}
|
||||
|
||||
|
|
|
@ -71,11 +71,11 @@ struct ForeignRef {
|
|||
DeferGC const defer_gc(heap);
|
||||
auto* cell = T::create(&heap, forward<Args>(args)...);
|
||||
if constexpr (IsSame<decltype(cell), Cell*>) {
|
||||
return ForeignRef(*verify_cast<ForeignCell>(cell));
|
||||
return ForeignRef(*as<ForeignCell>(cell));
|
||||
} else {
|
||||
static_assert(IsSame<decltype(cell), void*>);
|
||||
auto* cast_cell = static_cast<Cell*>(cell);
|
||||
return ForeignRef(*verify_cast<ForeignCell>(cast_cell));
|
||||
return ForeignRef(*as<ForeignCell>(cast_cell));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ ScaledFont::ScaledFont(NonnullRefPtr<Typeface> typeface, float point_width, floa
|
|||
m_pixel_size = m_point_height * (DEFAULT_DPI / POINTS_PER_INCH);
|
||||
m_pixel_size_rounded_up = static_cast<int>(ceilf(m_pixel_size));
|
||||
|
||||
auto const* sk_typeface = verify_cast<TypefaceSkia>(*m_typeface).sk_typeface();
|
||||
auto const* sk_typeface = as<TypefaceSkia>(*m_typeface).sk_typeface();
|
||||
SkFont const font { sk_ref_sp(sk_typeface), m_pixel_size };
|
||||
|
||||
SkFontMetrics skMetrics;
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace Gfx {
|
|||
|
||||
SkFont ScaledFont::skia_font(float scale) const
|
||||
{
|
||||
auto const& sk_typeface = verify_cast<TypefaceSkia>(*m_typeface).sk_typeface();
|
||||
auto const& sk_typeface = as<TypefaceSkia>(*m_typeface).sk_typeface();
|
||||
auto sk_font = SkFont { sk_ref_sp(sk_typeface), pixel_size() * scale };
|
||||
sk_font.setSubpixel(true);
|
||||
return sk_font;
|
||||
|
|
|
@ -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<ScaledFont>(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<ScaledFont>(font).skia_font(1), m_path.ptr());
|
||||
}
|
||||
NonnullOwnPtr<PathImpl> PathImplSkia::place_text_along(Utf8View text, Font const& font) const
|
||||
{
|
||||
auto sk_font = verify_cast<ScaledFont>(font).skia_font(1);
|
||||
auto sk_font = as<ScaledFont>(font).skia_font(1);
|
||||
size_t const text_length = text.length();
|
||||
SkScalar x = 0;
|
||||
SkScalar y = 0;
|
||||
|
|
|
@ -12,22 +12,22 @@ namespace IDL {
|
|||
|
||||
ParameterizedType const& Type::as_parameterized() const
|
||||
{
|
||||
return verify_cast<ParameterizedType const>(*this);
|
||||
return as<ParameterizedType const>(*this);
|
||||
}
|
||||
|
||||
ParameterizedType& Type::as_parameterized()
|
||||
{
|
||||
return verify_cast<ParameterizedType>(*this);
|
||||
return as<ParameterizedType>(*this);
|
||||
}
|
||||
|
||||
UnionType const& Type::as_union() const
|
||||
{
|
||||
return verify_cast<UnionType const>(*this);
|
||||
return as<UnionType const>(*this);
|
||||
}
|
||||
|
||||
UnionType& Type::as_union()
|
||||
{
|
||||
return verify_cast<UnionType>(*this);
|
||||
return as<UnionType>(*this);
|
||||
}
|
||||
|
||||
// https://webidl.spec.whatwg.org/#dfn-includes-a-nullable-type
|
||||
|
|
|
@ -1217,8 +1217,8 @@ ByteString MemberExpression::to_string_approximation() const
|
|||
if (is_computed())
|
||||
return ByteString::formatted("{}[<computed>]", object_string);
|
||||
if (is<PrivateIdentifier>(*m_property))
|
||||
return ByteString::formatted("{}.{}", object_string, verify_cast<PrivateIdentifier>(*m_property).string());
|
||||
return ByteString::formatted("{}.{}", object_string, verify_cast<Identifier>(*m_property).string());
|
||||
return ByteString::formatted("{}.{}", object_string, as<PrivateIdentifier>(*m_property).string());
|
||||
return ByteString::formatted("{}.{}", object_string, as<Identifier>(*m_property).string());
|
||||
}
|
||||
|
||||
bool MemberExpression::ends_in_private_name() const
|
||||
|
|
|
@ -611,13 +611,13 @@ Bytecode::CodeGenerationErrorOr<Optional<ScopedOperand>> AssignmentExpression::g
|
|||
else
|
||||
generator.emit<Bytecode::Op::PutByValueWithThis>(*base, *computed_property, *this_value, rval);
|
||||
} else if (expression.property().is_identifier()) {
|
||||
auto identifier_table_ref = generator.intern_identifier(verify_cast<Identifier>(expression.property()).string());
|
||||
auto identifier_table_ref = generator.intern_identifier(as<Identifier>(expression.property()).string());
|
||||
if (!lhs_is_super_expression)
|
||||
generator.emit<Bytecode::Op::PutById>(*base, identifier_table_ref, rval, Bytecode::Op::PropertyKind::KeyValue, generator.next_property_lookup_cache(), move(base_identifier));
|
||||
else
|
||||
generator.emit<Bytecode::Op::PutByIdWithThis>(*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<PrivateIdentifier>(expression.property()).string());
|
||||
auto identifier_table_ref = generator.intern_identifier(as<PrivateIdentifier>(expression.property()).string());
|
||||
generator.emit<Bytecode::Op::PutPrivateById>(*base, identifier_table_ref, rval);
|
||||
} else {
|
||||
return Bytecode::CodeGenerationError {
|
||||
|
@ -985,7 +985,7 @@ Bytecode::CodeGenerationErrorOr<Optional<ScopedOperand>> ForStatement::generate_
|
|||
|
||||
if (m_init) {
|
||||
if (m_init->is_variable_declaration()) {
|
||||
auto& variable_declaration = verify_cast<VariableDeclaration>(*m_init);
|
||||
auto& variable_declaration = as<VariableDeclaration>(*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<BaseAndValue> get_base_and_value_from_mem
|
|||
generator.emit<Bytecode::Op::GetByValueWithThis>(value, super_base, *computed_property, this_value);
|
||||
} else {
|
||||
// 3. Let propertyKey be StringValue of IdentifierName.
|
||||
auto identifier_table_ref = generator.intern_identifier(verify_cast<Identifier>(member_expression.property()).string());
|
||||
auto identifier_table_ref = generator.intern_identifier(as<Identifier>(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<BaseAndValue> get_base_and_value_from_mem
|
|||
generator.emit<Bytecode::Op::GetPrivateById>(
|
||||
value,
|
||||
base,
|
||||
generator.intern_identifier(verify_cast<PrivateIdentifier>(member_expression.property()).string()));
|
||||
generator.intern_identifier(as<PrivateIdentifier>(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<Identifier>(member_expression.property()).string()), move(base_identifier));
|
||||
generator.emit_get_by_id(value, base, generator.intern_identifier(as<Identifier>(member_expression.property()).string()), move(base_identifier));
|
||||
}
|
||||
|
||||
return BaseAndValue { base, value };
|
||||
|
|
|
@ -660,7 +660,7 @@ CodeGenerationErrorOr<Generator::ReferenceOperands> Generator::emit_load_from_re
|
|||
emit<Bytecode::Op::GetByValueWithThis>(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<Identifier>(expression.property()).string());
|
||||
auto identifier_table_ref = intern_identifier(as<Identifier>(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::ReferenceOperands> Generator::emit_load_from_re
|
|||
};
|
||||
}
|
||||
if (expression.property().is_identifier()) {
|
||||
auto identifier_table_ref = intern_identifier(verify_cast<Identifier>(expression.property()).string());
|
||||
auto identifier_table_ref = intern_identifier(as<Identifier>(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::ReferenceOperands> Generator::emit_load_from_re
|
|||
};
|
||||
}
|
||||
if (expression.property().is_private_identifier()) {
|
||||
auto identifier_table_ref = intern_identifier(verify_cast<PrivateIdentifier>(expression.property()).string());
|
||||
auto identifier_table_ref = intern_identifier(as<PrivateIdentifier>(expression.property()).string());
|
||||
auto dst = preferred_dst.has_value() ? preferred_dst.value() : allocate_register();
|
||||
emit<Bytecode::Op::GetPrivateById>(dst, base, identifier_table_ref);
|
||||
return ReferenceOperands {
|
||||
|
@ -733,7 +733,7 @@ CodeGenerationErrorOr<void> Generator::emit_store_to_reference(JS::ASTNode const
|
|||
emit<Bytecode::Op::PutByValueWithThis>(*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<Identifier>(expression.property()).string());
|
||||
auto identifier_table_ref = intern_identifier(as<Identifier>(expression.property()).string());
|
||||
emit<Bytecode::Op::PutByIdWithThis>(*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<void> Generator::emit_store_to_reference(JS::ASTNode const
|
|||
auto property = TRY(expression.property().generate_bytecode(*this)).value();
|
||||
emit<Bytecode::Op::PutByValue>(object, property, value);
|
||||
} else if (expression.property().is_identifier()) {
|
||||
auto identifier_table_ref = intern_identifier(verify_cast<Identifier>(expression.property()).string());
|
||||
auto identifier_table_ref = intern_identifier(as<Identifier>(expression.property()).string());
|
||||
emit<Bytecode::Op::PutById>(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<PrivateIdentifier>(expression.property()).string());
|
||||
auto identifier_table_ref = intern_identifier(as<PrivateIdentifier>(expression.property()).string());
|
||||
emit<Bytecode::Op::PutPrivateById>(object, identifier_table_ref, value);
|
||||
} else {
|
||||
return CodeGenerationError {
|
||||
|
@ -808,7 +808,7 @@ CodeGenerationErrorOr<Optional<ScopedOperand>> Generator::emit_delete_reference(
|
|||
if (super_reference.referenced_name.has_value()) {
|
||||
emit<Bytecode::Op::DeleteByValueWithThis>(dst, *super_reference.base, *super_reference.this_value, *super_reference.referenced_name);
|
||||
} else {
|
||||
auto identifier_table_ref = intern_identifier(verify_cast<Identifier>(expression.property()).string());
|
||||
auto identifier_table_ref = intern_identifier(as<Identifier>(expression.property()).string());
|
||||
emit<Bytecode::Op::DeleteByIdWithThis>(dst, *super_reference.base, *super_reference.this_value, identifier_table_ref);
|
||||
}
|
||||
|
||||
|
@ -822,7 +822,7 @@ CodeGenerationErrorOr<Optional<ScopedOperand>> Generator::emit_delete_reference(
|
|||
auto property = TRY(expression.property().generate_bytecode(*this)).value();
|
||||
emit<Bytecode::Op::DeleteByValue>(dst, object, property);
|
||||
} else if (expression.property().is_identifier()) {
|
||||
auto identifier_table_ref = intern_identifier(verify_cast<Identifier>(expression.property()).string());
|
||||
auto identifier_table_ref = intern_identifier(as<Identifier>(expression.property()).string());
|
||||
emit<Bytecode::Op::DeleteById>(dst, object, identifier_table_ref);
|
||||
} else {
|
||||
// NOTE: Trying to delete a private field generates a SyntaxError in the parser.
|
||||
|
|
|
@ -1499,7 +1499,7 @@ inline ThrowCompletionOr<void> 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<GlobalEnvironment>(vm.variable_environment())->create_global_var_binding(name, false);
|
||||
return as<GlobalEnvironment>(vm.variable_environment())->create_global_var_binding(name, false);
|
||||
}
|
||||
|
||||
inline ThrowCompletionOr<ECMAScriptFunctionObject*> new_class(VM& vm, Value super_class, ClassExpression const& class_expression, Optional<IdentifierTableIndex> const& lhs_name, ReadonlySpan<Value> element_keys)
|
||||
|
@ -1555,7 +1555,7 @@ inline ThrowCompletionOr<GC::Ref<Object>> super_call_with_argument_array(VM& vm,
|
|||
auto result = TRY(construct(vm, static_cast<FunctionObject&>(*func), arg_list.span(), &new_target.as_function()));
|
||||
|
||||
// 7. Let thisER be GetThisEnvironment().
|
||||
auto& this_environment = verify_cast<FunctionEnvironment>(*get_this_environment(vm));
|
||||
auto& this_environment = as<FunctionEnvironment>(*get_this_environment(vm));
|
||||
|
||||
// 8. Perform ? thisER.BindThisValue(result).
|
||||
TRY(this_environment.bind_this_value(vm, result));
|
||||
|
@ -1575,7 +1575,7 @@ inline ThrowCompletionOr<GC::Ref<Object>> super_call_with_argument_array(VM& vm,
|
|||
|
||||
inline ThrowCompletionOr<GC::Ref<Array>> iterator_to_array(VM& vm, Value iterator)
|
||||
{
|
||||
auto& iterator_record = verify_cast<IteratorRecord>(iterator.as_object());
|
||||
auto& iterator_record = as<IteratorRecord>(iterator.as_object());
|
||||
|
||||
auto array = MUST(Array::create(*vm.current_realm(), 0));
|
||||
size_t index = 0;
|
||||
|
@ -2522,7 +2522,7 @@ ThrowCompletionOr<void> ResolveSuperBase::execute_impl(Bytecode::Interpreter& in
|
|||
auto& vm = interpreter.vm();
|
||||
|
||||
// 1. Let env be GetThisEnvironment().
|
||||
auto& env = verify_cast<FunctionEnvironment>(*get_this_environment(vm));
|
||||
auto& env = as<FunctionEnvironment>(*get_this_environment(vm));
|
||||
|
||||
// 2. Assert: env.HasSuperBinding() is true.
|
||||
VERIFY(env.has_super_binding());
|
||||
|
@ -2870,14 +2870,14 @@ ThrowCompletionOr<void> GetIterator::execute_impl(Bytecode::Interpreter& interpr
|
|||
|
||||
ThrowCompletionOr<void> GetObjectFromIteratorRecord::execute_impl(Bytecode::Interpreter& interpreter) const
|
||||
{
|
||||
auto& iterator_record = verify_cast<IteratorRecord>(interpreter.get(m_iterator_record).as_object());
|
||||
auto& iterator_record = as<IteratorRecord>(interpreter.get(m_iterator_record).as_object());
|
||||
interpreter.set(m_object, iterator_record.iterator);
|
||||
return {};
|
||||
}
|
||||
|
||||
ThrowCompletionOr<void> GetNextMethodFromIteratorRecord::execute_impl(Bytecode::Interpreter& interpreter) const
|
||||
{
|
||||
auto& iterator_record = verify_cast<IteratorRecord>(interpreter.get(m_iterator_record).as_object());
|
||||
auto& iterator_record = as<IteratorRecord>(interpreter.get(m_iterator_record).as_object());
|
||||
interpreter.set(m_next_method, iterator_record.next_method);
|
||||
return {};
|
||||
}
|
||||
|
@ -2900,7 +2900,7 @@ ThrowCompletionOr<void> GetObjectPropertyIterator::execute_impl(Bytecode::Interp
|
|||
ThrowCompletionOr<void> IteratorClose::execute_impl(Bytecode::Interpreter& interpreter) const
|
||||
{
|
||||
auto& vm = interpreter.vm();
|
||||
auto& iterator = verify_cast<IteratorRecord>(interpreter.get(m_iterator_record).as_object());
|
||||
auto& iterator = as<IteratorRecord>(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<void> IteratorClose::execute_impl(Bytecode::Interpreter& inter
|
|||
ThrowCompletionOr<void> AsyncIteratorClose::execute_impl(Bytecode::Interpreter& interpreter) const
|
||||
{
|
||||
auto& vm = interpreter.vm();
|
||||
auto& iterator = verify_cast<IteratorRecord>(interpreter.get(m_iterator_record).as_object());
|
||||
auto& iterator = as<IteratorRecord>(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<void> AsyncIteratorClose::execute_impl(Bytecode::Interpreter&
|
|||
ThrowCompletionOr<void> IteratorNext::execute_impl(Bytecode::Interpreter& interpreter) const
|
||||
{
|
||||
auto& vm = interpreter.vm();
|
||||
auto& iterator_record = verify_cast<IteratorRecord>(interpreter.get(m_iterator_record).as_object());
|
||||
auto& iterator_record = as<IteratorRecord>(interpreter.get(m_iterator_record).as_object());
|
||||
interpreter.set(dst(), TRY(iterator_next(vm, iterator_record)));
|
||||
return {};
|
||||
}
|
||||
|
|
|
@ -334,7 +334,7 @@ ThrowCompletionOr<Promise*> 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<Promise>(m_top_level_capability->promise().ptr());
|
||||
return as<Promise>(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<Promise*> 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<Promise>(m_top_level_capability->promise().ptr());
|
||||
return as<Promise>(m_top_level_capability->promise().ptr());
|
||||
}
|
||||
|
||||
// 5. Let stack be a new empty List.
|
||||
|
@ -414,7 +414,7 @@ ThrowCompletionOr<Promise*> CyclicModule::evaluate(VM& vm)
|
|||
}
|
||||
|
||||
// 11. Return capability.[[Promise]].
|
||||
return verify_cast<Promise>(m_top_level_capability->promise().ptr());
|
||||
return as<Promise>(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<u32> CyclicModule::inner_module_evaluation(VM& vm, Vector<Modu
|
|||
if (!is<CyclicModule>(*required_module))
|
||||
continue;
|
||||
|
||||
GC::Ref<CyclicModule> cyclic_module = verify_cast<CyclicModule>(*required_module);
|
||||
GC::Ref<CyclicModule> cyclic_module = as<CyclicModule>(*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<Promise>(capability->promise().ptr())->perform_then(on_fulfilled, on_rejected, {});
|
||||
as<Promise>(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<PromiseCapability> promise_capability, Thro
|
|||
|
||||
// 8. Perform PerformPromiseThen(loadPromise, linkAndEvaluate, onRejected).
|
||||
// FIXME: This is likely a spec bug, see load_requested_modules.
|
||||
verify_cast<Promise>(*load_promise.promise()).perform_then(link_and_evaluate, on_rejected, {});
|
||||
as<Promise>(*load_promise.promise()).perform_then(link_and_evaluate, on_rejected, {});
|
||||
|
||||
// 9. Return unused.
|
||||
}
|
||||
|
|
|
@ -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<FunctionEnvironment>(*env).function_object();
|
||||
auto& active_function = as<FunctionEnvironment>(*env).function_object();
|
||||
|
||||
// 5. Let superConstructor be ! activeFunction.[[GetPrototypeOf]]().
|
||||
auto* super_constructor = MUST(active_function.internal_get_prototype_of());
|
||||
|
@ -1715,7 +1715,7 @@ ThrowCompletionOr<Value> perform_import_call(VM& vm, Value specifier, Value opti
|
|||
if (active_script_or_module.has<GC::Ref<Script>>())
|
||||
return active_script_or_module.get<GC::Ref<Script>>();
|
||||
|
||||
return GC::Ref<CyclicModule> { verify_cast<CyclicModule>(*active_script_or_module.get<GC::Ref<Module>>()) };
|
||||
return GC::Ref<CyclicModule> { as<CyclicModule>(*active_script_or_module.get<GC::Ref<Module>>()) };
|
||||
}();
|
||||
|
||||
// 7. Let promiseCapability be ! NewPromiseCapability(%Promise%).
|
||||
|
|
|
@ -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<Promise>(value_wrapper)->perform_then(move(on_fulfilled), js_undefined(), &promise_capability);
|
||||
as<Promise>(value_wrapper)->perform_then(move(on_fulfilled), js_undefined(), &promise_capability);
|
||||
|
||||
// 12. Return promiseCapability.[[Promise]].
|
||||
return promise_capability.promise();
|
||||
|
|
|
@ -104,7 +104,7 @@ ThrowCompletionOr<void> 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>(promise_object);
|
||||
m_current_promise = as<Promise>(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
|
||||
|
|
|
@ -134,7 +134,7 @@ ThrowCompletionOr<void> 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>(promise_object);
|
||||
m_current_promise = as<Promise>(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>(promise);
|
||||
m_current_promise = as<Promise>(promise);
|
||||
m_current_promise->perform_then(on_fulfilled, on_rejected, {});
|
||||
|
||||
// 15. Return unused.
|
||||
|
|
|
@ -93,7 +93,7 @@ ThrowCompletionOr<Value> 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>(promise_object);
|
||||
auto promise = as<Promise>(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
|
||||
|
|
|
@ -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<FunctionEnvironment>(*local_env).bind_this_value(vm, this_value));
|
||||
MUST(as<FunctionEnvironment>(*local_env).bind_this_value(vm, this_value));
|
||||
|
||||
// 10. Return unused.
|
||||
}
|
||||
|
|
|
@ -265,7 +265,7 @@ ThrowCompletionOr<Value> shadow_realm_import_value(VM& vm, ByteString specifier_
|
|||
});
|
||||
|
||||
// 13. Return PerformPromiseThen(innerCapability.[[Promise]], onFulfilled, callerRealm.[[Intrinsics]].[[%ThrowTypeError%]], promiseCapability).
|
||||
return verify_cast<Promise>(inner_capability->promise().ptr())->perform_then(on_fulfilled, throw_type_error, promise_capability);
|
||||
return as<Promise>(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
|
||||
|
|
|
@ -352,7 +352,7 @@ Value VM::get_new_target()
|
|||
|
||||
// 2. Assert: envRec has a [[NewTarget]] field.
|
||||
// 3. Return envRec.[[NewTarget]].
|
||||
return verify_cast<FunctionEnvironment>(*env).new_target();
|
||||
return as<FunctionEnvironment>(*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<SourceTextModule>(*script_or_module.get<GC::Ref<Module>>());
|
||||
auto& module = as<SourceTextModule>(*script_or_module.get<GC::Ref<Module>>());
|
||||
|
||||
// 3. Let importMeta be module.[[ImportMeta]].
|
||||
auto* import_meta = module.import_meta();
|
||||
|
@ -553,7 +553,7 @@ ThrowCompletionOr<void> 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>(*promise_capability.promise()); promise.state() == Promise::State::Rejected)
|
||||
if (auto const& promise = as<Promise>(*promise_capability.promise()); promise.state() == Promise::State::Rejected)
|
||||
return JS::throw_completion(promise.result());
|
||||
|
||||
dbgln_if(JS_MODULE_DEBUG, "[JS MODULE] Linking module {}", filename);
|
||||
|
|
|
@ -732,7 +732,7 @@ ThrowCompletionOr<void> SourceTextModule::execute_module(VM& vm, GC::Ptr<Promise
|
|||
}
|
||||
|
||||
// d. Let env be moduleContext's LexicalEnvironment.
|
||||
auto& env = verify_cast<DeclarativeEnvironment>(*module_context->lexical_environment);
|
||||
auto& env = as<DeclarativeEnvironment>(*module_context->lexical_environment);
|
||||
|
||||
// e. Set result to Completion(DisposeResources(env.[[DisposeCapability]], result)).
|
||||
result = dispose_resources(vm, env.dispose_capability(), result);
|
||||
|
|
|
@ -894,25 +894,25 @@ ALWAYS_INLINE bool is<OpCode_Compare>(OpCode const& opcode)
|
|||
template<typename T>
|
||||
ALWAYS_INLINE T const& to(OpCode const& opcode)
|
||||
{
|
||||
return verify_cast<T>(opcode);
|
||||
return as<T>(opcode);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
ALWAYS_INLINE T* to(OpCode* opcode)
|
||||
{
|
||||
return verify_cast<T>(opcode);
|
||||
return as<T>(opcode);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
ALWAYS_INLINE T const* to(OpCode const* opcode)
|
||||
{
|
||||
return verify_cast<T>(opcode);
|
||||
return as<T>(opcode);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
ALWAYS_INLINE T& to(OpCode& opcode)
|
||||
{
|
||||
return verify_cast<T>(opcode);
|
||||
return as<T>(opcode);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -883,7 +883,7 @@ NonnullOwnPtr<DateTimeFormat> 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<icu::SimpleDateFormat>([&]() {
|
||||
auto formatter = adopt_own(*as<icu::SimpleDateFormat>([&]() {
|
||||
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());
|
||||
|
|
|
@ -62,7 +62,7 @@ WebIDL::ExceptionOr<GC::Ref<Animation>> Animatable::animate(Optional<GC::Root<JS
|
|||
// https://drafts.csswg.org/web-animations-1/#dom-animatable-getanimations
|
||||
WebIDL::ExceptionOr<Vector<GC::Ref<Animation>>> Animatable::get_animations(Optional<GetAnimationsOptions> options)
|
||||
{
|
||||
verify_cast<DOM::Element>(*this).document().update_style();
|
||||
as<DOM::Element>(*this).document().update_style();
|
||||
return get_animations_internal(options);
|
||||
}
|
||||
|
||||
|
@ -103,8 +103,8 @@ WebIDL::ExceptionOr<Vector<GC::Ref<Animation>>> 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<Animation>& a, GC::Ref<Animation>& b) {
|
||||
auto& a_effect = verify_cast<KeyframeEffect>(*a->effect());
|
||||
auto& b_effect = verify_cast<KeyframeEffect>(*b->effect());
|
||||
auto& a_effect = as<KeyframeEffect>(*a->effect());
|
||||
auto& b_effect = as<KeyframeEffect>(*b->effect());
|
||||
return KeyframeEffect::composite_order(a_effect, b_effect) < 0;
|
||||
});
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ GC::Ref<Animation> Animation::create(JS::Realm& realm, GC::Ptr<AnimationEffect>
|
|||
// 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::Window>(HTML::current_principal_global_object());
|
||||
auto& window = as<HTML::Window>(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<HTML::Window>(realm.global_object()).associated_document();
|
||||
auto& document = as<HTML::Window>(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<HTML::Window>(realm.global_object()).associated_document();
|
||||
auto& document = as<HTML::Window>(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));
|
||||
|
|
|
@ -36,7 +36,7 @@ WebIDL::ExceptionOr<GC::Ref<DocumentTimeline>> 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<HTML::Window>(realm.global_object());
|
||||
auto& window = as<HTML::Window>(realm.global_object());
|
||||
return create(realm, window.associated_document(), options.origin_time);
|
||||
}
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ JS::ThrowCompletionOr<GC::Ref<JS::Object>> AudioConstructor::construct(FunctionO
|
|||
auto& vm = this->vm();
|
||||
|
||||
// 1. Let document be the current global object's associated Document.
|
||||
auto& window = verify_cast<HTML::Window>(HTML::current_principal_global_object());
|
||||
auto& window = as<HTML::Window>(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.
|
||||
|
|
|
@ -43,7 +43,7 @@ JS::ThrowCompletionOr<GC::Ref<JS::Object>> ImageConstructor::construct(FunctionO
|
|||
auto& vm = this->vm();
|
||||
|
||||
// 1. Let document be the current principal global object's associated Document.
|
||||
auto& window = verify_cast<HTML::Window>(HTML::current_principal_global_object());
|
||||
auto& window = as<HTML::Window>(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.
|
||||
|
|
|
@ -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<Bindings::HostDefined>(*realm.host_defined()).intrinsics;
|
||||
return as<Bindings::HostDefined>(*realm.host_defined()).intrinsics;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -61,10 +61,10 @@ HTML::Script* active_script()
|
|||
// 3. Return record.[[HostDefined]].
|
||||
return record.visit(
|
||||
[](GC::Ref<JS::Script>& js_script) -> HTML::Script* {
|
||||
return verify_cast<HTML::ClassicScript>(js_script->host_defined());
|
||||
return as<HTML::ClassicScript>(js_script->host_defined());
|
||||
},
|
||||
[](GC::Ref<JS::Module>& js_module) -> HTML::Script* {
|
||||
return verify_cast<HTML::ModuleScript>(js_module->host_defined());
|
||||
return as<HTML::ModuleScript>(js_module->host_defined());
|
||||
},
|
||||
[](Empty) -> HTML::Script* {
|
||||
return nullptr;
|
||||
|
@ -77,7 +77,7 @@ ErrorOr<void> initialize_main_thread_vm(HTML::EventLoop::Type type)
|
|||
|
||||
s_main_thread_vm = TRY(JS::VM::create(make<WebEngineCustomData>()));
|
||||
|
||||
auto& custom_data = verify_cast<WebEngineCustomData>(*s_main_thread_vm->custom_data());
|
||||
auto& custom_data = as<WebEngineCustomData>(*s_main_thread_vm->custom_data());
|
||||
custom_data.agent.event_loop = s_main_thread_vm->heap().allocate<HTML::EventLoop>(type);
|
||||
|
||||
s_main_thread_vm->on_unimplemented_property_access = [](auto const& object, auto const& property_key) {
|
||||
|
@ -110,10 +110,10 @@ ErrorOr<void> 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>& js_script) {
|
||||
script = verify_cast<HTML::ClassicScript>(js_script->host_defined());
|
||||
script = as<HTML::ClassicScript>(js_script->host_defined());
|
||||
},
|
||||
[&script](GC::Ref<JS::Module>& js_module) {
|
||||
script = verify_cast<HTML::ModuleScript>(js_module->host_defined());
|
||||
script = as<HTML::ModuleScript>(js_module->host_defined());
|
||||
},
|
||||
[](Empty) {
|
||||
});
|
||||
|
@ -160,7 +160,7 @@ ErrorOr<void> 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<HTML::Window>(global);
|
||||
auto& window = as<HTML::Window>(global);
|
||||
|
||||
HTML::PromiseRejectionEventInit event_init {
|
||||
{}, // Initialize the inherited DOM::EventInit
|
||||
|
@ -180,7 +180,7 @@ ErrorOr<void> 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<JS::Value> arguments_list) {
|
||||
auto& callback_host_defined = verify_cast<WebEngineCustomJobCallbackData>(*callback.custom_data());
|
||||
auto& callback_host_defined = as<WebEngineCustomJobCallbackData>(*callback.custom_data());
|
||||
|
||||
// 1. Let incumbent realm be callback.[[HostDefined]].[[IncumbentRealm]].
|
||||
auto& incumbent_realm = callback_host_defined.incumbent_realm;
|
||||
|
@ -327,10 +327,10 @@ ErrorOr<void> initialize_main_thread_vm(HTML::EventLoop::Type type)
|
|||
script_execution_context->function = nullptr;
|
||||
script_execution_context->realm = &script->realm();
|
||||
if (is<HTML::ClassicScript>(script)) {
|
||||
script_execution_context->script_or_module = GC::Ref<JS::Script>(*verify_cast<HTML::ClassicScript>(script)->script_record());
|
||||
script_execution_context->script_or_module = GC::Ref<JS::Script>(*as<HTML::ClassicScript>(script)->script_record());
|
||||
} else if (is<HTML::ModuleScript>(script)) {
|
||||
if (is<HTML::JavaScriptModuleScript>(script)) {
|
||||
script_execution_context->script_or_module = GC::Ref<JS::Module>(*verify_cast<HTML::JavaScriptModuleScript>(script)->record());
|
||||
script_execution_context->script_or_module = GC::Ref<JS::Module>(*as<HTML::JavaScriptModuleScript>(script)->record());
|
||||
} else {
|
||||
// NOTE: Handle CSS and JSON module scripts once we have those.
|
||||
VERIFY_NOT_REACHED();
|
||||
|
@ -351,7 +351,7 @@ ErrorOr<void> initialize_main_thread_vm(HTML::EventLoop::Type type)
|
|||
auto& vm = realm.vm();
|
||||
|
||||
// 1. Let moduleScript be moduleRecord.[[HostDefined]].
|
||||
auto& module_script = *verify_cast<HTML::Script>(module_record.host_defined());
|
||||
auto& module_script = *as<HTML::Script>(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<void> initialize_main_thread_vm(HTML::EventLoop::Type type)
|
|||
// 6. If referrer is a Script Record or a Cyclic Module Record, then:
|
||||
if (referrer.has<GC::Ref<JS::Script>>() || referrer.has<GC::Ref<JS::CyclicModule>>()) {
|
||||
// 1. Set referencingScript to referrer.[[HostDefined]].
|
||||
referencing_script = verify_cast<HTML::Script>(referrer.has<GC::Ref<JS::Script>>() ? *referrer.get<GC::Ref<JS::Script>>()->host_defined() : *referrer.get<GC::Ref<JS::CyclicModule>>()->host_defined());
|
||||
referencing_script = as<HTML::Script>(referrer.has<GC::Ref<JS::Script>>() ? *referrer.get<GC::Ref<JS::Script>>()->host_defined() : *referrer.get<GC::Ref<JS::CyclicModule>>()->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<WebEngineCustomData>(*vm.custom_data()).agent;
|
||||
auto& surrounding_agent = as<WebEngineCustomData>(*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)
|
||||
|
|
|
@ -52,12 +52,12 @@ JS::ThrowCompletionOr<GC::Ref<JS::Object>> 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::Window>(HTML::current_principal_global_object());
|
||||
auto& window = as<HTML::Window>(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<HTML::HTMLOptionElement> option_element = verify_cast<HTML::HTMLOptionElement>(*element);
|
||||
GC::Ref<HTML::HTMLOptionElement> option_element = as<HTML::HTMLOptionElement>(*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));
|
||||
|
|
|
@ -30,17 +30,17 @@ struct PrincipalHostDefined : public HostDefined {
|
|||
|
||||
[[nodiscard]] inline HTML::EnvironmentSettingsObject& principal_host_defined_environment_settings_object(JS::Realm& realm)
|
||||
{
|
||||
return *verify_cast<PrincipalHostDefined>(realm.host_defined())->environment_settings_object;
|
||||
return *as<PrincipalHostDefined>(realm.host_defined())->environment_settings_object;
|
||||
}
|
||||
|
||||
[[nodiscard]] inline HTML::EnvironmentSettingsObject const& principal_host_defined_environment_settings_object(JS::Realm const& realm)
|
||||
{
|
||||
return *verify_cast<PrincipalHostDefined>(realm.host_defined())->environment_settings_object;
|
||||
return *as<PrincipalHostDefined>(realm.host_defined())->environment_settings_object;
|
||||
}
|
||||
|
||||
[[nodiscard]] inline Page& principal_host_defined_page(JS::Realm& realm)
|
||||
{
|
||||
return *verify_cast<PrincipalHostDefined>(realm.host_defined())->page;
|
||||
return *as<PrincipalHostDefined>(realm.host_defined())->page;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ GC::Ref<CSSAnimation> CSSAnimation::create(JS::Realm& realm)
|
|||
// https://www.w3.org/TR/css-animations-2/#animation-composite-order
|
||||
Optional<int> CSSAnimation::class_specific_composite_order(GC::Ref<Animations::Animation> other_animation) const
|
||||
{
|
||||
auto other = GC::Ref { verify_cast<CSSAnimation>(*other_animation) };
|
||||
auto other = GC::Ref { as<CSSAnimation>(*other_animation) };
|
||||
|
||||
// The existance of an owning element determines the animation class, so both animations should have their owning
|
||||
// element in the same state
|
||||
|
|
|
@ -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<CSSImportRule>(*rule);
|
||||
auto& import_rule = as<CSSImportRule>(*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<CSSLayerBlockRule>(*rule);
|
||||
auto& layer_rule = as<CSSLayerBlockRule>(*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<CSSMediaRule>(*rule);
|
||||
auto& media_rule = as<CSSMediaRule>(*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<CSSSupportsRule>(*rule);
|
||||
auto& supports_rule = as<CSSSupportsRule>(*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<CSSStyleRule>(*rule);
|
||||
auto& style_rule = as<CSSStyleRule>(*rule);
|
||||
if (style_rule.css_rules().evaluate_media_queries(window))
|
||||
any_media_queries_changed_match_state = true;
|
||||
break;
|
||||
|
|
|
@ -35,7 +35,7 @@ WebIDL::ExceptionOr<GC::Ref<CSSStyleSheet>> 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::Window>(HTML::current_principal_global_object()).document();
|
||||
auto associated_document = as<HTML::Window>(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<CSSImportRule>(*rule));
|
||||
m_import_rules.append(as<CSSImportRule>(*rule));
|
||||
break;
|
||||
}
|
||||
case CSSRule::Type::Namespace: {
|
||||
auto& namespace_rule = verify_cast<CSSNamespaceRule>(*rule);
|
||||
auto& namespace_rule = as<CSSNamespaceRule>(*rule);
|
||||
if (!namespace_rule.namespace_uri().is_empty() && namespace_rule.prefix().is_empty())
|
||||
m_default_namespace_rule = namespace_rule;
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ Animations::AnimationClass CSSTransition::animation_class() const
|
|||
|
||||
Optional<int> CSSTransition::class_specific_composite_order(GC::Ref<Animations::Animation> other_animation) const
|
||||
{
|
||||
auto other = GC::Ref { verify_cast<CSSTransition>(*other_animation) };
|
||||
auto other = GC::Ref { as<CSSTransition>(*other_animation) };
|
||||
|
||||
// Within the set of CSS Transitions, two animations A and B are sorted in composite order (first to last) as
|
||||
// follows:
|
||||
|
|
|
@ -1060,7 +1060,7 @@ Vector<ShadowData> 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::NodeWithStyle>(layout_node)),
|
||||
value.color()->to_color(as<Layout::NodeWithStyle>(layout_node)),
|
||||
value.placement()
|
||||
};
|
||||
};
|
||||
|
|
|
@ -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<DOM::Element>(*originating_node);
|
||||
auto& innermost_element = as<DOM::Element>(*originating_node);
|
||||
|
||||
if (&innermost_element == element
|
||||
|| (innermost_element.parent() == element->parent() && innermost_element.is_before(*element))) {
|
||||
|
|
|
@ -178,7 +178,7 @@ FontFace::FontFace(JS::Realm& realm, GC::Ref<WebIDL::Promise> font_status_promis
|
|||
// FIXME: Have gettter reflect this member instead of the string
|
||||
m_unicode_ranges.empend(0x0u, 0x10FFFFu);
|
||||
|
||||
if (verify_cast<JS::Promise>(*m_font_status_promise->promise()).state() == JS::Promise::State::Rejected)
|
||||
if (as<JS::Promise>(*m_font_status_promise->promise()).state() == JS::Promise::State::Rejected)
|
||||
m_status = Bindings::FontFaceLoadStatus::Error;
|
||||
}
|
||||
|
||||
|
|
|
@ -209,7 +209,7 @@ static WebIDL::ExceptionOr<GC::Ref<JS::Set>> 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<FontFace>(font_face_value.key.as_object());
|
||||
auto& font_face = as<FontFace>(font_face_value.key.as_object());
|
||||
if (font_face.family() != font_family_name)
|
||||
continue;
|
||||
|
||||
|
@ -253,7 +253,7 @@ JS::ThrowCompletionOr<GC::Ref<WebIDL::Promise>> 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<FontFace>(font_face_value.key.as_object());
|
||||
auto& font_face = as<FontFace>(font_face_value.key.as_object());
|
||||
font_face.load();
|
||||
|
||||
promises.append(font_face.font_status_promise());
|
||||
|
|
|
@ -366,7 +366,7 @@ RefPtr<CSSStyleValue const> ResolvedCSSStyleDeclaration::style_value_for_propert
|
|||
|
||||
// 2. Post-multiply all <transform-function>s in <transform-list> to transform.
|
||||
VERIFY(layout_node.first_paintable());
|
||||
auto const& paintable_box = verify_cast<Painting::PaintableBox const>(*layout_node.first_paintable());
|
||||
auto const& paintable_box = as<Painting::PaintableBox const>(*layout_node.first_paintable());
|
||||
for (auto transformation : transformations) {
|
||||
transform = transform * transformation.to_matrix(paintable_box).release_value();
|
||||
}
|
||||
|
@ -497,14 +497,14 @@ RefPtr<CSSStyleValue const> 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<Painting::PaintableBox const>(*layout_node.first_paintable());
|
||||
auto const& paintable_box = as<Painting::PaintableBox const>(*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<Painting::PaintableBox const>(*layout_node.first_paintable());
|
||||
auto const& paintable_box = as<Painting::PaintableBox const>(*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;
|
||||
}
|
||||
|
|
|
@ -1177,7 +1177,7 @@ static void apply_animation_properties(DOM::Document& document, CascadedProperti
|
|||
if (!animation.effect())
|
||||
return;
|
||||
|
||||
auto& effect = verify_cast<Animations::KeyframeEffect>(*animation.effect());
|
||||
auto& effect = as<Animations::KeyframeEffect>(*animation.effect());
|
||||
|
||||
Optional<CSS::Time> duration;
|
||||
if (auto duration_value = cascaded_properties.property(PropertyID::AnimationDuration); duration_value) {
|
||||
|
@ -2339,7 +2339,7 @@ GC::Ptr<ComputedProperties> 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<HTML::HTMLElement>(*element.root().parent_or_shadow_host());
|
||||
auto& parent_element = as<HTML::HTMLElement>(*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::RuleCache> 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<CSSKeyframeRule>(*keyframe_rule);
|
||||
auto const& keyframe = as<CSSKeyframeRule>(*keyframe_rule);
|
||||
Animations::KeyframeEffect::KeyFrameSet::ResolvedKeyFrame resolved_keyframe;
|
||||
|
||||
auto key = static_cast<u64>(keyframe.key().value() * Animations::KeyframeEffect::AnimationKeyFrameKeyScaleFactor);
|
||||
|
|
|
@ -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<CSSColor>(other_color);
|
||||
auto const& other_lab_like = as<CSSColor>(other_color);
|
||||
return m_properties == other_lab_like.m_properties;
|
||||
}
|
||||
|
||||
|
|
|
@ -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<CSSHSL>(other_color);
|
||||
auto const& other_hsl = as<CSSHSL>(other_color);
|
||||
return m_properties == other_hsl.m_properties;
|
||||
}
|
||||
|
||||
|
|
|
@ -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<CSSHWB>(other_color);
|
||||
auto const& other_hwb = as<CSSHWB>(other_color);
|
||||
return m_properties == other_hwb.m_properties;
|
||||
}
|
||||
|
||||
|
|
|
@ -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<CSSLCHLike>(other_color);
|
||||
auto const& other_oklch_like = as<CSSLCHLike>(other_color);
|
||||
return m_properties == other_oklch_like.m_properties;
|
||||
}
|
||||
|
||||
|
|
|
@ -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<CSSLabLike>(other_color);
|
||||
auto const& other_lab_like = as<CSSLabLike>(other_color);
|
||||
return m_properties == other_lab_like.m_properties;
|
||||
}
|
||||
|
||||
|
|
|
@ -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<CSSLightDark>(other_color);
|
||||
auto const& other_light_dark = as<CSSLightDark>(other_color);
|
||||
return m_properties == other_light_dark.m_properties;
|
||||
}
|
||||
|
||||
|
|
|
@ -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<CSSRGB>(other_color);
|
||||
auto const& other_rgb = as<CSSRGB>(other_color);
|
||||
return m_properties == other_rgb.m_properties;
|
||||
}
|
||||
|
||||
|
|
|
@ -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<GC::Ref<FileAPI::Blob>> items, String presentation_style)
|
||||
{
|
||||
auto& window = verify_cast<HTML::Window>(realm.global_object());
|
||||
auto& window = as<HTML::Window>(realm.global_object());
|
||||
|
||||
// FIXME: 1. Let webCustomFormats be a sequence<Blob>.
|
||||
|
||||
|
@ -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<HTML::Window>(realm.global_object()).has_transient_activation();
|
||||
auto has_gesture = as<HTML::Window>(realm.global_object()).has_transient_activation();
|
||||
|
||||
// 2. If hasGesture then,
|
||||
if (has_gesture) {
|
||||
|
|
|
@ -586,7 +586,7 @@ JS::ThrowCompletionOr<NonnullOwnPtr<AlgorithmParams>> EcdhKeyDeriveParams::from_
|
|||
return vm.throw_completion<JS::TypeError>(JS::ErrorType::NotAnObjectOfType, "CryptoKey");
|
||||
}
|
||||
|
||||
auto& key = verify_cast<CryptoKey>(*key_object);
|
||||
auto& key = as<CryptoKey>(*key_object);
|
||||
|
||||
return adopt_own<AlgorithmParams>(*new EcdhKeyDeriveParams { key });
|
||||
}
|
||||
|
@ -672,7 +672,7 @@ WebIDL::ExceptionOr<GC::Ref<JS::ArrayBuffer>> RSAOAEP::encrypt(AlgorithmParams c
|
|||
|
||||
auto const& handle = key->handle();
|
||||
auto public_key = handle.get<::Crypto::PK::RSAPublicKey<>>();
|
||||
auto hash = TRY(verify_cast<RsaHashedKeyAlgorithm>(*key->algorithm()).hash().name(vm));
|
||||
auto hash = TRY(as<RsaHashedKeyAlgorithm>(*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<GC::Ref<JS::ArrayBuffer>> RSAOAEP::decrypt(AlgorithmParams c
|
|||
|
||||
auto const& handle = key->handle();
|
||||
auto private_key = handle.get<::Crypto::PK::RSAPrivateKey<>>();
|
||||
auto hash = TRY(verify_cast<RsaHashedKeyAlgorithm>(*key->algorithm()).hash().name(vm));
|
||||
auto hash = TRY(as<RsaHashedKeyAlgorithm>(*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<GC::Ref<JS::Object>> 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<RsaHashedKeyAlgorithm>(*key->algorithm()).hash().name(vm));
|
||||
auto hash = TRY(as<RsaHashedKeyAlgorithm>(*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<GC::Ref<JS::ArrayBuffer>> RSAPSS::sign(AlgorithmParams const
|
|||
|
||||
auto const& private_key = key->handle().get<::Crypto::PK::RSAPrivateKey<>>();
|
||||
auto pss_params = static_cast<RsaPssParams const&>(params);
|
||||
auto hash = TRY(verify_cast<RsaHashedKeyAlgorithm>(*key->algorithm()).hash().name(vm));
|
||||
auto hash = TRY(as<RsaHashedKeyAlgorithm>(*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<JS::Value> RSAPSS::verify(AlgorithmParams const& params, GC:
|
|||
|
||||
auto const& public_key = key->handle().get<::Crypto::PK::RSAPublicKey<>>();
|
||||
auto pss_params = static_cast<RsaPssParams const&>(params);
|
||||
auto hash = TRY(verify_cast<RsaHashedKeyAlgorithm>(*key->algorithm()).hash().name(vm));
|
||||
auto hash = TRY(as<RsaHashedKeyAlgorithm>(*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<GC::Ref<JS::Object>> 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<RsaHashedKeyAlgorithm>(*key->algorithm()).hash().name(vm));
|
||||
auto hash = TRY(as<RsaHashedKeyAlgorithm>(*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<GC::Ref<JS::ArrayBuffer>> 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<RsaHashedKeyAlgorithm>(*key->algorithm()).hash().name(vm));
|
||||
auto hash = TRY(as<RsaHashedKeyAlgorithm>(*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<JS::Value> 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<RsaHashedKeyAlgorithm>(*key->algorithm()).hash().name(vm));
|
||||
auto hash = TRY(as<RsaHashedKeyAlgorithm>(*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<GC::Ref<JS::Object>> 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<RsaHashedKeyAlgorithm>(*key->algorithm()).hash().name(vm));
|
||||
auto hash = TRY(as<RsaHashedKeyAlgorithm>(*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<GC::Ref<JS::ArrayBuffer>> 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<ByteBuffer>();
|
||||
auto const& algorithm = verify_cast<HmacKeyAlgorithm>(*key->algorithm());
|
||||
auto const& algorithm = as<HmacKeyAlgorithm>(*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<JS::Value> HMAC::verify(AlgorithmParams const&, GC::Ref<Cryp
|
|||
// 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<ByteBuffer>();
|
||||
auto const& algorithm = verify_cast<HmacKeyAlgorithm>(*key->algorithm());
|
||||
auto const& algorithm = as<HmacKeyAlgorithm>(*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<GC::Ref<JS::Object>> 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<HmacKeyAlgorithm>(*key->algorithm());
|
||||
auto const& algorithm = as<HmacKeyAlgorithm>(*key->algorithm());
|
||||
|
||||
// Let hash be the hash attribute of algorithm.
|
||||
auto hash = algorithm.hash();
|
||||
|
|
|
@ -447,7 +447,7 @@ JS::ThrowCompletionOr<GC::Ref<WebIDL::Promise>> 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<KeyAlgorithm>(*key->algorithm());
|
||||
auto& algorithm = as<KeyAlgorithm>(*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<GC::Ref<WebIDL::Promise>> 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<KeyAlgorithm>(*key->algorithm());
|
||||
auto& key_algorithm = as<KeyAlgorithm>(*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<GC::Ref<WebIDL::Promise>> 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<JS::ArrayBuffer>(*key_data).buffer();
|
||||
bytes = as<JS::ArrayBuffer>(*key_data).buffer();
|
||||
}
|
||||
|
||||
// If format is equal to the string "jwk":
|
||||
|
|
|
@ -21,7 +21,7 @@ Comment::Comment(Document& document, String const& data)
|
|||
// https://dom.spec.whatwg.org/#dom-comment-comment
|
||||
WebIDL::ExceptionOr<GC::Ref<Comment>> Comment::construct_impl(JS::Realm& realm, String const& data)
|
||||
{
|
||||
auto& window = verify_cast<HTML::Window>(realm.global_object());
|
||||
auto& window = as<HTML::Window>(realm.global_object());
|
||||
return realm.create<Comment>(window.associated_document(), data);
|
||||
}
|
||||
|
||||
|
|
|
@ -268,7 +268,7 @@ WebIDL::ExceptionOr<GC::Ref<Document>> Document::create_and_initialize(Type type
|
|||
});
|
||||
|
||||
// 6. Set window to the global object of realmExecutionContext's Realm component.
|
||||
window = verify_cast<HTML::Window>(realm_execution_context->realm->global_object());
|
||||
window = as<HTML::Window>(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::HTMLHtmlElement>(html))
|
||||
return verify_cast<HTML::HTMLHtmlElement>(html);
|
||||
return as<HTML::HTMLHtmlElement>(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<Layout::Viewport>(*tree_builder.build(*this));
|
||||
m_layout_root = as<Layout::Viewport>(*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<Layout::NodeWithStyleAndBoxModelMetrics>(*document_element->layout_node()));
|
||||
auto& icb_state = layout_state.get_mutable(as<Layout::NodeWithStyleAndBoxModelMetrics>(*document_element->layout_node()));
|
||||
icb_state.set_content_width(viewport_rect.width());
|
||||
}
|
||||
|
||||
|
@ -1747,7 +1747,7 @@ GC::Ref<NodeList> Document::get_elements_by_name(FlyString const& name)
|
|||
return LiveNodeList::create(realm(), *this, LiveNodeList::Scope::Descendants, [name](auto const& node) {
|
||||
if (!is<HTML::HTMLElement>(node))
|
||||
return false;
|
||||
return verify_cast<HTML::HTMLElement>(node).name() == name;
|
||||
return as<HTML::HTMLElement>(node).name() == name;
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -2208,7 +2208,7 @@ WebIDL::ExceptionOr<GC::Ref<Node>> Document::adopt_node_binding(GC::Ref<Node> no
|
|||
if (is<ShadowRoot>(*node))
|
||||
return WebIDL::HierarchyRequestError::create(realm(), "Cannot adopt a shadow root into a document"_string);
|
||||
|
||||
if (is<DocumentFragment>(*node) && verify_cast<DocumentFragment>(*node).host())
|
||||
if (is<DocumentFragment>(*node) && as<DocumentFragment>(*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<Node>(retarget(candidate, this));
|
||||
candidate = as<Node>(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<Document>(candidate)) {
|
||||
set_active_element(verify_cast<Element>(candidate));
|
||||
set_active_element(as<Element>(candidate));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2530,7 +2530,7 @@ void Document::dispatch_events_for_transition(GC::Ref<CSS::CSSTransition> transi
|
|||
void Document::dispatch_events_for_animation_if_necessary(GC::Ref<Animations::Animation> animation)
|
||||
{
|
||||
if (animation->is_css_transition()) {
|
||||
dispatch_events_for_transition(verify_cast<CSS::CSSTransition>(*animation));
|
||||
dispatch_events_for_transition(as<CSS::CSSTransition>(*animation));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2541,7 +2541,7 @@ void Document::dispatch_events_for_animation_if_necessary(GC::Ref<Animations::An
|
|||
if (!effect || !effect->is_keyframe_effect() || !animation->is_css_animation() || animation->pending())
|
||||
return;
|
||||
|
||||
auto& css_animation = verify_cast<CSS::CSSAnimation>(*animation);
|
||||
auto& css_animation = as<CSS::CSSAnimation>(*animation);
|
||||
|
||||
GC::Ptr<Element> target = effect->target();
|
||||
if (!target)
|
||||
|
@ -3496,7 +3496,7 @@ GC::Ptr<HTML::CustomElementDefinition> Document::lookup_custom_element_definitio
|
|||
return nullptr;
|
||||
|
||||
// 3. Let registry be document's relevant global object's custom element registry.
|
||||
auto registry = verify_cast<HTML::Window>(relevant_global_object(*this)).custom_elements();
|
||||
auto registry = as<HTML::Window>(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::Window>(HTML::relevant_global_object(*this)).has_transient_activation(),
|
||||
.has_transient_activation = as<HTML::Window>(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<Document>)
|
|||
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<HTML::Window>(relevant_global_object(*this)).fire_a_page_transition_event(HTML::EventNames::pagehide, m_salvageable);
|
||||
as<HTML::Window>(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<Document>)
|
|||
// 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<HTML::Window>(relevant_global_object(*this)).dispatch_event(event);
|
||||
as<HTML::Window>(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<GC::Ref<Attr>> Document::create_attribute_ns(Optional<FlyStr
|
|||
void Document::make_active()
|
||||
{
|
||||
// 1. Let window be document's relevant global object.
|
||||
auto& window = verify_cast<HTML::Window>(HTML::relevant_global_object(*this));
|
||||
auto& window = as<HTML::Window>(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<JS::Value> {
|
||||
// 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<JS::Array>(vm.argument(0).as_object());
|
||||
auto& entries = as<JS::Array>(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<IntersectionObserver::IntersectionObserverEntry>(entries.get_without_side_effects(property_key).as_object());
|
||||
auto& entry = as<IntersectionObserver::IntersectionObserverEntry>(entries.get_without_side_effects(property_key).as_object());
|
||||
|
||||
// 1. Let resumptionSteps be null.
|
||||
GC::Ptr<GC::Function<void()>> resumption_steps;
|
||||
|
@ -4784,7 +4784,7 @@ void Document::update_for_history_step_application(GC::Ref<HTML::SessionHistoryE
|
|||
history()->m_length = script_history_length;
|
||||
|
||||
// 5. Let navigation be history's relevant global object's navigation API.
|
||||
auto navigation = verify_cast<HTML::Window>(HTML::relevant_global_object(*this)).navigation();
|
||||
auto navigation = as<HTML::Window>(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::Ref<HTML::SessionHistoryE
|
|||
// FIXME: Initialise hasUAVisualTransition
|
||||
HTML::PopStateEventInit popstate_event_init;
|
||||
popstate_event_init.state = history()->unsafe_state();
|
||||
auto& relevant_global_object = verify_cast<HTML::Window>(HTML::relevant_global_object(*this));
|
||||
auto& relevant_global_object = as<HTML::Window>(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<double> const& timesta
|
|||
return true;
|
||||
if (!b.animation->effect())
|
||||
return false;
|
||||
auto& a_effect = verify_cast<Animations::KeyframeEffect>(*a.animation->effect());
|
||||
auto& b_effect = verify_cast<Animations::KeyframeEffect>(*b.animation->effect());
|
||||
auto& a_effect = as<Animations::KeyframeEffect>(*a.animation->effect());
|
||||
auto& b_effect = as<Animations::KeyframeEffect>(*b.animation->effect());
|
||||
return Animations::KeyframeEffect::composite_order(a_effect, b_effect) < 0;
|
||||
};
|
||||
|
||||
|
@ -5655,11 +5655,11 @@ Optional<String> 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<HTML::HTMLStyleElement>(*node).sheet())
|
||||
if (auto* sheet = as<HTML::HTMLStyleElement>(*node).sheet())
|
||||
return sheet->source_text({});
|
||||
}
|
||||
if (node->is_svg_style_element()) {
|
||||
if (auto* sheet = verify_cast<SVG::SVGStyleElement>(*node).sheet())
|
||||
if (auto* sheet = as<SVG::SVGStyleElement>(*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::Window>(HTML::relevant_global_object(*this)).associated_document().url());
|
||||
parser->run(as<HTML::Window>(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<HTML::Window>(global_object);
|
||||
auto& window = as<HTML::Window>(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);
|
||||
|
|
|
@ -37,7 +37,7 @@ void DocumentFragment::set_host(Web::DOM::Element* element)
|
|||
// https://dom.spec.whatwg.org/#dom-documentfragment-documentfragment
|
||||
WebIDL::ExceptionOr<GC::Ref<DocumentFragment>> DocumentFragment::construct_impl(JS::Realm& realm)
|
||||
{
|
||||
auto& window = verify_cast<HTML::Window>(realm.global_object());
|
||||
auto& window = as<HTML::Window>(realm.global_object());
|
||||
return realm.create<DocumentFragment>(window.associated_document());
|
||||
}
|
||||
|
||||
|
|
|
@ -793,11 +793,11 @@ WebIDL::ExceptionOr<void> 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<Element>(*context).parse_fragment(value));
|
||||
auto fragment = TRY(as<Element>(*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<HTML::HTMLTemplateElement>(*context))
|
||||
context = verify_cast<HTML::HTMLTemplateElement>(*context).content();
|
||||
context = as<HTML::HTMLTemplateElement>(*context).content();
|
||||
|
||||
// 5. Replace all with fragment within context.
|
||||
context->replace_all(fragment);
|
||||
|
@ -1627,7 +1627,7 @@ WebIDL::ExceptionOr<void> 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<Element>(*parent).parse_fragment(value));
|
||||
auto fragment = TRY(as<Element>(*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<void> 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<Element>(*context).parse_fragment(string));
|
||||
auto fragment = TRY(as<Element>(*context).parse_fragment(string));
|
||||
|
||||
// 5. Use the first matching item from this list:
|
||||
|
||||
|
@ -1756,7 +1756,7 @@ WebIDL::ExceptionOr<GC::Ptr<Element>> Element::insert_adjacent_element(String co
|
|||
auto returned_node = TRY(insert_adjacent(where, element));
|
||||
if (!returned_node)
|
||||
return GC::Ptr<Element> { nullptr };
|
||||
return GC::Ptr<Element> { verify_cast<Element>(*returned_node) };
|
||||
return GC::Ptr<Element> { as<Element>(*returned_node) };
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-element-insertadjacenttext
|
||||
|
@ -3101,7 +3101,7 @@ WebIDL::ExceptionOr<void> 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<HTML::HTMLTemplateElement>(*this))
|
||||
target = verify_cast<HTML::HTMLTemplateElement>(*this).content().ptr();
|
||||
target = as<HTML::HTMLTemplateElement>(*this).content().ptr();
|
||||
|
||||
// 3. Unsafe set HTML given target, this, and compliantHTML. FIXME: Use compliantHTML.
|
||||
TRY(target->unsafely_set_html(*this, html));
|
||||
|
|
|
@ -578,7 +578,7 @@ WebIDL::ExceptionOr<GC::Ref<Element>> create_element(Document& document, FlyStri
|
|||
if (!result.has_value() || !result->is_object() || !is<HTML::HTMLElement>(result->as_object()))
|
||||
return JS::throw_completion(JS::TypeError::create(realm, "Custom element constructor must return an object that implements HTMLElement"_string));
|
||||
|
||||
GC::Ref<HTML::HTMLElement> element = verify_cast<HTML::HTMLElement>(result->as_object());
|
||||
GC::Ref<HTML::HTMLElement> element = as<HTML::HTMLElement>(result->as_object());
|
||||
|
||||
// FIXME: 3. Assert: result’s custom element state and custom element definition are initialized.
|
||||
|
||||
|
|
|
@ -85,11 +85,11 @@ void Event::append_to_path(EventTarget& invocation_target, GC::Ptr<EventTarget>
|
|||
|
||||
// 2. If invocationTarget is a node and its root is a shadow root, then set invocationTargetInShadowTree to true.
|
||||
if (is<Node>(invocation_target)) {
|
||||
auto& invocation_target_node = verify_cast<Node>(invocation_target);
|
||||
auto& invocation_target_node = as<Node>(invocation_target);
|
||||
if (is<ShadowRoot>(invocation_target_node.root()))
|
||||
invocation_target_in_shadow_tree = true;
|
||||
if (is<ShadowRoot>(invocation_target_node)) {
|
||||
auto& invocation_target_shadow_root = verify_cast<ShadowRoot>(invocation_target_node);
|
||||
auto& invocation_target_shadow_root = as<ShadowRoot>(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;
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ bool EventDispatcher::inner_invoke(Event& event, Vector<GC::Root<DOM::DOMEventLi
|
|||
|
||||
// 8. If global is a Window object, then:
|
||||
if (is<HTML::Window>(global)) {
|
||||
auto& window = verify_cast<HTML::Window>(global);
|
||||
auto& window = as<HTML::Window>(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<GC::Root<DOM::DOMEventLi
|
|||
|
||||
// 13. If global is a Window object, then set global’s current event to currentEvent.
|
||||
if (is<HTML::Window>(global)) {
|
||||
auto& window = verify_cast<HTML::Window>(global);
|
||||
auto& window = as<HTML::Window>(global);
|
||||
window.set_current_event(current_event);
|
||||
}
|
||||
|
||||
|
@ -203,7 +203,7 @@ bool EventDispatcher::dispatch(GC::Ref<EventTarget> target, Event& event, bool l
|
|||
if (!legacy_target_override) {
|
||||
target_override = target;
|
||||
} else {
|
||||
target_override = &verify_cast<HTML::Window>(*target).associated_document();
|
||||
target_override = &as<HTML::Window>(*target).associated_document();
|
||||
}
|
||||
|
||||
// 3. Let activationTarget be null.
|
||||
|
@ -279,7 +279,7 @@ bool EventDispatcher::dispatch(GC::Ref<EventTarget> 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<HTML::Window>(parent)
|
||||
|| (is<Node>(parent) && verify_cast<Node>(*target).root().is_shadow_including_inclusive_ancestor_of(verify_cast<Node>(*parent)))) {
|
||||
|| (is<Node>(parent) && as<Node>(*target).root().is_shadow_including_inclusive_ancestor_of(as<Node>(*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<EventTarget> 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<Node>(clear_targets_struct.value().shadow_adjusted_target.ptr())) {
|
||||
auto& shadow_adjusted_target_node = verify_cast<Node>(*clear_targets_struct.value().shadow_adjusted_target);
|
||||
auto& shadow_adjusted_target_node = as<Node>(*clear_targets_struct.value().shadow_adjusted_target);
|
||||
if (is<ShadowRoot>(shadow_adjusted_target_node.root()))
|
||||
clear_targets = true;
|
||||
}
|
||||
|
||||
if (!clear_targets && is<Node>(clear_targets_struct.value().related_target.ptr())) {
|
||||
auto& related_target_node = verify_cast<Node>(*clear_targets_struct.value().related_target);
|
||||
auto& related_target_node = as<Node>(*clear_targets_struct.value().related_target);
|
||||
if (is<ShadowRoot>(related_target_node.root()))
|
||||
clear_targets = true;
|
||||
}
|
||||
|
@ -337,7 +337,7 @@ bool EventDispatcher::dispatch(GC::Ref<EventTarget> target, Event& event, bool l
|
|||
if (!clear_targets) {
|
||||
for (auto touch_target : clear_targets_struct.value().touch_target_list) {
|
||||
if (is<Node>(*touch_target.ptr())) {
|
||||
auto& touch_target_node = verify_cast<Node>(*touch_target.ptr());
|
||||
auto& touch_target_node = as<Node>(*touch_target.ptr());
|
||||
if (is<ShadowRoot>(touch_target_node.root())) {
|
||||
clear_targets = true;
|
||||
break;
|
||||
|
|
|
@ -161,7 +161,7 @@ static bool default_passive_value(FlyString const& type, EventTarget* event_targ
|
|||
return true;
|
||||
|
||||
if (is<Node>(event_target)) {
|
||||
auto* node = verify_cast<Node>(event_target);
|
||||
auto* node = as<Node>(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<EventTarget>(HTML::relevant_global_object(event_target_element.document()));
|
||||
return &as<EventTarget>(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> document;
|
||||
|
||||
if (is<Element>(this)) {
|
||||
auto* element_event_target = verify_cast<Element>(this);
|
||||
auto* element_event_target = as<Element>(this);
|
||||
element = element_event_target;
|
||||
document = &element_event_target->document();
|
||||
} else {
|
||||
VERIFY(is<HTML::Window>(this));
|
||||
auto* window_event_target = verify_cast<HTML::Window>(this);
|
||||
auto* window_event_target = as<HTML::Window>(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<DOM::Event>(event_wrapper_argument.as_object());
|
||||
auto& event = as<DOM::Event>(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<void> 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<HTML::ErrorEvent>(event);
|
||||
auto& error_event = as<HTML::ErrorEvent>(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());
|
||||
|
|
|
@ -100,7 +100,7 @@ WebIDL::ExceptionOr<void> MutationObserver::observe(Node& target, MutationObserv
|
|||
|
||||
if (node->registered_observer_list()) {
|
||||
node->registered_observer_list()->remove_all_matching([®istered_observer](RegisteredObserver& observer) {
|
||||
return is<TransientRegisteredObserver>(observer) && verify_cast<TransientRegisteredObserver>(observer).source().ptr() == registered_observer;
|
||||
return is<TransientRegisteredObserver>(observer) && as<TransientRegisteredObserver>(observer).source().ptr() == registered_observer;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<HTML::HTMLElement>(*node) && verify_cast<HTML::HTMLElement>(*node).has_attribute(attribute))
|
||||
return verify_cast<HTML::HTMLElement>(node);
|
||||
if (is<HTML::HTMLElement>(*node) && as<HTML::HTMLElement>(*node).has_attribute(attribute))
|
||||
return as<HTML::HTMLElement>(node);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -212,7 +212,7 @@ void Node::set_text_content(Optional<String> const& maybe_content)
|
|||
// If CharacterData, replace data with node this, offset 0, count this’s length, and data the given value.
|
||||
else if (is<CharacterData>(this)) {
|
||||
|
||||
auto* character_data_node = verify_cast<CharacterData>(this);
|
||||
auto* character_data_node = as<CharacterData>(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<String> Node::node_value() const
|
|||
|
||||
// If Attr, return this’s value.
|
||||
if (is<Attr>(this)) {
|
||||
return verify_cast<Attr>(this)->value();
|
||||
return as<Attr>(this)->value();
|
||||
}
|
||||
|
||||
// If CharacterData, return this’s data.
|
||||
if (is<CharacterData>(this)) {
|
||||
return verify_cast<CharacterData>(this)->data();
|
||||
return as<CharacterData>(this)->data();
|
||||
}
|
||||
|
||||
// Otherwise, return null.
|
||||
|
@ -364,10 +364,10 @@ void Node::set_node_value(Optional<String> const& maybe_value)
|
|||
|
||||
// If Attr, set an existing attribute value with this and the given value.
|
||||
if (is<Attr>(this)) {
|
||||
verify_cast<Attr>(this)->set_value(move(value));
|
||||
as<Attr>(this)->set_value(move(value));
|
||||
} else if (is<CharacterData>(this)) {
|
||||
// If CharacterData, replace data with node this, offset 0, count this’s length, and data the given value.
|
||||
verify_cast<CharacterData>(this)->set_data(value);
|
||||
as<CharacterData>(this)->set_data(value);
|
||||
}
|
||||
|
||||
// Otherwise, do nothing.
|
||||
|
@ -536,9 +536,9 @@ String Node::child_text_content() const
|
|||
return String {};
|
||||
|
||||
StringBuilder builder;
|
||||
verify_cast<ParentNode>(*this).for_each_child([&](auto& child) {
|
||||
as<ParentNode>(*this).for_each_child([&](auto& child) {
|
||||
if (is<Text>(child)) {
|
||||
auto maybe_content = verify_cast<Text>(child).text_content();
|
||||
auto maybe_content = as<Text>(child).text_content();
|
||||
if (maybe_content.has_value())
|
||||
builder.append(maybe_content.value());
|
||||
}
|
||||
|
@ -615,7 +615,7 @@ WebIDL::ExceptionOr<void> Node::ensure_pre_insertion_validity(GC::Ref<Node> node
|
|||
if (is<DocumentFragment>(*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<DocumentFragment>(*node).child_element_count();
|
||||
auto node_element_child_count = as<DocumentFragment>(*node).child_element_count();
|
||||
if ((node_element_child_count > 1 || node->has_child_of_type<Text>())
|
||||
|| (node_element_child_count == 1 && (has_child_of_type<Element>() || is<DocumentType>(child.ptr()) || (child && child->has_following_node_of_type_in_tree_order<DocumentType>())))) {
|
||||
return WebIDL::HierarchyRequestError::create(realm(), "Invalid node type for insertion"_string);
|
||||
|
@ -1025,7 +1025,7 @@ WebIDL::ExceptionOr<GC::Ref<Node>> Node::replace_child(GC::Ref<Node> node, GC::R
|
|||
if (is<DocumentFragment>(*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<DocumentFragment>(*node).child_element_count();
|
||||
auto node_element_child_count = as<DocumentFragment>(*node).child_element_count();
|
||||
if ((node_element_child_count > 1 || node->has_child_of_type<Text>())
|
||||
|| (node_element_child_count == 1 && (first_child_of_type<Element>() != child || child->has_following_node_of_type_in_tree_order<DocumentType>()))) {
|
||||
return WebIDL::HierarchyRequestError::create(realm(), "Invalid node type for insertion"_string);
|
||||
|
@ -1119,10 +1119,10 @@ WebIDL::ExceptionOr<GC::Ref<Node>> 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<Element>(*this);
|
||||
auto& node_element = as<Element>(*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<Element>(*copy);
|
||||
auto& copy_element = as<Element>(*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<GC::Ref<Node>> 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<Element>(this);
|
||||
auto& element = *as<Element>(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<GC::Ref<Node>> 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<Attr>(*copy_attribute));
|
||||
element_copy->append_attribute(as<Attr>(*copy_attribute));
|
||||
});
|
||||
|
||||
if (maybe_exception.has_value())
|
||||
|
@ -1183,7 +1183,7 @@ WebIDL::ExceptionOr<GC::Ref<Node>> Node::clone_single_node(Document& document) c
|
|||
else {
|
||||
if (is_document()) {
|
||||
// -> Document
|
||||
auto& document_ = verify_cast<Document>(*this);
|
||||
auto& document_ = as<Document>(*this);
|
||||
auto document_copy = [&] -> GC::Ref<Document> {
|
||||
switch (document_.document_type()) {
|
||||
case Document::Type::XML:
|
||||
|
@ -1205,7 +1205,7 @@ WebIDL::ExceptionOr<GC::Ref<Node>> Node::clone_single_node(Document& document) c
|
|||
copy = move(document_copy);
|
||||
} else if (is_document_type()) {
|
||||
// -> DocumentType
|
||||
auto& document_type = verify_cast<DocumentType>(*this);
|
||||
auto& document_type = as<DocumentType>(*this);
|
||||
auto document_type_copy = realm().create<DocumentType>(document);
|
||||
|
||||
// Set copy’s name, public ID, and system ID to those of node.
|
||||
|
@ -1216,11 +1216,11 @@ WebIDL::ExceptionOr<GC::Ref<Node>> 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<Attr>(*this);
|
||||
auto& attr = as<Attr>(*this);
|
||||
copy = attr.clone(document);
|
||||
} else if (is_text()) {
|
||||
// -> Text
|
||||
auto& text = verify_cast<Text>(*this);
|
||||
auto& text = as<Text>(*this);
|
||||
|
||||
// Set copy’s data to that of node.
|
||||
copy = [&]() -> GC::Ref<Text> {
|
||||
|
@ -1235,14 +1235,14 @@ WebIDL::ExceptionOr<GC::Ref<Node>> Node::clone_single_node(Document& document) c
|
|||
}();
|
||||
} else if (is_comment()) {
|
||||
// -> Comment
|
||||
auto& comment = verify_cast<Comment>(*this);
|
||||
auto& comment = as<Comment>(*this);
|
||||
|
||||
// Set copy’s data to that of node.
|
||||
auto comment_copy = realm().create<Comment>(document, comment.data());
|
||||
copy = move(comment_copy);
|
||||
} else if (is<ProcessingInstruction>(this)) {
|
||||
// -> ProcessingInstruction
|
||||
auto& processing_instruction = verify_cast<ProcessingInstruction>(*this);
|
||||
auto& processing_instruction = as<ProcessingInstruction>(*this);
|
||||
|
||||
// Set copy’s target and data to those of node.
|
||||
auto processing_instruction_copy = realm().create<ProcessingInstruction>(document, processing_instruction.data(), processing_instruction.target());
|
||||
|
@ -1443,7 +1443,7 @@ ParentNode* Node::parent_or_shadow_host()
|
|||
{
|
||||
if (is<ShadowRoot>(*this))
|
||||
return static_cast<ShadowRoot&>(*this).host();
|
||||
return verify_cast<ParentNode>(parent());
|
||||
return as<ParentNode>(parent());
|
||||
}
|
||||
|
||||
Element* Node::parent_or_shadow_host_element()
|
||||
|
@ -1513,14 +1513,14 @@ u16 Node::compare_document_position(GC::Ptr<Node> other)
|
|||
|
||||
// 4. If node1 is an attribute, then set attr1 to node1 and node1 to attr1’s element.
|
||||
if (is<Attr>(node1)) {
|
||||
attr1 = verify_cast<Attr>(node1);
|
||||
attr1 = as<Attr>(node1);
|
||||
node1 = const_cast<Element*>(attr1->owner_element());
|
||||
}
|
||||
|
||||
// 5. If node2 is an attribute, then:
|
||||
if (is<Attr>(node2)) {
|
||||
// 1. Set attr2 to node2 and node2 to attr2’s element.
|
||||
attr2 = verify_cast<Attr>(node2);
|
||||
attr2 = as<Attr>(node2);
|
||||
node2 = const_cast<Element*>(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<ShadowRoot>(root());
|
||||
auto& shadow_root = as<ShadowRoot>(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<DocumentType>(*this);
|
||||
auto& other_doctype = verify_cast<DocumentType>(*other_node);
|
||||
auto& this_doctype = as<DocumentType>(*this);
|
||||
auto& other_doctype = as<DocumentType>(*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<Element>(*this);
|
||||
auto& other_element = verify_cast<Element>(*other_node);
|
||||
auto& this_element = as<Element>(*this);
|
||||
auto& other_element = as<Element>(*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<CharacterData>(*this);
|
||||
auto& other_cdata = verify_cast<CharacterData>(*other_node);
|
||||
auto& this_cdata = as<CharacterData>(*this);
|
||||
auto& other_cdata = as<CharacterData>(*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<Attr>(*this);
|
||||
auto& other_attr = verify_cast<Attr>(*other_node);
|
||||
auto& this_attr = as<Attr>(*this);
|
||||
auto& other_attr = as<Attr>(*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<ProcessingInstruction>(*this);
|
||||
auto& other_processing_instruction = verify_cast<ProcessingInstruction>(*other_node);
|
||||
auto& this_processing_instruction = as<ProcessingInstruction>(*this);
|
||||
auto& other_processing_instruction = as<ProcessingInstruction>(*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<String> Node::locate_a_namespace(Optional<String> 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<Element>(*this);
|
||||
auto& element = as<Element>(*this);
|
||||
if (element.namespace_uri().has_value() && element.prefix() == prefix)
|
||||
return element.namespace_uri()->to_string();
|
||||
|
||||
|
@ -2023,7 +2023,7 @@ Optional<String> Node::locate_a_namespace(Optional<String> const& prefix) const
|
|||
// Document
|
||||
if (is<Document>(*this)) {
|
||||
// 1. If its document element is null, then return null.
|
||||
auto* document_element = verify_cast<Document>(*this).document_element();
|
||||
auto* document_element = as<Document>(*this).document_element();
|
||||
if (!document_element)
|
||||
return {};
|
||||
|
||||
|
@ -2041,7 +2041,7 @@ Optional<String> Node::locate_a_namespace(Optional<String> const& prefix) const
|
|||
// Attr
|
||||
if (is<Attr>(*this)) {
|
||||
// 1. If its element is null, then return null.
|
||||
auto* element = verify_cast<Attr>(*this).owner_element();
|
||||
auto* element = as<Attr>(*this).owner_element();
|
||||
if (!element)
|
||||
return {};
|
||||
|
||||
|
@ -2082,14 +2082,14 @@ Optional<String> Node::lookup_prefix(Optional<String> namespace_) const
|
|||
// Element
|
||||
if (is<Element>(*this)) {
|
||||
// Return the result of locating a namespace prefix for it using namespace.
|
||||
auto& element = verify_cast<Element>(*this);
|
||||
auto& element = as<Element>(*this);
|
||||
return element.locate_a_namespace_prefix(namespace_);
|
||||
}
|
||||
|
||||
// Document
|
||||
if (is<Document>(*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<Document>(*this).document_element();
|
||||
auto* document_element = as<Document>(*this).document_element();
|
||||
if (!document_element)
|
||||
return {};
|
||||
|
||||
|
@ -2105,7 +2105,7 @@ Optional<String> Node::lookup_prefix(Optional<String> namespace_) const
|
|||
// Attr
|
||||
if (is<Attr>(*this)) {
|
||||
// Return the result of locating a namespace prefix for its element, if its element is non-null; otherwise null.
|
||||
auto* element = verify_cast<Attr>(*this).owner_element();
|
||||
auto* element = as<Attr>(*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<CharacterData>(*this).length_in_utf16_code_units();
|
||||
return as<CharacterData>(*this).length_in_utf16_code_units();
|
||||
|
||||
// 3. Return the number of node’s children.
|
||||
return child_count();
|
||||
|
@ -2826,7 +2826,7 @@ ErrorOr<String> 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::TextNode>(layout_node())->text_for_rendering();
|
||||
return as<Layout::TextNode>(layout_node())->text_for_rendering();
|
||||
return text_content().release_value();
|
||||
}
|
||||
|
||||
|
|
|
@ -652,7 +652,7 @@ public:
|
|||
{
|
||||
for (auto* node = first_child(); node; node = node->next_sibling()) {
|
||||
if (is<U>(node)) {
|
||||
if (callback(verify_cast<U>(*node)) == IterationDecision::Break)
|
||||
if (callback(as<U>(*node)) == IterationDecision::Break)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -669,7 +669,7 @@ public:
|
|||
{
|
||||
for (auto* node = first_child(); node; node = node->next_sibling()) {
|
||||
if (is<U>(node)) {
|
||||
if (TRY(callback(verify_cast<U>(*node))) == IterationDecision::Break)
|
||||
if (TRY(callback(as<U>(*node))) == IterationDecision::Break)
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
@ -687,7 +687,7 @@ public:
|
|||
{
|
||||
for (auto* sibling = next_sibling(); sibling; sibling = sibling->next_sibling()) {
|
||||
if (is<U>(*sibling))
|
||||
return &verify_cast<U>(*sibling);
|
||||
return &as<U>(*sibling);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -703,7 +703,7 @@ public:
|
|||
{
|
||||
for (auto* sibling = previous_sibling(); sibling; sibling = sibling->previous_sibling()) {
|
||||
if (is<U>(*sibling))
|
||||
return &verify_cast<U>(*sibling);
|
||||
return &as<U>(*sibling);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -725,7 +725,7 @@ public:
|
|||
{
|
||||
for (auto* child = first_child(); child; child = child->next_sibling()) {
|
||||
if (is<U>(*child))
|
||||
return &verify_cast<U>(*child);
|
||||
return &as<U>(*child);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -735,7 +735,7 @@ public:
|
|||
{
|
||||
for (auto* child = last_child(); child; child = child->previous_sibling()) {
|
||||
if (is<U>(*child))
|
||||
return &verify_cast<U>(*child);
|
||||
return &as<U>(*child);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -757,7 +757,7 @@ public:
|
|||
{
|
||||
for (auto* ancestor = parent(); ancestor; ancestor = ancestor->parent()) {
|
||||
if (is<U>(*ancestor))
|
||||
return &verify_cast<U>(*ancestor);
|
||||
return &as<U>(*ancestor);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ public:
|
|||
{
|
||||
for (auto* sibling = static_cast<NodeType*>(this)->previous_sibling(); sibling; sibling = sibling->previous_sibling()) {
|
||||
if (is<Element>(*sibling))
|
||||
return verify_cast<Element>(sibling);
|
||||
return as<Element>(sibling);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ public:
|
|||
{
|
||||
for (auto* node = static_cast<NodeType*>(this)->previous_in_pre_order(); node; node = node->previous_in_pre_order()) {
|
||||
if (is<Element>(*node))
|
||||
return verify_cast<Element>(node);
|
||||
return as<Element>(node);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ public:
|
|||
{
|
||||
for (auto* sibling = static_cast<NodeType*>(this)->next_sibling(); sibling; sibling = sibling->next_sibling()) {
|
||||
if (is<Element>(*sibling))
|
||||
return verify_cast<Element>(sibling);
|
||||
return as<Element>(sibling);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ public:
|
|||
{
|
||||
for (auto* node = static_cast<NodeType*>(this)->next_in_pre_order(); node; node = node->next_in_pre_order()) {
|
||||
if (is<Element>(*node))
|
||||
return verify_cast<Element>(node);
|
||||
return as<Element>(node);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
@ -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<U>(*ancestor))
|
||||
return &verify_cast<U>(*ancestor);
|
||||
return &as<U>(*ancestor);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ GC::Ref<Range> Range::create(GC::Ref<Node> start_container, WebIDL::UnsignedLong
|
|||
|
||||
WebIDL::ExceptionOr<GC::Ref<Range>> Range::construct_impl(JS::Realm& realm)
|
||||
{
|
||||
auto& window = verify_cast<HTML::Window>(realm.global_object());
|
||||
auto& window = as<HTML::Window>(realm.global_object());
|
||||
return Range::create(window);
|
||||
}
|
||||
|
||||
|
@ -625,7 +625,7 @@ WebIDL::ExceptionOr<GC::Ref<DocumentFragment>> 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<CharacterData const&>(*original_start_node).substring_data(original_start_offset, original_end_offset - original_start_offset));
|
||||
verify_cast<CharacterData>(*clone).set_data(move(result));
|
||||
as<CharacterData>(*clone).set_data(move(result));
|
||||
|
||||
// 3. Append clone to fragment.
|
||||
TRY(fragment->append_child(clone));
|
||||
|
@ -715,7 +715,7 @@ WebIDL::ExceptionOr<GC::Ref<DocumentFragment>> 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<CharacterData const&>(*original_start_node).substring_data(original_start_offset, original_start_node->length() - original_start_offset));
|
||||
verify_cast<CharacterData>(*clone).set_data(move(result));
|
||||
as<CharacterData>(*clone).set_data(move(result));
|
||||
|
||||
// 3. Append clone to fragment.
|
||||
TRY(fragment->append_child(clone));
|
||||
|
@ -753,13 +753,13 @@ WebIDL::ExceptionOr<GC::Ref<DocumentFragment>> 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<CharacterData const&>(*original_end_node).substring_data(0, original_end_offset));
|
||||
verify_cast<CharacterData>(*clone).set_data(move(result));
|
||||
as<CharacterData>(*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<CharacterData>(*original_end_node).replace_data(0, original_end_offset, String {}));
|
||||
TRY(as<CharacterData>(*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<GC::Ref<DocumentFragment>> 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<CharacterData const&>(*original_start_node).substring_data(original_start_offset, original_end_offset - original_start_offset));
|
||||
verify_cast<CharacterData>(*clone).set_data(move(result));
|
||||
as<CharacterData>(*clone).set_data(move(result));
|
||||
|
||||
// 3. Append clone to fragment.
|
||||
TRY(fragment->append_child(clone));
|
||||
|
@ -1016,7 +1016,7 @@ WebIDL::ExceptionOr<GC::Ref<DocumentFragment>> 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<CharacterData const&>(*original_start_node).substring_data(original_start_offset, original_start_node->length() - original_start_offset));
|
||||
verify_cast<CharacterData>(*clone).set_data(move(result));
|
||||
as<CharacterData>(*clone).set_data(move(result));
|
||||
|
||||
// 3. Append clone to fragment.
|
||||
TRY(fragment->append_child(clone));
|
||||
|
@ -1055,7 +1055,7 @@ WebIDL::ExceptionOr<GC::Ref<DocumentFragment>> 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<CharacterData const&>(*original_end_node).substring_data(0, original_end_offset));
|
||||
verify_cast<CharacterData>(*clone).set_data(move(result));
|
||||
as<CharacterData>(*clone).set_data(move(result));
|
||||
|
||||
// 3. Append clone to fragment.
|
||||
TRY(fragment->append_child(clone));
|
||||
|
|
|
@ -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<Node>(*event.path().first().invocation_target);
|
||||
auto& events_first_invocation_target = as<Node>(*event.path().first().invocation_target);
|
||||
if (&events_first_invocation_target.root() == this)
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ void Text::visit_edges(Cell::Visitor& visitor)
|
|||
WebIDL::ExceptionOr<GC::Ref<Text>> 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::Window>(HTML::current_principal_global_object());
|
||||
auto& window = as<HTML::Window>(HTML::current_principal_global_object());
|
||||
return realm.create<Text>(window.associated_document(), data);
|
||||
}
|
||||
|
||||
|
|
|
@ -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<Node>(a);
|
||||
auto* a_node = as<Node>(a);
|
||||
auto& a_root = a_node->root();
|
||||
if (!is<ShadowRoot>(a_root))
|
||||
return a;
|
||||
|
||||
// - B is a node and A’s root is a shadow-including inclusive ancestor of B
|
||||
if (is<Node>(b) && a_root.is_shadow_including_inclusive_ancestor_of(verify_cast<Node>(*b)))
|
||||
if (is<Node>(b) && a_root.is_shadow_including_inclusive_ancestor_of(as<Node>(*b)))
|
||||
return a;
|
||||
|
||||
// 2. Set A to A’s root’s host.
|
||||
auto& a_shadow_root = verify_cast<ShadowRoot>(a_root);
|
||||
auto& a_shadow_root = as<ShadowRoot>(a_root);
|
||||
a = a_shadow_root.host();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -700,7 +700,7 @@ static WebIDL::ExceptionOr<String> 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<HTML::HTMLTemplateElement>(element);
|
||||
auto const& template_element = as<HTML::HTMLTemplateElement>(element);
|
||||
markup.append(TRY(serialize_document_fragment(template_element.content(), inherited_ns, map, prefix_index, require_well_formed)));
|
||||
}
|
||||
|
||||
|
|
|
@ -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<DOM::Element>(node)) {
|
||||
builder.appendff("<{}", verify_cast<DOM::Element>(node).local_name());
|
||||
verify_cast<DOM::Element>(node).for_each_attribute([&](auto& name, auto& value) {
|
||||
builder.appendff("<{}", as<DOM::Element>(node).local_name());
|
||||
as<DOM::Element>(node).for_each_attribute([&](auto& name, auto& value) {
|
||||
builder.appendff(" {}={}", name, value);
|
||||
});
|
||||
builder.append(">\n"sv);
|
||||
auto& element = verify_cast<DOM::Element>(node);
|
||||
auto& element = as<DOM::Element>(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<DOM::Text>(node)) {
|
||||
builder.appendff("\"{}\"\n", verify_cast<DOM::Text>(node).data());
|
||||
builder.appendff("\"{}\"\n", as<DOM::Text>(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<SVG::SVGDecodedImageData>(*image_data);
|
||||
auto& svg_data = as<SVG::SVGDecodedImageData>(*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<HTML::HTMLTemplateElement>(node);
|
||||
auto& template_element = as<HTML::HTMLTemplateElement>(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<DOM::Element>(layout_node.dom_node()))
|
||||
tag_name = verify_cast<DOM::Element>(*layout_node.dom_node()).local_name();
|
||||
tag_name = as<DOM::Element>(*layout_node.dom_node()).local_name();
|
||||
else
|
||||
tag_name = layout_node.dom_node()->node_name();
|
||||
|
||||
String identifier;
|
||||
if (layout_node.dom_node() && is<DOM::Element>(*layout_node.dom_node())) {
|
||||
auto& element = verify_cast<DOM::Element>(*layout_node.dom_node());
|
||||
auto& element = as<DOM::Element>(*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::Box>(layout_node);
|
||||
auto& box = as<Layout::Box>(layout_node);
|
||||
StringView color_on = is<Layout::SVGBox>(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<HTML::HTMLImageElement>(*layout_node.dom_node())) {
|
||||
if (auto image_data = static_cast<HTML::HTMLImageElement const&>(*layout_node.dom_node()).current_request().image_data()) {
|
||||
if (is<SVG::SVGDecodedImageData>(*image_data)) {
|
||||
auto& svg_data = verify_cast<SVG::SVGDecodedImageData>(*image_data);
|
||||
auto& svg_data = as<SVG::SVGDecodedImageData>(*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<DOM::Element>(layout_node.dom_node())->computed_properties()) {
|
||||
if (show_cascaded_properties && layout_node.dom_node() && layout_node.dom_node()->is_element() && as<DOM::Element>(layout_node.dom_node())->computed_properties()) {
|
||||
struct NameAndValue {
|
||||
FlyString name;
|
||||
String value;
|
||||
};
|
||||
Vector<NameAndValue> properties;
|
||||
verify_cast<DOM::Element>(*layout_node.dom_node()).computed_properties()->for_each_property([&](auto property_id, auto& value) {
|
||||
as<DOM::Element>(*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<CSS::CSSFontFaceRule const>(rule), indent_levels);
|
||||
dump_font_face_rule(builder, as<CSS::CSSFontFaceRule const>(rule), indent_levels);
|
||||
break;
|
||||
case CSS::CSSRule::Type::Import:
|
||||
dump_import_rule(builder, verify_cast<CSS::CSSImportRule const>(rule), indent_levels);
|
||||
dump_import_rule(builder, as<CSS::CSSImportRule const>(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<CSS::CSSLayerBlockRule const>(rule), indent_levels);
|
||||
dump_layer_block_rule(builder, as<CSS::CSSLayerBlockRule const>(rule), indent_levels);
|
||||
break;
|
||||
case CSS::CSSRule::Type::LayerStatement:
|
||||
dump_layer_statement_rule(builder, verify_cast<CSS::CSSLayerStatementRule const>(rule), indent_levels);
|
||||
dump_layer_statement_rule(builder, as<CSS::CSSLayerStatementRule const>(rule), indent_levels);
|
||||
break;
|
||||
case CSS::CSSRule::Type::Media:
|
||||
dump_media_rule(builder, verify_cast<CSS::CSSMediaRule const>(rule), indent_levels);
|
||||
dump_media_rule(builder, as<CSS::CSSMediaRule const>(rule), indent_levels);
|
||||
break;
|
||||
case CSS::CSSRule::Type::Namespace:
|
||||
dump_namespace_rule(builder, verify_cast<CSS::CSSNamespaceRule const>(rule), indent_levels);
|
||||
dump_namespace_rule(builder, as<CSS::CSSNamespaceRule const>(rule), indent_levels);
|
||||
break;
|
||||
case CSS::CSSRule::Type::NestedDeclarations:
|
||||
dump_nested_declarations(builder, verify_cast<CSS::CSSNestedDeclarations const>(rule), indent_levels);
|
||||
dump_nested_declarations(builder, as<CSS::CSSNestedDeclarations const>(rule), indent_levels);
|
||||
break;
|
||||
case CSS::CSSRule::Type::Style:
|
||||
dump_style_rule(builder, verify_cast<CSS::CSSStyleRule const>(rule), indent_levels);
|
||||
dump_style_rule(builder, as<CSS::CSSStyleRule const>(rule), indent_levels);
|
||||
break;
|
||||
case CSS::CSSRule::Type::Supports:
|
||||
dump_supports_rule(builder, verify_cast<CSS::CSSSupportsRule const>(rule), indent_levels);
|
||||
dump_supports_rule(builder, as<CSS::CSSSupportsRule const>(rule), indent_levels);
|
||||
break;
|
||||
case CSS::CSSRule::Type::Property:
|
||||
dump_property_rule(builder, verify_cast<CSS::CSSPropertyRule const>(rule), indent_levels);
|
||||
dump_property_rule(builder, as<CSS::CSSPropertyRule const>(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<CSS::CSSStyleSheet>(sheet);
|
||||
auto& css_stylesheet = as<CSS::CSSStyleSheet>(sheet);
|
||||
|
||||
builder.appendff("CSSStyleSheet{{{}}}: {} rule(s)\n", &sheet, css_stylesheet.rules().length());
|
||||
|
||||
|
|
|
@ -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<HTML::HTMLBRElement>(*new_line_range->start_container()));
|
||||
|
||||
auto& container_element = verify_cast<DOM::Element>(*container);
|
||||
auto& container_element = as<DOM::Element>(*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.
|
||||
|
|
|
@ -153,7 +153,7 @@ WebIDL::ExceptionOr<void> 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<JS::Promise>(*chunk_promise->promise()) };
|
||||
auto promise = GC::Ref { as<JS::Promise>(*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<void> 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<JS::Uint8Array>(value.as_object())) {
|
||||
// 1. Let bs be the byte sequence represented by the Uint8Array object.
|
||||
auto const& byte_sequence = verify_cast<JS::Uint8Array>(value.as_object());
|
||||
auto const& byte_sequence = as<JS::Uint8Array>(value.as_object());
|
||||
|
||||
// 2. Append bs to bytes.
|
||||
bytes.append(byte_sequence.data());
|
||||
|
|
|
@ -211,7 +211,7 @@ WebIDL::ExceptionOr<BrowsingContext::BrowsingContextAndDocument> BrowsingContext
|
|||
auto load_timing_info = DOM::DocumentLoadTimingInfo();
|
||||
load_timing_info.navigation_start_time = HighResolutionTime::coarsen_time(
|
||||
unsafe_context_creation_time,
|
||||
verify_cast<WindowEnvironmentSettingsObject>(Bindings::principal_host_defined_environment_settings_object(window->realm())).cross_origin_isolated_capability() == CanUseCrossOriginIsolatedAPIs::Yes);
|
||||
as<WindowEnvironmentSettingsObject>(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());
|
||||
|
|
|
@ -43,7 +43,7 @@ GC::Ref<CloseWatcher> CloseWatcher::establish(HTML::Window& window)
|
|||
// https://html.spec.whatwg.org/multipage/interaction.html#dom-closewatcher
|
||||
WebIDL::ExceptionOr<GC::Ref<CloseWatcher>> CloseWatcher::construct_impl(JS::Realm& realm, CloseWatcherOptions const& options)
|
||||
{
|
||||
auto& window = verify_cast<HTML::Window>(realm.global_object());
|
||||
auto& window = as<HTML::Window>(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<HTML::Window>(realm().global_object());
|
||||
auto& window = as<HTML::Window>(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<HTML::Window>(realm().global_object()).associated_document().is_fully_active())
|
||||
if (!as<HTML::Window>(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<HTML::Window>(realm().global_object()).close_watcher_manager();
|
||||
auto manager = as<HTML::Window>(realm().global_object()).close_watcher_manager();
|
||||
|
||||
// 2-3. Moved to CloseWatcherManager::remove
|
||||
manager->remove(*this);
|
||||
|
|
|
@ -289,7 +289,7 @@ JS::ThrowCompletionOr<void> 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<HTML::Window>(relevant_global_object(*this)).associated_document();
|
||||
auto& document = as<HTML::Window>(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.
|
||||
|
|
|
@ -47,14 +47,14 @@ GC::Ref<DOM::Document> 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<HTML::Window>(relevant_global_object(*this)).associated_document().url());
|
||||
document = HTML::HTMLDocument::create(realm(), as<HTML::Window>(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<HTML::Window>(relevant_global_object(*this)).associated_document().url());
|
||||
document = DOM::XMLDocument::create(realm(), as<HTML::Window>(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);
|
||||
|
||||
|
|
|
@ -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<HTML::Window>(global_object)) {
|
||||
auto& window_object = verify_cast<HTML::Window>(global_object);
|
||||
auto& window_object = as<HTML::Window>(global_object);
|
||||
document = &window_object.associated_document();
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ static void fire_a_focus_event(GC::Ptr<DOM::EventTarget> 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<HTML::Window>(focus_event_target->realm().global_object()).window();
|
||||
focus_event_init.view = as<HTML::Window>(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<DOM::Document>(old_chain.last().ptr());
|
||||
auto* top_document = as<DOM::Document>(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) {
|
||||
|
|
|
@ -51,7 +51,7 @@ WebIDL::ExceptionOr<XHR::FormDataEntry> 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<FileAPI::File>(*blob));
|
||||
return GC::make_root(as<FileAPI::File>(*blob));
|
||||
}));
|
||||
|
||||
// 4. Return an entry whose name is name and whose value is value.
|
||||
|
|
|
@ -211,7 +211,7 @@ WebIDL::ExceptionOr<void> 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<DOM::Event>(vm.argument(0).as_object());
|
||||
auto& event = as<DOM::Event>(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)
|
||||
|
|
|
@ -294,7 +294,7 @@ static Vector<Variant<String, RequiredLineBreakCount>> rendered_text_collection_
|
|||
// or it ends with a br element. Soft hyphens should be preserved. [CSSTEXT]
|
||||
|
||||
if (is<DOM::Text>(node)) {
|
||||
auto const* layout_text_node = verify_cast<Layout::TextNode>(layout_node);
|
||||
auto const* layout_text_node = as<Layout::TextNode>(layout_node);
|
||||
items.append(layout_text_node->text_for_rendering());
|
||||
return items;
|
||||
}
|
||||
|
@ -667,7 +667,7 @@ GC::Ptr<DOM::NodeList> HTMLElement::labels()
|
|||
|
||||
if (!m_labels) {
|
||||
m_labels = DOM::LiveNodeList::create(realm(), root(), DOM::LiveNodeList::Scope::Descendants, [&](auto& node) {
|
||||
return is<HTMLLabelElement>(node) && verify_cast<HTMLLabelElement>(node).control() == this;
|
||||
return is<HTMLLabelElement>(node) && as<HTMLLabelElement>(node).control() == this;
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -962,7 +962,7 @@ WebIDL::ExceptionOr<bool> 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<HTMLDialogElement>(*this) && verify_cast<HTMLDialogElement>(*this).is_modal())) {
|
||||
if (!is_connected() || !document().is_fully_active() || (expected_document && &document() != expected_document) || (is<HTMLDialogElement>(*this) && as<HTMLDialogElement>(*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;
|
||||
|
|
|
@ -72,7 +72,7 @@ Variant<Empty, DOM::Element*, GC::Root<RadioNodeList>> HTMLFormControlsCollectio
|
|||
if (!is<DOM::Element>(node))
|
||||
return false;
|
||||
|
||||
auto const& element = verify_cast<DOM::Element>(node);
|
||||
auto const& element = as<DOM::Element>(node);
|
||||
return element.id() == name || element.name() == name;
|
||||
}));
|
||||
}
|
||||
|
|
|
@ -521,7 +521,7 @@ static bool is_form_control(DOM::Element const& element, HTMLFormElement const&
|
|||
GC::Ref<HTMLFormControlsCollection> HTMLFormElement::elements() const
|
||||
{
|
||||
if (!m_elements) {
|
||||
auto& root = verify_cast<ParentNode>(const_cast<HTMLFormElement*>(this)->root());
|
||||
auto& root = as<ParentNode>(const_cast<HTMLFormElement*>(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<FlyString> HTMLFormElement::supported_property_names() const
|
|||
JS::Value HTMLFormElement::named_item_value(FlyString const& name) const
|
||||
{
|
||||
auto& realm = this->realm();
|
||||
auto& root = verify_cast<ParentNode>(this->root());
|
||||
auto& root = as<ParentNode>(this->root());
|
||||
|
||||
// To determine the value of a named property name for a form element, the user agent must run the following steps:
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ void HTMLIFrameElement::attribute_changed(FlyString const& name, Optional<String
|
|||
// https://html.spec.whatwg.org/multipage/iframe-embed-object.html#the-iframe-element:html-element-post-connection-steps
|
||||
void HTMLIFrameElement::post_connection()
|
||||
{
|
||||
DOM::Document& document = verify_cast<DOM::Document>(shadow_including_root());
|
||||
DOM::Document& document = as<DOM::Document>(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())
|
||||
|
|
|
@ -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::ImageBox>(*layout_node()));
|
||||
did_update_alt_text(as<Layout::ImageBox>(*layout_node()));
|
||||
}
|
||||
|
||||
if (name == HTML::AttributeNames::decoding) {
|
||||
|
|
|
@ -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::ImageBox>(*layout_node()));
|
||||
did_update_alt_text(as<Layout::ImageBox>(*layout_node()));
|
||||
} else if (name == HTML::AttributeNames::maxlength) {
|
||||
handle_maxlength_attribute();
|
||||
} else if (name == HTML::AttributeNames::multiple) {
|
||||
|
@ -1728,7 +1728,7 @@ WebIDL::ExceptionOr<void> 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<HTMLInputElement>(copy);
|
||||
auto& input_clone = as<HTMLInputElement>(copy);
|
||||
input_clone.m_value = m_value;
|
||||
input_clone.m_dirty_value = m_dirty_value;
|
||||
input_clone.m_checked = m_checked;
|
||||
|
|
|
@ -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<HTML::HTMLFieldSetElement>(parent_element())) {
|
||||
return verify_cast<HTML::HTMLFieldSetElement>(parent_element())->form();
|
||||
return as<HTML::HTMLFieldSetElement>(parent_element())->form();
|
||||
}
|
||||
|
||||
// Otherwise, it must return null.
|
||||
|
|
|
@ -1202,7 +1202,7 @@ WebIDL::ExceptionOr<void> HTMLMediaElement::process_media_data(Function<void(Str
|
|||
auto duration = video_track ? video_track->duration() : audio_track->duration();
|
||||
set_duration(static_cast<double>(duration.to_milliseconds()) / 1000.0);
|
||||
|
||||
auto& video_element = verify_cast<HTMLVideoElement>(*this);
|
||||
auto& video_element = as<HTMLVideoElement>(*this);
|
||||
video_element.set_video_width(video_track->pixel_width());
|
||||
video_element.set_video_height(video_track->pixel_height());
|
||||
|
||||
|
|
|
@ -107,7 +107,7 @@ static void concatenate_descendants_text_content(DOM::Node const* node, StringBu
|
|||
if (is<HTMLScriptElement>(node) || is<SVG::SVGScriptElement>(node))
|
||||
return;
|
||||
if (is<DOM::Text>(node))
|
||||
builder.append(verify_cast<DOM::Text>(node)->data());
|
||||
builder.append(as<DOM::Text>(node)->data());
|
||||
node->for_each_child([&](auto const& node) {
|
||||
concatenate_descendants_text_content(&node, builder);
|
||||
return IterationDecision::Continue;
|
||||
|
@ -202,7 +202,7 @@ GC::Ptr<HTMLFormElement> HTMLOptionElement::form() const
|
|||
parent = parent->parent_element();
|
||||
|
||||
if (is<HTML::HTMLSelectElement>(parent)) {
|
||||
auto const* select_element = verify_cast<HTMLSelectElement>(parent);
|
||||
auto const* select_element = as<HTMLSelectElement>(parent);
|
||||
return const_cast<HTMLFormElement*>(select_element->form());
|
||||
}
|
||||
|
||||
|
|
|
@ -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<HTMLSelectElement>(*root()).selected_index();
|
||||
return as<HTMLSelectElement>(*root()).selected_index();
|
||||
}
|
||||
|
||||
void HTMLOptionsCollection::set_selected_index(WebIDL::Long index)
|
||||
{
|
||||
verify_cast<HTMLSelectElement>(*root()).set_selected_index(index);
|
||||
as<HTMLSelectElement>(*root()).set_selected_index(index);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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<ClassicScript>(*m_result.get<GC::Ref<Script>>()).run();
|
||||
(void)as<ClassicScript>(*m_result.get<GC::Ref<Script>>()).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<JavaScriptModuleScript>(*m_result.get<GC::Ref<Script>>()).run();
|
||||
(void)as<JavaScriptModuleScript>(*m_result.get<GC::Ref<Script>>()).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<GC::Ref<ImportMapParseResult>>()->register_import_map(verify_cast<Window>(relevant_global_object(*this)));
|
||||
m_result.get<GC::Ref<ImportMapParseResult>>()->register_import_map(as<Window>(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<void> 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<HTMLScriptElement>(copy);
|
||||
auto& script_copy = as<HTMLScriptElement>(copy);
|
||||
script_copy.m_already_started = m_already_started;
|
||||
|
||||
return {};
|
||||
|
|
|
@ -145,14 +145,14 @@ WebIDL::ExceptionOr<void> 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<HTMLOptionElement>(const_cast<HTMLOptionsCollection&>(*options()).item(index));
|
||||
return as<HTMLOptionElement>(const_cast<HTMLOptionsCollection&>(*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<HTMLOptionElement>(const_cast<HTMLOptionsCollection&>(*options()).named_item(name));
|
||||
return as<HTMLOptionElement>(const_cast<HTMLOptionsCollection&>(*options()).named_item(name));
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/form-elements.html#dom-select-add
|
||||
|
@ -187,7 +187,7 @@ GC::Ref<DOM::HTMLCollection> HTMLSelectElement::selected_options()
|
|||
if (!m_selected_options) {
|
||||
m_selected_options = DOM::HTMLCollection::create(*this, DOM::HTMLCollection::Scope::Descendants, [](Element const& element) {
|
||||
if (is<HTML::HTMLOptionElement>(element)) {
|
||||
auto const& option_element = verify_cast<HTMLOptionElement>(element);
|
||||
auto const& option_element = as<HTMLOptionElement>(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<HTMLOptGroupElement>(*child)) {
|
||||
auto& opt_group_element = verify_cast<HTMLOptGroupElement>(*child);
|
||||
auto& opt_group_element = as<HTMLOptGroupElement>(*child);
|
||||
Vector<SelectItemOption> option_group_items;
|
||||
for (auto const& child : opt_group_element.children_as_vector()) {
|
||||
if (is<HTMLOptionElement>(*child)) {
|
||||
auto& option_element = verify_cast<HTMLOptionElement>(*child);
|
||||
auto& option_element = as<HTMLOptionElement>(*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<HTMLOptionElement>(*child)) {
|
||||
auto& option_element = verify_cast<HTMLOptionElement>(*child);
|
||||
auto& option_element = as<HTMLOptionElement>(*child);
|
||||
m_select_items.append(SelectItemOption { id_counter++, option_element.selected(), option_element.disabled(), option_element, strip_newlines(option_element.label()), option_element.value() });
|
||||
}
|
||||
|
||||
|
|
|
@ -189,7 +189,7 @@ GC::Ptr<HTMLTableSectionElement> HTMLTableElement::t_head()
|
|||
// if any, or null otherwise.
|
||||
for (auto* child = first_child(); child; child = child->next_sibling()) {
|
||||
if (is<HTMLTableSectionElement>(*child)) {
|
||||
auto table_section_element = &verify_cast<HTMLTableSectionElement>(*child);
|
||||
auto table_section_element = &as<HTMLTableSectionElement>(*child);
|
||||
if (table_section_element->local_name() == TagNames::thead)
|
||||
return table_section_element;
|
||||
}
|
||||
|
@ -224,7 +224,7 @@ WebIDL::ExceptionOr<void> HTMLTableElement::set_t_head(HTMLTableSectionElement*
|
|||
if (is<HTMLTableCaptionElement>(*child))
|
||||
continue;
|
||||
if (is<HTMLTableColElement>(*child)) {
|
||||
auto table_col_element = &verify_cast<HTMLTableColElement>(*child);
|
||||
auto table_col_element = &as<HTMLTableColElement>(*child);
|
||||
if (table_col_element->local_name() == TagNames::colgroup)
|
||||
continue;
|
||||
}
|
||||
|
@ -256,7 +256,7 @@ GC::Ref<HTMLTableSectionElement> HTMLTableElement::create_t_head()
|
|||
if (is<HTMLTableCaptionElement>(*child))
|
||||
continue;
|
||||
if (is<HTMLTableColElement>(*child)) {
|
||||
auto table_col_element = &verify_cast<HTMLTableColElement>(*child);
|
||||
auto table_col_element = &as<HTMLTableColElement>(*child);
|
||||
if (table_col_element->local_name() == TagNames::colgroup)
|
||||
continue;
|
||||
}
|
||||
|
@ -287,7 +287,7 @@ GC::Ptr<HTMLTableSectionElement> HTMLTableElement::t_foot()
|
|||
// if any, or null otherwise.
|
||||
for (auto* child = first_child(); child; child = child->next_sibling()) {
|
||||
if (is<HTMLTableSectionElement>(*child)) {
|
||||
auto table_section_element = &verify_cast<HTMLTableSectionElement>(*child);
|
||||
auto table_section_element = &as<HTMLTableSectionElement>(*child);
|
||||
if (table_section_element->local_name() == TagNames::tfoot)
|
||||
return table_section_element;
|
||||
}
|
||||
|
@ -360,7 +360,7 @@ GC::Ref<HTMLTableSectionElement> HTMLTableElement::create_t_body()
|
|||
if (!is<HTMLElement>(*child))
|
||||
continue;
|
||||
if (is<HTMLTableSectionElement>(*child)) {
|
||||
auto table_section_element = &verify_cast<HTMLTableSectionElement>(*child);
|
||||
auto table_section_element = &as<HTMLTableSectionElement>(*child);
|
||||
if (table_section_element->local_name() == TagNames::tbody) {
|
||||
// We have found an element which is a <tbody> we'll insert after this
|
||||
child_to_insert_before = child->next_sibling();
|
||||
|
|
|
@ -59,7 +59,7 @@ WebIDL::ExceptionOr<void> 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<HTMLTemplateElement>(copy);
|
||||
auto& template_copy = as<HTMLTemplateElement>(copy);
|
||||
for (auto child = content()->first_child(); child; child = child->next_sibling()) {
|
||||
TRY(child->clone_node(&template_copy.content()->document(), true, template_copy.content()));
|
||||
}
|
||||
|
|
|
@ -141,7 +141,7 @@ WebIDL::ExceptionOr<void> 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<HTMLTextAreaElement>(copy);
|
||||
auto& textarea_copy = as<HTMLTextAreaElement>(copy);
|
||||
textarea_copy.m_raw_value = m_raw_value;
|
||||
textarea_copy.m_dirty_value = m_dirty_value;
|
||||
|
||||
|
|
|
@ -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<HTMLMediaElement>(parent())) {
|
||||
cors_attribute_state = verify_cast<HTMLMediaElement>(parent())->crossorigin();
|
||||
cors_attribute_state = as<HTMLMediaElement>(parent())->crossorigin();
|
||||
}
|
||||
|
||||
// 9. End the synchronous section, continuing the remaining steps in parallel.
|
||||
|
|
|
@ -211,7 +211,7 @@ WebIDL::ExceptionOr<void> 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<Window>(relevant_global_object(*this)).navigation();
|
||||
auto navigation = as<Window>(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,
|
||||
|
|
|
@ -79,7 +79,7 @@ GC::Ptr<DOM::Document> 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::Window>(HTML::relevant_global_object(*this)).browsing_context();
|
||||
auto* browsing_context = as<HTML::Window>(HTML::relevant_global_object(*this)).browsing_context();
|
||||
return browsing_context ? browsing_context->active_document() : nullptr;
|
||||
}
|
||||
|
||||
|
@ -87,13 +87,13 @@ GC::Ptr<DOM::Document> Location::relevant_document() const
|
|||
WebIDL::ExceptionOr<void> 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::Window>(HTML::relevant_global_object(*this)).navigable();
|
||||
auto navigable = as<HTML::Window>(HTML::relevant_global_object(*this)).navigable();
|
||||
|
||||
// 2. Let sourceDocument be the incumbent global object's associated Document.
|
||||
auto& source_document = verify_cast<HTML::Window>(incumbent_global_object()).associated_document();
|
||||
auto& source_document = as<HTML::Window>(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<HTML::Window>(incumbent_global_object()).has_transient_activation()) {
|
||||
if (!relevant_document()->is_completely_loaded() && !as<HTML::Window>(incumbent_global_object()).has_transient_activation()) {
|
||||
history_handling = Bindings::NavigationHistoryBehavior::Replace;
|
||||
}
|
||||
|
||||
|
|
|
@ -403,7 +403,7 @@ void MessagePort::post_message_task_steps(SerializedTransferRecord& serialize_wi
|
|||
Vector<GC::Root<MessagePort>> new_ports;
|
||||
for (auto const& object : deserialize_record.transferred_values) {
|
||||
if (is<HTML::MessagePort>(*object)) {
|
||||
new_ports.append(verify_cast<MessagePort>(*object));
|
||||
new_ports.append(as<MessagePort>(*object));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue