Skip to content

Conversation

@karlseguin
Copy link
Collaborator

This isn't complete.

Can't test because scripts run into other blockers before reaching this point (i.e. Dom.resolveNode). I do think it's pretty safe to merge this as-is though.

Looking for feedback on the FlatRenderer in browser.zig and Page.click handling (netsurf code is a bit tedious to us).

Besides the inability to manually test. I'm also looking for feedback about how to test this. These flows are starting to get more complicated and I'm not sure they're reasonable for unit tests.

Copy link
Member

@krichprollsch krichprollsch left a comment

Choose a reason for hiding this comment

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

Thanks for this PR, it looks fine to me 👍

Page.click looks correct to me. The only thing we could change would be to dispatch a PointerEvent instead of a simple Event. See https://html.spec.whatwg.org/multipage/webappapis.html#fire-a-synthetic-pointer-event

But it implies some changes:

FlatRenderer looks good to me.

Regarding tests I don't have strong opinion. We will add end-to-end test for click at least...


// TODO: hard coded ID
bc.loader_id = "AF8667A203C5392DBE9AC290044AA4C2";
bc.url = url;
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 afraid this one is not correct is case of redirection...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This was existing code, but I agree. I removed the url state from the browsercontext and instead added a getURL() []const u8 method which gets the URL from the session's page.

I think there's more of this encapsulation / ownership we need to do, and I think that, in most cases, the Browser Session/Page should be the authoritative source.

@krichprollsch
Copy link
Member


const bc = cmd.browser_context orelse return;
const page = bc.session.currentPage() orelse return;
const click_result = (try page.click(cmd.arena, params.x, params.y)) orelse return;
Copy link
Member

@krichprollsch krichprollsch Apr 4, 2025

Choose a reason for hiding this comment

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

according with https://chromedevtools.github.io/devtools-protocol/tot/Input/#method-dispatchMouseEvent we should dispatch the event corresponding to the type given in parameter.
So I think we should:

  • call page.click if the event type is mousePressed or mouseReleased
  • add a TODO to dispatch only the corresponding event in case of mouseMoved, mouseWheel (and we don't want to click in this case)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I made it all more generic, page.click -> page.mouseEvent, taking in a struct when an event type enum)

@karlseguin
Copy link
Collaborator Author

libdom has a mouse_event https://github.com/lightpanda-io/libdom/blob/master/include/dom/events/mouse_event.h

I switched to the mouse_event, but one of the parameters is a struct dom_abstract_view *view which I couldn't find anything about. I pass null for now, any idea about this?

@krichprollsch
Copy link
Member

I switched to the mouse_event, but one of the parameters is a struct dom_abstract_view *view which I couldn't find anything about. I pass null for now, any idea about this?

it looks like it's the window object 🤔
https://developer.mozilla.org/fr/docs/Web/API/MouseEvent#exemple

It is inherited from the UIEvent: https://developer.mozilla.org/en-US/docs/Web/API/UIEvent/view

@krichprollsch
Copy link
Member

@karlseguin can you rebase to fix the conflict please?

FlatRenderer positions items on a single row, giving each a height and width of
1.

Added getBoundingClientRect to the DOMelement which, when requested for the
first time, will place the item in with the renderer.

The goal here is to give elements a fixed position and to make it easy to map
x,y coordinates onto an element. This should work, at least with puppeteer,
since it first requests the boundingClientRect before issuing a click.
Add BrowserContext.getURL which gets the URL from the session.page.
@karlseguin
Copy link
Collaborator Author

@karlseguin can you rebase to fix the conflict please?

@krichprollsch ready

@krichprollsch krichprollsch merged commit 07e8dfa into lightpanda-io:main Apr 8, 2025
12 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Apr 8, 2025
@karlseguin karlseguin deleted the renderer branch April 9, 2025 00:50
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants