Skip to content

Conversation

@rodarima
Copy link
Member

Handle display:none properly for form elements. This is specially notable in the wikipedia.

Fixes #433

@rodarima
Copy link
Member Author

This is causing leaks due to elements being outside the tree. We need to find a way to clean them as well.

@rodarima rodarima marked this pull request as draft August 24, 2025 17:06
@rodarima rodarima force-pushed the fix-hidden-form-inputs branch from fe286f0 to 7fb97b7 Compare August 30, 2025 13:25
When the current element or a parent has display:none, the display_none
flag is set and no new element should be added to the viewport. For form
inputs, instead of always adding the Embed to the viewport, we only do
it if display_none is not set. The Embed is still registered as an input
in the form, so it will continue to send the proper form values to the
server.

For complex buttons that can contain nested elements inside, we switch
to a dummy button that doesn't have a Textbox and rely on the logic at
html.cc to avoid creating more child elements until the display_none is
unset.

Fixes: #433
The display_none flag is only set _after_ the open tag has run, so it
will only affect child elements. If the current form input element has a
display:none itself, it should be also considered. The new function
a_Html_should_display() evaluates both conditions.
When an input element should not be displayed due to display:none, don't
allocate the Resource or the Embed directly. It won't be added to the
Widget tree either. This prevents allocating Resources that are not tied
to a Widget so they are not leaked when the tree is destroyed.

The Embed or Resource elements won't be needed as the DilloHtmlInput
handles all the form logic.
@rodarima
Copy link
Member Author

This is causing leaks due to elements being outside the tree. We need to find a way to clean them as well.

Managed to avoid creating new Embed and Resource elements, so there is no need to release them.

Let's make sure the memory leaks are first detected and then fixed on the CI.

@rodarima rodarima force-pushed the fix-hidden-form-inputs branch from 7fb97b7 to 79c10b3 Compare August 30, 2025 14:32
@rodarima
Copy link
Member Author

Fails as expected: https://github.com/dillo-browser/dillo/actions/runs/17344978575/job/49243747678?pr=434

==== Total leaks after filter: 51 ====

@rodarima rodarima marked this pull request as ready for review August 30, 2025 14:40
@rodarima
Copy link
Member Author

No leaks detected, seems to be working fine now.

@rodarima rodarima merged commit 47ab7c7 into master Aug 30, 2025
11 checks passed
@rodarima rodarima deleted the fix-hidden-form-inputs branch August 30, 2025 20:42
@rodarima rodarima added this to the Release 3.3.0 milestone Aug 31, 2025
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.

Form inputs are not hidden with display:none

2 participants