Skip to content

webapi: reject elementFromPoint outside viewport - #3236

Closed
FAIpang wants to merge 2 commits into
lightpanda-io:mainfrom
FAIpang:codex/elementfrompoint-viewport-bounds
Closed

FAIpang wants to merge 2 commits into
lightpanda-io:mainfrom
FAIpang:codex/elementfrompoint-viewport-bounds

Conversation

@FAIpang

@FAIpang FAIpang commented Aug 20, 2026

Copy link
Copy Markdown

Summary

  • return early when elementFromPoint() receives coordinates outside the viewport
  • preserve internal document-coordinate hit testing used by elementFromVerticalPoint()
  • cover negative, viewport-overflow, exact-boundary, and Taobao reproduction coordinates

Motivation

CSSOM View requires negative coordinates or coordinates greater than the viewport dimensions to return null. For very large y values, the existing traversal shortcut does not fire, so the browser unnecessarily walks the DOM and performs visibility checks.

Testing

  • git diff --check
  • embedded test-script syntax validation
  • CI: TEST_FILTER="WebApi: Document#element_from_point.html" make test

@github-actions

github-actions Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@FAIpang

FAIpang commented Aug 20, 2026

Copy link
Copy Markdown
Author

Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.

I have read the CLA Document and I hereby sign the CLA

You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

recheck

@FAIpang

FAIpang commented Aug 20, 2026

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

@karlseguin

Copy link
Copy Markdown
Collaborator

Can you provide an exact link that causes the performance issue?

I think this change is likely to break sites. Since we don't change the viewport, any script that expects an element to become visible from a scroll or some other viewport change will hang. Also, while it might not be correct, all of our coordinates are document-based, not viewport based, e.g. getBoundingClientRect() doesn't consider the scroll position. So at least we're consistent.

@FAIpang

FAIpang commented Aug 23, 2026

Copy link
Copy Markdown
Author

Can you provide an exact link that causes the performance issue?

I think this change is likely to break sites. Since we don't change the viewport, any script that expects an element to become visible from a scroll or some other viewport change will hang. Also, while it might not be correct, all of our coordinates are document-based, not viewport based, e.g. getBoundingClientRect() doesn't consider the scroll position. So at least we're consistent.

@FAIpang FAIpang closed this Aug 23, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 23, 2026
@FAIpang FAIpang reopened this Aug 23, 2026
@krichprollsch

krichprollsch commented Aug 28, 2026

Copy link
Copy Markdown
Member

@FAIpang any update about the use case?

EDIT: I didn't see #3251, my bad

@karlseguin

Copy link
Copy Markdown
Collaborator

Hi @FAIpang closing this as I believe #3353 fixes the issue.

@karlseguin karlseguin closed this Aug 31, 2026
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.

3 participants