Commit graph

56737 commits

Author SHA1 Message Date
Andreas Kling
cc9de38ea4 LibWeb: Fix null pointer dereference in DOM::Node::remove()
Instead of blindly dereferencing m_registered_observer_list, just use
the add_registered_observer() helper.

Fixes #22005
2023-11-20 20:50:53 +01:00
Aliaksandr Kalenik
7320fdc1f5 LibWeb: Implement FillEllipse command for GPU executor 2023-11-20 20:08:41 +01:00
Aliaksandr Kalenik
53c015695e LibAccelGfx+LibWeb: Implement rounded corners rectangle painting
For now corners antialiasing is missing.
2023-11-20 19:35:25 +01:00
david072
0e1bd54896 Shell/PosixParser: Correctly parse the OR_IF token
This fixes an unfortunate typo where we would parse the OR_IF token as
an AST::And node. Now, it is parsed into an AST::Or node :^).
2023-11-20 22:02:30 +03:30
Shannon Booth
c5d3ccca00 LibWeb: Port AriaData from DeprecatedString to String 2023-11-20 15:00:19 +01:00
Shannon Booth
6c42de3e8b LibWeb: Port XMLSerializer from DeprecatedString to String 2023-11-20 15:00:19 +01:00
Shannon Booth
e28fb5c64c LibWeb: Port Cookie from DeprecatedString to String 2023-11-20 15:00:19 +01:00
Shannon Booth
e3bc8610a9 LibWeb: Port HTMLInputElement from DeprecatedString to String
And dealing with the fallout of doing so. I am not 100% sure that it is
safe for us to be treating Strings in the value sanitization algorithm
in all cases as if they are ASCII, but this commit does not change any
existing behaviour there.
2023-11-20 15:00:19 +01:00
Shannon Booth
6c9fffc4c1 LibGfx: Add String variants of Color::to_string*() 2023-11-20 15:00:19 +01:00
Shannon Booth
6aff55d655 LibWeb: Port NavigatorID from DeprecatedString to String 2023-11-20 15:00:19 +01:00
Shannon Booth
0a4586d510 LibWeb: Port HTMLHyperlinkElementUtils from DeprecatedString to String 2023-11-20 15:00:19 +01:00
Aliaksandr Kalenik
9888db1c27 LibWeb: Add basic support for borders painting in GPU executor
For now all borders are painted without rounded corners.
2023-11-20 14:59:47 +01:00
Aliaksandr Kalenik
29ff1f67be LibWeb: Introduce dedicated painting command for borders
Currently, in CPU painter, border painting is implemented by building
a Gfx::Path that is filled by Gfx::AntiAliasingPainter. In the GPU
painter, we will likely want to do something different, and with a
special command, it becomes possible.

Also, by making this change, the CPU executor also benefits because now
we can skip building paths for borders that are out of the viewport.
2023-11-20 14:59:47 +01:00
Aliaksandr Kalenik
70353b79af LibWeb: Change paint_all_borders() to accept only device pixel values
By consistently accepting only device pixel values instead of a mix of
CSSPixels and DevicePixels values, we can simplify the implementation
of paint_border() and paint_all_borders().
2023-11-20 14:59:47 +01:00
Simon Wanner
ae8c98104a LibJS: Cache bytecode executables on the corresponding AST nodes
This greatly reduces the number of compilations necessary when functions
declaring local functions are re-executed.

For example Octane/typescript.js goes from 58080 bytecode executables
to 960.
2023-11-20 14:28:16 +01:00
Blake Smith
e346331424 Kernel/FS: Fix check-then-act concurrency bug in FileSystem/Inode
When the FileSystem does a sync, it gathers up all the inodes with
dirty metadata into a vector. The inode mutex is not held while
checking the inode dirty bit, which can lead to a kernel panic
due to concurrent inode modifications.

Fixes: #21796
2023-11-20 09:44:29 +01:00
Andreas Kling
2372584b18 LibJS/JIT: Continue to outer finally before returning
Fixes #21854
2023-11-20 09:30:08 +01:00
Andreas Kling
7ee47d81ca LibWeb: Allocate custom element reactions queue on demand
This shrinks most DOM elements by 16 bytes.
2023-11-20 00:39:42 +01:00
Andreas Kling
ac8bb89f50 LibWeb: Allocate list of registered intersection observers on demand
This shrinks most DOM elements by 16 bytes.
2023-11-20 00:39:42 +01:00
Andreas Kling
bdac94870c LibWeb: Convert Element "attribute change steps" from vector to virtual
By using a virtual function and overriding it on HTMLSlotElement, we
shrink every DOM element by 24 bytes. :^)
2023-11-20 00:39:42 +01:00
Andreas Kling
aa23a7b58d LibWeb: Rearrange HTMLElement members to save 8 bytes per instance 2023-11-20 00:39:42 +01:00
Andreas Kling
48dbec8a9e LibWeb: Allocate storage for pseudo element layout nodes on demand
This saves us 64 bytes for every element that doesn't have pseudo
elements associated with it. Which is most of them. :^)
2023-11-20 00:39:42 +01:00
Andreas Kling
37505d9746 LibWeb: Allocate storage for pseudo element custom properties on demand
Most elements don't have pseudo elements with CSS custom properties.
By only allocating this data structure when it's used, we can shrink
most elements by 208 bytes each. :^)
2023-11-20 00:39:42 +01:00
Andreas Kling
9edfd5e360 LibWeb: Only allocate DOM::Node registered observer list on demand
Most DOM nodes don't have registered mutation observers, so let's put
the metadata about them behind an OwnPtr to save space in the common
case.

Saves 16 bytes per DOM node that doesn't have registered observers.
2023-11-20 00:39:42 +01:00
Andreas Kling
c1fd55ce94 LibWeb: Only allocate EventTarget listener/handler storage on demand
This shaves 40 bytes off of all EventTargets that don't actually get
listeners or handlers attached (which is most of them).
2023-11-20 00:39:42 +01:00
Andreas Kling
a71eaefdf6 LibWeb: Make EventTarget::activation_behavior a virtual function
(Instead of using an AK::Function on EventTarget). This shaves 48 bytes
off of every EventTarget instance.
2023-11-20 00:39:42 +01:00
Stephan Vedder
84eecbb10e LibJS/JIT: Add fastpath for set variable 2023-11-19 22:36:07 +01:00
Nicolas Ramz
b3cbe0fdb9 LibGfx/Path: Round numerator in elliptical_arc_to
This avoids rounding problems which made Ladybird crash with some SVGs
on macOS/Clang.
2023-11-19 22:33:48 +01:00
Nico Weber
eedd978974 Tests: Add a type3 test pdf
A manual test, but better than nothing.

I hand-wrote the file, and used mutool to fix up xref and stream
lengths:

    mutool clean Tests/LibPDF/type3.pdf Tests/LibPDF/type3.pdf

The file contains one `d1` character which per spec shouldn't
contain color statements, and if it does it should be ignored,
and one `d0` character which can contain color.

The text then sets a color before rendering the text.

Per spec, the text color should affect the `d1` character but
not the `d0` one. We get this wrong, but so does Preview.app.
(PDFium gets it right.)

But independent of the colors, just rendering the glyphs at all
at the right position is already good :^)
2023-11-19 22:33:34 +01:00
Andreas Kling
bfd354492e LibWeb: Put most LibWeb GC objects in type-specific heap blocks
With this change, we now have ~1200 CellAllocators across both LibJS and
LibWeb in a normal WebContent instance.

This gives us a minimum heap size of 4.7 MiB in the scenario where we
only have one cell allocated per type. Of course, in practice there will
be many more of each type, so the effective overhead is quite a bit
smaller than that in practice.

I left a few types unconverted to this mechanism because I got tired of
doing this. :^)
2023-11-19 22:00:48 +01:00
Matthew Olsson
536596632b LibWeb: Implement Animation::update_finished_state 2023-11-19 18:54:37 +01:00
Matthew Olsson
979b9b942b LibWeb: Add Document's pending animation event queue
This is needed for Animation's update finished state procedure
2023-11-19 18:54:37 +01:00
Matthew Olsson
8053d40fd5 LibWeb: Add Animation helpers needed for update_finished_state 2023-11-19 18:54:37 +01:00
Shannon Booth
1daded768d LibWeb: Implement ReadableStreamBYOBReader::read
Similiarly to the underlying AO's, currently only TypedArrays are
supported.
2023-11-19 18:53:17 +01:00
Shannon Booth
dcb7bb4a92 LibWeb: Support BYOB readers in ReadableByteStreamControllerEnqueue 2023-11-19 18:53:17 +01:00
Shannon Booth
9662872b20 LibWeb: Implement AO ReadableStreamByobReaderRead
We've finally implemented enough of the Streams AOs so that we are close
to actually performing read operations with BYOB readers.
2023-11-19 18:53:17 +01:00
Shannon Booth
3d37cb0753 LibWeb: Partially implement ReadableByteStreamControllerPullInto
This implementation does not handle DataViews at the moment, but should
handle all of the typed arrays.
2023-11-19 18:53:17 +01:00
Shannon Booth
1443715775 LibWeb: Add ReadableBSControllerProcessPullIntoDescriptorsUsingQueue 2023-11-19 18:53:17 +01:00
Shannon Booth
737dc6ce4e LibWeb: Add ReadableByteStreamControllerFillPullIntoDescriptorFromQueue 2023-11-19 18:53:17 +01:00
Shannon Booth
aca63fd947 LibWeb: Implement ReadableByteStreamControllerCommitPullIntoDescriptor 2023-11-19 18:53:17 +01:00
Shannon Booth
cdcc1ebbba LibWeb: Implement ReadableByteStreamControllerFillHeadPullIntoDescriptor 2023-11-19 18:53:17 +01:00
Shannon Booth
8d4095d00e LibWeb: Add some const overloads in ReadableByteStreamController 2023-11-19 18:53:17 +01:00
Shannon Booth
26e393fbbc LibWeb: Implement ReadableByteStreamControllerConvertPullIntoDescriptor 2023-11-19 18:53:17 +01:00
Shannon Booth
25f8b80eab LibWeb: Use move on ByteBuffer in TransferArrayBuffer 2023-11-19 18:53:17 +01:00
Shannon Booth
446a78f30e LibWeb: Implement Streams AO ReadableStreamAddReadIntoRequest
This is effectively identical to ReadableStreamAddReadRequest besides
from the fact that it takes a ReadIntoRequest instead of a ReadRequest,
and is instead intended to be used for BYOB readers.
2023-11-19 18:53:17 +01:00
Shannon Booth
f27e76b0b7 LibWeb: Make ReadableStreamAddReadRequest take a NonnullGCPtr
Make it more obvious in the function signature that this function will
be taking a GC ref to a ReadRequest by appending it to the
ReadableStreams pending read requests.
2023-11-19 18:53:17 +01:00
Shannon Booth
5ef41dca53 LibWeb: Implement Streams AO ReadableStreamFulfillReadIntoRequest 2023-11-19 18:53:17 +01:00
Shannon Booth
0880ea3e1c LibWeb: Add missing initialize override for ReadableStreamBYOBReader
This hasn't really come up as of yet because not enough of this class
has been implemented yet to actually do anything with it.
2023-11-19 18:53:17 +01:00
Shannon Booth
746526ca29 LibWeb: Add ReadIntoRequest to forwarding header 2023-11-19 18:53:17 +01:00
Andreas Kling
3c74dc9f4d LibJS: Segregate GC-allocated objects by type
This patch adds two macros to declare per-type allocators:

- JS_DECLARE_ALLOCATOR(TypeName)
- JS_DEFINE_ALLOCATOR(TypeName)

When used, they add a type-specific CellAllocator that the Heap will
delegate allocation requests to.

The result of this is that GC objects of the same type always end up
within the same HeapBlock, drastically reducing the ability to perform
type confusion attacks.

It also improves HeapBlock utilization, since each block now has cells
sized exactly to the type used within that block. (Previously we only
had a handful of block sizes available, and most GC allocations ended
up with a large amount of slack in their tails.)

There is a small performance hit from this, but I'm sure we can make
up for it elsewhere.

Note that the old size-based allocators still exist, and we fall back
to them for any type that doesn't have its own CellAllocator.
2023-11-19 12:10:31 +01:00