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

68260 commits

Author SHA1 Message Date
Timothy Flynn
2810071a9c LibWebView: Support custom search engines
This allows the user to store custom search engines via about:settings.
Custom engines will be displayed below the builtin engines in the drop-
down to select the default engine.

A couple of edge cases here:

1. We currently reject a custom engine if one with the same name already
   exists. In the future, we should allow editing custom engines.

2. If a custom engine which was the default engine is removed, we will
   disable search rather than falling back to any other engine.
2025-04-06 13:45:10 +02:00
Timothy Flynn
dbf4b189a4 LibWebView: Do not use AK::format to format search engine URLs
This is to prepare for custom search engines. If we use AK::format, it
would be trivial for a user (or bad actor) to come up with a template
search engine URL that ultimately crashes the browser due to internal
assertions in AK::format. For example:

    https://example.com/crash={1}

Rather than coming up with a complicated pre-format validator, let's
just not use AK::format. Custom URLs will signify their template query
parameters with "%s". So we can do the same with our built-in engines.
When it comes time to format the URL, we will do a simple string
replacement.
2025-04-06 13:45:10 +02:00
Timothy Flynn
cbee476dac LibWebView: Store search engine names/URLs as String
In order to support custom search engines, we will need to store the
engine properties as String to hold user-provided data.

This also caused a compile error trying to assign Optional<SearchEngine>
to Optional<SearchEngine const&>, so there's a bit of extra churn here.
2025-04-06 13:45:10 +02:00
Timothy Flynn
7f37a8f60f AK: Add an AK::find helper to return a reference to the found value
This is often more convenient than dealing with iterators.

This commit includes a couple conversions to find_value as examples.
2025-04-06 13:45:10 +02:00
Timothy Flynn
9cab5dc0c9 Base: Consolidate a couple of about:settings container classes 2025-04-06 13:45:10 +02:00
Andreas Kling
d138474e0d LibJS: Avoid unnecessary shifts in Value empty/null/undefined checks
We know that the payload is always 0 for these three Value types, and so
we can implement checking for them as full 64-bit compares against
constant values instead of checking just the tag.

This avoids shifting the tag 48 bits to the right before comparing it.
Since these are used all over the place, it actually leads to a nice
code size reduction.
2025-04-06 04:47:01 +02:00
Andreas Kling
c8865458da LibJS: Mark exception-handling paths with [[unlikely]] in interpreter
This appears actually helpful and consistently makes all benchmarks
slightly faster on my machine.
2025-04-06 04:47:01 +02:00
Andreas Kling
aec7dd5778 LibJS: Mark Interpreter::handle_exception() as NEVER_INLINE
Before this change, we were inlining this function after every
handler for instructions that could throw.

Forcing it out-of-line shrinks the main bytecode interpreter by 15%
and yields a decent 2.5% speedup on JetStream/gcc-loops.cpp.js
2025-04-06 04:47:01 +02:00
Aliaksandr Kalenik
d5edd62e57 LibWeb: Limit usage of getElementById() cache to connected roots
Fixes bug when we always return null from getElementById() on
unconnected roots because id to element cache is only maintained for
connected roots.

Fixes broken Perf-Dashboard suite in Speedometer 3.
2025-04-06 04:14:29 +02:00
Andreas Kling
3c2a2bb39f LibJS: Shrink JS::Bytecode::Operand from 8 bytes to 4 bytes
This packs the bytecode much better and gives us a decent performance
boost on throughput-focused benchmarks.

Measured on my M3 MacBook Pro:
- 4.7% speedup on Kraken
- 2.3% speedup on Octane
- 2.7% speedup on JetStream1
2025-04-06 02:05:27 +02:00
Andreas Kling
70411a117b LibJS: Use u32 instead of size_t for bytecode instruction array sizes
Instructions that have an embedded tail array are not going to have
more than 2^32 elements in any remotely sane situation.
2025-04-06 02:05:27 +02:00
Andreas Kling
42cc481091 LibJS: Make Optional<StringTableIndex> use less space
We can use the index's invalid state to signal an empty optional.
This makes Optional<StringTableIndex> 4 bytes instead of 8,
shrinking every bytecode instruction that uses these.
2025-04-06 02:05:27 +02:00
Andreas Kling
f1a54ef281 LibJS: Use u32 for RegexTableIndex
Same as we already do for StringTableIndex and IdentifierTableIndex.
2025-04-06 02:05:27 +02:00
rmg-x
37998895d8 AK+Meta+LibCore+Tests: Remove unused SipHash implementation
This is a homegrown implementation that wasn't actually used in
dependent classes. If this is needed in the future, using OpenSSL would
probably be a better option.
2025-04-06 01:47:50 +02:00
Timothy Flynn
f1f7f68f36 LibWebView: Highlight about: and data: URL schemes 2025-04-06 00:32:14 +02:00
Aliaksandr Kalenik
c3121c9d8a LibIPC+Meta: Keep message buffer alive until acknowledged by peer
This change ensures that instead of immediately deallocating the message
buffer after sending, we retain it in an acknowledgement wait queue
until an acknowledgement is received from the peer. This is necessary
to handle a behavior of the macOS kernel, which may prematurely
garbage-collect file descriptors contained within the message buffer
before the peer receives them.

The acknowledgement mechanism assumes messages are received in the same
order they were sent so, each acknowledgement message simply indicates
the count of successfully received messages, specifying how many entries
can safely be removed from the acknowledgement wait queue.
2025-04-05 23:14:32 +02:00
Andreas Kling
15e2c78e9a LibJS: Shrink ThrowCompletionOr<void>
By specializing this template and using the special empty JS::Value as a
marker for the `void` state, we shrink this very common class from 16
bytes to 8 bytes.

This allows bytecode instruction handlers to return their result in a
single 64-bit register, allowing tighter code generation.
2025-04-05 21:34:13 +02:00
Andreas Kling
c5a239b8c4 LibJS: Add missing visit for CyclicModule::m_evaluation_error 2025-04-05 21:34:13 +02:00
Lukas Scheller
852e8ff12f LibWeb: Fix grid placement with named lines 2025-04-05 21:30:37 +02:00
devgianlu
6fc9de7aab LibJS: Remove invalid call to realm() on bytecode generator error
There is no realm when that call happens, use the same logic as the
lines above to create an error from the VM alone.
2025-04-05 20:55:21 +02:00
rmg-x
27c19c02d2 RequestServer: Remove check for square brackets in host before resolving
This is no longer needed since `IPv6Address::from_string` supports
square brackets. After the update to curl, `CURLOPT_RESOLVE` now
supports replacing IPv6 hosts as well.
2025-04-05 14:26:09 -04:00
rmg-x
6480e1a3fe AK+Tests: Add support for URI syntax in IPv6Address::from_string
This supports IPv6 strings that start with `[` and end with `]` in
accordance with RFC3986 which states:

A host identified by an Internet Protocol literal address, version 6
[RFC3513] or later, is distinguished by enclosing the IP literal
within square brackets ("[" and "]").  This is the only place where
square bracket characters are allowed in the URI syntax.
2025-04-05 14:26:09 -04:00
rmg-x
20e6de9340 Meta: Update curl to 8.13.0 2025-04-05 14:26:09 -04:00
devgianlu
08cfd5ff1b LibJS: Set empty function parameters on ClassStaticInit scope
This prevents the variables declared inside a class static initializer
to escape to the nearest containing function causing all sorts of memory
corruptions.
2025-04-05 18:20:36 +01:00
devgianlu
6aea459e00 LibJS: Wrap static_init_block_scope call in its own scope 2025-04-05 18:20:36 +01:00
Ali Mohammad Pur
396f35c41d Meta: Don't require LTO to build in release mode
check_ipo_supported() will by default fail the generation if IPO is not
available; this commit makes it so we continue the build just without
LTO.
2025-04-05 19:09:59 +02:00
Andreas Kling
fe1962d7fa LibJS: Make SetCompletionType bytecode instruction actually set type
This recovers 38 tests in test262 that regressed in a0bb31f7a0.
2025-04-05 15:00:05 +02:00
Tim Ledbetter
026bc91d6c LibWeb/CSS: Extract border width values directly
There's no need to keep a copy of a `BorderData` object in this case.
This makes the variable names used a bit less confusing.
2025-04-05 12:54:22 +02:00
Tim Ledbetter
32812f5db0 LibWeb: Return absolutized computed value for outline width property 2025-04-05 12:54:22 +02:00
Andreas Kling
b05b9378ed LibJS: Demote VERIFYs in Completion() to ASSERT
These were *extremely* hot in profiles (noticed when looking at
disassembly).

Now that we've made the special empty JS::Value much harder to create
accidentally, we can feel better about turning these into ASSERT and
catching them in debug builds.
2025-04-05 11:20:26 +02:00
Andreas Kling
3cf50539ec LibJS: Make Value() default-construct the undefined value
The special empty value (that we use for array holes, Optional<Value>
when empty and a few other other placeholder/sentinel tasks) still
exists, but you now create one via JS::js_special_empty_value() and
check for it with Value::is_special_empty_value().

The main idea here is to make it very unlikely to accidentally create an
unexpected special empty value.
2025-04-05 11:20:26 +02:00
Andreas Kling
0d91363742 LibJS: Remove weird fallback behavior in VM::argument/argument_count
If there's no running execution context, let's just error out in there
instead of returning a weird empty value.
2025-04-05 11:20:26 +02:00
Andreas Kling
ceddc8d660 LibJS: Make a bunch of functions in Environment pure virtual 2025-04-05 11:20:26 +02:00
Andreas Kling
de424d6879 LibJS: Make Completion.[[Value]] non-optional
Instead, just use js_undefined() whenever the [[Value]] field is unused.
This avoids a whole bunch of presence checks.
2025-04-05 11:20:26 +02:00
Andreas Kling
c0600c4353 LibJS: Remove unused ThrowCompletionOr<T>::release... helper 2025-04-05 11:20:26 +02:00
Andreas Kling
6d8bc2b1d6 LibJS: Remove unused Completion::update_empty() 2025-04-05 11:20:26 +02:00
Andreas Kling
41314d0460 LibJS: Remove unnecessary exception checks in bytecode dispatch
No need to check for exceptions after instructions that cannot throw.
2025-04-05 11:20:26 +02:00
Tim Ledbetter
8738987e44 LibWeb: Return absolutized computed value for border width properties 2025-04-04 23:45:06 +02:00
Andrew Kaster
743f8a3a0a CMake: Add macro to wrap C++ command line definitions for swiftc
Similar to the existing macros for compile options and link options,
this macro wraps the command line definitions for swiftc in a way that
avoids warnings about conditional compilation flags not having values.
2025-04-04 13:06:53 -06:00
Andrew Kaster
8fd81c3338 LibGC+LibWeb+LibJS: Remove workaround for Swift boolean bitfield issue
We're using a main snapshot everywhere, so we can yeet the workaround.
2025-04-04 13:06:53 -06:00
Tim Ledbetter
e73438e82c LibWeb: Clamp grayscale, invert, filter and opacity filter values to 1 2025-04-04 17:12:47 +01:00
Tim Ledbetter
e5f21b2f9c LibWeb: Set blur filter radius to 0px if omitted 2025-04-04 17:12:47 +01:00
Tim Ledbetter
2ee86d1e18 LibWeb: Set hue-rotate angle to 0 degrees if omitted 2025-04-04 17:12:47 +01:00
Tim Ledbetter
61f76c7ec5 LibWeb: Set color filter value to 1 if omitted 2025-04-04 17:12:47 +01:00
Tim Ledbetter
46411295d6 LibWeb: Serialize drop-shadow filter properties in canonical order 2025-04-04 17:12:47 +01:00
Jess
83e46b3728 LibRegex: Fix crash when parse result exceeds max cache size
Before, If the cache was empty we would try and evict non-existant
entries and crash. So the fix is to make sure that we don't saturate
the cache with a single parse result.
2025-04-04 16:10:25 +02:00
Jelle Raaijmakers
99df80f81e LibWeb: Only apply box offset if the box is not already the ancestor
When determining the content/margin box rects within their ancestor's
coordinate space, we were returning early if the passed in values
already belonged to the requested ancestor. Unfortunately, we had
already applied the used values' offset to the rect, which is the offset
to the ancestor's ancestor.

This simplifies the logic to always apply the rect offset after checking
if we've reached the ancestor. Fixes determining float intrusions inside
block elements with `margin: auto` set.

Fixes #4083.
2025-04-04 15:35:26 +02:00
R-Goc
28d5d982ce Everywhere: Remove unused private fields
This commit removes the -Wno-unusued-private-field flag, thus
reenabling the warning. Unused field were either removed or marked
[[maybe_unused]] when unsure.
2025-04-04 12:40:07 +02:00
Sam Atkins
e43bb1410c LibWeb/CSS: Reject non-grouping-rules as descendants of style rules
For example, `@font-face` is not only invalid inside a style rule, it's
also invalid inside a child of a style rule. This fixes a test
regression that we previously passed by accident.
2025-04-04 10:40:32 +01:00
Sam Atkins
9cce791424 LibWeb/CSS: Only attempt to load valid @font-face fonts
These must have a `font-family` and `src` set to be included in
font-matching. Otherwise they should be ignored, but still exist in the
CSSOM.
2025-04-04 10:40:32 +01:00