Commit graph

75160 commits

Author SHA1 Message Date
Andreas Kling
9418fb0f8e Tests: Exclude JS AST and bytecode tests from prettier checks 2026-02-19 02:45:37 +01:00
Zaggy1024
ad92622cf4 LibWeb: Make HTMLMediaElement's FetchController reference weak
This allows the FetchController to be reclaimed when the fetch
completes.
2026-02-18 13:13:32 -06:00
Zaggy1024
7c0802bd4f LibWeb: Make FetchController's Requests::Request reference weak
This allows the Request to be cleaned up when it becomes inactive,
which in turn allows the GC to clean up the FetchController which is
indirectly captured by a root in the Request callbacks.
2026-02-18 13:13:32 -06:00
Zaggy1024
282c054ddc AK: Make SourceLocation's copy assignment operator take const 2026-02-18 13:13:32 -06:00
Zaggy1024
af2ac67be3 LibMedia: Don't lock the main loop while initializing a media source
We only need to take a strong reference to the main event loop when
an error occurred in order to invoke the callback on the main thread.
By taking this lock for the entire duration of the thread, we were
preventing the main thread from exiting if the init thread hangs.
2026-02-18 13:13:32 -06:00
Zaggy1024
7dd0c70ee5 LibMedia: Avoid a ref count of the stream when adding a media source 2026-02-18 13:13:32 -06:00
Zaggy1024
b25562ead7 LibWeb: Break a reference loop on HTMLMediaElement::FetchData
The stream's data request callback can't hold a strong reference to
FetchData, as that will create a reference loop:

FetchData -> IncrementallyPopulatedStream -> (lambda) -> FetchData

To prevent a use-after-free on the FetchData& capture, we clear the
data request callback in ~FetchData().
2026-02-18 13:13:32 -06:00
Zaggy1024
a283489799 LibWeb: Close the media element's stream when it is destroyed
This prevents the PlaybackManager's init thread from hanging waiting
for data that will never come after the media element gets GCed.
2026-02-18 13:13:32 -06:00
Zaggy1024
b223b3edf0 LibMedia: Allow clearing incremental streams' data request callbacks 2026-02-18 13:13:32 -06:00
Zaggy1024
af45418fbf Everywhere: Rename IncrementallyPopulatedStream::reached_end_of_body
This needs to be called even if we haven't reached the end of the body,
so let's call it close() instead.
2026-02-18 13:13:32 -06:00
Zaggy1024
15d0bc86fc LibWeb: Pass HTMLMediaElement::FetchData& to restart_fetch_at_offset
No behavior change.
2026-02-18 13:13:32 -06:00
Zaggy1024
d146adfd66 LibWeb: Don't keep HTMLMediaElement alive in its fetch callbacks
This isn't strictly necessary to allow the element to be collected, but
it doesn't make sense for a fetch to keep the media element alive.
2026-02-18 13:13:32 -06:00
Zaggy1024
a3619cd995 LibGC: Take GC::Function's AK::Function as rvalue reference
This saves us some copies that may result in useless ref counts when
constructing a GC::Function.
2026-02-18 13:13:32 -06:00
Zaggy1024
d5bf929699 AK+Tests: Destroy moved-from CallableWrappers
We won't attempt to destroy this wrapper later because m_kind gets set
to NullPointer. If any fields of the CallableType are not movable, this
results in a leak.

A test replicating the issue before the fix is added to a new
TestFunction.cpp file.
2026-02-18 13:13:32 -06:00
Zaggy1024
a0052316e5 Tests: Rename TestFunction -> TestFunctionObjC 2026-02-18 13:13:32 -06:00
Zaggy1024
e31fe7804c AK: Call deref_base() on the pointer type
This makes it easier to print logs when unrefing a RefCounted type
without rebuilding the world.
2026-02-18 13:13:32 -06:00
Shannon Booth
2e3c59f791 LibHTTP: Simplify serializing a URL for cache storage
The serialization function already has a flag to skip the fragment
or not.
2026-02-18 12:52:19 -05:00
Timothy Flynn
fe4c22e4e2 CI: Run test262 on blacksmith runners and on PRs
On GitHub runners (which are much slower than blacksmith runners),
test262 only takes ~6 minutes nowadays. So let's try running it on
blacksmith. It's generally been a headache to make changes to the
test262 workflow on our dedicated runner, so this will alleviate
that.
2026-02-18 12:22:04 -05:00
Timothy Flynn
5a916940e2 Revert "CI: Ensure lsb-release is installed on Ubuntu"
This reverts commit c813505450.

This did not work on the dedicated test262 runner. And we are looking
into switching to blacksmith runners instead.
2026-02-18 12:22:04 -05:00
Timothy Flynn
85c6264323 CI: Remove download_cache_path argument from cache restore action
It used to be for CLDR, UCD, etc. downloads. But it is now unused.
2026-02-18 12:22:04 -05:00
Timothy Flynn
53bcbe411f CI: Use the setup action on the test262 runner 2026-02-18 10:10:07 -05:00
Timothy Flynn
81d5ad9777 CI: Use setup-python@v6 in the setup action 2026-02-18 10:10:07 -05:00
Timothy Flynn
a2515c0705 CI: Ensure pip itself is up to date
Our test262 runner already does this, and we do see out-of-date messages
in users of the setup action.
2026-02-18 10:10:07 -05:00
Timothy Flynn
c813505450 CI: Ensure lsb-release is installed on Ubuntu
Our test262 runner does not have it.
2026-02-18 10:10:07 -05:00
Timothy Flynn
5f350784a6 Meta: Add a default value to pick_host_compiler's clang_only arg 2026-02-18 14:27:28 +01:00
Timothy Flynn
ea32502947 Everywhere: Run clang-format
The following command was used to clang-format these files:

    clang-format-21 -i $(find . \
        -not \( -path "./\.*" -prune \) \
        -not \( -path "./Build/*" -prune \) \
        -not \( -path "./Toolchain/*" -prune \) \
        -type f -name "*.cpp" -o -name "*.mm" -o -name "*.h")
2026-02-18 08:02:45 -05:00
Timothy Flynn
415625d398 Meta: Switch to clang-format-21 as the standard formatter 2026-02-18 08:02:45 -05:00
Timothy Flynn
372c7b9822 CI: Update the Clang pipeline to Clang 21 2026-02-18 08:02:45 -05:00
Timothy Flynn
f200920a6c CI: Simplify upgrading toolchain versions in CI
Set the gcc and llvm versions as variables, and use them anywhere we
install a specific version. We then export these as outputs so that any
interested caller can retrieve the installed versions.

Our check for llvm.list also will have prevented us from upgrading llvm
versions. We now check that it contains the exact version we expect.
2026-02-18 08:02:45 -05:00
Timothy Flynn
b9c6263408 Meta: Use find_compiler.py when building fuzzers
One less location we need to update when updating clang.
2026-02-18 08:02:45 -05:00
Timothy Flynn
4facec1b40 LibWeb: Mark [Managed]MediaSource[Handle] as experimental 2026-02-17 22:17:50 +01:00
Timothy Flynn
316ffb300b LibWeb: Mark OffscreenCanvas[RenderingContext2D] as experimental 2026-02-17 22:17:50 +01:00
Timothy Flynn
8ad1c72ed3 LibWeb+LibWebView+Services: Add a flag to enable experimental interfaces
This adds the --expose-experimental-interfaces command line flag to
enable experimental IDL interfaces. Any IDL interface with Experimental
in its exposed attributes will be disabled by default.

The problem is that by stubbing out or partially implementing interfaces
in LibWeb, we actually make some sites behave worse. For example, the
OffscreenCanvas interface being exposed makes sites believe we fully
support it, even though we don't. If the interface was not exposed,
these sites may fall back to ordinary canvas objects. Similarly, to
use YouTube, we currently have to patch out MSE interfaces.

This flag will allow developers to iteratively work on features,
without breaking such sites. We enable experimental interfaces during
tests.
2026-02-17 22:17:50 +01:00
Timothy Flynn
b357d3c3c8 LibWebView+WebContent: Move test-mode special handling to the UI process
We will need to propagate test mode behavior to both the WebContent and
WebWorker processes. By moving this handling to the UI process, we will
only need to update one location.
2026-02-17 22:17:50 +01:00
Andreas Kling
ce3742724a LibJS: Propagate declaration_kind for existing identifier groups
When an identifier was registered and its group already existed but
had no declaration_kind set, we failed to propagate it. This caused
var declarations to lose their annotation in AST dumps when the
identifier was referenced before its declaration.
2026-02-17 20:44:57 +01:00
Andreas Kling
47e552e8fd LibJS: Consolidate TDZ check emission into Generator helper
Move the duplicated ThrowIfTDZ emission logic from three places in
ASTCodegen.cpp into a single Generator::emit_tdz_check_if_needed()
helper. This handles both argument TDZ (which requires a Mov to
empty first) and lexically-declared variable TDZ uniformly.

This avoids emitting some unnecessary ThrowIfTDZ instructions.
2026-02-17 20:44:57 +01:00
Andreas Kling
9923745d34 LibJS: Remove unused bytecode register allocation in array destructuring 2026-02-17 20:44:57 +01:00
Andreas Kling
fdd7809bd1 Tests/LibJS: Add a big pile of AST, bytecode, and runtime tests
Created these while experimenting with LibJS. Might as well bring them
into the tree and increase our coverage.
2026-02-17 20:44:57 +01:00
Andreas Kling
06f7abe00f Tests/LibJS: Add test-js-bytecode --rebaseline 2026-02-17 20:44:57 +01:00
Aliaksandr Kalenik
36acd1cf3d LibWeb: Rebuild stacking context tree on any z-index value change
The stacking context tree rebuild had an optimization that skipped
rebuilding when a property changed between two values that both create
stacking contexts. This is correct for most properties (e.g. opacity
0.5 -> 0.8 doesn't change tree structure), but incorrect for z-index.

During tree construction, elements with z-index 0/auto are placed in
m_positioned_descendants_and_stacking_contexts_with_stack_level_0,
while elements with other z-index values are painted from m_children
(negative at step 3, positive at step 9 per CSS 2.1 Appendix E).
When z-index changed between non-auto values (e.g. 0 -> 10), the
optimization skipped the rebuild, leaving the element in the wrong
list and causing it to be painted from both step 8 and step 9.

This was visible on pages like shopify.com where elements with
transition-all would transition z-index, producing a flood of
"Painting commands are recorded twice for stacking context" messages.
2026-02-17 20:44:46 +01:00
Aliaksandr Kalenik
94d7c76226 LibWeb: Add test for z-index change causing double paint in display list
When z-index changes from 0 to a positive value on a positioned element,
the stacking context tree is not rebuilt, causing the element to be
painted twice. This test captures the current (incorrect) behavior.
2026-02-17 20:44:46 +01:00
Jelle Raaijmakers
288c544827 LibJS: Don't duplicate var-scoped declarations per bound identifier
ScopeCollector::add_declaration() was adding var declarations to the
top-level scope's m_var_declarations once per bound identifier and once
more after the for_each_bound_identifier loop - so a `var a, b, c`
would be added 4 times instead of 1.

The Script constructor iterates m_var_declarations and expands each
entry's bound identifiers, resulting in O(N²) work for a single var
statement with N declarators.

Running the Emscripten-compiled version of ScummVM with a 32,174-
declarator var statement, this produced over 1 billion entries,
consuming 14+ GB of RAM and blocking the event loop for 35+ seconds.
After this fix, this drops down to 200 MB and just short of 200ms.
2026-02-17 20:19:08 +01:00
Jelle Raaijmakers
f2e6f70fbb LibWeb: Use saveLayer compositing for background-clip: text
Instead of rendering text glyphs into a separate mask surface and using
clipShader, paint the backgrounds first and then composite the text
glyphs via saveLayer with SkBlendMode::kDstIn. Skia's saveLayer
automatically sizes its backing at device resolution including CSS
transforms, so no manual scale computation is needed.

Fixes pixelation when zooming in on clipped backgrounds on e.g. the
title of https://modern-css.com/.
2026-02-17 18:59:33 +01:00
Timothy Flynn
7c9b3c08fa LibWeb: Allow selecting text in dialog and label elements
We were previously not allowing the user to select text when the clicked
position represented a click-focusable area. This included text within
dialogs (as the dialog element is click-focusable) and labels (as the
associated input element would be considered click-focusable).

We now no longer consider associated input elements when clicking on a
label. This is handled separately already by the label's activation
behavior steps, so there is no loss of functionality here. In those
steps, though, we now no longer propagate the click event to the input
element if a selection was made during the click. This matches the
behavior of Firefox and Chrome.

With label elements no longer considered here, we can then enter the
character selection mode when click-focusable areas are clicked.
2026-02-17 18:36:54 +01:00
Timothy Flynn
a055e36715 LibWeb: Modernize spec comment and coding style in EventHandler.cpp
* Prefer NB over NOTE for our own comments.
* Wrap comments at ~120 characters.
* Resolve some trivial clangd warnings.
2026-02-17 18:36:54 +01:00
Andreas Kling
e87f889e31 Everywhere: Abandon Swift adoption
After making no progress on this for a very long time, let's acknowledge
it's not going anywhere and remove it from the codebase.
2026-02-17 10:48:09 -05:00
Aliaksandr Kalenik
b3231ea2a0 LibWeb: Make foreignObject establish a containing block for abspos
Absolutely positioned elements inside SVG foreignObject were being
positioned relative to an ancestor containing block outside the SVG,
instead of relative to the foreignObject itself. Per a W3C resolution
and the behavior of other browsers, foreignObject should establish a
containing block for absolutely and fixed positioned elements.

With this fix, the `has_abspos_with_external_containing_block` check
in `set_needs_layout_update()` and the abspos preservation loop in
`relayout_svg_root()` become dead code — remove both and simplify the
ancestor loops. Rename related tests to reflect the new behavior.

Fixes https://github.com/LadybirdBrowser/ladybird/issues/3241
2026-02-17 15:59:59 +01:00
Timothy Flynn
fa49de8956 LibWeb: Do not mark CSSFontFeatureValuesMap::map_entries as virtual
This is a final class, and thus this cannot be overridden. Caught by
clang 21.
2026-02-17 15:18:46 +01:00
Timothy Flynn
2387f633ec LibWeb: Initialize plain member in CSSFontFeatureValuesMap
We should always be in the habit of initializing plain types. Let's not
open ourselves up to UB.
2026-02-17 15:18:46 +01:00
Sam Atkins
c5f117f1a2 LibWeb/Fetch: Store Body Blob as Ref not Root
To avoid some churn, Body::source() returns the SourceTypeInternal
object, as it's not exposed to JS. The constructor is also adjusted so
that Body::clone() doesn't have to convert to a SourceType and then
immediately back again.
2026-02-17 07:40:03 -05:00