Commit graph

70518 commits

Author SHA1 Message Date
Aliaksandr Kalenik
9bb5e70f5a LibWeb: Skip tree traversal if invalidation set doesn't have properties
This allows us to skip unnecessary tree traversal to mark style for
recalculation when invalidation set only has `InvalidateSelf`.
2025-07-14 09:32:05 +02:00
Tim Ledbetter
80ccb12a12 LibWeb: Don't crash when appending to an XML document template element
When the XML parser appends child nodes to a template element, it must
actually append the template element's contents. This special behavior
caused us to return to the wrong parent element after adding child
nodes to a template element, leading to a crash.
2025-07-14 09:15:41 +02:00
Callum Law
7cc718f1c1 LibWeb: Avoid vector creation getting {short,long}hands for CSS property
The `shorthands_for_longhand`, `longhands_for_shorthand`, and
`expanded_longhands_for_shorthand` methods can be pretty hot in
profiles where we serialize a lot of CSS properties.

By returning a const reference to a static vector instead of allocating
and returning a new vector every time we can avoid a decent amount of
work.

Overall runtime for the particularly serialization heavy
wpt.live/css/cssom/cssom-getPropertyValue-common-checks.html
decreased by ~20% comparing before and after this change.
2025-07-14 09:08:55 +02:00
Luke Wilde
a3cacbfaaa Meta/curl: Add upstream patch for issue 17917
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
See: https://github.com/curl/curl/issues/17917

This allows us to connect to https://developer.mozilla.org/ with
HTTP/3 enabled.

Thanks to Tim Ledbetter (https://github.com/tcl3) for finding that we
couldn't connect!
2025-07-13 20:54:45 +02:00
Aliaksandr Kalenik
f65db4507a UI+WebContent: Add menu option to dump display list 2025-07-13 19:15:05 +02:00
Aliaksandr Kalenik
8ae7417445 LibWeb: Add internals call to dump display list
It's useful to have tests that dump display list items, so we can more
easily see how changes to the display list recording process affect the
output. Even the small sample test added in this commit shows that we
currently record an unnecessary AddClipRect item for empty paint phases.

For now, the dump doesn't include every single property of an item, but
we can shape it to include more useful information as we iterate on it.
2025-07-13 19:15:05 +02:00
Aliaksandr Kalenik
6be559f639 AK: Define ConstIterator for SegmentedVector 2025-07-13 19:15:05 +02:00
Tim Ledbetter
941da11ece LibWeb: Avoid accessing opaque origin port during CSP checks 2025-07-13 14:33:33 +02:00
Tim Ledbetter
cd0cadc5e1 LibWasm: Use correct null check when getting iterator method
Some checks are pending
CI / Linux, x86_64, Fuzzers, Clang (push) Waiting to run
CI / macOS, arm64, Sanitizer, 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-07-13 11:28:19 +02:00
Tim Ledbetter
5478361ba0 LibWeb: Avoid division by zero with small aspect ratios
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-07-13 05:41:48 +02:00
Tim Ledbetter
cd0074528e LibWeb: Verify type before casting PaintableBox to PaintableWithLines
Previously, calling `BlockContainer::paintable_with_lines()` would cast
a `PaintableBox` to a `PaintableWithLines` without verifying that the
cast was valid, which isn't the cast for `FieldsetPaintable`, for
example. This method now returns null if it isn't poossible to cast to
`PaintableWithLines`.
2025-07-13 03:01:59 +02:00
Aliaksandr Kalenik
4f9aca4302 LibWeb: Skip backing store allocation for traversables created for SVG
Recently, we moved the backing store manager into Navigable, which means
we now try to allocate a backing store for all navigables, including
those corresponding to SVG image documents. This change disables that
behavior for all navigables except top-level non-SVG traversables,
because otherwise it causes issues when we stop repainting: the browser
process was notified about an allocated backing stores that does not
correspond to the page, and then all subsequent repaints are ignored
until the window is resized.
2025-07-13 00:06:30 +02:00
Jelle Raaijmakers
1e0013a3bc LibWeb: Use margin box height for inline-block vertical alignment
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
For `vertical-align: middle` and `vertical-align: text-bottom`, we used
just the content height of the inline box to determine its alignment
position. This caused incorrect positioning when padding is applied.

This fixes the button alignment on our GitHub page.

Fixes #290.
2025-07-12 18:03:14 +02:00
Andreas Kling
8e49b69f42 LibWeb: Never split <svg> for inline continuations
This fixes an issue where we'd make an absolute mess from nested SVG
roots with display:block. Before this fix, the inner SVG root would
trigger the inline continuation logic and try to split the tree.
2025-07-12 14:11:41 +02:00
Andreas Kling
4e23882995 LibWeb: Use foreignObject's own size as available space inside it
This ensures that percentages resolve against the foreignObject's size
instead of the size of its containing block.

This makes user profile pictures clip correctly in the "Friends" view
of the Discord app.
2025-07-12 14:11:41 +02:00
Jelle Raaijmakers
c39edfab2d Tests: Fix calculation of elapsed time in tests
We were already taking the "elapsed" part of the global timer, by
subtracting the known runtime from that we always ended up with 0
milliseconds.
2025-07-12 14:05:32 +02:00
Tim Ledbetter
4dd538e708 LibWeb/SVG: Prefer href to xlink:href attribute on images
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-07-12 13:13:47 +02:00
Tim Ledbetter
93a35895ae LibWeb/SVG: Don't crash when changing SVG image href
Previously, a segfault could occur if `m_resource_request` was replaced
before its callbacks were invoked.
2025-07-12 13:13:47 +02:00
Ali Mohammad Pur
5b45223d5f LibRegex: Account for uppercase characters in insensitive patterns 2025-07-12 11:26:23 +02:00
Tim Ledbetter
31e8189f9f LibWeb/SVG: Implement the SVGAElement.referrerPolicy attribute 2025-07-12 11:05:48 +02:00
Tim Ledbetter
d86f0a1b29 LibWeb/SVG: Implement the SVGAElement.target attribute 2025-07-12 11:05:48 +02:00
Aliaksandr Kalenik
910fd426a2 LibWeb: Allow <svg> to establish a stacking context
83b6bc4 went too far by forbidding SVGSVGElement from establishing a
stacking context. This element type does follow the behavior of CSS
boxes, unlike inner SVG elements like `<rect>`, `<circle>`, etc., which
are not supposed to be aware of concepts like stacking contexts,
overflow clipping, scroll offsets, etc.

This change allows us to delete overrides of `before_paint()` and
`after_paint()` in SVGPaintable and SVGSVGPaintable, because display
list recording code has been rearranged to take care of clipping and
scrolling before recursing into SVGSVGPaintable descendants.

`Screenshot/images/css-transform-box-ref.png` expectation is updated and
fixes a bug where a rectangle at the very bottom of the page was not
clipped correctly.
`Screenshot/images/svg-filters-lb-website-ref.png` has a more subtle
difference, but if you look closely, you’ll see it matches other
browsers more closely now.
2025-07-12 11:01:15 +02:00
Shannon Booth
79293a3cbc LibWeb/XHR: Don't construct a String from a String
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
Serializing a URL already returns a String.
2025-07-12 02:57:36 +01:00
Luke Wilde
f50f23b19f LibWeb/CSP: Implement the script-src-attr directive 2025-07-12 13:06:33 +12:00
Luke Wilde
f382bccc3d LibWeb/CSP: Implement the script-src-elem directive 2025-07-12 13:06:33 +12:00
Tim Ledbetter
caf45f2317 LibWeb: Implement the SVGGeometryElement.pathLength attribute 2025-07-12 11:49:10 +12:00
Aliaksandr Kalenik
410e82c9fd LibWeb: Rearrange code such that a lot less files include Command.h
Some checks failed
CI / Linux, x86_64, Fuzzers, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer, GNU (push) Waiting to run
CI / macOS, arm64, Sanitizer, Clang (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
With this change number of recompiled files after modification of
`Command.h` goes down from >1000 to <100.
2025-07-11 17:37:27 +02:00
Callum Law
d980321a77 LibWeb: Include own shadow root in for_each_shadow_including_descendant
Fixes a crash in wpt.live/css/cssom/CSSStyleSheet-constructable.html
2025-07-11 16:21:11 +02:00
Luke Wilde
409758f040 Meta: Enable the zstd feature for curl
This content encoding is used by Facebook.

For example:

```
> GET /rsrc.php/v5/yj/l/0,cross/VNfVTw9fSM1.css HTTP/3
Host: static.xx.fbcdn.net
Accept-Encoding: deflate, gzip, br, zstd
Alt-Used: (nil):0
User-Agent: Mozilla/5.0 (macOS; AArch64) Ladybird/1.0
Accept: text/css,*/*;q=0.1
Accept-Language: en
Sec-Fetch-Dest: style
Sec-Fetch-Mode: cors
Origin: https://www.facebook.com
Sec-Fetch-Site: cross-site
Referer: https://www.facebook.com/
```

The response (with some headers removed for brevity):
```
< HTTP/3 200
< content-encoding: zstd
< content-type: text/css; charset=utf-8
< last-modified: Mon, 01 Jan 2001 08:00:00 GMT
< expires: Fri, 10 Jul 2026 07:47:17 GMT
< cache-control: public,max-age=31536000,immutable
< content-length: 7448
< date: Fri, 11 Jul 2025 11:52:03 GMT
< access-control-allow-origin: https://www.facebook.com
* Added alt-svc: static.xx.fbcdn.net:443 over h3
< alt-svc: h3=":443"; ma=86400
< priority: u=3,i
<
```
2025-07-11 14:16:07 +02:00
Jelle Raaijmakers
0fccc75fd7 Meta: Remove bookmarks.json
This seems to be unused.
2025-07-11 14:04:23 +02:00
Jelle Raaijmakers
97fa0be16e LibWeb: Implement SVGAnimatedNumber
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-07-11 11:25:59 +01:00
Jelle Raaijmakers
ffcf91cd30 LibWeb: Correct initialization order for SVGFE*Element
We should first set the prototype before initializing our base,
otherwise e.g. attributes will simply not work.
2025-07-11 11:25:59 +01:00
Callum Law
1a0d4487a8 LibWeb: Implement matches attribute on CSSSupportsRule and CSSMediaRule
Gains us 4 WPT tests.
2025-07-11 10:57:19 +02:00
Callum Law
fc395f9824 Tests: Always load WPT interfaces from root interfaces directory
Previously we would load from "../interfaces" which wouldn't work for
nested tests.
2025-07-11 10:57:19 +02:00
ayeteadoe
ccb87b4cb4 Tests/LibGfx: Enable file based tests on Windows
These actually were always working since we first enabling LibGfx
on Windows. I was just running them outside of the ctest context
and therefore had the wrong working directory so the test-inputs folder
could not be found
2025-07-11 10:54:37 +02:00
Tim Ledbetter
88efb362c4 LibWeb: Remove UA styles for h1 in article, aside, nav and section 2025-07-11 08:24:32 +02:00
Jelle Raaijmakers
2998049fe9 LibWeb: Implement the unreachable scrollable overflow
Whenever we end up with a scrollable overflow rect that goes beyond
either of its axes (i.e. the rect has a negative X or Y position
relative to its parent's absolute padding box position), we need to clip
that rect to prevent going into the "unreachable scrollable overflow".

This fixes the horizontal scrolling on https://ladybird.org (gets more
pronounced if you make the window very narrow).
2025-07-11 08:23:46 +02:00
Shannon Booth
05ddf5c718 LibWeb/DOM: Add StorageEvent and DragEvent to Document.createEvent
We have since implemented these interfaces.
2025-07-11 08:22:36 +02:00
Shannon Booth
1d5ca2ae80 Tests/LibWeb: Import WPT Document-createEvent WPT tests 2025-07-11 08:22:36 +02:00
Andrew Kaster
c2a37e693c Utilites: Remove extra dashes from raw strings argument to js
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
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
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-07-10 16:28:40 -06:00
Olekoop
d6ea941208 Meta: Fix linker issue when compiling for Android 2025-07-10 15:44:53 -06:00
Olekoop
f26a898ffc Android: Workaround the system certificate issue
Due to removal of local ca-certificates we need to use system's
certificate. However, on Android it is stored in multiple files.
Ladybird doesn't support multiple certificates yet, so we just
concatenate all of them into one big file.
2025-07-10 15:44:53 -06:00
Olekoop
0738852466 Documentation: Update the version of Android Studio 2025-07-10 15:44:53 -06:00
Olekoop
e65a38bb0e Meta: Enable Vulkan and ANGLE when compiling for Android
Vulkan seems to have been disabled due to not being able to compile.
However, it compiles on my machine and it works on my phone.

As for ANGLE, someone just forgot about Android.
2025-07-10 15:44:53 -06:00
Olekoop
af2d46bd3d LibMedia+Meta: Enable FFmpeg under Android and remove the stubs
The licensing issue seems to be resolved (#2214).
The stubs are not longer necessary. Even if they were, they do not
compile properly.
2025-07-10 15:44:53 -06:00
Olekoop
a70fade461 Documentation: Remove metions about Android port not working 2025-07-10 15:44:53 -06:00
Olekoop
f6c90d00a9 Meta: Don't compile libproxy for Android
libproxy isn't availiable for Android.
2025-07-10 15:44:53 -06:00
Olekoop
4b384a3593 Meta: Add a workaround when compiling for Android
We shouldn't do any of this but it's necessary in order to link it
properly.
2025-07-10 15:44:53 -06:00
Olekoop
834eb04d33 ImageDecoder: Make it compile for Android 2025-07-10 15:44:53 -06:00
Olekoop
6f350c51fd Android: Keep up with the times
While some of the changes are due to syntax and have no effect on
the functionality, others are more important.

The major changes are
- Use Painter instead of now removed DeprecatedPainter
- Remove the need of LibArchive by using Java's native zip support
- Have a proper C++23 compiler by updating NDK to r29 beta 2
- Store user data and config in an user accessible way
- Update AGP to 8.11 and update compile target to SDK level 35
2025-07-10 15:44:53 -06:00