diff --git a/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp b/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp
index ac0c598cace..53dde33bcc6 100644
--- a/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp
+++ b/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp
@@ -791,10 +791,7 @@ GC::Ref HTMLParser::create_element_for(HTMLToken const& token, Opt
// element is either not listed or doesn't have a form attribute, and the intended parent is in the same tree as the element pointed to by the form element pointer,
// then associate element with the form element pointed to by the form element pointer and set element's parser inserted flag.
// FIXME: Check if the element is not a form-associated custom element.
- if (is(*element)) {
- auto* form_associated_element = dynamic_cast(element.ptr());
- VERIFY(form_associated_element);
-
+ if (auto* form_associated_element = as_if(*element)) {
auto& html_element = form_associated_element->form_associated_element_to_html_element();
if (m_form_element.ptr()
diff --git a/Libraries/LibWeb/HTML/StructuredSerialize.cpp b/Libraries/LibWeb/HTML/StructuredSerialize.cpp
index ba2eefb5c53..6c273c4ac1a 100644
--- a/Libraries/LibWeb/HTML/StructuredSerialize.cpp
+++ b/Libraries/LibWeb/HTML/StructuredSerialize.cpp
@@ -1211,8 +1211,8 @@ WebIDL::ExceptionOr structured_serialize_with_transfer
// 5. For each transferable of transferList:
for (auto& transferable : transfer_list) {
- auto is_array_buffer = is(*transferable);
- auto is_detached = is_array_buffer && dynamic_cast(*transferable).is_detached();
+ auto array_buffer = as_if(*transferable);
+ auto is_detached = array_buffer && array_buffer->is_detached();
// 1. If transferable has an [[ArrayBufferData]] internal slot and IsDetachedBuffer(transferable) is true, then throw a "DataCloneError" DOMException.
if (is_detached) {
@@ -1220,9 +1220,8 @@ WebIDL::ExceptionOr structured_serialize_with_transfer
}
// 2. If transferable has a [[Detached]] internal slot and transferable.[[Detached]] is true, then throw a "DataCloneError" DOMException.
- if (is(*transferable)) {
- auto& transferable_object = dynamic_cast(*transferable);
- if (transferable_object.is_detached()) {
+ if (auto* transferable_object = as_if(*transferable)) {
+ if (transferable_object->is_detached()) {
return WebIDL::DataCloneError::create(*vm.current_realm(), "Value already transferred"_string);
}
}
@@ -1232,17 +1231,16 @@ WebIDL::ExceptionOr structured_serialize_with_transfer
TransferDataHolder data_holder;
// 4. If transferable has an [[ArrayBufferData]] internal slot, then:
- if (is_array_buffer) {
+ if (array_buffer) {
// 1. If transferable has an [[ArrayBufferMaxByteLength]] internal slot, then:
- auto& array_buffer = dynamic_cast(*transferable);
- if (!array_buffer.is_fixed_length()) {
+ if (!array_buffer->is_fixed_length()) {
// 1. Set dataHolder.[[Type]] to "ResizableArrayBuffer".
// 2. Set dataHolder.[[ArrayBufferData]] to transferable.[[ArrayBufferData]].
// 3. Set dataHolder.[[ArrayBufferByteLength]] to transferable.[[ArrayBufferByteLength]].
// 4. Set dataHolder.[[ArrayBufferMaxByteLength]] to transferable.[[ArrayBufferMaxByteLength]].
serialize_enum(data_holder.data, TransferType::ResizableArrayBuffer);
- MUST(serialize_bytes(vm, data_holder.data, array_buffer.buffer().bytes())); // serializes both byte length and bytes
- serialize_primitive_type(data_holder.data, array_buffer.max_byte_length());
+ MUST(serialize_bytes(vm, data_holder.data, array_buffer->buffer().bytes())); // serializes both byte length and bytes
+ serialize_primitive_type(data_holder.data, array_buffer->max_byte_length());
}
// 2. Otherwise:
@@ -1251,12 +1249,12 @@ WebIDL::ExceptionOr structured_serialize_with_transfer
// 2. Set dataHolder.[[ArrayBufferData]] to transferable.[[ArrayBufferData]].
// 3. Set dataHolder.[[ArrayBufferByteLength]] to transferable.[[ArrayBufferByteLength]].
serialize_enum(data_holder.data, TransferType::ArrayBuffer);
- MUST(serialize_bytes(vm, data_holder.data, array_buffer.buffer().bytes())); // serializes both byte length and bytes
+ MUST(serialize_bytes(vm, data_holder.data, array_buffer->buffer().bytes())); // serializes both byte length and bytes
}
// 3. Perform ? DetachArrayBuffer(transferable).
// NOTE: Specifications can use the [[ArrayBufferDetachKey]] internal slot to prevent ArrayBuffers from being detached. This is used in WebAssembly JavaScript Interface, for example. See: https://html.spec.whatwg.org/multipage/references.html#refsWASMJS
- TRY(JS::detach_array_buffer(vm, array_buffer));
+ TRY(JS::detach_array_buffer(vm, *array_buffer));
}
// 5. Otherwise: