Commit Graph

57608 Commits

Author SHA1 Message Date
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
Luke Wilde
54972e3ceb LibWeb: Implement SVGUseElement#href
Required by Ruffle.
b196c8d1bc/web/packages/core/src/shadow-template.ts (L601-L602)
2023-12-30 18:50:29 +01:00
Luke Wilde
968bec9844 LibWeb: Add SVGURIReference 2023-12-30 18:50:29 +01:00
Luke Wilde
55646893d8 LibWeb: Add xlink:href to SVG attribute names 2023-12-30 18:50:29 +01:00
Luke Wilde
ddf601830a LibWeb: Implement SVGAnimatedString 2023-12-30 18:50:29 +01:00
Luke Wilde
d503fd51ec LibWeb: Add test for valueAsNumber 2023-12-30 18:50:29 +01:00
Timothy Flynn
3572a047d1 LibWebView+WebContent: Make the DOM node editing IPCs async
All DOM node mutation IPCs now invoke an async completion IPC after the
DOM is mutated. This allows consolidating where the Inspector updates
its view and the selected DOM node.

This also allows improving the response to removing a DOM node. We would
previously just select the <body> tag after removing a DOM node because
the Inspector client had no idea what node preceded the removed node.
Now the WebContent process can just indicate what that node is. So now
after removing a DOM node, we inspect either its previous sibling (if it
had one) or its parent.
2023-12-30 17:30:55 +01:00
Timothy Flynn
1eba170d03 LibWebView+WebContent: Make the hovered node retrieval IPC async 2023-12-30 17:30:55 +01:00
Timothy Flynn
760ba5932b LibWebView+WebContent: Make the DOM node inspection IPC async 2023-12-30 17:30:55 +01:00
Timothy Flynn
4c3bff264e LibWebView+WebContent: Rename DOM/a11y tree IPC response methods
Rename them from "did_get_*" to "did_inspect_*", to correspond to the
request methods "inspect_dom_tree" and "inspect_accessibility_tree". No
functional change, but this makes it a bit easier to stare at IPC files
side-by-side and know which response method corresponds to a request
method at a quick glance.
2023-12-30 17:30:55 +01:00
Aliaksandr Kalenik
c7e22c7a72 LibWeb: Skip empty paint borders commands in RecordingPainter
With this change, we create substantially fewer border painting
commands, which means fewer reallocations of the vector that stores
commands.

This makes the rendering of
https://html.spec.whatwg.org/multipage/browsing-the-web.html visibly
faster, where we allocated ~10 of such commands now vs ~8000 before.
2023-12-30 17:07:11 +01:00
Idan Horowitz
f7a1f28d7f Kernel: Add initial basic support for KASAN
This commit adds minimal support for compiler-instrumentation based
memory access sanitization.
Currently we only support detection of kmalloc redzone accesses, and
kmalloc use-after-free accesses.

Support for inline checks (for improved performance), and for stack
use-after-return and use-after-return detection is left for future PRs.
2023-12-30 13:57:10 +01:00
Andreas Kling
7ad7ae7000 AK: Check URL parser input for invalid (tabs or spaces) in 1 pass
Combine 2 passes into 1 by iterating over the input once and checking
for both '\t' and '\n'.
2023-12-30 13:49:50 +01:00
Andreas Kling
7e2d9bfd53 LibWeb: Avoid String<->ByteString src conversion in HTMLImageElement
We already have the src attribute stored as a String, so it's completely
wasteful to convert it to a ByteString. We were even doing it twice when
loading each image.
2023-12-30 13:49:50 +01:00