Commit Graph

54860 Commits

Author SHA1 Message Date
Lucas CHOLLET
e62a4c169b Ports: Add libjxl :^) 2023-09-27 03:14:44 +02:00
Lucas CHOLLET
48a1fe8308 Ports/brotli: Update to 1.1.0 2023-09-27 03:14:44 +02:00
Lucas CHOLLET
7a993cad7a Ports: Add highway
This library is used by multiple projects but was ported to get `libjxl`
on SerenityOS.
2023-09-27 03:14:44 +02:00
Tim Ledbetter
09099cc9a3 du: Prevent multiple counting of the same file
Previously, the same file would be counted more than once if its
containing directory was visited multiple times, or there were
multiple hard links pointing to it.

We now keep track of every visited inode to ensure that files aren't
evaluated multiple times. This matches the behavior of `du` on FreeBSD
and Linux.
2023-09-26 21:27:25 +02:00
Aliaksandr Kalenik
46254101f7 LibWeb: Change DOM::Position to be GC-allocated 2023-09-26 21:25:54 +02:00
Aliaksandr Kalenik
35623ad52e LibWeb: Visit IntersectionObserverRegistration instead of using Handle
This fixes GC-leak caused by JS::Handle<IntersectionObserverver>
preventing an element that owns the handle from being deallocated.
2023-09-26 21:25:54 +02:00
Aliaksandr Kalenik
ac5c4705fd LibWeb: Do not use JS::Handle for captures of AbortSignal callbacks
There is no need to use JS::Handle for captures because AbortSignal
will visit them anyway because it uses JS::HeapFunction to store the
callback.
2023-09-26 21:25:54 +02:00
Aliaksandr Kalenik
3bcd368703 LibWeb: Do not pass JS::Handle into NativeFunction callback captures
NativeFunction uses JS::HeapFunction for the callback so GC-allocated
captures will be visited anyway.
2023-09-26 21:25:54 +02:00
Sam Atkins
90aaa8ab40 LibWeb: Handle shorthands in ResolvedCSSStyleDeclaration generically
Most shorthands can be reconstructed this way, using our generated
property data, so let's use them instead of manually implementing the
code.

Some of these were previously doing some form of error checking or
defaulting, but both of those are unnecessary. (And actually, would
crash if there wasn't a value available due to calling release_nonnull()
on a null RefPtr.) At this point, the CSS machinery has already made
sure each property has a value, and that the value is valid for that
property.
2023-09-26 21:19:42 +02:00
Sam Atkins
c103269a8e LibWeb: Fill out font property data 2023-09-26 21:19:42 +02:00
Sam Atkins
2e3f63fe3b LibWeb: Correct longhands for grid property
These three are the ones that ShorthandStyleValue uses to serialize
`grid`, so let's use them here.

The spec also mentions `grid-auto-*` properties as being set by `grid`,
but I'll leave that for someone who understands grid better.
2023-09-26 21:19:42 +02:00
Sam Atkins
28dbe8eb10 LibWeb: Use SVGPresentationAttribute mode for SVG attributes
This replaces the previous TemporarilyEnableQuirksMode hack, which has
now been removed. :^)
2023-09-26 20:01:55 +02:00
Sam Atkins
79a30c209d LibWeb: Add SVG-presentation-attribute-parsing mode to CSS parser
When parsing these, <number> is allowed anywhere that would usually
allow a <length>, <length-percentage>, or <angle>. The spec is not
clear on exactly how this should work
(see https://github.com/w3c/svgwg/issues/792 ) so I'm using some
artistic license until things are clearer:
- If we expected a <length>, treat the <number> as pixels.
- If we expected an <angle>, treat the <number> as degrees.
- Only allow direct <number> tokens, not calc() or other functions.

From what I can tell this is what the spec *intended* but I may be very
wrong. In any case, telling the ParsingContext whether we're parsing
one of these attributes is a cleaner approach and more correct than
temporarily enabling quirks mode, which we did previously.
2023-09-26 20:01:55 +02:00
Aliaksandr Kalenik
c46ce53ce3 LibJS: Declare HeapFunction::function() with [[nodiscard]] 2023-09-26 19:42:59 +02:00
Aliaksandr Kalenik
fe3a824ad4 Tests/LibWeb: Add basic tests for setTimeout and setInterval
It is useful to have at least very basic tests for those APIs :)
2023-09-26 19:42:59 +02:00
Aliaksandr Kalenik
4e8654e31b LibWeb: Use JS::HeapFunction for HTML::Timer callback
Before the completion_steps for timer were casted from JS::SafeFunction
to Function in HTML::Timer constructor, which is incorrect because then
callback's captured GC-allocated objects are not protected from being
deallocated. Let's modify HTML::Timer to use JS::HeapFunction for the
callback instead.
2023-09-26 19:42:59 +02:00
Aliaksandr Kalenik
883a97984c LibWeb: Use Core::Timer instead of Platform::Timer in HTML::Timer
By using Core::Timer that accepts Function instead of JS::SafeFunction
in Platform::Timer does we fix memory leak caused by circular
dependency of timer's callback and timer itself.
2023-09-26 19:42:59 +02:00
Aliaksandr Kalenik
67c727177e LibWeb: Clear all active timers when document is destroyed
This change implements a step from the document's destroy procedure in
the specification, saying that all active timers should be cleared.

By doing this, we also fix the leaking of a document in case where we
have navigated away from a page that has scheduled timers that haven't
yet been triggered.
2023-09-26 19:42:59 +02:00
stelar7
73ef102b01 LibCrypto: Add Chacha20Poly1305 2023-09-26 13:22:04 +03:30
Andreas Kling
4c5b9fa6a2 LibJS: Remove unused SetVariable::InitializationMode::InitializeOrSet 2023-09-26 09:38:32 +02:00
Tim Ledbetter
ba40526db2 ls: Add the -p option to append a trailing slash to directories
This overrides the `-F` option and vice-versa.
2023-09-26 07:19:02 +02:00
Ali Mohammad Pur
6820e0e175 LibWasm: Make sure to place imported functions before the module's
aafef1e92d broke this while trying to
make the global import available in initialisation, this commit makes
sure we place the module's own functions after all resolved imports.
2023-09-26 07:47:20 +03:30
Aliaksandr Kalenik
78f56a0908 LibJS: Use JS::HeapFunction in NativeFunction 2023-09-25 21:14:53 +02:00
Aliaksandr Kalenik
0c46d79e78 LibWeb: Use JS::HeapFunction for resumption steps in HTMLImageElement 2023-09-25 21:14:53 +02:00
Aliaksandr Kalenik
67aa86b5b6 LibWeb: Use JS::HeapFunction for AbortSignal callback 2023-09-25 21:14:53 +02:00
Aliaksandr Kalenik
baf37af09c LibWeb: Use JS::HeapFunction for callbacks in FetchController
If a function that captures a GC-allocated object is owned by another
GC-allocated object, it is more preferable to use JS::HeapFunction.
This is because JS::HeapFunction is visited, unlike introducing a new
heap root as JS::SafeFunction does.
2023-09-25 21:14:53 +02:00
Aliaksandr Kalenik
df86e52d75 LibWeb: Use JS::HeapFunction for callbacks in SharedImageRequest
If a function that captures a GC-allocated object is owned by another
GC-allocated object, it is more preferable to use JS::HeapFunction.
This is because JS::HeapFunction is visited, unlike introducing a new
heap root as JS::SafeFunction does.
2023-09-25 21:14:53 +02:00
Andreas Kling
4f488f7e07 LibJS: Avoid creating empty environment for catch without parameter
When there is no `catch` parameter to bind the error, we don't need
to allocate an environment, since there's nothing to add to it.

This avoids one environment allocation every time we catch like this:

    try {
        ...
    } catch {
        ...
    }
2023-09-25 19:47:24 +02:00
Cubic Love
4c64c0b61e Base+Maps: Add manpage for Maps
Also, list Maps in Applications.md and add a link to the manpage in
Map's Help menu.
2023-09-25 16:20:20 +01:00
Shannon Booth
47514e07b4 LibWeb: Make Element attribute getters take a StringView
These functions are deferring to NamedNodeMap::get_attribute which
already takes a StringView. This changes also leads to finding some
places which were passing though a const char* instead of an entry from
Attribute names. Fix that where applicable, and switch to has_attribute
in some of those places instead of deprecated_attribute where
equivalent.

Ideally this should be taking a 'FlyString const&', but to continue
porting away from DeprecatedString, just leave a FIXME for now.
2023-09-25 15:39:29 +02:00
Shannon Booth
dbf8ff64fb LibWeb: Add AttributeNames::list 2023-09-25 15:39:29 +02:00
Shannon Booth
3458a53cb4 LibWeb: Make Element::get_elements_by_class_name take a StringView
We only make use of the view of the view in this function.
2023-09-25 15:39:29 +02:00
Shannon Booth
79f97da4b4 LibWeb: Make Element::has_attribute take a StringView
It calls Element::get_attribute which takes a StringView. Ultimately,
this should be taking a FlyString, but to help in porting away from
DeprecatedString, just leave a FIXME for that for now.
2023-09-25 15:39:29 +02:00
Shannon Booth
52fccae654 LibWeb: Make Element::set_inner_html take a StringView
It delegates to DOMParsing::inner_html_setter, which already takes a
StringView.
2023-09-25 15:39:29 +02:00
Shannon Booth
dbd46f240b LibWeb: Make DOMParsing::parse_fragment take a StringView
It calls HTMLParser::parse_html_fragment which already accepts a
StringView.
2023-09-25 15:39:29 +02:00
Shannon Booth
ab674f3bf6 LibWeb: Make Element::remove_attribute take a StringView
It already delegates to a function which accepts a StringView, so there
is no advantage here in taking a FlyString. Ideally, both of these
functions should be taking a 'FlyString const&', so leave a FIXME for
that. In the meantime, this should help in porting away from
DeprecatedString.
2023-09-25 15:39:29 +02:00
Shannon Booth
fc7f79e0e7 LibWeb: Use Element::namespace_ instead of ELement::namespace_uri
These are equivalent, and should make our lives a little eaiser porting
over this IDL interface to new String.
2023-09-25 15:39:29 +02:00
Shannon Booth
3bd04d2c58 LibWeb: Port Attr interface from DeprecatedString to String
There are an unfortunate number of DeprecatedString conversions required
here, but these should all fall away and look much more pretty again
when other places are also ported away from DeprecatedString.

Leaves only the Element IDL interface left :^)
2023-09-25 15:39:29 +02:00
Aliaksandr Kalenik
a41f23a0fc LibWeb: Fix document leak in SVGDecodedImageData
The SVGDecodedImageData creates a new Page and replaces its document
with a new one that contains SVG content. This change adds a destroy
call on the replaced document. Without this addition, all tasks
scheduled on the event loop during navigation, initiated while the
page's traversable is being created, will never execute, as the
initial replaced document will become inactive. This leads to a
document leak because the tasks use JS::Handle to hold document
pointer. Making the destroy call resolves the issue because it removes
all tasks associated with the destroyed document from the queue.
2023-09-25 14:31:20 +02:00
Hendiadyoin1
12c6692611 LibJS: Defer GC during cell construction
This stops us from trying to collect not fully constructed Cells,
which's vtables are not fully initialized, which would cause issues
during GC.
2023-09-25 13:19:25 +02:00
Hendiadyoin1
87e063db65 LibJS: Make GC deferral friendship based 2023-09-25 13:19:25 +02:00
Matthias Zimmerman
9871bd4bec LibJS: Fix spelling in VM.cpp 2023-09-25 10:58:58 +02:00
Tim Ledbetter
f34b1c7a7e PixelPaint: Make tool properties widget construction non-fallible
`Tool::get_properties_widget()` now also returns a NNRP to a widget
rather than a raw pointer.
2023-09-25 10:58:31 +02:00
Tim Ledbetter
5df88dab07 FileManager: Make PropertiesWindow::make_button() non-fallible 2023-09-25 10:58:31 +02:00
Tim Ledbetter
b4e134cb52 Userland: Use non-fallible EventReceiver::add() where possible 2023-09-25 10:58:31 +02:00
Aliaksandr Kalenik
707ca984bd LibWeb: Fix memory leak in CSS::ImageStyleValue
Before this change, whenever ImageStyleValue had a non-null
`m_image_request`, it was always leaked along with everything related
to the document to which this value belongs. The issue arises due to
the use of `JS::Handle` for the image request, as it introduces a
cyclic dependency where `ImageRequest` prevents the `CSSStyleSheet`,
that owns `ImageStyleValue`, from being deallocated:
- ImageRequest
- FetchController
- FetchParams
- Window
- HTMLDocument
- HTMLHtmlElement
- HTMLBodyElement
- Text
- HTMLHeadElement
- Text
- HTMLMetaElement
- Text
- HTMLTitleElement
- Text
- HTMLStyleElement
- CSSStyleSheet

This change solves this by visiting `m_image_request` from
`visit_edges` instead of introducing new heap root by using
`JS::Handle`.
2023-09-25 04:16:36 +02:00
Shannon Booth
d81b0e3c86 LibWeb/Streams: Make ReadIntoRequest GC-allocated
This ports the same change which was made in 9c3e9e8981 to
ReadRequest, although nothing actually implements this interface yet.
2023-09-24 20:10:50 -06:00
Shannon Booth
acda17ccc4 LibWeb/Streams: Handle BYOB reader in ReadableStreamError 2023-09-24 20:10:50 -06:00
Tim Ledbetter
24aa43f3fd LibGUI: Use floating rect when saving window state on exit
Previously, exiting a fullscreen application when
`save_size_and_position_on_close()` was used would lead to the
application having an unexpectedly large size when it was reopened.

Exiting a maximized application would lead to the restore button not
working as expected when the application was reopened.
2023-09-24 20:07:54 -06:00
Tim Ledbetter
50d0d6e710 WindowServer: Add an IPC call to get the window floating rect 2023-09-24 20:07:54 -06:00