Skip to content

Conversation

@francisbouvier
Copy link
Member

@francisbouvier francisbouvier commented Jan 16, 2024

Closes #36

Signed-off-by: Francis Bouvier <francis@lightpanda.io>
@francisbouvier francisbouvier force-pushed the events branch 2 times, most recently from 51f921d to 1c9a8c2 Compare January 16, 2024 23:24
eventType: []const u8,
cbk: Callback,
) !void {
// TODO: when can we free this allocation?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on the removeListener call maybe?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes of course. But I want to investigate the lifetime of the Callback to see if we can do it before.

Signed-off-by: Francis Bouvier <francis@lightpanda.io>
Signed-off-by: Francis Bouvier <francis@lightpanda.io>
Signed-off-by: Francis Bouvier <francis@lightpanda.io>
@francisbouvier francisbouvier force-pushed the events branch 3 times, most recently from e827f7f to 5952902 Compare January 19, 2024 15:02
Signed-off-by: Francis Bouvier <francis@lightpanda.io>
@francisbouvier francisbouvier marked this pull request as ready for review January 19, 2024 15:47
@francisbouvier francisbouvier force-pushed the events branch 3 times, most recently from dcd7b74 to ef6c36b Compare January 19, 2024 15:55
Signed-off-by: Francis Bouvier <francis@lightpanda.io>
@krichprollsch
Copy link
Member

krichprollsch commented Jan 22, 2024

In order to try to pass some of the new WPT tests, I suggest to implement document.createEvent https://dom.spec.whatwg.org/#dom-document-createevent https://developer.mozilla.org/en-US/docs/Web/API/Document/createEvent

  • initEvent

Signed-off-by: Francis Bouvier <francis@lightpanda.io>
src/netsurf.zig Outdated
// EventListener
pub const EventListener = c.dom_event_listener;

pub fn eventListenerGetData(lst: *EventListener) ?*anyopaque {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could directly return a *Callback here isn't it?

src/netsurf.zig Outdated
return getVtable(c.dom_event_target_vtable, EventTarget, et);
}

pub fn eventTargetHasListener(et: *EventTarget, typ: []const u8, cbk_id: usize) !?*EventListener {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about the cbk_id: usize.
It seems inconsistent w/ the eventTargetAddEventListener signature which expects a cbk_ptr: *Callback.

And check if callback has been already added in addEventListener

Signed-off-by: Francis Bouvier <francis@lightpanda.io>
And unify the way allocator is used on eventTarget add/remove listener

Signed-off-by: Francis Bouvier <francis@lightpanda.io>
Signed-off-by: Francis Bouvier <francis@lightpanda.io>
@francisbouvier francisbouvier merged commit d243963 into main Jan 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DOM Events

3 participants