Commit Graph

77190 Commits

Author SHA1 Message Date
Tim Ledbetter
8d4f8a2d7f LibWeb: Route lch()/oklch() through unified ColorFunctionStyleValue 2026-04-22 11:52:56 +01:00
Tim Ledbetter
43ba21a45b LibWeb: Route lab()/oklab() through unified ColorFunctionStyleValue 2026-04-22 11:52:56 +01:00
Tim Ledbetter
e358cf1f0d LibWeb: Route hwb() through unified ColorFunctionStyleValue 2026-04-22 11:52:56 +01:00
Tim Ledbetter
ebe12a8766 LibWeb: Route hsl()/hsla() through unified ColorFunctionStyleValue 2026-04-22 11:52:56 +01:00
Tim Ledbetter
9ea880dcf0 LibWeb: Route rgb()/rgba() through unified ColorFunctionStyleValue 2026-04-22 11:52:56 +01:00
Tim Ledbetter
53a0991ff5 LibWeb: Remove LightDark and ColorMix from the ColorType enum 2026-04-22 11:52:56 +01:00
Tim Ledbetter
e4c29811be LibWeb: Generalize ColorFunctionStyleValue to cover every color space
Introduce a descriptor table keyed by `ColorType` that encodes
per-space metadata: channel kind, percent reference value, clamp
bounds, function name and serialization behavior.

This descriptor table is then used so that a single class can back
every CSS color type. Resolution, serialization, and absolutization
are driven by the descriptor.
2026-04-22 11:52:56 +01:00
Tim Ledbetter
06ee7bc532 LibWeb: Skip unstyled descendants in animation updates
Animation updates propagate inherited animated values by walking the
animated target's subtree and calling `recompute_inherited_style()` on
each element. Elements inserted during the same rendering update may
not have computed properties yet, which violates an existing assertion,
causing a crash.

Fix this by skipping unstyled descendants during this walk. The
subsequent recursive style update computes their style from scratch.
2026-04-22 10:14:47 +02:00
Timothy Flynn
f426f021ef Meta: Don't use enum.StrEnum for GUI framework
This was added in Python 3.11, whereas the default macOS version is
still 3.9.
2026-04-21 18:48:42 -06:00
Zaggy1024
296216714a LibWeb: Handle object-fit in VideoPaintable 2026-04-21 19:11:24 -05:00
Zaggy1024
51aae8b3b0 LibGfx: Allow creation of ImmutableBitmaps from const Bitmaps 2026-04-21 19:11:24 -05:00
Zaggy1024
a2bd655b1a LibWeb: Use CSSPixelFraction to calculate painted image sizes
The round trip to float here isn't necessary.
2026-04-21 19:11:24 -05:00
Zaggy1024
b20312efd4 LibWeb: Factor out replaced element sizing to its own file 2026-04-21 19:11:24 -05:00
Zaggy1024
04cc5bced9 LibWeb: Update video elements' natural dimensions during playback
This tightens the implementation of video element sizing to the spec by
implementing two spec concepts:
- The media resource's natural width and height, and
- The video element's natural width and height.
The element's natural dimensions change based on the representation,
which has many inputs, so update checks are triggered from many
locations.

The resize event is fired when the media resource's natural dimensions
change, and the layout is invalidated if the element's natural
dimensions change.

Tests for a few important resize triggers have been added.
2026-04-21 19:11:24 -05:00
Zaggy1024
938c254d6f LibWeb: Remove VideoTrack's list reference when it is removed from it 2026-04-21 19:11:24 -05:00
Zaggy1024
2420e87be9 LibWeb: Simplify video element's first poster representation condition
The HAVE_METADATA check was redundant.
2026-04-21 19:11:24 -05:00
Zaggy1024
f3d3c1f421 LibWeb: Don't clear video posters before the fetch and decode complete
Also, make all the callbacks capture the element weakly. No reason to
keep it alive here.
2026-04-21 19:11:24 -05:00
Zaggy1024
c198df4967 Tests: Add a simple video element screenshot test 2026-04-21 19:11:24 -05:00
Zaggy1024
08faa83340 LibMedia+LibWeb: Add an initial Starting state to PlaybackManager
This state will indicate to the media element that it's not guaranteed
to have a frame yet, for the purposes of determining the ready state.
JavaScript should be sure that video elements with a ready state of
HAVE_CURRENT_DATA or greater represent the current video frame already.

To allow the state to be exited if audio is disabled, audio tracks are
now only added to the buffering set on enable if the audio sink exists,
since without the sink starting the data provider, it will never be
removed.

This is a step towards making video ref tests.
2026-04-21 19:11:24 -05:00
Zaggy1024
e1e752cc28 LibMedia+LibWeb: Indicate playback states' available data with an enum
This allows us to differentiate between having no data available yet,
having current data, and having future data. The main purpose of this
is to allow a new starting state to explicitly force HAVE_METADATA
instead of >= HAVE_CURRENT_DATA.

Note that the SeekingStateHandler returns Current instead of None. This
is deliberate, since the buffered ranges from the demuxer(s) can be
used to inform whether the possibly-current data is actually available
at the seek target.
2026-04-21 19:11:24 -05:00
Zaggy1024
bedcccbdb9 LibMedia: Simplify starting/stopping buffering
The check for the previous state isn't really necessary, states that
don't care about buffering can just make this a no-op.
2026-04-21 19:11:24 -05:00
Zaggy1024
9494f4e8c5 LibWeb: Relayout video elements when setting the initial size
A while ago, we removed the relayout upon rendering a new frame. In
doing so, it became possible for the layout to remain stale after the
video metadata had loaded, leaving the video drawn in a 0x0 box.
2026-04-21 19:11:24 -05:00
Zaggy1024
29d9667511 LibWeb: Always close remote media resource streams on a request error
Otherwise, the PlaybackManager may get stuck waiting for enough data to
read the metadata and call on_metadata_parsed.

This is unfortunately difficult to test without direct control over the
fetching process, but it could cause flakes in tests that wait for
loadeddata.
2026-04-21 19:11:24 -05:00
Zaggy1024
973d3da0e7 LibWeb: Correct the MediaCapture bindings include paths
Regressed in baefb519
2026-04-22 00:41:29 +02:00
Tim Ledbetter
e5d615cb11 LibWeb: Implement autofocus candidate processing
This change implements the algorithms necessary to focus elements with
the autofocus attribute on page load.
2026-04-21 23:47:05 +02:00
Jonathan Gamble
baefb51902 LibWeb: Add Media Capture and Stream APIs 2026-04-21 16:40:46 -05:00
Jonathan Gamble
d388502a3a LibWeb: Add placeholders for mic/camera perms 2026-04-21 16:40:46 -05:00
Jonathan Gamble
736ee40db0 test-web: Dont leak captured fds when a helper process dies 2026-04-21 20:01:41 +02:00
InvalidUsernameException
06a7723ee3 LibWeb: Convert early return into assertions
When we are recomputing inherited styles, we should already have
computed style for that element at least once, so cascaded and computed
properties should exist at that point. So make the invariant explicit.
2026-04-21 18:39:00 +02:00
InvalidUsernameException
67e3b2d446 LibWeb: Recompute inherited style even if there is no layout node
`recompute_inherited_style()` assumed that there is no work to do if the
element has no layout node. This however is not necessarily true.

In particular, the following can happen:
1. The element in question is a descendant at least two layers below an
   element that has `display: none`, i.e. with at least one other
   element between them. (If it is a direct child, a full style
   recomputation will be forced for unrelated reasons).
2. TreeBuilder decides to skip creating layout nodes for the `display:
   none` element and all its descendants.
3. Due to some change on the ancestor (e.g. class added, id changed),
   the value of a property that can be inherited changes on the
   ancestor.
4. The property value of the descendant now also needs to change.

In that scenario, we won't compute the entire style of the descendant,
since that already happened. But we do need to update its inherited
properties because the old ones are now stale. At that point we still
don't have a layout node for the element since it will only be created
after this style update.

Instead of skipping the update for inherited properties, simply allow
`recompute_inherited_style()` to run even in absence of a layout node.
And then apply the style to the layout node only if one exists. If none
exists, the style will be applied later if and when a corresponding
layout node is created.

This partially fixes the blank main navigation menus on
https://bleepingcomputer.com.
2026-04-21 18:39:00 +02:00
InvalidUsernameException
059a5a245a Tests/LibWeb: Add regression test for stale inherited style
The tested behavior will be fixed by the next commit.
2026-04-21 18:39:00 +02:00
Tim Ledbetter
df34c626d8 AK: Avoid UAF for consecutive SinglyLinkedList removals
The iterator returned by SinglyLinkedList::remove() left `m_prev`
default-initialized to `nullptr`. If the caller removed another element
without first advancing, the previous node's next pointer was left
dangling to the freed node.

This caused a UAF in FinalizationRegistry's `remove_by_token()` when
two consecutive records shared an unregister token.
2026-04-21 18:09:29 +02:00
Johan Dahlin
75ae9abe7a LibGfx: Re-enable tech(variations) font support 2026-04-21 16:40:43 +02:00
Aliaksandr Kalenik
7685a5e14a LibRegex: Inline \w and \d ranges in legacy positive char classes
Previously, a character class containing any builtin (\d, \w, \s)
forced the compiler down the slow "complex class" path, which emits
a disjunction of alternatives and backtracks at runtime.

For non-unicode, non-unicode-sets, non-negated classes, \w and \d
can be inlined as their raw ASCII code-point ranges. The resulting
class stays on the fast path and compiles into a single sorted
CharClass instruction.

The unicode/unicode_sets and negation guards are required for
correctness: with the /u + /i flags, \w gains non-ASCII members
via case folding (e.g. U+017F, U+212A), and negated classes have
a separate, smarter compilation path.
2026-04-21 16:36:38 +02:00
Aliaksandr Kalenik
8c4870f207 RequestServer: Disable curl socket notifiers when no longer needed
When curl invokes the socket callback to tell us it only wants one
polling direction (e.g. CURL_POLL_IN without CURL_POLL_OUT, or vice
versa), we previously had no way to disable the other direction's
notifier. Once created, a notifier stayed enabled and kept firing
curl_multi_socket_action() for events curl was no longer interested in.

Merge the read and write branches into a single helper that also
disables the notifier for a direction when its CURL_POLL_* flag is
absent from the mask. This measurably improves performance by avoiding
redundant curl_multi_socket_action() calls on sockets curl has asked
us to stop watching in a given direction.
2026-04-21 15:45:41 +02:00
Jelle Raaijmakers
6171cb7bbf LibWeb: Override HTMLFormElement::is_supported_property_name()
By implementing this method ourselves, we no longer go through
::supported_property_names() and skip both the vector allocation and
sorting, which we don't need to determine if a property name is present.
2026-04-21 14:02:54 +01:00
Jelle Raaijmakers
e63af74dda LibWeb: Use tree order in HTMLFormElement::supported_property_names()
Calling into ::compare_document_position() for each node comparison
inside quick_sort() is quite expensive - it calculates more than we need
and allocates. Replace it with TreeNode::is_before() which does not, and
gives us the required positional info.
2026-04-21 14:02:54 +01:00
Jelle Raaijmakers
bf414f5d8f LibWeb: Simplify result in HTMLFormElement::supported_property_names()
We were doing the exact same thing as HashTable::values(). No functional
changes.
2026-04-21 14:02:54 +01:00
Andreas Kling
51758f3022 LibJS: Make bytecode register allocator O(1)
Generator::allocate_register used to scan the free pool to find the
lowest-numbered register and then Vec::remove it, making every
allocation O(n) in the size of the pool. When loading https://x.com/
on my Linux machine, we spent ~800ms in this function alone!

This logic only existed to match the C++ register allocation ordering
while transitioning from C++ to Rust in the LibJS compiler, so now
we can simply get rid of it and make it instant. :^)

So drop the "always hand out the lowest-numbered free register" policy
and use the pool as a plain LIFO stack. Pushing and popping the back
of the Vec are both O(1), and peak register usage is unchanged since
the policy only affects which specific register gets reused, not how
aggressively.
2026-04-21 13:59:55 +02:00
Timothy Flynn
06796f5f7f LibURL+LibWeb+LibWebView: Convert about:version to a proper WebUI
Passing the browser command line and executable path to every WebContent
process just in case we load about:version always felt a bit weird. We
now use the WebUI framework to load this information on demand.
2026-04-21 06:59:11 -04:00
Andrew Kaster
5c835157c6 Documentation+Meta: Remove references to nonexistent Toolchain directory
After b1d708dd16, the Toolchain directory
was removed from the repository. Some documentation and scripts still
referenced it, so this commit removes those references. The only
remaining references are in the gitignore file, to prevent bisections
from being polluted by the presence of a Toolchain directory in the
working copy.
2026-04-21 06:56:32 -04:00
Shannon Booth
fd44da6829 LibWeb/Bindings: Emit one bindings header and cpp per IDL
Previously, the LibWeb bindings generator would output multiple per
interface files like Prototype/Constructor/Namespace/GlobalMixin
depending on the contents of that IDL file.

This complicates the build system as it means that it does not know
what files will be generated without knowledge of the contents of that
IDL file.

Instead, for each IDL file only generate a single Bindings/<IDLFile>.h
and Bindings/<IDLFile>.cpp.
2026-04-21 07:36:13 +02:00
Andrew Kaster
f7c932f50e Meta: Add option to select GUI Framework to ladybird.py 2026-04-20 18:41:42 -04:00
Andrew Kaster
c16d5ebe0e CMake: Set VCPKG_MANIFEST_FEATURES as a cache variable
This reduces vcpkg churn when it thinks that the manifest features have
changed, but they haven't due to the Gui framework staying the same.
2026-04-20 18:41:42 -04:00
Undefine
8cee6ba5a0 Meta: Remove a Qt option related from RequestServer's CMakeLists
Since those are no longer set in the top level CMake file this is no
longer necessary.
2026-04-20 16:41:29 -06:00
Undefine
61c6b9230a Meta: Add the check-style target unconditionally
Python3 is guaranteed to be available as we require it to run some
generators.
2026-04-20 16:41:29 -06:00
Undefine
e39a8719fd Meta: Move most dependency checks to check_for_dependencies.cmake
This file was here for quite a long while now. Let's finally move most
of the dependency checks to one centralized place.
2026-04-20 16:41:29 -06:00
Undefine
8721dbe094 Meta: Remove unused git-patch.cmake
It remains used ever since the Swift stuff got removed.
2026-04-20 16:41:29 -06:00
Undefine
942786d263 Meta+LibWeb: Pull a vcpkg Angle port change to remove an include hack
The issue mentioned there was resolved on the vcpkg side and only
required pulling in this one change.
2026-04-20 16:41:29 -06:00
Undefine
2536690aa6 Meta: Remove a global link to Threads::Threads
Globally linking to anything isn't a good thing to do and this doesn't
seem to be necessary. If it ends up breaking any platform it can be
readded as a specific link later.
2026-04-20 16:41:29 -06:00