Commit graph

71146 commits

Author SHA1 Message Date
Jelle Raaijmakers
9e29d0c040 LibWeb: Make button layout wrappers inherit styles correctly
There are some nuances to creating these wrappers, such as manually
propagating certain text styles that are not inherited by default. We
already have the logic for this in
`NodeWithStyle::create_anonymous_wrapper()`, so reuse that method in our
implementation of the button layout.

Fixes applying certain text styles (such as `text-decoration`) to the
text of a `<button>`.
2025-08-19 11:12:23 +02:00
Jelle Raaijmakers
f530ea5f7e Tests: Rename button test to something sensible
This had nothing to do with table cells.
2025-08-19 11:12:23 +02:00
Jelle Raaijmakers
715de4693c LibGC+LibWeb: Remove unused include and class 2025-08-19 11:12:23 +02:00
Tim Ledbetter
cfc6439c12 LibWeb: Use shape-rendering to control anti aliasing for SVG paths
Some checks are pending
CI / macOS, arm64, Sanitizer, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer, Clang (push) Waiting to run
Package the js repl as a binary artifact / Linux, arm64 (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / Linux, x86_64 (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
Anti-aliasing is disabled if `shape-rendering` is set to
`optimizeSpeed` or `crispEdges`.
2025-08-19 09:47:28 +01:00
Tim Ledbetter
1d745884be LibWeb: Parse the shape-rendering property 2025-08-19 09:47:28 +01:00
Aliaksandr Kalenik
d94b33e205 LibWeb: Handle correctly case when abspos and relpos GFC is interleaved
...by another GFC. When searching for grid item that contains an
abspos box positioned relative to GFC, it's incorrect to assume that the
closest ancestor box whose parent establishes GFC is always the one we
are looking for, because there may be non-positioned GFC in between.

Fixes regression introduced in 80c8e78.
2025-08-19 09:28:45 +02:00
Erik Kurzinger
8fd1df4f8b LibGfx: Enable WebGL on Linux
Some checks are pending
CI / macOS, arm64, Sanitizer, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer, Clang (push) Waiting to run
Package the js repl as a binary artifact / Linux, arm64 (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / Linux, x86_64 (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
This enabled WebGL on Linux. It uses ANGLE's OpenGL backend running atop
EGL_PLATFORM_SURFACELESS_MESA. Eventually we should probably switch to
the Vulkan backend but that doesn't seem to be enabled in the vcpkg
angle package. Anyway, switching later should be trivial.

The painting surface is allocated through Vulkan and then imported into
EGL as a dma-buf. The DRM format modifier mechanism, along with Vulkan
initializing the image with VK_IMAGE_LAYOUT_GENERAL, should ensure
surface compatibility across the two APIs.

For now, we will synchronize rendering and presentation using glFinish,
although this is admittedly suboptimal. Really we should grab an
EGLSync, export that to an fd, import it into Skia and have it wait for
it before reading from the image. That can be implemented in a future
change, though.
2025-08-19 00:30:22 +02:00
Erik Kurzinger
80693274a7 LibGfx: Fail WebGL context creation if no EGLConfig is found 2025-08-19 00:30:22 +02:00
Erik Kurzinger
72a7051877 LibGfx: Request correct EGLConfig surface type for WebGL
We currently look for an EGLConfig that supports window surfaces, but we
actually use a pbuffer surface.
2025-08-19 00:30:22 +02:00
Erik Kurzinger
df09472d4d LibGfx: Free WebGL painting surface resources on resize
If a WebGL canvas is resized through the set_size function, we will
re-create the painting surface. However, this currently leaks all of the
associated EGL/OpenGL objects. This change introduces the
free_surface_resources function which will free all resources associated
with the painting surface. It will be called before allocating a new
surface and during context destruction. It keeps track of the OpenGL
texture for the color buffer in m_impl instead of just storing it on the
stack.
2025-08-19 00:30:22 +02:00
Erik Kurzinger
41f1e920d8 LibGfx: Allow creating a PaintingSurface from a Vulkan image
This adds a new PaintingSurface creation function, create_from_vkimage,
which returns a PaintingSurface backed by a vulkan image. It's analogous
to the existing create_from_iosurface function. In both cases the
backing object will be imported into Skia as a render target and then an
SkSurface will be wrapped around that.

In order to ensure that the image will not be freed while still in use
by Skia, we will manually bump the refcount of the VulkanImage object
before passing it to Skia and then use the releaseCallback parameter of
WrapBackendRenderTarget to register a callback that drops this
reference.
2025-08-19 00:30:22 +02:00
Erik Kurzinger
08343970fb LibGfx: Save VulkanContext in SkiaBackendContext
This retains access to the vulkan device, queue, etc. handles which will
be needed for image allocation and possible other things in the future.
2025-08-19 00:30:22 +02:00
Erik Kurzinger
60a7359f0f LibGfx: Implement Vulkan image allocation
This introduces the ability to allocate Vulkan images which can be
shared across graphics APIs or across processes using the Linux dma-buf
interface.

The create_shareable_vulkan_image function takes a VulkanContext, image
width, height, and format, and an array of DRM format modifiers
representing image memory layouts accepted by the caller. The function
will intersect this list with the list of modifiers supported by the
Vulkan implementation, ensuring the resulting image uses one of those
layouts (exactly which one is up to the implementation). The function
will return a VulkanImage object, which is reference-counted and
encapsulates the VkImage itself as well as the backing memory
allocation. It also stores various image parameters such as usage,
tiling, etc.

The VulkanImage::get_dma_buf_fd function will create a file descriptor
representing the image's backing dma-buf which can then be imported by a
different API or sent over a unix domain socket.
2025-08-19 00:30:22 +02:00
Erik Kurzinger
06c916d91c LibGfx: Allocate command buffer for VulkanContext
A later change will add the ability to allocate images. We need a
command buffer in order to initialize the layout of those images.
2025-08-19 00:30:22 +02:00
Erik Kurzinger
1a6a114667 LibGfx: Save graphics queue family index in VulkanContext
This will be needed for image allocation, and anyway I think we're
supposed to be passing this to Skia during context creation.
2025-08-19 00:30:22 +02:00
Erik Kurzinger
dc3cb2122d CI: Add libdrm-dev dependency
We need the drm_fourcc.h header to use the dma-bufs in LibGfx
2025-08-19 00:30:22 +02:00
Andreas Kling
29278038a2 LibWeb: Don't assume grid-related properties don't have var() in them
When serializing the "style" attribute, we were incorrectly assuming
that some of the grid-related CSS properties would never contain var()
substitution functions.

With this fixed, we can now book appointments on https://cal.com/ :^)
2025-08-18 21:18:16 +02:00
Sam Atkins
92dc2faa10 LibWeb/CSS: Use serialize_a_number() for Ratio serialization
Some checks are pending
CI / macOS, arm64, Sanitizer, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer, Clang (push) Waiting to run
Package the js repl as a binary artifact / Linux, arm64 (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / Linux, x86_64 (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
2025-08-18 16:52:39 +01:00
Sam Atkins
6b69b00a05 LibWeb/CSS: Use serialize_a_number() for Time serialization
As noted, the spec tells us to do something different than what is
expected by WPT, so we slightly ignore it.
2025-08-18 16:52:39 +01:00
Sam Atkins
682e080d57 LibWeb/CSS: Use serialize_a_number() for Resolution serialization
As noted, the spec tells us to do something different than what is
expected by WPT, so we slightly ignore it.
2025-08-18 16:52:39 +01:00
Sam Atkins
53f226c14c LibWeb/CSS: Use serialize_a_number() for Percentage serialization 2025-08-18 16:52:39 +01:00
Sam Atkins
e30d968049 LibWeb/CSS: Use serialize_a_number() for Frequency serialization 2025-08-18 16:52:39 +01:00
Sam Atkins
1c82d74a18 LibWeb/CSS: Use serialize_a_number() for Flex serialization 2025-08-18 16:52:39 +01:00
Sam Atkins
00b1b34c80 LibWeb/CSS: Use serialize_a_number() for Angle serialization
Gets us 12 known passes!
2025-08-18 16:52:39 +01:00
Sam Atkins
dffebee901 LibWeb/CSS: Use serialize_a_number() for Length serialization
This changes the maximum number of decimal places from 5 to 6, but 5 was
previously a guess, and not specified behaviour:

> For all of the decimal changes (except color) I couldn't really find a
> spec that mandates any required precision, so I just copied what
> Firefox seems to do, which is limit the output to 5 decimal places.
> https://github.com/SerenityOS/serenity/pull/23449
2025-08-18 16:52:39 +01:00
Sam Atkins
1a7f6c8f87 LibWeb/CSS: Define and use serialize_a_number()
No behaviour change, this just moves things.
2025-08-18 16:52:39 +01:00
Abhinav
0205480051 LibWeb: Process closure of socket for WebSockets 2025-08-18 09:35:47 -06:00
Abhinav
6077c51468 LibWeb: Make WebSocket closure adhere to spec for all ReadyStates 2025-08-18 09:35:47 -06:00
Timothy Flynn
5ec70bd00a Revert "LibJS: Revert common error types to only hold a single string"
This reverts commit 695bbcb991.

Despite improving performance on my Linux machine, this managed to tank
performance on the Linux benchmark machine.
2025-08-18 13:42:22 +02:00
Tim Ledbetter
b81d3e813c LibWeb: Eagerly create stacking context if will-change set for property
If `will-change` is set to a property value where that property could
create a stacking context, then we create a stacking context regardless
of the current value of that property.
2025-08-18 12:36:37 +01:00
Tim Ledbetter
4f663ca6e7 LibWeb: Parse the will-change property
This property provides a hint to the rendering engine about properties
that are likely to change in the near future, allowing for early
optimizations to be applied.
2025-08-18 12:36:37 +01:00
Timothy Flynn
0e4fb9ae73 LibWeb: Ensure up/down arrow navigation is grapheme-aware
Previously, it was possible for an up/down arrow press to place the
cursor in the middle of a multi-code point grapheme cluster. We want to
prevent this in a way that matches the behavior of other browsers.

Both Chrome and Firefox will map the starting position to a visually
equivalent position in the target line with harfbuzz and ICU segmenters.
The need for this is explained in a code comment. The result is a much
more natural feeling of text navigation.
2025-08-18 13:17:28 +02:00
Abhinav
be5c52bfef Meta: Detect urls to import from Worker 2025-08-18 11:27:12 +01:00
Callum Law
9a8c6ff8c3 LibWeb: Inherit animated CSS property values separately
When starting transitions we compute the after-change style, for any
inherited properties this should include the non-animated value.

Previously we were only inheriting the animated value and treating it as
non-animated so were instead including the animated value.

This commit fixes that by inheriting both the animated and non-animated
values (with the former being stored in `m_animated_property_values`,
and the latter in `m_property_values`).

This gains us 12 new WPT passes.

This brings with it 252 new WPT fails from the various 'events' tests in
css/css-transitions/properties-value-inherit-001.html, however these
also fail in other browsers (Chrome, Edge and Firefox) and the behaviour
that causes these failures is specifically mentioned in the spec.
2025-08-18 11:18:34 +01:00
Callum Law
54f1407177 LibWeb: Only associate transition with element once
We already handle this within the above call to `Animation::set_effect`

Gains us 3 WPT tests.
2025-08-18 11:18:34 +01:00
Callum Law
84fb0b458f LibWeb: Properly initialize KeyframeEffect contained in CSSTransition
This commit updates the CSSTransition constructor to:
 - Leave the KeyframeEffect start time unresolved
 - Set the KeyframeEffect start delay

Gains us 14 WPT passes but exposes one false positive in
properties-value-inherit-001.html
2025-08-18 11:18:34 +01:00
Callum Law
589529e081 LibWeb: Import tests related to CSSTransition 2025-08-18 11:18:34 +01:00
Jelle Raaijmakers
087601832a LibWeb: Set fit-content width for buttons in used values, not computed
For button layouts, we were overriding the computed `width` value with
`fit-content` in `TreeBuilder::wrap_in_button_layout_if_needed()`. But
the spec asks us to set the _used value_ instead, so we now actually
calculate the fit-content width and set the box' content width to it.

Fixes #2516.
2025-08-18 11:04:34 +01:00
Jelle Raaijmakers
39f36327d4 LibWeb: Simplify obtaining used value for PaintableBox
No functional changes.
2025-08-18 11:04:34 +01:00
Jelle Raaijmakers
ff5f80a196 LibWeb: Add HTMLElement::uses_button_layout()
This suits the spec a bit better, and exposes the fact that we were
allowing `::ImageButton` to use the button layout although it is never
specified that it should do so. Tests were rebaselined for this.
2025-08-18 11:04:34 +01:00
Callum Law
027c9f53be LibWeb: Handle text-overflow: ellipsis with trailing whitespace
We should calculate whether we need to truncate text with an ellipsis
exclusive of any trailing collapsible whitespace.

This was causing issues where an inline element was automatically sized
(e.g. min-content) as we would calculate available width exclusive of
trailing collapsible whitespace and then our text chunk would be wider,
always inserting an ellipsis.

Fixes the visual element of #4048 but we still are incorrect in how we
collapse whitespace more generally
2025-08-18 11:00:26 +01:00
Callum Law
3aff3327c4 LibWeb: Invalidate layout on opacity change to/from zero
As of 7dc8062 paintables compute and cache their visibility (which
depends on opacity) at construction - this cached value can fall out of
sync with reality if if the opacity changes to/from zero within the
lifetime of that paintable.

This commit invalidates layout when an opacity changes to/from zero so
that we reconstruct paintables with the correct visibility.
2025-08-18 10:21:44 +01:00
Sam Atkins
089f70a918 LibWeb/CSS: Reify StyleValues in StylePropertyMap get()/getAll()
The limitations right now are:
- We don't know if a property is a list or not.
- We always reify as a CSSStyleValue directly.

So, we pass some tests but only ones that expect a CSSStyleValue.
2025-08-18 10:12:53 +01:00
Sam Atkins
25c4c2397e LibWeb/CSS: Add StyleValue getter to CSSStyleDeclarations
Will be used by StylePropertyMap, as that wants a StyleValue to reify,
not a string representation.
2025-08-18 10:12:53 +01:00
Sam Atkins
276540fbe9 LibWeb/CSS: Add ability to reify a StyleValue
When no better reification form is available, we produce an opaque
CSSStyleValue with a serialized value. For starters, this will be the
only way to reify, and then we'll add others later.
2025-08-18 10:12:53 +01:00
Sam Atkins
b80930ae34 LibWeb/CSS: Connect up StylePropertyMaps to their source
After looking into this more, the `[[declarations]]` slot does not seem
to need to be a literal map of property names and values. Instead, it
can just point at the source (an element or style declaration), and
then direct all read or write operations to that.

This means the `has()` and `delete()` methods actually work now.

A few remaining failures in these tests are because of:
- StylePropertyMap[ReadOnly]s not being iterable yet
- We're not populating an element's custom properties map, which get
  fixed whenever someone gets around to producing proper computed
  values of them.
2025-08-18 10:12:53 +01:00
Sam Atkins
37ea9a4ce3 LibWeb/CSS: Add has_property() to CSSStyleDeclaration
This isn't part of the CSSOM API directly, but will be used by
StylePropertyMapReadOnly.has() to avoid doing the work to serialize a
string version of the property's value, just to throw it away again.
2025-08-18 10:12:53 +01:00
Jelle Raaijmakers
fcd39b67af Tests: Set SIGTERM as the timeout signal handler for ctest
Some checks are pending
CI / macOS, arm64, Sanitizer, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer, Clang (push) Waiting to run
Package the js repl as a binary artifact / Linux, arm64 (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / Linux, x86_64 (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
We occasionally (frequently) time out in CI. If ctest triggers this
timeout, it sends a SIGSTOP followed by a SIGKILL. Since we want to
gracefully exit the test runner, ask ctest to send a SIGTERM instead.

This should cause active test status reports to show up in CI.
2025-08-17 20:51:56 -04:00
Jelle Raaijmakers
bee0ba2bb4 Tests: Report status on SIGINT and SIGTERM in LibWeb test runner
If you interrupt the test runner (Ctrl+C, SIGINT) or if the test runner
is gracefully being terminated (SIGTERM), it now reports the current
status of all the spawned views with their URL and, if an active test is
still being run, the time since the start of the test.

Hopefully this will help gain insight into which tests are hanging.
2025-08-17 20:51:56 -04:00
Jelle Raaijmakers
63119355e3 LibIPC: Do not try to send a response back if transport was closed
The local handling of some messages might cause the transport to get
closed. If that's the case, we shouldn't try to send back a response.

This fixes many of the "Trying to post_message during IPC shutdown"
errors I was seeing when terminating Ladybird or when abnormally exiting
from LibWeb tests.
2025-08-17 20:51:56 -04:00