Commit graph

71177 commits

Author SHA1 Message Date
Jelle Raaijmakers
1a52fcd6ad LibWeb: Draw selected text with its own color
Other browsers such as Chrome and Firefox retain the text's color when
the text is part of a selection, so let's mimic them.
2025-08-20 14:30:16 +02:00
Jelle Raaijmakers
9887b52663 LibWeb: Convert fragment's enclosing device rect to IntRect just once
No functional changes.
2025-08-20 14:30:16 +02:00
Jelle Raaijmakers
51ce46859e LibWeb: Make DOM::Position's node mandatory
We can only construct positions if there's a node involved, which was
already enforced by Position::create() only accepting a GC::Ref.
2025-08-20 12:25:00 +01:00
Jelle Raaijmakers
cd08b3b6f4 LibWeb: Reset cursor blink cycle, even if there's no viewport paintable
If we programmatically set a selection in an editable element during
document load, we failed to start the cursor blink cycle timer. The
cursor blink logic already takes care of us not having the paintable
yet, so start it unconditionally.
2025-08-20 12:36:01 +02:00
Jamie Mansfield
97746fb574 LibGfx: Fix colour with Photoshop JPEG files using CMYK
This is based on the original functionality Lucus wrote prior to using
libjpeg.

Co-authored-by: Lucas CHOLLET <lucas.chollet@free.fr>
2025-08-20 12:04:39 +02:00
Jelle Raaijmakers
738eb68dda LibWeb: Always focus on editing host if currently not focused
We were constraining the focusing behavior for editing hosts a bit too
much; regardless of how the selection changed, if the start container is
inside an editing host and it's currently not focused, we should focus
it. This fixes focus stealing by other elements that set a selection
inside an editing host on a click event, for example.
2025-08-20 11:36:40 +02:00
Jelle Raaijmakers
3a741b0ce6 LibWeb: Indicate focus on contenteditable elements
This mirrors what Chrome and Firefox do.
2025-08-20 11:36:27 +02:00
Andreas Kling
05d6090fcc Revert "LibWeb: Invalidate layout on opacity change to/from zero"
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 partially reverts commit 3aff3327c4
by removing the code change but keeping the added test.

Now that paintables visibility caching has been reverted, this is no
longer doing anything except causing excessive relayouts on pages
like https://linear.app/
2025-08-20 09:14:58 +02:00
Andreas Kling
f4ee341a14 Revert "LibWeb: Store visibility for Paintables"
This reverts commit 7dc8062283.

This did not propagate correctly to paintables whose style was inherited
from an ancestor, causing rendering artifacts on https://linear.app/
2025-08-20 09:14:58 +02:00
Andreas Kling
657f1c37a8 LibWeb: Mark CSS filter property as affecting stacking context tree 2025-08-20 09:14:58 +02:00
Andreas Kling
0baf068bbf LibWeb: Remove redundant dynamic_cast in ~AnimationUpdateContext() 2025-08-20 09:14:58 +02:00
Andreas Kling
775d15c115 LibWeb: Avoid unnecessary style invalidation in Document::set_url()
If we set the same URL that we already had, there's no need to
invalidate style for the base URL changing.

This avoids some style recomputation while loading pages.
2025-08-20 09:14:58 +02:00
Andreas Kling
ec2b568919 LibWeb: Add missing StyleInvalidationReason for HTMLDialogElement
We were accidentally using NodeRemove instead of a unique reason.
2025-08-20 09:14:58 +02:00
Tim Ledbetter
83b1ead1e7 LibWeb: Ensure UIEventInit.view is set for mouse and pointer events 2025-08-20 09:13:32 +02:00
Rocco Corsi
a60debe7bb LibWeb: Don't always stop drawing scrollbar on mouseleave
Some checks failed
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
Build Dev Container Image / build (push) Has been cancelled
PaintableBox::handle_mouseleave is turning off scrollbar updating, but
the user might still have the primary button down to scroll. Don't turn
it off if grabbing the thumb to scroll.

Resolves crashing on MacOSX AppKit and Qt where gutter_size is 0 when
mouse is moved outside window.
2025-08-19 20:12:01 -04:00
Tete17
658477620a LibWeb/LibURL/LibIPC: Extend createObjectURL to also accept MediaSources
This required some changes in LibURL & LibIPC since it has its own
definition of an BlobURLEntry. For now, we don't have a concrete usage
of MediaSource in LibURL so it is defined as an empty struct.

This removes one FIXME in an idl file.
2025-08-19 23:50:38 +02:00
Tete17
f60529dac5 LibWeb: Modify createObjectURL to return Utf16Strings 2025-08-19 23:50:38 +02:00
Luke Wilde
a04f2d0796 Meta: Remove curl overlay port
The http3 feature is now upstream, so we no longer need an overlay port
to use it.
2025-08-19 22:08:55 +02:00
Luke Wilde
43c1b1b434 Meta: Bump vcpkg baseline 2025-08-19 22:08:55 +02:00
Jelle Raaijmakers
0cf6bd0324 LibWeb: Maintain rect positioning when rounding to device pixel rects
When rounding a CSSPixelRect to a DevicePixelRect, we simply pulled its
width and height through round() and called it a day. Unfortunately this
could negatively affect the rect's perceived positioning.

A rect at { 0.5, 0.0 } with size { 19.5 x 20.0 } should have its right
edge at position 20, but after rounding it would end up at { 1, 0 } with
size { 20 x 20 }, causing its right edge to be at position 21 instead.

Fix this by first rounding the right and bottom edges of the input rect,
and then determining the dimensions by subtracting its rounded position.

Fixes #245.
2025-08-19 21:53:46 +02:00
Jelle Raaijmakers
64acef30ec LibWeb: Simplify filling rects with rounded corners
We can use BorderRadiiData::as_corners() to avoid converting the corners
one by one. Instead of passing all four corners one by one, use a
reference to CornerRadii.

No functional changes.
2025-08-19 21:53:46 +02:00
Jelle Raaijmakers
e421b34e14 LibWeb: Do not unnecessarily construct Colors in PaintableBox::paint()
No functional changes.
2025-08-19 21:53:46 +02:00
Jelle Raaijmakers
a83815360c LibWeb: Use unchecked appends and simplify code in GFC track handling
No functional changes.
2025-08-19 21:53:46 +02:00
Aliaksandr Kalenik
d04e3c9bce LibWeb/WebGL: Use auto when possible in OpenGLContext.cpp 2025-08-19 20:45:18 +02:00
Aliaksandr Kalenik
2df0b6024f LibGfx: Use array_size() when possible in VulkanContext.cpp 2025-08-19 20:45:18 +02:00
Aliaksandr Kalenik
3ec37978e6 LibGfx: Use reinterpret_cast instead of C style in create_vulkan_context 2025-08-19 20:45:18 +02:00
Sam Atkins
437062819b Documentation: Note libdrm-devel requirement on Fedora
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
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Build Dev Container Image / build (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
Push notes / build (push) Waiting to run
2025-08-19 12:49:51 +02:00
rmg-x
3721d4608b Devcontainer: Add libdrm-dev to list of Ubuntu packages 2025-08-19 11:43:51 +01:00
rmg-x
82dd8d4dd5 Documentation: Add libdrm-dev to Ubuntu/Debian build instructions 2025-08-19 11:43:51 +01:00
Jelle Raaijmakers
bc7658d3d3 LibCore: Don't send SIGTRAP when debugger attaches
Both gdb and lldb interrupt execution after attaching to the process, so
no need to send a SIGTRAP immediately after which would require typing
`continue` in the debugger twice.
2025-08-19 06:24:57 -04:00
Timothy Flynn
1869399fd1 AK: Specialize Optional for Utf16String and Utf16FlyString
We added this for String some time ago, so let's give Utf16String the
same optimization. Note that Utf16String was already handling its data
member potentially being null as of 5af99f4dd0.
2025-08-19 06:24:09 -04:00
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