Commit graph

54874 commits

Author SHA1 Message Date
Aliaksandr Kalenik 15629e8925 LibWeb: Do not use JS::Handle for mutation observers
Using JS::Handle in WebEngineCustomData means that mutation observers
will live as long as VM while actually they should be deallocated as
soon as they are no longer used in a script that created them.
2023-09-27 16:33:21 +02:00
Aliaksandr Kalenik e7a3040c9f LibWeb: Do not use JS::Handle for TimerHandler
There is no need to use JS::Handle for timer handler because it is
visited from JS::HeapFunction in HTML::Timer.
2023-09-27 16:33:21 +02:00
Aliaksandr Kalenik 3a1f617fbf LibJS: Use Function as callback type in define_native_function/accessor
There is not need to use SafeFunction because
define_native_function or define_native_accessor will pass callback
forward to NativeFunction that uses HeapFunction to visit it.
2023-09-27 16:33:21 +02:00
circl 84f845494e Ladybird/Qt: Add support for color pickers 2023-09-27 12:16:41 +01:00
circl 3e1a154440 Browser: Add support for color pickers 2023-09-27 12:16:41 +01:00
circl 2995a2e212 LibWeb+LibWebView+WebContent: Add support for <input type="color">
This commit introduces 3 things:
- Support for the color type in HTMLInputElement itself
- A mechanism for handling non event loop blocking dialogs in Page
- The associated plumbing up to ViewImplementation

Frontends may add support for the color picker with the
ViewImplementation.on_request_color_picker function
2023-09-27 12:16:41 +01:00
Andreas Kling 759ad905de LibWeb: Remove FIXME about spec bug in page visibility
Because the spec bug got fixed \o/
2023-09-27 09:31:27 +02:00
Sönke Holz c42e8ddc48 LibELF: Calculate size of relocation table correctly in all cases
RELASZ might include the PLT table as well. Check if that is the case
and correct the size of the non-PLT relocation table.
2023-09-27 03:33:36 +02:00
kleines Filmröllchen 968038aa79 LibAudio: Use mapped files for audio playback
This is 10-20% of a speed increase on platforms with fast I/O (Linux)
and not a slowdown on Serenity. Again, the file system layer is the
limit for us :^)
2023-09-27 03:22:56 +02:00
kleines Filmröllchen d6571f54d8 LibCore: Make MappedFile a Stream
The internal reuse of FixedMemoryStream makes this straightforward.
There alread is one user of the new API, demonstrating the need for this
change beyond what I said out to use it for :^)
2023-09-27 03:22:56 +02:00
kleines Filmröllchen 062e0db46c LibCore: Make MappedFile OwnPtr-based
Since it will become a stream in a little bit, it should behave like all
non-trivial stream classes, who are not primarily intended to have
shared ownership to make closing behavior more predictable. Across all
uses of MappedFile, there is only one use case of shared mapped files in
LibVideo, which now uses the thin SharedMappedFile wrapper.
2023-09-27 03:22:56 +02:00
kleines Filmröllchen 5b2496e522 AK: Make writability violation of FixedMemoryStream non-fatal
Writing to a read-only file is not a program-crashing error either, so
we just return the standard EBADFD (see write(2)) here.
2023-09-27 03:22:56 +02:00
kleines Filmröllchen bbeabe929b AK: Allow specifying writability of a FixedMemoryStream 2023-09-27 03:22:56 +02:00
kleines Filmröllchen 644d9c784d AK: Make FixedMemoryStream non-final 2023-09-27 03:22:56 +02:00
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