Skip to content
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: Prevent a popover crash and implement popovertarget #3285

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Gingeh
Copy link
Contributor

@Gingeh Gingeh commented Jan 17, 2025

The first commit is based on whatwg/html#9457 and prevents a crash when removing a visible popover.
That spec PR hasn't been merged yet and is currently slightly outdated, but the changes are spread throughout the code so I'm not sure what the best place to add a FIXME/AD-HOC would be.

The second commit implements popovertarget buttons (and includes a change to top layer elements to prevent a crash when hiding and showing a popover in the same frame).

This PR also fixes 29 crashing tests and gains at least 1656 new subtest passes.

(I may start a followup PR to update and implement the remaining parts of the popover spec)

Copy link

Your pull request has conflicts that need to be resolved before it can be reviewed and merged. Make sure to rebase your branch on top of the latest master.

@github-actions github-actions bot added the conflicts Pull request has merge conflicts that need resolution label Jan 18, 2025
@github-actions github-actions bot removed conflicts Pull request has merge conflicts that need resolution labels Jan 18, 2025
@Gingeh Gingeh force-pushed the popovertarget branch 2 times, most recently from 5e9dabe to 6931acb Compare January 21, 2025 10:19
Libraries/LibWeb/HTML/HTMLElement.cpp Show resolved Hide resolved
Libraries/LibWeb/HTML/HTMLElement.cpp Outdated Show resolved Hide resolved
Libraries/LibWeb/HTML/PopoverInvokerElement.cpp Outdated Show resolved Hide resolved
Libraries/LibWeb/HTML/PopoverInvokerElement.cpp Outdated Show resolved Hide resolved
Comment on lines 97 to 98
auto const* popover_invoker_element = dynamic_cast<PopoverInvokerElement const*>(node.ptr());
GC::Ptr<HTMLElement> popover_element = verify_cast<HTMLElement>(popover_invoker_element->m_popover_target_element.ptr());
Copy link
Member

Choose a reason for hiding this comment

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

If node isn't a PopoverInvokerElement, this is a null dereference.

If we know it is one, then use verify_cast instead of dynamic_cast.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That function is only ever called on FormAssociatedElements which are also PopoverInvokerElements, so neither dynamic_cast should fail. I don't know how to convince the compiler that a verify_cast is valid, so the best I can do is a VERIFY(popover_invoker_element).

@github-actions github-actions bot added the conflicts Pull request has merge conflicts that need resolution label Jan 21, 2025
Copy link

Your pull request has conflicts that need to be resolved before it can be reviewed and merged. Make sure to rebase your branch on top of the latest master.

Using whatwg/html#9457
(with some changes made to catch up with the current spec)
to fix a spec bug and a crash when removing a visible popover.
@github-actions github-actions bot removed the conflicts Pull request has merge conflicts that need resolution label Jan 21, 2025
@Gingeh Gingeh requested a review from AtkinsSJ January 21, 2025 23:38
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.

2 participants