1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-09 09:34:57 +09:00
Commit graph

69384 commits

Author SHA1 Message Date
devgianlu
4b3715ccba LibCrypto: Replace {Unsigned,Signed}BigInteger impl with LibTomMath
Replace the implementation of maths in `UnsignedBigInteger`
and `SignedBigInteger` with LibTomMath. This gives benefits in terms of
less code to maintain, correctness and speed.

These changes also remove now-unsued methods and improve the error
propagation for functions allocating lots of memory. Additionally, the
new implementation is always trimmed and won't have dangling zeros when
exporting it.
2025-05-23 11:57:21 +02:00
devgianlu
915c6fdcf8 LibCrypto: Add libtommath vcpkg dependency and link it
An overlay port is required to add the `stdc-iec-559` and `install-pc`
patches.

The `stdc-iec-559` patch is required because Clang doesn't define
`__STDC_IEC_559__`. However, glibc and musl define it if `__GCC_IEC_559`
is not defined. The macro is taken from glibc source code.

The `install-pc` patch is required because libtommath doesn't install
the pkg-config files when building statically compromising our ability
to find it during build.

Clang: https://clang.llvm.org/c_status.html#:~:text=Yes-,
IEC%2060559%20support,-Unknown
glibc: https://sourceware.org/git/?p=glibc.git;a=blob;
f=include/stdc-predef.h
2025-05-23 11:57:21 +02:00
devgianlu
5a4cfd05d0 LibCrypto+LibJS: Move Power to method of {Unsigned,Signed}BigInteger
Having it as a method instead of a free function is necessary for the
next commits and generally allows for optimizations that require deeper
access into the `UnsignedBigInteger` / `SignedBigInteger`.

Also restrict the exponent to 32 bits to avoid huge memory allocations.
2025-05-23 11:57:21 +02:00
devgianlu
a952d000be LibCrypto: Move GCD to method of UnsignedBigInteger
Having it as a method instead of a free function is necessary for the
next commits and generally allows for optimizations that require deeper
access into the `UnsignedBigInteger`.
2025-05-23 11:57:21 +02:00
Sam Atkins
e251b451ef LibWeb/CSS: Reject negative <resolution> values
Gets us 3 more WPT passes.
2025-05-23 10:17:58 +01:00
Sam Atkins
fb975cc156 LibWeb/CSS: Correct how we evaluate boolean media-features
The spec has a general rule for this, which is roughly that "If it's not
a falsey value, it's true". However, a couple of media-features are
always false, apparently breaking this rule. To handle that, we have an
array of false keywords in the JSON, instead of a single keyword. For
those always-false media-features, we can enter all their values into
this array.

Gets us 2 more WPT subtest passes.
2025-05-23 10:17:58 +01:00
Sam Atkins
00617884a6 LibWeb/CSS: Correct our scan media-feature
Despite what the spec suggests, modern displays are not progressive, and
WPT expects `@media (scan: progressive)` to fail. So, return `none`
here to accurately represent that.

I've left a FIXME in case we can detect the display type from the OS
somehow in the future.

Gets us 4 WPT subtest passes.
2025-05-23 10:17:58 +01:00
Sam Atkins
9fe8445946 LibWeb/CSS: Maintain original form of media-feature ranges
Previously, for `foo < 30px` ranges, we'd flip them and store them as
`30px > foo` instead. That worked fine, but means the serialization is
wrong. So instead, keep them in their original form.

I experimented with giving Range two optional sub-structs instead of 4
optional members, thinking it would be smaller - but it's actually
larger, because the two Optional<Comparison>s fit snugly together. So,
the slightly-goofy all-Optionals remains.

This gets us 2 WPT passes that I'm aware of.
2025-05-23 10:17:58 +01:00
Sam Atkins
9b8dc6b8d0 LibWeb/CSS: Parse media-feature values forgivingly
Instead of rejecting invalid media-feature values at parse time, we are
expected to parse them, and then treat them as Unknown when evaluating
their media query. To implement this, we first try to parse a valid
value as before. If that fails, or we have any trailing tokens that
could be part of a value, we then scoop up all the possible
ComponentValues and treat that as an "unknown"-type MediaFeatureValue.

This gets us 66 WPT passes.
2025-05-23 10:17:58 +01:00
Sam Atkins
72f50217b0 LibWeb/CSS: Implement device-aspect-ratio media feature
Gets us 8 WPT passes, and prevents a regression in the following commit.
2025-05-23 10:17:58 +01:00
Sam Atkins
b577302f07 LibWeb/CSS: Make media type and feature evaluation combination explicit
Functionally this is the same before, as result is always True or False
before this point, and `True && Foo` evaluates to `Foo`. But this is
more clearly correct, instead of correct by coincidence.
2025-05-23 10:17:58 +01:00
Sam Atkins
a4d3c62524 LibWeb/CSS: Return a MatchResult from MediaFeature::compare()
This commit on its own has no observable behaviour changes, as we still
only return True or False, but for the next commit, we'll need to be
able to return the Unknown state here, and without this change we'd get
regressions.
2025-05-23 10:17:58 +01:00
Sam Atkins
fe7bac73f0 LibWeb/CSS: Stub out a function for serializing ComponentValue sequences
This is very hacky and wrong, but it means there's one place to fix,
instead of one for UnresolvedStyleValue, and one for invalid
MediaFeatureValues which I'm about to implement.
2025-05-23 10:17:58 +01:00
Sam Atkins
987d510dbb LibWeb/CSS: Allow "picture-in-picture" in "display-mode" media feature
We don't implement detection for this yet, but it gets us a WPT pass.
2025-05-23 10:17:58 +01:00
Sam Atkins
38aca62ef5 LibWeb/CSS: Make media-type more permissive
The current spec defines this simply as `<ident>`, but does apparently
serialize as lowercase.

Because of this change, we no longer need to care about the deprecated
media types, as they all behave the same as unknown ones.

We still keep an enum around for KnownMediaType, to avoid repeated
string comparisons when evaluating it.

Gets us 2 WPT passes.
2025-05-23 10:17:58 +01:00
Sam Atkins
bb035fbfe0 Tests: Import a whole bunch of WPT mediaqueries tests
A lot of these are ref-tests, so I'm skipping the failing ones for now,
and will make as many pass as possible in subsequent commits.
2025-05-23 10:17:58 +01:00
Aziz Berkay Yesilyurt
6711438e0d LibWeb: Ensure anonymous wrappers inherit inline-block display
When restructuring a block node inside an inline parent, if the
nearest block ancestor is `display: inline-block`, ensure that
the generated anonymous wrappers also have `display: inline-block`.
This fixes layout issues with block elements nested
inside inline-block elements.
2025-05-23 11:16:06 +02:00
Ruben
09f5ce42f6 LibWeb: Ensure floats are correctly placed under the preceding float
Previously floats would be placed next to the highest float that
fitted the new float on its line. However, this violates the rule
that floats should be placed under the preceding float if it does
not fit next to it.
2025-05-23 10:58:15 +02:00
Shannon Booth
3bf7f94150 LibJS: Use caller_context to determine strict mode
This is functionaly the same since caller_context is the topmost
execution context on the stack, but makes it more clear that
we are directly inheriting the strict mode from the caller context
when pushing the next context on to the stack.
2025-05-23 03:25:55 +02:00
Shannon Booth
7d44640c0f LibJS: Assume is_strict_mode called with running execution context
This should always be invoked when there is an execution context
on the stack.
2025-05-23 03:25:55 +02:00
Shannon Booth
f2fb86abea LibJS: Always emit value in emit_named_evaluation_if_anonymous_function
There does not appear to be any case that we need to return an
OptionalNone{}.
2025-05-23 03:25:55 +02:00
Shannon Booth
20dba8f1ab LibJS: Make Op::Return value required
It turns out we do not have any scenario where this is not provided.
2025-05-23 03:25:55 +02:00
Timothy Flynn
17364c6d36 Tests: Disable XMLHttpRequest-override-mimetype-blob.html for now
It is extremely slow on macOS.
2025-05-22 18:40:25 -04:00
ayeteadoe
fdd3f35b61 Meta: Localize resource module import to fix ladybird.py on Windows 2025-05-22 17:48:03 -04:00
Timothy Flynn
4c8b5ba9de Tests/LibWeb: Add a screenshot test for acid2
This test has flaked over the years, so let's add a screenshot test to
catch future regressions.

This copy of the test was taken from:
https://www.webstandards.org/files/acid2/test.html#top

Our CI infra does not support navigating to the "#top" anchor out of the
gate. So the intro section was removed from this copy so that we render
the happy face immediately.
2025-05-22 17:44:40 -04:00
Timothy Flynn
8b787020a2 LibWeb: Delay the document load event while re-fetching <object> images
We are required to delay the load event while any fetch is ongoing. We
currently have a very hacky re-fetch for images to go through the shared
resource request infrastructure. We must delay the load event during
this re-fetch.

This becomes an issue in an upcoming commit to import the acid2 test.
2025-05-22 17:44:40 -04:00
Timothy Flynn
1bc7a52587 LibWeb: Keep delaying the load event on concurrent <object> tasks
If we queue the <object> representation task multiple times in a row, we
would end up clearing the delayer after the first task completed. We
must continue delaying the load event until the last task completes.

This becomes an issue in an upcoming commit to import the acid2 test.
2025-05-22 17:44:40 -04:00
Timothy Flynn
874e094ed8 LibWeb: Allow moving document load event delayers
This allows us to store lists of delayers.
2025-05-22 17:44:40 -04:00
Lion Kortlepel
900500c0b3 LibWeb: Remove obsolete font-style Keyword handling
`Parser::parse_font_style_value()` only produces
FontStyleStyleValues now, so we no longer need this
branch.
2025-05-22 17:39:05 +01:00
Lion Kortlepel
b1ee539e9d LibWeb: Fix font-style to slope conversion
In a recent refactor of font styles, the new FontStyleStyleValue was
introduced; however, the `to_font_slope()` function was not changed to
understand this new type. When it tries to convert such a font style to
a keyword, it fails. We then rendered the wrong font-style.
2025-05-22 17:39:05 +01:00
Timothy Flynn
d00d49ba2f Meta+Toolchain: Extract BuildVcpkg to an importable function
This lets ladybird.py import it properly, instead of invoking BuildVcpkg
main().
2025-05-22 12:21:24 -04:00
Timothy Flynn
8d4ac42205 Meta: Always invoke BuildVcpkg from ladybird.py's build command
We were previously only invoking it if the Build directory didn't exist.
We need to always invoke it to handle vcpkg baseline updates.
2025-05-22 12:21:24 -04:00
Callum Law
64f09b520d LibWeb: Be less aggressive in marking elements as not being named
When an element's ID is removed we only want to remove it from
`m_potentially_named_elements` if it is not also considered a
potentially named element due to it's name content attribute.
2025-05-22 16:56:02 +02:00
Timothy Flynn
2f9957c618 Everywhere: Format all python files with black 2025-05-22 16:21:42 +02:00
Timothy Flynn
9e8336c04f Meta: Lint python files with black
It's the industry standard nowadays. This also lets us add a flag to the
lint-python.sh script to overwrite our python files in place.
2025-05-22 16:21:42 +02:00
Tim Ledbetter
fe99c1fa7c LibCore: Increase MAX_LOCAL_SOCKET_TRANSFER_FDS
It is currently possible to hit this limit on pages with large numbers
of images. This temporary workaround prevents some WPT tests with large
numbers of images from failing.
2025-05-22 08:00:01 -04:00
Gingeh
71222df4c4 LibWeb: Update button activation behaviour to match spec
See: https://github.com/whatwg/html/pull/11248
See: https://github.com/whatwg/html/pull/11325
2025-05-22 07:55:34 +01:00
Gingeh
f1eaecc630 LibWeb: Escape "<" and ">" when serializing attribute values
See https://github.com/whatwg/html/pull/6362
2025-05-22 07:55:34 +01:00
Gingeh
fbc56f74bd LibWeb: Move popover invoker reset later
See https://github.com/whatwg/html/pull/11304
2025-05-22 07:55:34 +01:00
Ali Mohammad Pur
a3b913bf91 Tests: Import the call-indirect wpt wasm test
This found some broken wasm-js implementations, so let's make sure it
doesn't break again.
2025-05-22 07:35:58 +01:00
Ali Mohammad Pur
83995ada1f LibWasm: Quit early in memory_fill if store_to_memory traps
We shouldn't try to run the next 'instruction' if we trap.
Unbreaks the memory-fill test in wpt.
2025-05-22 07:35:58 +01:00
Ali Mohammad Pur
bfc1ebb2d4 LibWasm: Disable spammy 'memory access oob' debug prints 2025-05-22 07:35:58 +01:00
Ali Mohammad Pur
d79d5b70a5 LibWasm: Validate indirect calls at runtime
This is required by the spec, and also unbreaks all of the call-indirect
wpt tests.
2025-05-22 07:35:58 +01:00
Ali Mohammad Pur
39b637a446 LibWasm+LibWeb: Throw a js stack-overflow error if wasm stack overflows
Follows the spec.
2025-05-22 07:35:58 +01:00
Timothy Flynn
9ae85e5c68 Meta: Avoid manual formation of user-variables.cmake path
We're using python specifically to be platform-independent.
2025-05-21 16:55:27 -06:00
Timothy Flynn
5b830b4c05 Meta: Be a bit less aggressive with newlines in list extensions 2025-05-21 16:55:27 -06:00
Timothy Flynn
bac61926b2 Meta: Use fewer abbreviated variable names in ladybird.py 2025-05-21 16:55:27 -06:00
Timothy Flynn
b54f273770 Meta: Ignore pyright warning for dynamic BuildVcpkg import
There are now zero pyright warnings.
2025-05-21 16:55:27 -06:00
Timothy Flynn
6a1b3f740c Meta: Avoid double-access of LADYBIRD_SOURCE_DIR environment variable
The `ensure_ladybird_source_dir` function returns the source directory.
Let's just use it. This silences a pyright warning.
2025-05-21 16:55:27 -06:00
Timothy Flynn
23a95cfb9a Meta: Add missing type hints to ladybird.py
This enables significantly better LSP integration.
2025-05-21 16:55:27 -06:00