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: Add inline-size containment for replaced elements #3344

Closed

Conversation

Psychpsyo
Copy link
Contributor

@Psychpsyo Psychpsyo commented Jan 23, 2025

NOTE: This can only be merged once my changes in #3296 and #3271 have been merged, as it relies on both of them.

I'll probably want to properly test this an import some more WPTs once that has happened though.

EDIT: Messed up a rebase, will just reopen this once those other PRs have been merged.

Psychpsyo and others added 30 commits January 11, 2025 01:34
We'll need to call it from elsewhere.

Also add a missing step 5 from where we previously called it.
Previously, the DOM complete time was never being set, as the HTML
parser was detached before `DocumentReadyState` was set to complete.
Add a couple of macros to aid error handling with OpenSSL and some RAII
classes that manage the lifetime of some OpenSSL objects.
Implement the Ed448 curve for signing and verifying using OpenSSL.

The methods could be all made static, but all other curves are not.
I think this is material for further refactoring.
Add full support for Ed448 and import relevant tests.
This matches the behavior of other browsers, which always set the dirty
checkedness flag when setting checkedness, except when setting the
`checked` content attribute.
URL::basic_parse has a subtle bug where the resulting URL is not set
to valid when StateOveride is provided and the URL parser early returns
a valid URL.

This has not surfaced as a problem so far, as the only users of the
state override API provide an already valid URL buffer and also ignore
the result of basic parsing with a state override.

However, this bug surfaces implementing the URL pattern spec, which as
part of URL canonicalization:
 * Provides a dummy URL record
 * Basic URL parses that URL with state override
 * Checks the result of the URL parser to validate the URL

While we could set URL validity on every early return of the URL parser
during state override, it has been a long standing FIXME around the code
to try and remove the awkward validity state of the URL class. So this
commit makes the first stage of this change by migrating the basic
parser API to return Optional, which also happens to make this subtle
issue not a problem any more.
This makes it more convenient to use the 'relvant agent' concept,
instead of the awkward dynamic casts we needed to do for every call
site.

mutation_observers is also changed to hold a GC::Root instead of raw
GC::Ptr. Somehow this was not causing problems before, but trips up CI
after these changes.
Previously, the namespace of the attributes on the cloned element was
not being set.
Previously, the build would fail if the CMake source directory
contained regex special characters.
The drag-and-drop event names are already included, and the app cache
event names no longer exist (and the spec link here 404s).
We added these methods to propagate OOM errors at process startup, but
we longer fret about these tiny OOM failures. Requiring that these init
methods be called prohibits using these strings in processes that have
not set up a MainThreadVM. So let's just remove them and initialize the
strings in a sane manner.

In doing so, this also standardizes how we initialize strings whose C++
variable name differs from their string value. Instead of special-casing
these strings, we just include their string value in the x-macro list.
Now that we can use these string constants, let's avoid the replication.
Not currently needed as it cannot fail, but useful for future commits.
The current default is unsafe, but determining a safe value is not easy.
Leave it up to the caller to decide.
Make `encrypt`, `decrypt`, `sign` and `verify` return `ErrorOr` for
better error propagation.
Lubrsi and others added 22 commits January 23, 2025 13:37
Namely:
- Perform case-insensitive matching
- Return the same extension objects every time
- Only enable the extension if it's supported by the current context
This is done by using the combination of format and type to map to the
appropriate Skia bitmap type. With this, we then read the SkImage of
the TexImageSource into a new SkPixmap with the destination format
information and holding an appropriately sized buffer. Once created,
readPixels is called to convert and write the image into the buffer.
This is used to put together the list of supported WebGL extensions
based on the available extensions, per-extension required extensions
and WebGL version.
This already exists in URL::Host, and used appropriately.
The spec intends to pass through a URL record object as it needs to
be serialized on removal. This has no functional impact on our
implementation other than the double parsing of every URL being
revoked.

It is also missing an error check for an invalid URL being passed
through. This does not impact our implementation currently as we
just end up using an empty URL which is not part of the blob entry
map. This will cause problems once DOMURL::parse is updated to
return an Optional<URL::URL> however.
This ports one more function away from needing to use the awkward
valid state of the URL class.
This fixes issue where it was impossible to paste text into
inspector console input.
This allows for easy child removal similar to `DOM::Node::remove()`.
The existing `::unite_horizontally()` and `::unite_vertically()` tests
did not properly test the edge cases where left/top in the Rect were
updated, so they get re-arranged a bit.
Our layout tree requires that all containers either have inline or
non-inline children. In order to support the layout of non-inline
elements inside inline elements, we need to do a bit of tree
restructuring. It effectively simulates temporarily closing all inline
nodes, appending the block element, and resumes appending to the last
open inline node.

The acid1.txt expectation needed to be updated to reflect the fact that
we now hoist its <p> elements out of the inline <form> they were in.
Visually, the before and after situations for acid1.html are identical.
There are many simpler APIs that we can use here. No functional changes.
Instead of ignoring any paintable immediately when they're invisible to
hit-testing, consider every candidate and while the most specific
candidate is invisible to hit-testing, traverse up to its parent
paintable.

This more closely reflects the behavior expected when wrapping block
elements inside inline elements, where although the block element might
have `pointer-events: none`, it still becomes part of the hit-test body
of the inline parent.

This makes the following link work as expected:

  <a href="https://ladybird.org">
    <div style="pointer-events: none">Ladybird</div>
  </a>
Before this change, it was possible for a second GC to get triggered
in the middle of a first GC, due to allocations happening in the
FinalizationRegistry cleanup host hook. To avoid this causing problems,
we add a "post-GC task" mechanism and use that to invoke the host hook
once all other GC activity is finished, and we've unset the "collecting
garbage" flag.

Note that the test included here only fails reliably when running with
the -g flag (collect garbage after each allocation).

Fixes LadybirdBrowser#3051
@Psychpsyo Psychpsyo requested a review from AtkinsSJ as a code owner January 23, 2025 12:39
@Psychpsyo Psychpsyo force-pushed the inline-size-contain-thing branch from 4b9e574 to a483cd4 Compare January 23, 2025 12:40
@github-actions github-actions bot added the conflicts Pull request has merge conflicts that need resolution label Jan 23, 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.

@Psychpsyo Psychpsyo closed this Jan 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
conflicts Pull request has merge conflicts that need resolution
Projects
None yet
Development

Successfully merging this pull request may close these issues.