Skip to content

Commit

Permalink
LibWeb: Use correct type for MessageEventInit.ports
Browse files Browse the repository at this point in the history
This didn't work previously because the IDL generator used the
incorrect type for some types of sequences within dictionaries.
  • Loading branch information
tcl3 authored and awesomekling committed May 16, 2024
1 parent 763b7f0 commit 6324657
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -888,7 +888,7 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
)~~~");
} else {
sequence_generator.append(R"~~~(
@sequence.storage_type@ @cpp_name@ { global_object.heap() };
@sequence.storage_type@<@sequence.type@> @cpp_name@ { vm.heap() };
)~~~");
}
}
Expand Down
5 changes: 3 additions & 2 deletions Userland/Libraries/LibWeb/HTML/MessageEvent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <LibWeb/Bindings/Intrinsics.h>
#include <LibWeb/Bindings/MessageEventPrototype.h>
#include <LibWeb/HTML/MessageEvent.h>
#include <LibWeb/HTML/MessagePort.h>

namespace Web::HTML {

Expand All @@ -31,9 +32,9 @@ MessageEvent::MessageEvent(JS::Realm& realm, FlyString const& event_name, Messag
, m_source(event_init.source)
{
m_ports.ensure_capacity(event_init.ports.size());
for (auto& port : event_init.ports) {
for (auto const& port : event_init.ports) {
VERIFY(port);
m_ports.unchecked_append(*port);
m_ports.unchecked_append(static_cast<JS::Object&>(*port));
}
}

Expand Down
2 changes: 1 addition & 1 deletion Userland/Libraries/LibWeb/HTML/MessageEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ struct MessageEventInit : public DOM::EventInit {
String origin {};
String last_event_id {};
Optional<MessageEventSource> source;
Vector<JS::Handle<JS::Object>> ports;
Vector<JS::Handle<MessagePort>> ports;
};

class MessageEvent : public DOM::Event {
Expand Down
3 changes: 1 addition & 2 deletions Userland/Libraries/LibWeb/HTML/MessageEvent.idl
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,5 @@ dictionary MessageEventInit : EventInit {
USVString origin = "";
DOMString lastEventId = "";
MessageEventSource? source = null;
// FIXME: sequence<MessagePort> ports = [];
sequence<object> ports = [];
sequence<MessagePort> ports = [];
};
4 changes: 2 additions & 2 deletions Userland/Libraries/LibWeb/HTML/MessagePort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,10 +372,10 @@ void MessagePort::post_message_task_steps(SerializedTransferRecord& serialize_wi

// 5. Let newPorts be a new frozen array consisting of all MessagePort objects in deserializeRecord.[[TransferredValues]], if any, maintaining their relative order.
// FIXME: Use a FrozenArray
Vector<JS::Handle<JS::Object>> new_ports;
Vector<JS::Handle<MessagePort>> new_ports;
for (auto const& object : deserialize_record.transferred_values) {
if (is<HTML::MessagePort>(*object)) {
new_ports.append(object);
new_ports.append(verify_cast<MessagePort>(*object));
}
}

Expand Down
4 changes: 2 additions & 2 deletions Userland/Libraries/LibWeb/HTML/Window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1160,10 +1160,10 @@ WebIDL::ExceptionOr<void> Window::window_post_message_steps(JS::Value message, W
// 6. Let newPorts be a new frozen array consisting of all MessagePort objects in deserializeRecord.[[TransferredValues]],
// if any, maintaining their relative order.
// FIXME: Use a FrozenArray
Vector<JS::Handle<JS::Object>> new_ports;
Vector<JS::Handle<MessagePort>> new_ports;
for (auto const& object : deserialize_record.transferred_values) {
if (is<HTML::MessagePort>(*object)) {
new_ports.append(object);
new_ports.append(verify_cast<MessagePort>(*object));
}
}

Expand Down

0 comments on commit 6324657

Please sign in to comment.