Commit graph

42470 commits

Author SHA1 Message Date
Ali Mohammad Pur
6b50425013 wasm: Map the entire input wasm file instead of using Core::File
This is a 30x (!) speedup in parsing time as we don't lose time to
Core::File's silly memmove()-into-provided-buffer stuff anymore.
2022-10-24 15:54:20 +02:00
Ali Mohammad Pur
8b0f05c540 LibWasm: Allow vectors of up to 500M entries
This usually shows up in custom sections, containing plain bytes.
2022-10-24 15:54:20 +02:00
Ali Mohammad Pur
21c6e4c257 LibWasm: Calculate the max data segment size correctly
This is given in pages, we need to first convert to bytes before
comparing with bytes.
2022-10-24 15:54:20 +02:00
Tim Schumacher
18e2bc635f LibCore: Link against LibSystem
Depending on what OS LibCore is being built for (either SerenityOS or
not-SerenityOS), the library does not just wrap functions from LibC,
but it also implements syscalls itself. Therefore, it needs to link
against LibSystem, as that is the only library that is allowed to do
syscalls.

When cross-compiling the OS this is currently not an issue because
LibC links against LibSystem, and CMake passes that dependency through
transitively by accident. However, on Lagom, LibC is just a dummy
INTERFACE library, so the LibSystem dependency is never pulled in,
resulting in undefined symbols whenever we build LibCore on SerenityOS
as a part of Lagom.
2022-10-24 15:52:42 +02:00
Tim Schumacher
4ee0737d10 Meta: Default to the SDL QEMU frontend on SerenityOS
We don't yet have anything else than SDL, and certainly not GTK.
2022-10-24 15:52:42 +02:00
Tim Schumacher
40165a1c40 Meta: Also set CC/CXX when selecting the host toolchain
This ensures that the toolchain building scripts will use the host
toolchain that has been found manually, and that they won't fall back to
`cc` (which in the worst case may not even be installed).
2022-10-24 15:52:42 +02:00
Tim Schumacher
7ecc50db57 Lagom: Link the system's LibSystem on SerenityOS 2022-10-24 15:52:42 +02:00
Gunnar Beutner
8cc952b3dc Ports: Add port for the Boost C++ libraries
This currently requires GCC.
2022-10-24 15:49:39 +02:00
Gunnar Beutner
de6048b7d3 Kernel: Add definitions for SO_SNDLOWAT and SO_RCVLOWAT 2022-10-24 15:49:39 +02:00
Gunnar Beutner
01ffed710c Kernel: Add definition for MSB_EOR
None of the protocols we support at the moment use this, but it makes
boost happy.
2022-10-24 15:49:39 +02:00
Gunnar Beutner
1b13d52a87 LibC: Make 'attributes' parameter for pthread_create const 2022-10-24 15:49:39 +02:00
Gunnar Beutner
ce4b66e908 Kernel: Add support for MSG_NOSIGNAL and properly send SIGPIPE
Previously we didn't send the SIGPIPE signal to processes when
sendto()/sendmsg()/etc. returned EPIPE. And now we do.

This also adds support for MSG_NOSIGNAL to suppress the signal.
2022-10-24 15:49:39 +02:00
Tim Schumacher
e5e7ea90b1 Toolchain: Update LLVM to 15.0.3 2022-10-24 15:33:58 +02:00
Linus Groh
9ad6031bca LibWeb: Move internal response in FilteredResponse create() functions 2022-10-24 09:26:16 +01:00
Linus Groh
02a4cba086 LibWeb: Use MUST() for infallible ByteBuffer::copy() invocations
ByteBuffer has an inline capacity of 32 bytes, so when we provide a
string smaller than that, it cannot fail.
2022-10-24 09:26:16 +01:00
Linus Groh
65f5c7adbc LibWeb: Add Fetch::Infrastructure::Header::from_string_pair() helper
This allows us to use this:

```cpp
auto header = TRY_OR_RETURN_OOM(realm,
    Infrastructure::Header::from_string_pair(name, value));
```

Instead of the somewhat unwieldly:

```cpp
auto header = Infrastructure::Header {
    .name = TRY_OR_RETURN_OOM(realm, ByteBuffer::copy(name.bytes())),
    .value = TRY_OR_RETURN_OOM(realm, ByteBuffer::copy(value.bytes())),
};
```
2022-10-24 09:26:16 +01:00
Linus Groh
c12c6fd5ea LibWeb: Fix typo in Fetch::Infrastructure::Request::add_range_header() 2022-10-24 09:24:15 +01:00
Gunnar Beutner
eca4c51f78 Ports: Add Pacman port 2022-10-24 03:25:20 +02:00
Gunnar Beutner
7d4387d383 Ports: Fix building TiMidity++
The build would previously fail if Xorg headers are installed on the
host system.
2022-10-24 03:25:20 +02:00
Andreas Kling
8aab33de5f LibWeb: Skip positioned children in paint_descendants()
Positioned descendants are now handled entirely by paint_internal()
so we can just skip over positioned children in paint_descendants().
This avoids drawing the same boxes multiple times.
2022-10-23 23:32:42 +02:00
Andreas Kling
8bf0e71c0c LibWeb: Paint non-positioned stacking contexts with z-index 0 or auto
As I understand it, these have to be painted interleaved with positioned
descendants in the same z-index category, in tree order.
2022-10-23 23:32:42 +02:00
Andreas Kling
447519f678 LibWeb: Paint positioned descendants with z-index: auto
This "worked" before because all positioned elements would create their
own stacking context. When we stopped doing this, there was nobody to
actually paint positioned descendants with `z-index: auto`.

This patch splits up steps 8 and 9 of the paint order algorithm and
implements step 8 as a paint tree traversal. There's more to step 8 than
I've implemented here, so I've left a FIXME for our future selves.
2022-10-23 23:32:42 +02:00
Andreas Kling
8a0e40c5b0 LibWeb: Update StackingContext::paint_descendants() for new rule
Since positioned elements no longer automatically create stacking
contexts, we can't rely on this assumption when painting descendants of
a stacking context.

In this commit, we fix an issue that manifested as a failure to
Gfx::Painter::restore() in the "Overlay" paint phase. What happened was
that a CSS clip was being applied in the "Background" paint phase, and
then unapplied in the "Overlay" phase. Due to bogus checks in
paint_descendants(), the "Background" phase never ran for positioned
elements, but the "Overlay" phase did.

The check for positioned elements was bogus in the first place and had
never actually worked before, since we would always skip over positioned
descendants due to them having stacking contexts.
2022-10-23 23:32:42 +02:00
Andreas Kling
055a1998c1 LibWeb: StackingContext::paint_descendants() can take const layout node
It doesn't mutate the layout tree in any way.
2022-10-23 23:32:42 +02:00
Andreas Kling
faba3ebfca LibWeb: Don't create stacking contexts for all positioned elements
We were mistakenly creating stacking contexts for all elements with
non-static CSS position.

For `absolute` and `relative`, we should only create stacking contexts
if the `z-index` value is something other than `auto`.

This makes it possible to click the cookie on Cookie Clicker. :^)
2022-10-23 23:32:42 +02:00
Andreas Kling
29c6aabf49 LibWeb: Try harder to find a suitable DOM node for mouse event dispatch
Since our hit testing mechanism gives you the Paintable under the mouse
cursor, we can't just give up if that paintable doesn't have a
corresponding DOM node. That meant that generated content like pseudo-
elements didn't generate mouse events at all.

Fix this by making a dom_node_for_event_dispatch() helper function that
finds a suitable DOM node when given a paintable. This first cut is very
naive, and there's probably more we should do, but we have to start
somewhere. :^)
2022-10-23 23:32:42 +02:00
Gunnar Beutner
2968cbca11 Ports: Prefix output with the build step and port name
We already have something similar for the toolchain builds. This makes
it easier to identify which build step is currently running.
2022-10-23 20:37:27 +02:00
Aliaksandr Kalenik
9cbf031b6d LibWeb: Add button property in MouseEvent 2022-10-23 15:58:16 +02:00
Aliaksandr Kalenik
501fb1cccb LibWeb: Dispatch "wheel" event 2022-10-23 15:58:16 +02:00
davidot
97dc1585b1 WindowServer: Reset mouse acceleration if out of range
Before if the mouse acceleration was out of range the WindowServer would
crash, this could happen if the config had an out of range or non double
vaule.
2022-10-23 15:48:45 +02:00
davidot
1ab6cb1ee9 LibWeb: Make SVG::AttributeParser use the new double parser
Because the result will be a float anyway get rid of the int parsing.
Also the grammar of SVG numbers matches the double parser grammar except
it can't have a sign but that should have been checked by the caller.
2022-10-23 15:48:45 +02:00
davidot
051134a21e LibGfx: Make parse_rgba_color use the new double parser
Since this is used by LibWeb when parsing CSS colors we should not use
strtod here.
2022-10-23 15:48:45 +02:00
davidot
62fc3e50f3 LibJS: Make parseFloat use the new double parser
This means it no longer is locale dependent and doesn't incorrectly
accept hex floats anymore.
2022-10-23 15:48:45 +02:00
davidot
29a96b1304 LibWeb: Make HTMLProgressElement use the new double parser 2022-10-23 15:48:45 +02:00
davidot
6e9969ded0 LibWeb: Make HTMLInputElement of type number use the new double parser 2022-10-23 15:48:45 +02:00
davidot
8abd4f6102 LibWeb: Make the CSS parser use the new double parser
This could potentially be sped up by tracking the up to three different
ranges of characters known to be digits. This would save the double
parser from checking whether these are digits and because it has the
size it can use the fast parsing method.
2022-10-23 15:48:45 +02:00
davidot
783b1a479d LibJS: Make string_to_double use the new double parser 2022-10-23 15:48:45 +02:00
davidot
6805ded21d LibJS: Make canonical_numeric_index_string use the new double parser 2022-10-23 15:48:45 +02:00
davidot
3dc99af3dc LibJS: Make parse_temporal_duration use the new double parser 2022-10-23 15:48:45 +02:00
davidot
d66bfcc3f4 LibJS: Make PluralRules use the new double parser 2022-10-23 15:48:45 +02:00
davidot
7db59124e8 LibJS: Make Token use the new double parser 2022-10-23 15:48:45 +02:00
davidot
9921f80817 LibJS: Fix that non-double numbers from JSON were truncated to i32 2022-10-23 15:48:45 +02:00
davidot
c9aa664eb0 AK: Make the JsonParser use the new double parser for numbers
Because we still support u64 and i64 (on top of i32 and u32) we do still
have to parse the number ourself first. Then if we determine that the
number is a floating point or is outside of the range of i64 and u64 we
fallback and parse it as a double.

Before JsonParser had ifdefs guarding the double computation, but it
just build when we error on ifdef KERNEL so JsonParser is no longer
usable in the Kernel. This can be remedied fairly easily but since
it is not needed we #error on that for now.
2022-10-23 15:48:45 +02:00
davidot
35e52f7bfd LibC+Tests: Add extra tests for special values for strtod 2022-10-23 15:48:45 +02:00
davidot
1986b8b066 LibC: Make strtod use the new exact number parser
Because strtod need to set ERANGE and track the last character we have
to check the resulting value. We also have to check for nan and inf in
strtod itself as the new double parser doesn't accept that as floating
points.
2022-10-23 15:48:45 +02:00
davidot
6fd8e96d53 AK: Add to_{double, float} convenience functions to all string types
These are guarded with #ifndef KERNEL, since doubles (and floats) are
not allowed in KERNEL mode.
In StringUtils there is convert_to_floating_point which does have a
template parameter incase you have a templated type.
2022-10-23 15:48:45 +02:00
davidot
2334cd85a2 AK: Add an exact and fast hex float parsing algorithm
Similar to decimal floating point parsing the current strtod hex float
parsing gives a lot of incorrect results. We can use a similar technique
as with decimal parsing however hex floats are much simpler as we don't
need to scale with a power of 5.

For hex floats we just provide the parse_first_hexfloat API as there is
currently no need for a parse_hexfloat_completely API.

Again the accepted input for parse_first_hexfloat is very lenient and
any validation should be done before calling this method.
2022-10-23 15:48:45 +02:00
davidot
53b7f5e6a1 AK: Add an exact and fast floating point parsing algorithm
This is based on the paper by Daniel Lemire called
"Number parsing at a Gigabyte per second", currently available at
https://arxiv.org/abs/2101.11408
An implementation can be found at
https://github.com/fastfloat/fast_float

To support both strtod like methods and String::to_double we have two
different APIs. The parse_first_floating_point gives back both the
result, next character to read and the error/out of range status.
Out of range here means we rounded to infinity 0.

The other API, parse_floating_point_completely, will return a floating
point only if the given character range contains just the floating point
and nothing else. This can be much faster as we can skip actually
computing the value if we notice we did not parse the whole range.

Both of these APIs support a very lenient format to be usable in as many
places as possible. Also it does not check for "named" values like
"nan", "inf", "NAN" etc. Because this can be different for every usage.

For integers and small values this new method is not faster and often
even a tiny bit slower than the current strtod implementation. However
the strtod implementation is wrong for a lot of values and has a much
less predictable running time.

For correctness this method was tested against known string -> double
datasets from https://github.com/nigeltao/parse-number-fxx-test-data
This method gives 100% accuracy.
The old strtod gave an incorrect value in over 50% of the numbers
tested.
2022-10-23 15:48:45 +02:00
davidot
bf6d4a5cbf AK: Make truncating UFixedBigInts constexpr
Also add some tests and shift tests while we're at it.
2022-10-23 15:48:45 +02:00
davidot
66d07a452f LibJS: Make a TypedArray test actually run on all different types 2022-10-23 15:48:45 +02:00