Commit Graph

57671 Commits

Author SHA1 Message Date
Shannon Booth
7067c5c972 LibWeb: Port TypeError in UnderlyingSource from ByteString 2024-01-02 10:01:26 +01:00
Shannon Booth
6b88fc2e05 LibWeb: Properly convert UnderlyingSource's autoAllocateChunkSize to u64
The JS::Value being passed through is not a bigint, and needs to be
converted using ConvertToInt, as per:

https://webidl.spec.whatwg.org/#es-unsigned-long-long

Furthermore, the IDL definition also specifies that this is associated
with the [EnforceRange] extended attribute.

This makes it actually possible to pass through an autoAllocateChunkSize
to the ReadableStream constructor without it throwing a TypeError.
2024-01-02 10:01:26 +01:00
Shannon Booth
99bf986889 LibWeb: Use unsigned long long for ReadableStreamBYOBRequest.respond
Now that the IDL generator supports this :^)
2024-01-02 10:01:26 +01:00
Shannon Booth
e54f272024 LibWeb: Add support for unsigned long long parameters 2024-01-02 10:01:26 +01:00
Shannon Booth
9f5323e173 LibWeb: Use ConvertToInt for IDL integer conversion
This is how the spec tells us we should be converting to these integer
types.

Also leave around a FIXME to pass through information about the [Clamp]
and [EnforceRange] extended attributes, and port over these instances to
the new WebIDL integer typedefs.
2024-01-02 10:01:26 +01:00
Shannon Booth
11371acfaf LibWeb/WebIDL: Implement ConvertToInt and IntegerPart AOs
These are used when converting JS::Values to integers in IDL, as opposed
to our current AD-HOC solution.
2024-01-02 10:01:26 +01:00
Shannon Booth
f1f369b6c6 LibWeb: Add IDL integer typedefs
To make it easier to work out what the correctly sized type should be,
instead of needing to consult the spec or IDL generator.
2024-01-02 10:01:26 +01:00
Shannon Booth
f589bedb0d LibJS: Improve JS::modulo precision for large floating values
JS::modulo was yielding a result of '0' for the input:
```
modulo(1., 18446744073709551616.)
```

Instead of the expected '1'.

As far as I can tell the reason for this is that the repeated calls to
fmod is losing precision in the calculation, leading to the wrong
result. Fix this by only calling fmod once, and preserving the negative
value behaviour by an 'if' check.

Without this, the LibWeb text test:
`/Streams/ReadableByteStream-enqueue-respond.html`

Would hang forever after using this function in the IDL conversion of a
u64 in ConvertToInt.

This should also be more efficient :^)
2024-01-02 10:01:26 +01:00
Shannon Booth
986abe7047 LibJS: Rename IntlNumberIsNaNOrInfinity to NumberIsNaNOrInfinity
While only currently used in Intl in LibJS, this is a pretty generic
error and is useful elsewhere. Rename it to something more generic.
2024-01-02 10:01:26 +01:00
Shannon Booth
56ec36a9dc LibJS: Export MAX_ARRAY_LIKE_INDEX & NEGATIVE_ZERO_BITS in JS namespace 2024-01-02 10:01:26 +01:00
Kevin Meyer
f86ec46a6e Ladybird+LibWebView: Cleanup missing callbacks in InspectorClient
This was causing reproducible crashes, when closing the inspector
window of ladybird running on macos.
2024-01-01 16:04:29 -05:00
Luke Wilde
6231aee761 LibWeb: Add missing DOMRectList::visit_edges 2024-01-01 18:41:14 +01:00
Luke Wilde
5af058d2b6 LibWeb: Only reload iframe on src/srcdoc attribute changes, not all
Fixes Cloudflare Turnstile suddenly going blank and stopping when it
changes the style attribute after doing some setup on the iframe.
2024-01-01 18:41:14 +01:00
Andreas Kling
6eeda29642 LibWeb: Paint 1x1 backgrounds as color fill instead of tiling bitmap
This yields a huge speedup on pages that use this weird but
not-entirely-uncommon technique.
2024-01-01 15:16:58 +01:00
Aliaksandr Kalenik
e8f04be3ae LibWeb/CSS: Fix crashing when calc() is used for border-radius
`BorderRadiusStyleValue::absolutized` should not try to extract length
from LengthPercentage that represents calculated.
2024-01-01 10:12:20 +01:00
Timothy Flynn
d8fa226a8f Ladybird+LibWebView+WebContent: Make the screenshot IPCs async
These IPCs are different than other IPCs in that we can't just set up a
callback function to be invoked when WebContent sends us the screenshot
data. There are multiple places that would set that callback, and they
would step on each other's toes.

Instead, the screenshot APIs on ViewImplementation now return a Promise
which callers can interact with to receive the screenshot (or an error).
2024-01-01 10:11:45 +01:00
Timothy Flynn
93db790974 LibWebView+WebContent: Make the DOM node HTML retrieval IPC async 2024-01-01 10:11:45 +01:00
Timothy Flynn
c190294a76 LibCore: Fix compilation of infallible Promise::when_resolved handlers
This overload is currently unused. When used, it doesn't compile due to
mismatched return types in the handler provided to the function and the
type of `on_resolution`.
2024-01-01 10:11:45 +01:00
Ali Mohammad Pur
75e60d3a68 LibHTTP: Tolerate random whitespace in chunked encoding size field
Some servers decide to add newlines (and not \r\n) into that field, this
commit makes us tolerate that and not crash in cases like in #22463.

Fixes #22463.
2023-12-31 15:36:47 +01:00
Ali Mohammad Pur
267040dde7 LibRegex: Error out on Eof when parsing nonempty class range elements
Fixes #22507.
2023-12-31 15:36:42 +01:00
Andreas Kling
ee3d09f225 LibJS: Show class in SerenityOS mmap name for type-specific allocators 2023-12-31 15:35:56 +01:00
Andreas Kling
b6d4eea7ac LibJS: Never give back virtual memory once it belongs to a cell type
Instead of returning HeapBlock memory to the kernel (or a non-type
specific shared cache), we now keep a BlockAllocator per CellAllocator
and implement "deallocation" by basically informing the kernel that we
don't need the physical memory right now.

This is done with MADV_FREE or MADV_DONTNEED if available, but for other
platforms (including SerenityOS) we munmap and then re-mmap the memory
to achieve the same effect. It's definitely clunky, so I've added a
FIXME about implementing the madvise options on SerenityOS too.

The important outcome of this change is that GC types that use a
type-specific allocator become immune to use-after-free type confusion
attacks, since their virtual addresses will only ever be re-used for
the same exact type again and again.

Fixes #22274
2023-12-31 15:35:56 +01:00
Nico Weber
bcb1e548f1 LibGfx/ICC: Improve XYZ coordinates of gray colors
In XYZ space, gray doesn't have three equal values. Instead, it is
a line through the whitepoint.

(Multiplying by the whitepoint has the same effect as multiplying
the sRGB matrix with a (g, g, g) vector, since the numbers on
the matrix's rows add up to the whitepoint.)

Fixes the very slight red tint on all the figures in chapter 4
of the PDF 1.7 spec.
2023-12-31 13:20:37 +01:00
Lucas CHOLLET
726fa41d4a Mandelbrot: Modernize code by using the FileSystemAccessClient
This allows us to stop using raw `FILE*` and reintroduce `unveil` calls.
2023-12-31 10:12:50 +01:00
Sönke Holz
0c8c0ff412 Kernel/riscv64: Fix backtrace generation on RISC-V
RISC-V uses a different convention for storing stack frame information
described here: https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/master/riscv-cc.adoc#frame-pointer-convention
This part of the psABI is not yet in a ratified version, but both GCC
and Clang seem to use this convention.

Note that the backtrace dumping code still won't work for the initial
stack, as it is located before `kernel_mapping_base`.
2023-12-30 23:24:18 +01:00
Lucas CHOLLET
31b5f17f79 LibGfx/TIFF: Reject images with invalid StripByteCounts or StripOffsets
These two arrays should have the exact same size, files not respecting
this condition should be considered as invalid.
2023-12-30 23:24:05 +01:00
Lucas CHOLLET
82d40aab18 LibGfx/TIFF: Don't try to check non-existent values
We were previously only checking the first value, this is wrong for tags
that accept multiple values (e.g. ExtraSamples) and can lead to crashes
on malformed images containing tags with a count of 0.
2023-12-30 23:24:05 +01:00
Lucas CHOLLET
d66a421757 LibGfx/TIFF: Enforce a length of one for more tags
The TIFF spec is constructed in a way that many tags are defined in
multiple places but some of these definitions are partial. If we look
into "Section 8: Baseline Field Reference Guide", we can see that these
tags indeed have an enforced length of 1.
2023-12-30 23:24:05 +01:00
MacDue
7c162747ef Tests/LibWeb: Add ref test for SVG background without natural size 2023-12-30 23:23:19 +01:00
MacDue
8c59f359eb LibWeb: Implement the default sizing algorithm steps for backgrounds
This now correctly handles sizing SVG backgrounds that have no natural
width/height, but do have a natural aspect ratio.

Fixes #20992
2023-12-30 23:23:19 +01:00
MacDue
d2c96e213f LibWeb: Add AbstractImageStyleValue::natural_aspect_ratio() 2023-12-30 23:23:19 +01:00
Idan Horowitz
bbceb155ce Kernel: Restrict KASLR randomization range when KASAN is enabled
To allow for easy mapping between the kernel virtual addresses and
KASAN shadow memory, we map shadow memory at the very end of the
virtual range, so that we can index into it using just an offset.
To ensure this range is free when needed, we restrict the possible
KASLR range when KASAN is enabled to make sure we don't use the end of
the virtual range.

This fixes the random kernel panics that could occur when KASAN is
enabled, if the kernel was randomly placed at the very end of the
virtual range.
2023-12-30 23:18:49 +01:00
Aliaksandr Kalenik
e394971209 AK+LibWeb: Use segmented vector to store commands in RecordingPainter
Using a vector to represent a list of painting commands results in many
reallocations, especially on pages with a lot of content.

This change addresses it by introducing a SegmentedVector, which allows
fast appending by representing a list as a sequence of fixed-size
vectors. Currently, this new data structure supports only the
operations used in RecordingPainter, which are appending and iterating.
2023-12-30 23:02:46 +01:00
Aliaksandr Kalenik
97f676dbf2 LibWeb: Avoid copying commands in RecordingPainter 2023-12-30 23:02:46 +01:00
Sam Atkins
4ee3090a7d LibWeb: Remove duplicate check for unitless lengths and zero
We call `parse_dimension()` immediately after this, which already deals
with lengths that have no unit. Also the comment here is woefully
outdated.
2023-12-30 20:11:24 +01:00
Sam Atkins
8b69f41bcd LibWeb: Remove old parse_length(ComponentValue const&) method 2023-12-30 20:11:24 +01:00
Sam Atkins
0811a39392 LibWeb: Use new parse_length() in filter parsing 2023-12-30 20:11:24 +01:00
Sam Atkins
e0875b99cc LibWeb: Use new parse_length() in shadow parsing 2023-12-30 20:11:24 +01:00
Sam Atkins
bf05aa88bc LibWeb: Add method for converting a FooOrCalculated to a StyleValue 2023-12-30 20:11:24 +01:00
Sam Atkins
306acf43c4 LibWeb: Convert parse_source_size_value() to TokenStream 2023-12-30 20:11:24 +01:00
Sam Atkins
a76f29e56b LibWeb: Allow creating a TokenStream from a single token
This is quite niche, but lets us convert parsing methods to accepting
TokenStream, while still being able to call them when we just have a
lone token. Specifically we'll use this in the next commit, but it's
likely to also be useful as a stop-gap measure when converting more
parsing methods.
2023-12-30 20:11:24 +01:00
Sam Atkins
2f5379bc9b LibWeb: Use parse_length() for rect() parsing 2023-12-30 20:11:24 +01:00
Sam Atkins
8200fdeddc LibWeb: Use parse_length_percentage() for border-radius parsing 2023-12-30 20:11:24 +01:00
Sam Atkins
30a11dc133 LibWeb: Use parsing helpers in parse_media_feature_value() 2023-12-30 20:11:24 +01:00
Sam Atkins
12bcd029ff LibWeb: Use parse_length_percentage() for radial-gradient radii 2023-12-30 20:11:24 +01:00
Sam Atkins
e62d692205 LibWeb: Implement helpers for parsing CSS numeric types
Frequently we want to parse "anything that's a `<length-percentage>`" or
similar, which could be a constant value or a calculation, but didn't
have a nice way of doing so. That meant repeating the same "try and
parse a dimension, see if it's the right type, then maybe try and parse
a calculation and see if that's the right type" boilerplate code. Or
more often, forgetting about calculations entirely.

These helpers should make that a lot more convenient to do. And they
also use TokenStream, so we can eventually drop the old `parse_length()`
method.
2023-12-30 20:11:24 +01:00
Sam Atkins
30dcbc306c LibWeb: Make resolution calculable
No tests unfortunately, because no CSS property we currently support
accepts `<resolution>`.
2023-12-30 20:11:24 +01:00
Sam Atkins
e907ad44c3 LibWeb: Fill in some missing FooOrCalculated types 2023-12-30 20:11:24 +01:00
Aliaksandr Kalenik
07928129dd LibWeb: Wait until new document becomes active before running scripts
Fixes https://github.com/SerenityOS/serenity/issues/22485

With this change WebContent does not crash when `location.reload()` is
invoked but `Navigable::reload()` still not working because of spec
issue (https://github.com/whatwg/html/issues/9869) so we can't add a
test yet.
2023-12-30 19:32:31 +01:00
Luke Wilde
7e8d3e370f LibWeb: Treat BufferSource as a DataView/ArrayBuffer/TA in IDL overloads
Required by WebAssembly.instantiate.
2023-12-30 18:50:29 +01:00