Commit Graph

28600 Commits

Author SHA1 Message Date
Aliaksandr Kalenik
b43b3d2f8d LibWeb: Null check container while creating srcdoc navigation params
Fixes https://github.com/SerenityOS/serenity/issues/21205
Fixes https://github.com/SerenityOS/serenity/issues/21240
2023-09-28 06:09:52 +02:00
Andreas Kling
feedbd6a01 LibJS: Put __builtin_unreachable() in unused bytecode opcode handlers
For the opcodes that are handled directly in the interpreter loop,
we want the compiler to know that there's nothing to inline here.
2023-09-28 06:09:16 +02:00
Andreas Kling
f3606adc58 LibJS: Inline bytecode ops for direct local/register access
These can do a lot less stuff if we put them directly in the interpreter
loop and allow them to access the locals/registers arrays directly.
2023-09-28 06:09:16 +02:00
Andreas Kling
ae1ac9871b LibJS: Move all bytecode instruction implementations to Interpreter.cpp
This allows aggressive inlining without LTO.
2023-09-28 06:09:16 +02:00
Andreas Kling
e5474c384d LibJS: Inline flow control ops in the bytecode interpreter loop
Instead of calling out to helper functions for flow control (and then
checking control flags on every iteration), we now simply inline those
ops in the interpreter loop directly.
2023-09-28 06:09:16 +02:00
Andreas Kling
39cfb64269 LibJS: Return early from Interpreter on unhandled exception
If we don't have a local unwind context to handle the exception, we can
just return right away. This allows us to remove one check from the
inner loop.
2023-09-28 06:09:16 +02:00
Andreas Kling
c9eff35b96 LibJS: Use goto instead of bool will_jump in interpreter loop
This is honestly less spaghetti-ish.
2023-09-28 06:09:16 +02:00
Andreas Kling
9fe38245b2 LibJS: Move bytecode interpreter's inner loop to its own function 2023-09-28 06:09:16 +02:00
Andreas Kling
951a85992b LibJS: Mark the exception path as [[unlikely]] in the interpreter loop 2023-09-28 06:09:16 +02:00
Andreas Kling
031ec98803 LibJS: Streamline InstructionStreamIterator
Nuke all the per-instruction bounds checking when iterating instructions
by using raw pointers instead of indexing into a ReadonlyBytes.

The interpreter loop already checks that we're in-bounds anyway.
2023-09-28 06:09:16 +02:00
Andreas Kling
213b835b57 LibJS: Remove Bytecode::Interpreter::debug_position()
This was only used in one place, and that place is already covered
by a VERIFY anyway.
2023-09-28 06:09:16 +02:00
Andreas Kling
0c746366cc LibJS: Keep return value in a call frame register 2023-09-28 06:09:16 +02:00
Andreas Kling
c833885fb5 LibJS: Keep cached this value in a call frame register
Just moving more things to call frame registers..
2023-09-28 06:09:16 +02:00
Andreas Kling
3887b840a3 LibJS: Keep current exception in a call frame register
Instead of keeping it in a Bytecode::Interpreter member, move it into
a dedicated call frame register.
2023-09-28 06:09:16 +02:00
Tim Ledbetter
ebb822def9 less: Add the -F option to quit if the input fits on one screen 2023-09-27 20:00:34 +02:00
Tim Ledbetter
938a287d3e ls: Left justify owner and group information in long format 2023-09-27 19:58:17 +02:00
Tim Ledbetter
cb1851f3cc ls: Add the -g option to omit owner information in long format 2023-09-27 19:58:17 +02:00
Tim Ledbetter
d618ef58fb ls: Display results in long format when -n or -o are used 2023-09-27 19:58:17 +02:00
Aliaksandr Kalenik
dc19de58d0 LibWeb: Do not use JS::Handle for "scripts to execute" in DOM::Document
Using JS::Handle in members of GC-allocated object almost always leaks.
Instead we should visit these members in visit_edges().
2023-09-27 19:39:57 +02:00
Aliaksandr Kalenik
cad2d2c85b LibWeb: Use JS::HeapFunction for DocumentObserver callbacks
If GC-allocated object wants to own a function it should use
HeapFunction because using SafeFunction will almost always lead to a
leak.
2023-09-27 19:39:57 +02:00
Tim Ledbetter
12adaac08d GameOfLife: Don't toggle cells on mouse move when placing patterns
Previously, it was very easy to inadvertently toggle cells when
placing a pattern by dragging the mouse slightly.
2023-09-27 19:12:14 +02:00
Tim Ledbetter
6eaae726fa GameOfLife: Clear the selected pattern when the game starts running 2023-09-27 19:12:14 +02:00
Tim Ledbetter
4b48757586 GameOfLife: Allow ctrl+click to place multiple patterns 2023-09-27 19:12:14 +02:00
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
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
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
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