-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LibWeb: Fix MouseEvent position values #2364
LibWeb: Fix MouseEvent position values #2364
Conversation
Hello! One or more of the commit messages in this PR do not match the Ladybird code submission policy, please check the |
f4cdddf
to
7db535b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you add a test for this change?
I've added a test over in #2372 (essentially part 2 of this commit) that takes care of all the mouse position values at once. |
I'd rather have a (partial) test in this PR so we don't depend on merging another PR for this code to be tested. |
7db535b
to
509b922
Compare
I've split the test into two now and added the relevant half here. |
Tests/LibWeb/Text/expected/CSSOMView/mouse-event-x-y-values.txt
Outdated
Show resolved
Hide resolved
could you include the text from the PR description in the commit message? the current commit message is a bit sparse, and since the commit message is more important than the PR description, it would be better to provide a detailed explanation there. |
509b922
to
2de45d2
Compare
The clientX and clientY values are, as per the spec, the offset from the viewport. This makes them actually be that and also fixes up the calculations for offsetX, offsetY, pageX and pageY. I assume all of these got messed up in some sort of refactor in the past. The spec comment from the now-removed compute_mouse_event_client_offset() function sadly has no convenient place to be anymore so, for now, it is just gone as well. Personally, I think it'd make sense to refactor a lot of this file so that not every mouse event repeats a large chunk of (almost) identical code. That way there'd be a nice place to put the comment without repeating it all over the file. But that is out of the scope of this PR. Also: I know, offsetX and Y are not fully fixed yet, they still don't ignore the element's CSS transforms but I am working on that in a new PR.
2de45d2
to
2cbb691
Compare
Also done. |
The clientX and clientY values are, as per the spec, the offset from the viewport.
This makes them actually be that and also fixes up the calculations for offsetX, offsetY, pageX and pageY.
I assume all of these got messed up in some sort of refactor in the past.
The spec comment from the now-removed
compute_mouse_event_client_offset()
function sadly has no convenient place to be anymore so, for now, it is just gone as well.Personally, I think it'd make sense to refactor a lot of this file so that not every mouse event repeats a large chunk of (almost) identical code. That way there'd be a nice place to put the comment without repeating it all over the file.
But that is out of the scope of this PR.
Also: I know, offsetX and Y are not fully fixed yet, they still don't ignore the element's CSS transforms but I am working on that in a new PR.