Commit graph

33891 commits

Author SHA1 Message Date
Andreas Kling 2aab56bf71 LibJS: Null-check current executable in VM::dump_backtrace()
If there is no current executable (because we're in a native function
call), we shouldn't try to dereference it.
2024-05-27 17:33:29 +02:00
Andreas Kling 802af5ad9d LibWeb: Allow Element.insertAdjacentHTML on the document element
This fixes wpt/domparsing/insert_adjacent_html.html
2024-05-27 17:33:29 +02:00
Andreas Kling f12dae7ea4 LibWeb: Update spec link & comments in Element.insertAdjacentHTML()
This has moved from DOM Parsing to HTML, and the comments are slightly
different.
2024-05-27 17:33:29 +02:00
Andreas Kling e7febd347b LibWeb: Don't advertise the empty string as HTMLCollection property name
This fixes wpt/dom/collections/HTMLCollection-empty-name.html
2024-05-27 17:33:29 +02:00
MacDue 8988dce93d LibGfx: Add early bounds checking to accumulate_non_zero_scanline()
Nonzero fills are much more common (as the default fill rule), so if
this does result in any speed-up it makes sense to do it here too.
2024-05-27 13:02:17 +02:00
MacDue 9a3470c2c5 LibGfx: Fix bounds checking in accumulate_even_odd_scanline()
`edge_extent.max_x` is inclusive so it must be < `m_scanline.size()`.
2024-05-27 13:02:17 +02:00
Diego e345d65def LibWasm: Use TRY macro when possible
This removes a lot of the error handling boilerplate, and is more
consistent with the rest of the codebase.
2024-05-27 12:44:21 +02:00
Aliaksandr Kalenik 0eeae7ff24 LibWeb: Use stack to represent blit/sample corners commands state
...instead of allocating separate BorderRadiusCornerClipper for each
executed sample/blit commands pair.

With this change a vector of BorderRadiusCornerClipper has far fewer
items. For example on twitter profile page its size goes down from
~3000 to ~3 items.
2024-05-27 04:26:17 +02:00
Aliaksandr Kalenik 9b65a2731b LibWeb: Remove clipper creation error check in sample_under_corners()
Before, this check was needed to prevent crashing when attempting to
allocate zero-size bitmap for sampled corners, which could have happened
if a corner had 0 radius in one axis.

Now, since SampleUnderCorners command is not emmited when radius is 0
in one axis, this check is no longer needed.
2024-05-27 04:26:17 +02:00
Aliaksandr Kalenik 9be65e35b5 Revert "LibGfx+LibWeb: Do not ignore corner radius if it is defined..."
This reverts commit 6b7b9ca1c4.

The whole corner radius is invisible if it has 0 radius in any axis, so
the reverted commit was a mistake that led to error checking during
painting command execution b61aab66d9 to
avoid crashing on attempt to allocate 0 size bitmap.
2024-05-27 04:26:17 +02:00
Aliaksandr Kalenik 49f75d2c0f LibWeb: Verify each sample corners command has matching blit command 2024-05-27 04:26:17 +02:00
Aliaksandr Kalenik 1a6cf7fadc LibWeb: Fix blit corner clipping command recording order
Before:
- sample corners id = 0
- sample corners id = 1
- sample corners id = 2
- blit corners   id = 0
- blit corners   id = 1
- blit corners   id = 2

After:
 - sample corners id = 0
 - sample corners id = 1
 - sample corners id = 2
 - blit corners   id = 2
 - blit corners   id = 1
 - blit corners   id = 0
2024-05-27 04:26:17 +02:00
Nico Weber 1a9d8e8fbe LibCompress: When limiting huffman tree depth, sacrifice bottom of tree
Deflate and WebP can store at most 15 bits per symbol, meaning their
huffman trees can be at most 15 levels deep.

During construction, when we hit this level, we used to try again
with an ever lower frequency cap per symbol. This had the effect
of giving the symbols with the highest frequency lower frequencies
first, causing the most-frequent symbols to be merged. For example,
maybe the most-frequent symbol had 1 bit, and the 2nd-frequent
two bits (and everything else at least 3). With the cap, the two
most frequent symbols might both have 2 symbols, freeing up bits
for the lower levels of the tree.

This has the effect of making the most-frequent symbols longer at
first, which isn't great for file size.

Instead of using a frequency cap, ignore ever more of the low
bits of the frequency. This sacrifices resolution where it hurts
the lower levels of the tree first, and those are stored less
frequently.

For deflate, the 64 kiB block size means this doesn't have a big
effect, but for WebP it can have a big effect:

sunset-retro.png (876K): 2.02M -> 1.73M -- now (very slightly) smaller
than twice the input size! Maybe we'll be competitive one day.

(For wow.webp and 7z7c.webp, it has no effect, since we don't hit
the "tree too deep" case there, since those have relatively few
colors.)

No behavior change other than smaller file size. (No performance
cost either, and it's less code too.)
2024-05-26 21:00:55 +02:00
Nico Weber 2023e8d8d9 LibCompress: Use saturating add in generate_huffman_lengths()
For our deflate, block size is limited to less than 64 kiB, so the sum
of all byte frequencies always fits in a u16 by construction.

But while I haven't hit this in practice, but it can conceivably happen
when writing WebP files, which currently use a single huffman tree
(per channel) for a while image -- which is often much larger than
64 kiB.

No dramatic behavior change in practice, just feels more correct.
2024-05-26 21:00:55 +02:00
Nico Weber 0711e9d749 LibGfx/WebPWriter: Use huffman compression
This implements some of basic webp compression: Huffman coding.
(The other parts of the basics are backreferences, and color cache
entries; and after that there are the four transforms -- predictor,
subtract green, color indexing, color.)

How much huffman coding helps depends on the input's entropy.
Constant-color channels are now encoded in constant space, but
otherwise a huffman code always needs at least one bit per symbol.
This means just huffman coding can at the very best reduce output
size to 1/8th of input size.

For three test input files:

sunset-retro.png (876K): 2.25M -> 2.02M
(helps fairly little; from 2.6x as big as the png input to 2.36x)

giphy.gif (184k): 11M -> 4.9M
(pretty decent, from 61x as big as the gif input to 27x as big)

7z7c.gif (11K): 775K -> 118K
(almost as good as possible an improvement for just huffman coding,
from 70x as big as the gif input to 10.7x as big)

No measurable encoding perf impact for encoding.

The code is pretty similar to Deflate.cpp in LibCompress, with just
enough differences that sharing code doesn't look like it's worth
it to me. I left comments outlining similarities.
2024-05-26 19:02:49 +02:00
Nico Weber a01fdca2de LibCompress: Use named EndOfBlock constant
No behavior change.
2024-05-26 19:02:49 +02:00
Nico Weber ff6d58f321 LibCompress: Pass ReadonlyBytes to encode_huffman_lengths()
...instead of Array and length. No behavior change.
2024-05-26 19:02:49 +02:00
Nico Weber 5c81b4b269 LibCompress: Make encode_block_lengths() a bit less clever
No behavior change.
2024-05-26 19:02:49 +02:00
Nico Weber 756a8fa02d LibGfx/WebP: Move kCodeLengthCodeOrder to WebPSharedLossless.h
...and make it an Array while at it.

(This makes it look a little less like the spec, but that seems
worth it.)

No behavior change.
2024-05-26 19:02:49 +02:00
Nico Weber d95e4831be LibCompress: Move generate_huffman_lengths() to a .h file
To be used in WebPWriter.

JPEGWriter currently hardcodes huffman tables; maybe it can use this
to build data-dependent huffman tables in the future as well.

Pure code move (except for removing the `DeflateCompressor::` prefix
on the function's name, and putting the default argument for the 4th
argument in the function's definition), no behavior change.
2024-05-26 19:02:49 +02:00
Lucas CHOLLET f0269daeb6 LibGfx: Make Color::NamedColor be an enum class
As this is used extensively across the codebase, the change would add a
lot of noise. To prevent it, let's also add an `using enum` declaration.
2024-05-26 18:51:52 +02:00
Lucas CHOLLET 5b2356b452 WebContent+WebWorker: Don't set the color value to the index of an enum
The NamedColor would be casted to its underlying int to fit the ARGB on
the left hand side.
2024-05-26 18:51:52 +02:00
Timothy Flynn eb3b8f8ee4 LibWeb: Implement EventSource for server-sent events
EventSource allows opening a persistent HTTP connection to a server over
which events are continuously streamed.

Unfortunately, our test infrastructure does not allow for automating any
tests of this feature yet. It only works with HTTP connections.
2024-05-26 18:29:24 +02:00
Timothy Flynn 79223f3e1b LibWeb: Correctly check the document's salvageable state during cleanup
The condition here was flipped.
2024-05-26 18:29:24 +02:00
Timothy Flynn 88d46b51ed LibWeb: Implement operation to error a ReadableStream 2024-05-26 18:29:24 +02:00
Timothy Flynn 2a2c59e74b LibWeb: Partially implement the ReadableStream pull-from-bytes AO
We do not handle BYOB request views yet, as they are not needed for the
upcoming usage of this AO.
2024-05-26 18:29:24 +02:00
Timothy Flynn 9cc186b929 LibWeb: Implement the "queue a task" steps as a distinct AO
This will be needed by EventSource.
2024-05-26 18:29:24 +02:00
Timothy Flynn b6f824a313 Browser: Don't assume downloads have a "total size" available
Ran into a crash here while testing LibProtocol changes. The method we
invoke here (did_progress) already accepts an Optional, and handles when
that Optional is empty. So there's no need to assume `total_size` is
non-empty.
2024-05-26 18:29:24 +02:00
Timothy Flynn 6056428cb5 LibWeb: Support unbuffered fetch requests
Supporting unbuffered fetches is actually part of the fetch spec in its
HTTP-network-fetch algorithm. We had previously implemented this method
in a very ad-hoc manner as a simple wrapper around ResourceLoader. This
is still the case, but we now implement a good amount of these steps
according to spec, using ResourceLoader's unbuffered API. The response
data is forwarded through to the fetch response using streams.

This will eventually let us remove the use of ResourceLoader's buffered
API, as all responses should just be streamed this way. The streams spec
then supplies ways to wait for completion, thus allowing fully buffered
responses. However, we have more work to do to make the other parts of
our fetch implementation (namely, Body::fully_read) use streams before
we can do this.
2024-05-26 18:29:24 +02:00
Timothy Flynn 1e97ae66e5 LibWeb: Support unbuffered resource load requests
This adds an alternate API to ResourceLoader to load HTTP/HTTPS/Gemini
requests unbuffered. Most of the changes here are moving parts of the
existing ResourceLoader::load method to helper methods so they can be
re-used by the new ResourceLoader::load_unbuffered.
2024-05-26 18:29:24 +02:00
Timothy Flynn 168d28c15f LibProtocol+Userland: Support unbuffered protocol requests
LibWeb will need to use unbuffered requests to support server-sent
events. Connection for such events remain open and the remote end sends
data as HTTP bodies at its leisure. The browser needs to be able to
handle this data as it arrives, as the request essentially never
finishes.

To support this, this make Protocol::Request operate in one of two
modes: buffered or unbuffered. The existing mechanism for setting up a
buffered request was a bit awkward; you had to set specific callbacks,
but be sure not to set some others, and then set a flag. The new
mechanism is to set the mode and the callbacks that the mode needs in
one API.
2024-05-26 18:29:24 +02:00
Timothy Flynn 086ddd481d Ladybird+LibWeb: Move User-Agent definitions to their own file
This is to avoid including any LibProtocol header in Objective-C source
files, which will cause a conflict between the Protocol namespace and a
@Protocol interface.

See Ladybird/AppKit/Application/ApplicationBridge.cpp for why this
conflict unfortunately cannot be worked around.
2024-05-26 18:29:24 +02:00
Aliaksandr Kalenik 663cc753a7 LibWeb: Fix clip box calculation in PaintableWithLines
All painting commands except SetClipRect are shifted by scroll offset
before command list execution. This change removes scroll offset
translation for sample/blit corner commands in
`PaintableWithLines::paint` so it is only applied once in
`CommandList::apply_scroll_offsets()`.
2024-05-26 16:11:53 +01:00
Aliaksandr Kalenik 7855d4a8f5 LibWeb: Transform blit corner clipping rectangle to device pixels
Rectangle saved in this command is only used to filter by bounding box,
so the problem was not very visible before.
2024-05-26 16:11:53 +01:00
Aliaksandr Kalenik 3d8349eb88 LibWeb: Fix blit corner clip position in PaintableWithLines
Fixes the bug when blit and sample commands position didn't match.

Before:
1. Emit sample under corners
2. Apply scroll offset
3. Paint content
3. Blit corner clipping

After:
1. Emit sample under corners
2. Save state
3. Apply scroll offset
4. Paint content
5. Restore state
6. Blit corner clipping
2024-05-26 16:11:53 +01:00
Lucas CHOLLET 09f4032eeb LibGfx/PNG: Read metadata from the eXIf chunk
The test image comes from this WPT test:
http://wpt.live/png/exif-chunk.html
2024-05-26 14:54:43 +01:00
Shannon Booth f28bb90d9b LibJS: Remove non-spec compliant code from internal_construct
It seems that we are now spec compliant enough to be able to remove this
code block :^)

Diff Tests:
    +2     -2 
2024-05-26 12:29:41 +02:00
MacDue 9e2c4f84fd LibWeb: Paint/apply basic-shape clip paths to PaintableBoxes
Currently, these only work when there are no CSS transforms (as the
stacking context painting is not set up to handle that case yet). This
is still enough to get most chat/comment markers working on GitHub
though :^)
2024-05-26 07:55:50 +02:00
MacDue 517379ff80 LibWeb: Resolve basic-shape clip-paths
These will be ignored within SVGs (for now SVGs only support <clipPath>
elements), but will allow clipping standard HTML elements.
2024-05-26 07:55:50 +02:00
MacDue 0135af6e60 Meta: Add basic-shape as a CSS property value type 2024-05-26 07:55:50 +02:00
MacDue 120915048c LibWeb: Parse the polygon() basic shape function 2024-05-26 07:55:50 +02:00
MacDue 5f17d9b34a LibWeb: Add BasicShapeStyleValue to represent CSS basic shapes
See: https://www.w3.org/TR/css-shapes-1/#basic-shape-functions

This patch only implements the `polygon()` basic shape (with the rest
left as FIXMEs).
2024-05-26 07:55:50 +02:00
Shannon Booth 71ccd8ad25 LibWeb: Implement BaseAudioContext.createBuffer
This is a simple factory function which effectively just calls the
AudioBuffer constructor.
2024-05-26 07:49:49 +02:00
Shannon Booth 17ae65cedc LibWeb: Implement AudioBuffer.copyToChannel 2024-05-26 07:48:37 +02:00
Shannon Booth 848d6f5074 LibWeb: Add const qualified BufferableObjectBase::raw_object 2024-05-26 07:48:37 +02:00
Shannon Booth 67b1f4af55 LibWeb: Implement HTMLFormElement.encoding 2024-05-26 07:47:59 +02:00
Shannon Booth aeb815cc66 LibWeb: Implement HTMLFormElement.enctype 2024-05-26 07:47:59 +02:00
Matthew Olsson a8ef84f8c3 LibWeb: Use LengthPercentage for calc values in Transformation matrix 2024-05-25 22:19:47 +02:00
Aliaksandr Kalenik e2b2b2439c LibWeb: Apply corner clip before scroll offset for PaintableWithLines
Fixes bug when corner clip mask moves along with the scrolled text.
2024-05-25 22:19:40 +02:00
Diego ba5192b2e7 LibWasm: Use u32's instead of size_t's when reading LEB128 numbers
The WebAssembly spec never relies on host system information, like
size_t. For consistency's sake, we should stick to the usage of u32's
instead of size_t's. This didn't cause issues before because
LEB128-encoded u64's are a superset of LEB128-encoded u32's.
2024-05-25 21:24:14 +02:00
Diego ed8d036b41 LibWasm: Properly read data section tags
The previous version of the function read the tag as a u8. However, as
per the spec, the tag of the data section should be a u32, LEB128
encoded.

https://webassembly.github.io/spec/core/binary/modules.html#data-section
2024-05-25 16:13:15 +02:00
Lucas CHOLLET fb79aa6159 LibGfx/GIF: Correctly write frames with a non-null position 2024-05-25 06:42:15 +01:00
Aliaksandr Kalenik 05f9733192 LibGfx: Make accumulate_even_odd_scanline() go faster
...by checking scanline vector bounds before entering the loop.
2024-05-24 12:34:52 +02:00
Aliaksandr Kalenik c413cd0f74 LibWbe: Skip recording of empty painting commands
- Less allocations
- Optimization pass that skips unnecessary sample/blit corner commands
  could be more effecient by ignoring corner radius clipping for empty
  painting commands
2024-05-24 12:34:52 +02:00
Aliaksandr Kalenik 3f3f3766be LibWeb: Make sample_under_corners() go faster
Both page target bitmap and mask bitmap are always BGRA8888, so we can
use `get_pixel<StorageFormat::BGRA8888>` and
`set_pixel<StorageFormat::BGRA8888>` to avoid branching by not
checking a bitmap format.
2024-05-24 12:34:52 +02:00
Matthew Olsson 15a8baee03 LibWeb: Save time for animationcancel event before transitioning to idle
The if statement in the dispatch implies we are in the idle state, so of
course the active time will always be undefined. If this was cancelled
via a call to cancel(), we can save the time at that point. Otherwise,
just send 0.
2024-05-24 07:25:10 +02:00
Lucas CHOLLET b30c361b08 LibWeb/Fetch: Implement logic to process a response from HTTP's cache
Co-Authored-By: Andrew Kaster <akaster@serenityos.org>
2024-05-23 13:25:29 -04:00
Lucas CHOLLET fcbc6123bb LibWeb/Fetch: Add freshness notion to HTTP::Response
Defined in RFC9111 "HTTP Caching".

Co-Authored-By: Andrew Kaster <akaster@serenityos.org>
2024-05-23 13:25:29 -04:00
Andrew Kaster c05f296014 LibWeb: Start adding infrastructure for an HTTP Cache 2024-05-23 13:25:29 -04:00
Andrew Kaster a40b331f39 LibWeb: Update steps of HTTP-network-or-cache-fetch per the latest spec
One step was added since we last visited this AO.
2024-05-23 13:25:29 -04:00
Andreas Kling 9c205537e1 LibWeb: Add missing navigable null check in Document::open()
I saw a null pointer dereference here on GitHub once, but don't know how
to reproduce, or how we'd get here. Nevertheless, null-checking the
navigable is reasonable so let's do it.
2024-05-23 13:58:12 +02:00
Aliaksandr Kalenik 63a56a77a2 LibJS: Add fast ExecutionContext allocator
...that maintains a list of allocated execution contexts so malloc()
does not have to be called every time we need to get a new one.

20% improvement in Octane/typescript.js
16% improvement in Kraken/imaging-darkroom.js
2024-05-23 13:36:02 +02:00
Andreas Kling f4636a0cf5 LibWeb: Stop spamming animation events on the wrong event target
This patch fixes two issues:

- Animation events that should go to the target element now do
  (some were previously being dispatched on the animation itself.)
- We update the "previous phase" and "previous iteration" fields of
  animation effects, so that we can actually detect phase changes.
  This means we stop thinking animations always just started,
  something that caused each animation to send 60 animationstart
  events every second (to the wrong target!)
2024-05-23 12:10:06 +02:00
Andrew Kaster a68222f654 LibWeb: Enable callbacks in chunk steps for ReadableStreamDefaultTee
We enqueue a microtask for this readable stream AO, and the methods that
we call from the chunk steps manipulate promises. As such, we need to
enable callbacks for the entire microtask's temporary execution
context.
2024-05-23 11:22:44 +02:00
Andrew Kaster bab546472e LibWeb: Mark FontFaceSet as a setlike IDL interface
And implement more of the constructor logic.
2024-05-23 10:57:34 +02:00
Andrew Kaster 7077e4d002 LibIDL+LibWeb: Add support for WebIDL setlike declarations on interfaces 2024-05-23 10:57:34 +02:00
Aliaksandr Kalenik f29ac8517e LibJS: Skip ordinary_call_bind_this() when possible
If during parsing it was found that function won't use `this` then
there is no need to initialise `this_value` during call.
2024-05-23 09:53:31 +02:00
Aliaksandr Kalenik e934132442 LibJS+LibWeb: Pass function metadata collected in parsing using a struct
By using separate struct we can avoid updating AST node and
ECMAScriptFunctionObject constructors every time there is a need to
add or remove some additional information colllected during parsing.
2024-05-23 09:53:31 +02:00
Ali Mohammad Pur 8b1341c77e LibWeb: Make exported Wasm functions keep the module instance alive
As it's not uncommon for users to drop the module instance on the floor
after having grabbed the few exports they need to hold on to.
Fixes a few UAFs that show up as "invalid" accesses to
memory/tables/etc.
2024-05-23 00:55:56 -06:00
dgaston 2d5cb1e02d Chess: Add display widget for moves
Adds a TextEditor widget to the chess application to display move
history. It is updated whenever Board::apply_move is called to reflect
the current board state.
2024-05-22 23:24:45 -06:00
Matthew Olsson a98ad191c7 Userland: Add ESCAPING annotations to a bunch of places
This isn't comprehensive; just a result of a simple grep search.
2024-05-22 21:55:34 -06:00
Matthew Olsson a5f4c9a632 AK+Userland: Remove NOESCAPE
See the next commit for an explanation
2024-05-22 21:55:34 -06:00
Andreas Kling 899c38d342 LibWeb: Mark IDBFactory.open() with FIXME extended attribute in IDL
The stub implementation broke x.com and probably other sites as well,
but let's at least mark it FIXME so we get some debug logging about it.
2024-05-22 21:46:08 +02:00
Andreas Kling 79870bc603 Revert "LibWeb: Add stub for IDBFactory.open"
This reverts commit f7beea1397.

This broke loading https://x.com/
2024-05-22 21:40:52 +02:00
Lucas CHOLLET 07446bbea1 LibGfx/GIF: Use the correct reference to seek before the trailer
This was working with files, but with pre-allocated buffers, the end
is not the same position as last written byte.
2024-05-22 13:29:05 -04:00
Lucas CHOLLET 3c4b8749f0 LibGfx/GIF: Write a Graphic Control Extension block
This allows us to write the duration of each frame.
2024-05-22 13:29:05 -04:00
Lucas CHOLLET bee8dd76ee LibGfx/GIF: Write the netscape extension block
This allows us to encode the required number of loops in the file.
2024-05-22 13:29:05 -04:00
Aliaksandr Kalenik ebb3d8025c LibJS: Get this from execution context for non-arrow functions
Allows to skip function environment allocation for non-arrow functions
if the only reason it is needed is to hold `this` binding.

The parser is changed to do following:
- If a function is an arrow function and uses `this` then all functions
  in a scope chain are marked to allocate function environment for
  `this` binding.
- If a function uses `new.target` then all functions in a scope chain
  are marked to allocate function environment.

`ordinary_call_bind_this()` is changed to put `this` value in execution
context when function environment allocation is skipped.

35% improvement in Octane/typescript.js
50% improvement in Octane/deltablue.js
19% improvement in Octane/raytrace.js
2024-05-22 18:30:13 +02:00
Dan Klishch 7ae990d2e5 LibCrypto: Don't compute 2*N remainders in Adler32
Otherwise Zlib decompression spends half of the time computing the
checksum.
2024-05-22 14:25:21 +02:00
Nico Weber b7b51d01c3 LibGfx/AnimationWriter: Survive animations with two identical frames
Creating a completely empty bitmap fails. Just write a 1x1 bitmap
if the bitmap ends up empty for now.
2024-05-22 06:41:47 -04:00
Nico Weber 51617929dc LibGfx/GIFLoader: Add more debug logging output 2024-05-22 06:41:47 -04:00
Dan Klishch 5a85067b49 Revert "LibCore: Add Core::deferred_invoke_if(F, Condition)"
This reverts commit a362c37c8b.

The commit tried to add an unused function that continued our tradition
of not properly waiting for things but instead flooding event loop with
condition checks that delay firing of the event. I think this is a
fundamentally flawed approach. See also checks for
`fire_when_not_visible` in LibCore/EventLoopImplementationUnix.cpp.
2024-05-21 23:32:54 +02:00
Tim Ledbetter c0e504fbdd LibWeb: Add some missing [FIXME] IDL attributes 2024-05-21 19:29:04 +02:00
Tim Ledbetter 58bb5e1f7a LibWeb: Use [Reflect] to implement HTMLPreElement.width 2024-05-21 19:28:43 +02:00
Tim Ledbetter 2a7cf1c588 LibWeb: Implement the width and height attributes where missing
This change adds the `width` and `height` properties to
`HTMLVideoElement` and `HTMLSourceElement`. These properties reflect
their respective content attribute values.
2024-05-21 19:28:43 +02:00
Tim Ledbetter 9f9aa62128 LibWeb: Implement the hspace and vspace attributes
These properties reflect their respective content attributes.
2024-05-21 19:28:43 +02:00
Aliaksandr Kalenik 4d37b9e715 LibJS: Do not count arguments as env binding when local variable is used
This is a follow up for 210a5d77dc that
actually allows to skip function environment allocation.
2024-05-21 15:49:29 +00:00
Dan Klishch 38b51b791e AK+Kernel+LibVideo: Include workarounds for missing P0960 only in Xcode
With this change, ".*make.*" function family now does error checking
earlier, which improves experience while using clangd. Note that the
change also make them instantiate classes a bit more eagerly, so in
LibVideo/PlaybackManager, we have to first define SeekingStateHandler
and only then make() it.

Co-Authored-By: stelar7 <dudedbz@gmail.com>
2024-05-21 14:24:59 +02:00
Ali Mohammad Pur 960a4b636c RequestServer: Account for null sockets in recreate_socket_if_needed()
A connection's socket is allowed to be null if it's being recreated
after a failed connect(), this was handled correctly in
request_did_finish but not in recreate_socket_if_needed; this commit
fixes this oversight.
2024-05-21 11:25:08 +02:00
Aliaksandr Kalenik 210a5d77dc LibJS: Use a local variable for arguments object when possible
This allows us to skip allocating a function environment in cases where
it was previously impossible because the arguments object needed a
binding.

This change does not bring visible improvement in Kraken or Octane
benchmarks but seems useful to have anyway.
2024-05-21 11:24:50 +02:00
Lucas CHOLLET 777e84b09b LibGfx+animation: Support writing animated GIF files 2024-05-21 09:47:46 +02:00
Lucas CHOLLET 6a5f8b5163 LibGfx/GIF: Make write_logical_descriptor() take an IntSize
The bitmap was only needed for its size.
2024-05-21 09:47:46 +02:00
Kenneth Myhra 29112f7365 LibWeb: Integrate Streams in XHR::send() 2024-05-20 16:57:52 -04:00
Kenneth Myhra 76418f3ffa LibWeb: Implement the concept incrementally read a body 2024-05-20 16:57:52 -04:00
Kenneth Myhra 34ecc59508 LibWeb: Implement read a chunk concept for ReadableStreamDefaultReader 2024-05-20 16:57:52 -04:00
Kenneth Myhra 50f454fdd5 LibWeb: Enqueue body chunks in Fetch::extract_body()
Co-authored-by: Timothy Flynn <trflynn89@pm.me>
2024-05-20 16:57:52 -04:00
Kenneth Myhra f119ac1a9d LibWeb: Integrate TransformStream into fetch_response_handover() 2024-05-20 16:57:52 -04:00
Kenneth Myhra 5a3e603b3d LibWeb: Implement AO transform_stream_set_up() 2024-05-20 16:57:52 -04:00
Kenneth Myhra f3ecdb22d5 LibWeb: Implement ReadableStream::close() 2024-05-20 16:57:52 -04:00
Kenneth Myhra e2c4019bfc LibWeb: Close acquired writer in AO readable_stream_pipe_to()
Also adds a test to prove that the WritableStream's close callback is
called.
2024-05-20 16:57:52 -04:00
Kenneth Myhra 15b677385c LibWeb: Provide an UInt8Array to AO writable_stream_default_writer_write
ReadLoopReadRequest::on_chunk expects an UInt8Array, so make sure we
convert the passed in ByteBuffer to an UInt8Array before passing it to
the AO writable_stream_default_writer_write.

Co-authored-by: Timothy Flynn <trflynn89@pm.me>
2024-05-20 16:57:52 -04:00
Timothy Flynn b5ba60f1d1 LibWeb: Change Fetch's ProcessBodyError to accept a plain JS value
This callback is meant to be triggered by streams, which does not always
provide a WebIDL::DOMException. Pass a plain value instead. Of all the
users of this callback, only one actually uses the value, and already
converts the DOMException to a plain value.
2024-05-20 16:57:52 -04:00
Timothy Flynn fb9c8324d9 LibThreading: Remove extra spammy log message upon starting a thread 2024-05-20 11:28:34 -06:00
Lucas CHOLLET a8bac0adc1 LibGfx/WebP: Use default initializer for CanonicalCode::m_code
No behavior change.
2024-05-20 13:17:34 -04:00
Nico Weber d294f150ed LibGfx+LibCompress: WebPWriter performance regression reduction
This moves both Gfx::CanonicalCode::write_symbol() and
Compress::CanonicalCode::write_symbol() inline.

It also adds `__attribute__((always_inline))` on the arguments
to visit() in the latter. (ALWAYS_INLINE doesn't work on lambdas.)

Numbers with `ministat`: I ran once:

    Build/lagom/bin/image -o test.bmp Base/res/wallpapers/sunset-retro.png

and then ran to bench:

    ~/src/hack/bench.py -n 20 -o bench_foo1.txt \
        Build/lagom/bin/image -o test.webp test.bmp

...and then `ministat bench_foo1.txt bench_foo2.txt` to compare.

The previous commit increased the time for this command by 38% compared
to the before state.

With this, it's an 8.6% regression. So still a regression, but a smaller
one.

Or, in other words, this commit reduces times by 21% compared to the
previous commit.

Numbers with hyperfine are similar -- with this on top of the previous
commit, this is a 7-11% regression, instead of an almost 50% regression.

(A local branch that changes how we compute CanonicalCodes so that we
actually compress a bit is perf-neutral since the image writing code
doesn't change.)

`hyperfine 'image -o test.webp test.bmp'`:
* Before:          23.7 ms ± 0.7 ms (116 runs)
* Previous commit: 33.2 ms ± 0.8 ms (82 runs)
* This commit:     25.5 ms ± 0.7 ms (102 runs)

`hyperfine 'animation -o wow.webp giphy.gif'`:
* Before:           85.5 ms ± 2.0 ms (34 runs)
* Previous commit: 127.7 ms ± 4.4 ms (22 runs)
* This commit:      95.3 ms ± 2.1 ms (31 runs)

`hyperfine 'animation -o wow.webp 7z7c.gif'`:
* Before:          12.6 ms ± 0.6 ms (198 runs)
* Previous commit: 16.5 ms ± 0.9 ms (153 runs)
* This commit:     13.5 ms ± 0.6 ms (186 runs)
2024-05-20 13:17:34 -04:00
Nico Weber 7aa61ca49b LibGfx/WebP: Add CanonicalCode::write_symbol(), use it in writer
We still construct the code length codes manually, and now we also
construct a PrefixCodeGroup manually that assigns 8 bits to all
symbols (except for fully-opaque alpha channels, and for the
unused distance codes, like before). But now we use the CanonicalCodes
from that PrefixCodeGroup for writing.

No behavior change at all, the output is bit-for-bit identical to
before. But this is a step towards actually huffman-coding symbols.

This is however a pretty big perf regression. For
`image -o test.webp test.bmp` (where test.bmp is retro-sunset.png
re-encoded as bmp), time goes from 23.7 ms to 33.2 ms.

`animation -o wow.webp giphy.gif` goes from 85.5 ms to 127.7 ms.

`animation -o wow.webp 7z7c.gif` goes from 12.6 ms to 16.5 ms.
2024-05-20 13:17:34 -04:00
Nico Weber 1bd1b6e5e9 LibGfx/WebPWriter: Put hot loop in its own function
This makes it easier to compare the generated assembly for this function
in different scenarios.

No behavior or perf change.
2024-05-20 13:17:34 -04:00
Nico Weber ed2658d72c LibGfx/WebP: Move some to-be-shared code to WebPSharedLossless.h
No behavior change. No measurable performance different either.

(I tried `hyperfine 'Build/lagom/bin/image --no-output foo.webp'`
for a few input images before and after this change, and I didn't
see a difference. I also tried if moving both
Gfx::CanonicalCode::read_symbol() and
Compress::CanonicalCode::read_symbol() inline, and that didn't
help either.)
2024-05-20 13:17:34 -04:00
Nico Weber 86b0a56899 LibGfx/WebPWriter: Minor cleanups
Replace a comment with equivalent code, and rename a variable.

No behavior change.
2024-05-20 13:17:34 -04:00
Andreas Kling 448b7ca87b LibJS/Bytecode: Add dedicated instruction for getting length property
By doing this, we can remove all the special-case checks for `length`
from the generic GetById and GetByIdWithThis code paths, making every
other property lookup a bit faster.

Small progressions on most benchmarks, and some larger progressions:

- 12% on Octane/crypto.js
- 6% on Kraken/ai-astar.js
2024-05-20 12:51:56 +02:00
Tim Ledbetter a6d6729034 LibWeb: Implement the MouseEvent.relatedTarget attribute
This returns the secondary target of a mouse event. For `onmouseenter`
and `onmouseover` events, this is the EventTarget the mouse exited
from. For `onmouseleave` and `onmouseout` events, this is the
EventTarget the mouse entered to.
2024-05-20 08:21:41 +02:00
Ali Mohammad Pur ddc622233f RequestServer: Serialise accesses to IPC::Connection
Most of IPC::Connection is thread-safe, but the responsiveness timer is
very much not so, this commit makes sure only one thread can send stuff
through IPC to avoid having threads racing in IPC::Connection.
This is simply less work than making sure everything IPC::Connection
uses (now and later) is thread-safe.
2024-05-20 08:03:35 +02:00
Ali Mohammad Pur def379ce3f LibCrypto: Move some data around earlier in GHash to make it go faster
This makes galois_multiply() about 10% faster.
2024-05-20 08:03:35 +02:00
Ali Mohammad Pur 57714fbb38 RequestServer: Handle IPC requests on multiple threads concurrently
Previously RS handled all the requests in an event loop, leading to
issues with connections being started in the middle of other connections
being started (and potentially blowing up the stack), ultimately causing
requests to be delayed because of other requests.
This commit reworks the way we handle these (specifically starting
connections) by first serialising the requests, and then performing them
in multiple threads concurrently; which yields a significant loading
performance and reliability increase.
2024-05-20 08:03:35 +02:00
Ali Mohammad Pur 4ef24e1c7c LibThreading: Add a ThreadPool 2024-05-20 08:03:35 +02:00
Ali Mohammad Pur d277fd4679 LibThreading: Expose the ProtectedType alias 2024-05-20 08:03:35 +02:00
Ali Mohammad Pur e003c0bf06 LibCore: Remove the spammy "too late for a reloading timer" debug log 2024-05-20 08:03:35 +02:00
Ali Mohammad Pur 96c7e83345 LibCore: Make Timers and Notifiers aware of threads
Previously sharing a Timer/Notifier between threads (or just handing
its ownership to another thread) lead to a crash as they are
thread-specific.
This commit makes it so we can handle mutation (i.e. just deletion
or unregistering) in a thread-safe and lockfree manner.
2024-05-20 08:03:35 +02:00
Ali Mohammad Pur 5cc90f848f LibThreading: Add RWLock and RWLockedProtected 2024-05-20 08:03:35 +02:00
Ali Mohammad Pur 06d522f017 LibTLS: Clear connected/error callbacks before leaving connect()
Otherwise error events will call into our setup code, eventually leading
to a UAF.
2024-05-20 08:03:35 +02:00
Ali Mohammad Pur a362c37c8b LibCore: Add Core::deferred_invoke_if(F, Condition)
This will invoke the function F only if the provided Condition is met,
otherwise the execution of the function F will be further deferred.
2024-05-20 08:03:35 +02:00
Tim Ledbetter 68a1a78a1a LibWeb: Use FIXME extended attribute where possible 2024-05-19 17:35:25 +02:00
Hendiadyoin1 d79347dd4a LibJS: Remove an old VERIFY from break handling in try-finally blocks
The VERIFY assumed that we either have a finally block which we already
visited through a previous boundary or have no finally block what so
ever; But since 301a1fc763 we propagate
finalizers through unwind scopes breaking that assumption.
2024-05-19 17:35:04 +02:00
Jamie Mansfield 3438293e7b LibWeb/Fetch: Share a conditional in fetch response handover
See:
- https://github.com/whatwg/fetch/commit/aaada1f
2024-05-19 16:25:50 +02:00
Jamie Mansfield 951fbb1837 LibWeb/Fetch: Expose a minimised Content-Type to Resource Timing
See:
- https://github.com/whatwg/fetch/commit/931cd06
2024-05-19 16:25:50 +02:00
Jamie Mansfield 08a3904309 LibWeb/MimeSniff: Implement "minimize a supported MIME type"
See:
- https://github.com/whatwg/mimesniff/commit/227a469
2024-05-19 16:25:50 +02:00
Jamie Mansfield 08e4cf1f3b LibWeb/Fetch: Implement Body::bytes()
See:
- https://github.com/whatwg/fetch/commit/1085f4f
2024-05-19 16:25:50 +02:00
Shannon Booth 4fe0cbcf85 LibWeb: Use 'FIXME' extended attribute where possible
This improves the debuggability of many live web pages :^)
2024-05-19 16:24:11 +02:00
Shannon Booth a8e3400a2a LibWeb: Make DOMImplementation IDL return an XMLDocument
Which the implementation was already doing, so no behaviour change :^)
2024-05-19 16:24:11 +02:00
Shannon Booth f7beea1397 LibWeb: Add stub for IDBFactory.open
I saw that this not being implemented was causing a javascript exception
to be thrown when loading https://profiler.firefox.com/.

I was hoping that like the last time that partially implementing this
interface would allow the page to load further, but it seems that this
is unfortunately not the case this time!

However, this may help other pages load slightly further, and puts some
of the scaffolding in place for a proper implementation :^)
2024-05-19 16:24:11 +02:00
Shannon Booth 3aa36caa52 LibWeb: Add stub interface for IDBOpenDBRequest 2024-05-19 16:24:11 +02:00
Shannon Booth bfa330914d LibWeb: Add stub interface for IDBRequest 2024-05-19 16:24:11 +02:00
Shannon Booth 8d5665ebe1 LibWeb: Add stub for IDBFactory 2024-05-19 16:24:11 +02:00
Matthew Olsson 74aeb57631 LibWeb: Add a few missing visits to m_rel_list members 2024-05-19 09:26:30 +02:00
Shannon Booth 3ccbc83168 LibWeb: Add a stubbed slot for DynamicsCompressorNode.reduction
For now, this slot is always 0 - (the default value per spec). But
once we start actually processing audio streams this internal slot
should be changed correspondingly.
2024-05-19 09:26:20 +02:00
Shannon Booth cf615cbd1c LibWeb: Add AudioParams for DynamicsCompressorNode 2024-05-19 09:26:20 +02:00
Shannon Booth 8fa7b2c173 LibWeb: Log a FIXME when parsing fragments for XML documents
This will help us in detecting potential web compatability issues from
not having this implemented.

While we're at it, update the spec link, as it was moved from the DOM
parsing spec to the HTML one, and implement this function in a manner
that closr resembles spec text.
2024-05-19 07:22:48 +02:00
Shannon Booth ccdf82c9be LibWeb: Implement scrollIntoView with 'center' block position
This fixes a crash on:

https://docs.github.com/en/get-started/learning-about-github/githubs-plans
2024-05-19 07:22:17 +02:00
Lucas CHOLLET 615d845ff2 LibGfx/GIF: Prefer local tables over a global one
Let's use local tables so every frame can use its own table.
2024-05-19 07:20:15 +02:00
Lucas CHOLLET f21a4111d2 LibGfx/GIF: Rename write_global_color_table => write_color_table
Local and Global tables are the exact same thing from an encoding
perspective.
2024-05-19 07:20:15 +02:00
Shannon Booth dd20156010 LibWeb: Fix division by zero on a zero-height viewport SVG image 2024-05-19 07:19:42 +02:00
Shannon Booth d48316ce15 LibWeb: Fix division by zero on a zero-width viewport SVG image
We were previously crashing by a division by zero due to an aspect ratio
of zero on https://comicbookshop.co.nz/
2024-05-19 07:19:42 +02:00
Lucas CHOLLET a0401b0d86 LibGfx/GIF: Add support for colors
To determine the palette of colors we use the median cut algorithm.
While being a correct implementation, enhancements are obviously
existing on both the median cut algorithm and the encoding side.
2024-05-18 18:30:07 +02:00
Lucas CHOLLET 1ba8a6f80f LibGfx: Add an implementation of the MedianCut algorithm
This is useful to find the best matching color palette from an existing
bitmap. It can be used in PixelPaint but also in encoders of old image
formats that only support indexed colors e.g. GIF.
2024-05-18 18:30:07 +02:00
Lucas CHOLLET 02e682950e LibGfx: Make Color hashable 2024-05-18 18:30:07 +02:00
Tim Ledbetter 272cd30f17 LibWeb: Add missing visit to m_labels in HTMLElement 2024-05-18 18:29:52 +02:00
Tim Ledbetter c36ba450be LibWeb: Generate binding for HTMLObjectElement.contentWindow attribute
This only required adding the appropriate definition to the IDL file,
as `NavigableContainer` already implements the logic that we need.
2024-05-18 18:12:08 +02:00
Andreas Kling b2e6843055 LibJS+AK: Fix integer overflow UB on (any Int32 - -2147483648)
It wasn't safe to use addition_would_overflow(a, -b) to check if
subtraction (a - b) would overflow, since it doesn't cover this case.

I don't know why we didn't have subtraction_would_overflow(), so this
patch adds it. :^)
2024-05-18 18:11:50 +02:00
Hendiadyoin1 1de475b404 LibJS: Prepare yield object before re-routing it through finally 2024-05-18 18:11:10 +02:00
Tim Ledbetter 2447a25753 LibWeb: Implement the labels attribute for all labelable elements
This returns a `NodeList` of all the labels associated with the given
element.
2024-05-18 18:09:18 +02:00
Tim Ledbetter 3dc86747f0 LibWeb: Implement the HTMLOutputElement.htmlFor attribute
This returns a DOMTokenList that reflects the `for` attribute.
2024-05-18 11:23:20 +02:00
Tim Ledbetter acc1fa3c62 LibWeb: Generate binding for the HTMLObjectElement.form attribute
This only required adding the appropriate definition to the IDL file,
as `FormAssociatedElement` already implements the logic that we need.
2024-05-18 11:04:04 +02:00
Tim Ledbetter 6bf22075ed LibWeb: Implement the HTMLLabelElement.form attribute
This returns the form element associated with the given label element's
control or null if the label has no control.
2024-05-18 11:04:04 +02:00
Tim Ledbetter 5296338e7a LibWeb: Check all elements in same tree to determine labeled control
Previously, when looking for the labeled control of a label element, we
were only checking its child elements. The specification says we should
check all elements in the same tree as the label element.
2024-05-18 11:04:04 +02:00
Tim Ledbetter fc395716e9 LibWeb: Return NonnullGCPtr<DOMTokenList> from relList getters 2024-05-18 11:03:49 +02:00
Tim Ledbetter d0555f3176 LibWeb: Flesh out DOMTokenList::supports() implementation
This change makes `DOMTokenList::supports()` work as expected for
`relList` attributes.
2024-05-16 20:31:23 +02:00
dgaston 55fe04a6fa Chess: Port application to GML
This commit ports the chess application to GML in order to
facilitate the addition of widgets in the future.
2024-05-16 07:41:05 +01:00
dgaston 10dbadced8 Chess: Add chess application to Chess namespace
This is required to port the application to GML.
2024-05-16 07:41:05 +01:00
Nico Weber b6bbff5f3f LibGfx/WebPWriter: Move VP8L compression to WebPWriterLossless.{h,cpp}
* Matches how the loader is organized
* `compress_VP8L_image_data()` will grow longer when we add actual
  compression
* Maybe someone wants to write a lossy compressor one day

No behavior change.
2024-05-16 08:06:50 +02:00
Nico Weber c0f67a0188 LibGfx/WebPWriter: Remove a copy in the animated frame writing code path
This code path now also compresses to memory once, and then writes to
the output stream.

Since the animation writer has a SeekableStream, it could compress to
the stream directly and fix up offsets later. That's more complicated
though, and keeping the animated and non-animated code paths similar
seems nice. And the drawback is just temporary higher memory use, and
the used memory is smaller than the memory needed by the input bitmap.
2024-05-16 08:06:50 +02:00
Nico Weber 0b06cbdca2 LibGfx/WebPWriter: Move frame data writing out of write_ANMF_chunk()
No behavior change. This also makes it clear that the conditional
alignment at the end can just be a VERIFY() instead of a conditional.
2024-05-16 08:06:50 +02:00
Nico Weber 768a7ea1e5 LibGfx/WebP: Split out ANMFChunk header data into ANMFChunkHeader
No behavior change.
2024-05-16 08:06:50 +02:00
Nico Weber c183f73922 LibGfx/WebPWriter: Use write_VP8L_chunk() in animation frame writing
This code path still has a redundant copy of the compressed data
after this change, but it's less code this way.

No behavior change.
2024-05-16 08:06:50 +02:00
Nico Weber 885a3d8c5c LibGfx/WebPWriter: One fewer copy of encoded data when saving still webp
Before, we used to compress the image data to memory, then make another
copy to memory, and then write to the output stream.

Now, we compress to memory once and then write to the output stream.

No behavior change.
2024-05-16 08:06:50 +02:00
Nico Weber 33acd4e747 LibGfx/WebPWriter: Extract another align_to_two() helper 2024-05-16 08:06:50 +02:00
Nico Weber 0175fff659 LibGfx/WebPWriter: Extract compress_VP8L_image_data() function 2024-05-16 08:06:50 +02:00
Tim Ledbetter 51fc30a191 LibWeb: Implement the HTMLLinkElement.relList attribute
This returns a DOMTokenList that reflects the `rel` attribute.
2024-05-16 08:06:26 +02:00
Tim Ledbetter fc4e0cf10e LibWeb: Implement the HTMLFormElement.relList attribute
This returns a DOMTokenList that reflects the `rel` attribute.
2024-05-16 08:06:26 +02:00
Tim Ledbetter 0a3e1846f0 LibWeb: Implement the HTMLAreaElement.relList attribute
This returns a DOMTokenList that reflects the `rel` attribute.
2024-05-16 08:06:26 +02:00
Tim Ledbetter b7fd39c2e6 LibWeb: Implement the HTMLAnchorElement.relList attribute
This returns a DOMTokenList that reflects the `rel` attribute.
2024-05-16 08:06:26 +02:00
Tim Ledbetter 63246577d2 LibWeb: Use correct type for MessageEventInit.ports
This didn't work previously because the IDL generator used the
incorrect type for some types of sequences within dictionaries.
2024-05-16 08:04:01 +02:00
Tim Ledbetter 763b7f0e0c LibWeb: Implement the HTMLOptionElement.form attribute
This returns the parent form of a HTMLOptionElement or null if the
element has no parent form.
2024-05-16 08:03:13 +02:00
Tim Ledbetter fe7df98d7d LibWeb: Use correct IDL definition for CanvasImageData methods
It is now possible to pass an optional `ImageDataSettings` object to
the `CanvasImageData.createImageData()` and
`CanvasImageData.getImageData()` methods.
2024-05-16 08:02:59 +02:00
Andrew Kaster 28f728dfdb LibWeb: Implement FontFace.load() for url() based font sources 2024-05-16 08:02:43 +02:00
Andrew Kaster b7526a39b0 LibWeb: Expose StyleComputer's FontLoader class publicly
We'll want to explicitly load fonts from FontFace and other Web APIs
in the future. A future refactor should also move this completely away
from StyleComputer and call it something like 'FontCache'.
2024-05-16 08:02:43 +02:00
Andrew Kaster d76167b8a4 LibWeb: Add CSS ParsingContext constructor with a realm and URL
This is useful for when we want to parse paths relative to the current
ESO's api base url when there isn't a document, such as in a Worker
context.
2024-05-16 08:02:43 +02:00
Andrew Kaster 8872008958 LibWeb: Use correct JS_CELL name for WorkerEnvironmentSettingsObject 2024-05-16 08:02:43 +02:00
Tim Ledbetter 6290f96aa7 LibGUI: Don't crash when rendering a collapsible toolbar with no items
This prevents a crash in GML Playground that would occur when
previewing a GUI with a collapsible toolbar.
2024-05-15 08:28:24 +02:00
Hendiadyoin1 c8e4499b08 LibJS: Make return control flow more static
With this only `ContinuePendingUnwind` needs to dynamically check if a
scheduled return needs to go through a `finally` block, making the
interpreter loop a bit nicer
2024-05-15 04:25:14 +02:00
Hendiadyoin1 73fdd31124 LibJS: Avoid returning Completions from more Bytecode instructions 2024-05-15 04:25:14 +02:00
MacDue 99579f1f5e LibWeb: Use "valid-types" to define fill-rule in Properties.json
No behaviour change.
2024-05-14 23:01:18 +01:00
MacDue 6c9069fa5d LibWeb: Implement the SVG clip-rule attribute
This controls the fill rule used when rasterizing `<clipPath>` elements.
2024-05-14 23:01:18 +01:00
MacDue 8e00fba71d LibWeb: Correct naming in SVGPathPaintable
The DOM node is a graphics element (not a geometry element) as this
paintable was generalized (to handle things like text).

No behaviour change.
2024-05-14 23:01:18 +01:00
theonlyasdk 6da1d5eb57 Demos: Add sleep option to CatDog
Now you can put your CatDog to sleep while
you're at work :)
2024-05-14 15:45:33 -06:00
Liav A 40a8b009db DynamicLoader: Add an option to list all ELF loaded dependencies
This actually allows us to re-introduce the ldd utility as a symlink to
our dynamic loader, so now ldd behaves exactly like on Linux - it will
load all dynamic dependencies for an ELF exectuable.

This has the advantage that running ldd on an ELF executable will
provide an exact preview of how the order in which the dynamic loader
loads the executable and its dependencies.
2024-05-14 15:42:42 -06:00
Liav A 56790098ea Utilities: Rename ldd => elfdeps
As a preparation to introducing ldd as a symlink to /usr/lib/Loader.so
we rename the ldd utility to be elfdeps, at its sole purpose is to list
ELF object dependencies, and not how the dynamic loader loads them.
2024-05-14 15:42:42 -06:00
Liav A 7437ccd66d DynamicLoader: Add an option to change argv0
This is useful for testing ELF binaries that expose other functionalites
based on the argv0 string (BuggieBox, for example, does it to determine
which utility to run).
2024-05-14 15:42:42 -06:00
Liav A a5e2694ebf DynamicLoader: Add an option to dry-run an ELF exectuable
This option is useful for measuring time of dynamic linking and
profiling the DynamicLoader itself.
2024-05-14 15:42:42 -06:00
Liav A 8fc1f470ef DynamicLoader: Add standard argument parsing for executing ELF binaries
This change essentially puts the DynamicLoader with 2 roles - the first
one is to be invoked by the kernel to dynamically link an ELF executable
in runtime.

The second role is to allow running ELF executables explicitly from
userspace so the kernel runs the DynamicLoader as the "intended" program
but now the DynamicLoader can do its own commandline argument parsing
and run a specified binary, with future options being possible to
implement easily.
2024-05-14 15:42:42 -06:00
Liav A 7e8dfe758c LibCore: Add a small library with only ArgsParser for DynamicLoader
This will be used in the DynamicLoader code, as it can't do syscalls via
LibCore code.
Because we can't use most of the LibCore code, we convert the versioning
code in Version.cpp to use LibC uname() function.
2024-05-14 15:42:42 -06:00
implicitfield c44a8fa57c LibC: Implement mkfifoat(2) 2024-05-14 22:30:39 +02:00
implicitfield 4574a8c334 Kernel+LibC+LibCore: Implement mknodat(2) 2024-05-14 22:30:39 +02:00
Sönke Holz 53a1c25638 LibCoredump: Use AK::unwind_stack_from_frame_pointer 2024-05-14 14:02:06 -06:00
Sönke Holz 3059ac71f3 HackStudio: Use AK::unwind_stack_from_frame_pointer 2024-05-14 14:02:06 -06:00
Andreas Kling ce7c925924 LibJS/Bytecode: Allow assignment expression to write directly to locals 2024-05-14 21:46:36 +02:00
Andreas Kling d22a06d671 LibJS/Bytecode: Remove all the unreachable execute_impl() functions
There are no calls to these anywhere anymore.
2024-05-14 21:46:36 +02:00
Andreas Kling 6ca94bd0b1 LibJS/Bytecode: Rename GetVariable => GetBinding 2024-05-14 21:46:36 +02:00
Andreas Kling b7c04f999a LibJS/Bytecode: Split SetVariable into four separate instructions
Instead of SetVariable having 2x2 modes for variable/lexical and
initialize/set, those 4 modes are now separate instructions, which
makes each instruction much less branchy.
2024-05-14 21:46:36 +02:00
Andreas Kling 640f195a70 LibJS/Bytecode: Sort ENUMERATE_BYTECODE_OPS list 2024-05-14 21:46:36 +02:00
Andreas Kling 9265385807 LibJS/Bytecode: Don't bother propagating completion values in functions
The last completion value in a function is not exposed to the language,
since functions always either return something, or undefined.

Given this, we can avoid emitting code that propagates the completion
value from various statements, as long as we know we're generating code
for a context where the completion value is not accessible. In practical
terms, this means that function code gets to do less completion
shuffling, while global and eval code has to keep doing it.
2024-05-14 21:46:36 +02:00
Liav A. 15ddc1f17a Kernel+Userland: Reject W->X prot region transition after a prctl call
We add a prctl option which would be called once after the dynamic
loader has finished to do text relocations before calling the actual
program entry point.

This change makes it much more obvious when we are allowed to change
a region protection access from being writable to executable.
The dynamic loader should be able to do this, but after a certain point
it is obvious that such mechanism should be disabled.
2024-05-14 12:41:51 -06:00
Liav A. e756567341 Kernel+Userland: Convert process syscall region enforce flag to SetOnce
This flag is set only once, and should never reset once it has been set,
making it an ideal SetOnce use-case.
It also simplifies the expected conditions for the enabling prctl call,
as we don't expect a boolean flag, but rather the specific prctl option
will always set (enable) Process' AddressSpace syscall region enforcing.
2024-05-14 12:41:51 -06:00
Liav A. f474d0c316 LibCompress: Remove Gzip compress_file & decompress_file methods
The gzip utility was the last user of these methods, but now is using
the more comfortable Stream mechanism so we can just remove this code.
2024-05-14 12:35:25 -06:00
Liav A 5b34b4af14 Utilities: Merge the gunzip utility with gzip
Now both /bin/zcat and /bin/gunzip are symlinks to /bin/gzip, and we
essentially running it in decompression mode through these symlinks.

This ensures we don't maintain 2 versions of code to decompress Gzipped
data anymore, and handle the use case of gzipped-streaming input only
once in the codebase.
2024-05-14 12:35:25 -06:00
Lucas CHOLLET cd486a7040 image: Support exporting GIF files 2024-05-14 12:33:53 -06:00
Lucas CHOLLET f43bf1086b LibGfx/GIF: Add a spec link 2024-05-14 12:33:53 -06:00
Lucas CHOLLET 2513a1b83f LibGfx: Add a GIF writer
This version is really barebone as it does not support colors (only
black and white) or animated images.
2024-05-14 12:33:53 -06:00
Lucas CHOLLET 54f33b43c6 LibCompress: Add an LZW compressor 2024-05-14 12:33:53 -06:00
Lucas CHOLLET ff33fa7e8b LibCompress/Lzw: Name a magic variable 2024-05-14 12:33:53 -06:00
Lucas CHOLLET 945e09e46d LibCompress/Lzw: Move shareable code to a base class 2024-05-14 12:33:53 -06:00
Lucas CHOLLET 70a3f1f02b LibCompress: Rename LZWDecoder => LzwDecompressor
This is more idiomatic for LibCompress' decoders.
2024-05-14 12:33:53 -06:00
Lucas CHOLLET 11f53ba9cc LibCompress: Rename LZWDecoder.h => Lzw.h 2024-05-14 12:33:53 -06:00
Andrew Kaster 60b3436ea3 LibWeb: Support loading FontFaces constructed with binary data 2024-05-14 12:31:10 -06:00
Shannon Booth 452ffa56dc LibWeb: Implement BaseAudioContext.createDynamicsCompressor 2024-05-14 13:45:43 -04:00
Shannon Booth 2a56df8ecd LibWeb: Add scaffolding for DynamicsCompressorNode 2024-05-14 13:45:43 -04:00
Nico Weber e2336e2099 LibGfx+animation: Only store changed pixels in animation frames
For example, for 7z7c.gif, we now store one 500x500 frame and then
a 94x78 frame at (196, 208) and a 91x78 frame at (198, 208).

This reduces how much data we have to store.

We currently store all pixels in the rect with changed pixels.
We could in the future store pixels that are equal in that rect
as transparent pixels. When inputs are gif files, this would
guaranteee that new frames only have at most 256 distinct colors
(since GIFs require that), which would help a future color indexing
transform. For now, we don't do that though.

The API I'm adding here is a bit ugly:

* WebPs can only store x/y offsets that are a multiple of 2. This
  currently leaks into the AnimationWriter base class.
  (Since we potentially have to make a webp frame 1 pixel wider
  and higher due to this, it's possible to have a frame that has
  <= 256 colors in a gif input but > 256 colors in the webp,
  if we do the technique above.)

* Every client writing animations has to have logic to track
  previous frames, decide which of the two functions to call, etc.

This also adds an opt-out flag to `animation`, because:

1. Some clients apparently assume the size of the last VP8L
   chunk is the size of the image
   (see https://github.com/discord/lilliput/issues/159).

2. Having incremental frames is good for filesize and for
   playing the animation start-to-end, but it makes it hard
   to extract arbitrary frames (have to extract all frames
   from start to target frame) -- but this is mean tto be a
   delivery codec, not an editing codec. It's also more vulnerable to
   corrupted bytes in the middle of the file -- but transport
   protocols are good these days.
   (It'd also be an idea to write a full frame every N frames.)

For https://giphy.com/gifs/XT9HMdwmpHqqOu1f1a (an 184K gif),
output webp size goes from 21M to 11M.

For 7z7c.gif (an 11K gif), output webp size goes from 2.1M to 775K.

(The webp image data still isn't compressed at all.)
2024-05-14 13:43:03 -04:00
Nico Weber 6c79efcae4 LibGfx: Move AnimationWriter to its own file
No behavior change.
2024-05-14 13:43:03 -04:00
Nico Weber 58cbecbe0c LibGfx/WebP: Move some code shared by loader and writer to WebPShared.h
Has (no-op) the effect of adding a few missing default-initializers for
the copy in WebPLoader.cpp.

No behavior change.
2024-05-14 13:43:03 -04:00
Nico Weber a19589649d LibGfx/WebPWriter: Add some checks to write_ANMF_chunk()
The function's implementation makes these assumptions, so check
that they are true instead of silently doing the wrong this when
they're not true.
2024-05-14 13:43:03 -04:00
Nico Weber cf4bad31f0 LibGfx/WebPWriter: Add debug logging for ANMF chunks 2024-05-14 13:43:03 -04:00
Nico Weber 437fd9ae2b LibGfx/GIFLoader: Add debug logging for image descriptors 2024-05-14 13:43:03 -04:00
Shannon Booth 27242c6be6 LibWeb: Implement Document.dir
This was seen getting called on stuff.co.nz (before it crashes due to an
unrelated navigation bug)
2024-05-14 13:35:36 -04:00
Andreas Kling ed50eb0aaa LibJS/Bytecode: Add environment coordinate caching to SetVariable
This means that SetVariable instructions will now remember which
(relative) environment contains the targeted binding, letting it bypass
the full binding resolution machinery on subsequent accesses.
2024-05-14 06:39:27 +02:00
Aliaksandr Kalenik caffd485b8 LibJS: Replace SetLocal instruction usage with Mov
No need for separate instuction to set a local.
2024-05-14 06:39:16 +02:00
Matthew Olsson 4ae7bbda52 Lagom: Add ClangPlugins to the build system 2024-05-13 16:50:54 -06:00
Tim Ledbetter a8c60d65fc LibWeb: Specify the correct argument type in IDL for AbortSignal::any()
This allows some boilerplate code to be generated automatically.
2024-05-13 23:45:45 +01:00
Lucas CHOLLET ff2c6cab55 LibGfx: Correctly round values when computing the luminosity of a Color
Truncating the value is mathematically incorrect, this error made the
conversion to grayscale unstable. In other world, calling `to_grayscale`
on a gray value would return a different value. As an example,
`Color::from_string("#686868ff"sv).to_grayscale()` used to return
#676767ff.
2024-05-13 23:43:58 +02:00
Andrew Kaster bd4f516e64 LibWeb: Stub out FontFaceSet.status and .ready attributes
WPT wants to check these properties before running ref tests.
This fixes a ton of crashes in our CI WPT runs.
2024-05-13 20:20:39 +00:00
Aliaksandr Kalenik d79438a2a6 LibJS: Join locals, constants and registers into single vector
Merging registers, constants and locals into single vector means:
- Better data locality
- No need to check type in Interpreter::get() and Interpreter::set()
  which are very hot functions

Performance improvement is visible in almost all Octane and Kraken
tests.
2024-05-13 19:54:11 +02:00
Andreas Kling 59cb7994c6 LibWeb: Use memcpy() in CanvasRenderingContext2D.getImageData()
Instead of copying the image data pixel-by-pixel, we can memcpy full
scanlines at a time.

This knocks a 4% item down to <1% in profiles of Another World JS.
2024-05-13 17:29:37 +02:00
Andreas Kling 6f5201b759 LibJS: Add fast paths in TypedArrayPrototype.fill()
Filling a typed array with an integer shouldn't have to go through the
generic Set for every element.

This knocks a 7% item down to <1% in profiles of Another World JS at
https://cyxx.github.io/another_js/
2024-05-13 17:29:37 +02:00
Andreas Kling d79353a477 LibJS/Bytecode: Add fast paths for compare-and-jump with 2 numbers
When comparing two numbers, we can avoid a lot of implicit type
conversion nonsense and go straight to comparison, saving time in the
most common case.
2024-05-13 17:29:37 +02:00
Hugh Davenport 9772590e9a MouseSettings: Only allow valid cursor themes
To align the cursor theme tab to how DisplaySettings themes tab works,
this change forces the theme combo box to not allow free-text. Currently
on a click it puts the text cursor in the box to allow typing anything
rather than acting as a dropdown when clicking anywhere on the field.

Fixes #24306
2024-05-13 08:26:16 +01:00
Andreas Kling 855f6417df LibJS/Bytecode: Move environment variable caches into instructions
These were out-of-line because we had some ideas about marking
instruction streams PROT_READ only, but that seems pretty arbitrary and
there's a lot of performance to be gained by putting these inline.
2024-05-13 09:22:14 +02:00
Andreas Kling a06441c88c LibJS/Bytecode: Defer GetGlobal identifier lookup until cache misses
This way we avoid looking up the identifier when the cache hits.
2024-05-13 09:22:14 +02:00
Andreas Kling 6ec4d6f668 LibJS/Bytecode: Cache the running execution context in interpreter 2024-05-13 09:22:14 +02:00
Andreas Kling 8447f6f6da LibJS: Inline more of cached environment variable access in interpreter
And stop passing VM strictness to direct access, since it doesn't care
about strictness anyway.
2024-05-13 09:22:14 +02:00
Shannon Booth 9b6a1de777 LibWeb: Implement URL.parse
This was an addition to the URL spec, see:

https://github.com/whatwg/url/commit/58acb0
2024-05-13 09:21:12 +02:00
Shannon Booth 67ea56da59 LibWeb: Factor out an 'initialize a URL' AO
This is a small refactor in the URL spec to avoid duplication as part of
the introduction of URL.parse, see:

https://github.com/whatwg/url/commit/58acb0
2024-05-13 09:21:12 +02:00
Shannon Booth 53eb9af42f LibWeb: Use URL's 'blob URL entry' for blob fetches
Performing a lookup in the blob URL registry does not work in the case
of a web worker - as the registry is not shared between processes.
However - the URL itself passed to a worker has the blob attached to it,
which we can pull out of the URL on a fetch.
2024-05-12 15:46:29 -06:00
Shannon Booth 2457fdc7a4 LibWeb: Attach blob to URL on DOMURL::parse
On a non-basic URL parse, we are meant to perform a lookup on the blob
URL registry and attach any blob to that URL if present. Now - we do
that :^)
2024-05-12 15:46:29 -06:00
Shannon Booth 4f30d50dc9 LibIPC: Remove uneeded NumericLimit<u32>::max check for ByteString
This is no longer needed now that ByteString does not have a null state.
2024-05-12 15:46:29 -06:00
Shannon Booth 55cd53e4ed LibIPC: Also encode URL::blob_url_entry over IPC 2024-05-12 15:46:29 -06:00
Shannon Booth 27e1f4762c LibURL: Add BlobURLEntry to URL 2024-05-12 15:46:29 -06:00
Shannon Booth ec381c122e LibWeb: Implement "Resolve a Blob URL"
Which performs a lookup to find a blob (if any) corresponding to the
given blob URL.
2024-05-12 15:46:29 -06:00
Shannon Booth c071720430 LibWeb: Handle blob URLs in Document::parse_url
Implement this function to the spec, and use the full blown URL parser
that handles blob URLs, instead of the basic-url-parser.

Also clean up a FIXME that does not seem relevant any more.
2024-05-12 15:46:29 -06:00
Timothy Flynn 95c6fdf401 LibWebView: Escape HTML entities in the Task Manager process titles 2024-05-12 15:38:18 -06:00
Alec Murphy 8b14b5ef36 Browser: Pledge thread for FilePicker
This fixes a crash when attempting to display thumbnails for image
files in the FilePicker if thread is not pledged.
2024-05-12 15:37:36 -06:00
Shannon Booth 5e7678d1c6 LibWeb: Implement AudioBuffer.copyFromChannel 2024-05-12 19:11:37 +02:00
Aliaksandr Kalenik 8bcaf68023 LibJS: Remove VM::execute_ast_node() 2024-05-12 19:10:25 +02:00
Aliaksandr Kalenik 6fb1d9e516 LibJS: Stop using execute_ast_node() for class property evaluation
Instead, generate bytecode to execute their AST nodes and save the
resulting operands inside the NewClass instruction.

Moving property expression evaluation to happen before NewClass
execution also moves along creation of new private environment and
its population with private members (private members should be visible
during property evaluation).

Before:
- NewClass

After:
- CreatePrivateEnvironment
- AddPrivateName
- ...
- AddPrivateName
- NewClass
- LeavePrivateEnvironment
2024-05-12 19:10:25 +02:00
Aliaksandr Kalenik b46fc47bf7 LibJS: Remove execute_ast_node() usage for ClassMethod function creation
Call ECMAScriptFunctionObject constructor directly instead of using
execute_ast_node() to emit NewFunction instruction.
2024-05-12 19:10:25 +02:00
Shannon Booth 2e1316507f LibWeb: Fix missing initialization of delta_z in WheelEvent 2024-05-12 14:24:18 +00:00
Shannon Booth 42e3ba409e LibWeb: Add constructor for WheelEvent
This makes https://profiler.firefox.com/ progress much further in
loading :^)
2024-05-12 14:24:18 +00:00
Shannon Booth 0c799b23cb LibWeb: Use WebIDL::UnsignedLong for deltaMode in WheelEvent
This matches the IDL definition. Without this we experience a compile
time error when adding the WheelEvent constructor due to a mimatched
type between the enum class and UnsignedLong that the prototype is
passing through to the event init struct for the constructor.
2024-05-12 14:24:18 +00:00
Shannon Booth e5206f5529 LibWeb: Only use lowercase attributes on toggle for HTML documents 2024-05-12 07:28:09 +01:00
Shannon Booth 89a536b57a LibWeb: Remove resolved FIXME about putting HTMLALlCollection in HTML NS
This was an unfortunate artifact from development. I originally added
this class in the DOM namespace alongside HTMLCollection until I
realized it was defined by the HTML spec instead. To remind myself to
move it over to the HTML namespace, I left this comment. It was moved
to the correct namespace before upstreaming to the main repo, but I
forgot to remove this comment!
2024-05-12 07:28:09 +01:00
Shannon Booth 97c1722ebd LibWeb: Remove resolved FIXME about implementing more methods in Range
We are not missing a whole bunch of IDL methods any more :^)
2024-05-12 07:28:09 +01:00
Shannon Booth dadc610e4a LibWeb: Pass a FlyString to getElementsByTagNameNS 2024-05-12 07:28:09 +01:00
Nico Weber f506818052 LibGfx/WebPWriter: Support animations with transparent pixels
Once we see a frame with transparent pixels, we now toggle the
"has alpha" bit in the header.

To not require a SeekableStream opened for reading, we now pass the
unmodified original flag bit to WebPAnimationWriter.
2024-05-11 15:43:02 -04:00
Nico Weber 3a4e0c2804 LibGfx+Utilities: Add animation utility, make it write animated webps
The high-level design is that we have a static method on WebPWriter that
returns an AnimationWriter object. AnimationWriter has a virtual method
for writing individual frames. This allows streaming animations to disk,
without having to buffer up the entire animation in memory first.
The semantics of this function, add_frame(), are that data is flushed
to disk every time the function is called, so that no explicit `close()`
method is needed.

For some formats that store animation length at the start of the file,
including WebP, this means that this needs to write to a SeekableStream,
so that add_frame() can seek to the start and update the size when a
frame is written.

This design should work for GIF and APNG writing as well. We can move
AnimationWriter to a new header if we add writers for these.

Currently, `animation` can read any animated image format we can read
(apng, gif, webp) and convert it to an animated webp file.

The written animated webp file is not compressed whatsoever, so this
creates large output files at the moment.
2024-05-11 15:43:02 -04:00
Nico Weber 27cc9e7386 LibGfx/WebPWriter: Write VP8X chunk header and bytes at once
For VP8L it arguably makes sense to separate the two, but for
fixed-size chunk like VP8X it doesn't.

No behavior change.
2024-05-11 15:43:02 -04:00
Aliaksandr Kalenik 0c8e76cbd7 LibJS: Delete named_evaluation_if_anonymous_function()
This code was a leftover from AST interpreter.
2024-05-11 18:16:15 +02:00
Andreas Kling 6ad6e09be1 LibJS: Make Environment::is_declarative_environment() non-virtual
This function was moderately hot (2%) on the clusters demo, and making
it non-virtual costs us nothing.
2024-05-11 15:22:36 +02:00
Andreas Kling b5a070e8ce LibJS/Bytecode: Don't create empty lexical environments
This patch stops emitting the BlockDeclarationInstantiation instruction
when there are no locals, and no function declarations in the scope.

We were spending 20% of CPU time on https://ventrella.com/Clusters/ just
creating empty environments for no reason.
2024-05-11 15:22:36 +02:00
theonlyasdk 9e976dfeac LibWebView: Add Wikipedia to builtin search engines list 2024-05-11 07:53:04 -04:00
Andreas Kling 239b9d8662 LibJS: Manually limit the recursion depth in Proxy
Instead of relying on native stack overflows to kick us out of circular
proxy chains, we now keep track of the recursion depth and kick
ourselves out if it exceeds 10'000.

This fixes an issue where compiler tail/sibling call optimizations would
turn infinite recursion into infinite loops, and thus never hit a stack
overflow to kick itself out.

For whatever reason, we've only seen the issue on SerenityOS with UBSAN,
but it could theoretically happen on any platform.
2024-05-11 13:00:46 +02:00
Lucas CHOLLET 7a55c4af0e LibGfx/GIF: Avoid copying LZW subblocks twice
I started to write that in order to remove the manual copy of the data
but that should produce some performance gains as well.
2024-05-11 12:53:57 +02:00
Lucas CHOLLET 7aa76e6c9f LibGfx/GIF: Shorten the lifetime of lzw_encoded_bytes_expected 2024-05-11 12:53:57 +02:00
Aliaksandr Kalenik 1e361db3f3 LibJS: Remove VM::binding_initialization()
This function was used for function params initialization but no longer
used after it got replaced by emitting bytecode.
2024-05-11 11:43:05 +02:00
Aliaksandr Kalenik 3d4b13a01c LibJS: Ensure capacity for created lexical and variable environments
If the minimal amount of required bindings is known in advance, it could
be used to ensure capacity to avoid resizing the internal vector that
holds bindings.
2024-05-11 11:43:05 +02:00
Aliaksandr Kalenik a4f70986a0 LibJS: Emit bytecode for function declaration instantiation
By doing that all instructions required for instantiation are emitted
once in compilation and then reused for subsequent calls, instead of
running generic instantiation process for each call.
2024-05-11 11:43:05 +02:00
Aliaksandr Kalenik 89a007327a LibJS: Change NewFunction instruction to accept FunctionNode
Preparation for upcoming changes where NewFunction will have to be used
with FunctionDeclaration node.
2024-05-11 11:43:05 +02:00
Aliaksandr Kalenik 00018ad415 LibJS: Move BindingPattern bytecode generation into a method
Preparation for upcoming function where binding pattern will have to be
used outside of ASTCodegen.cpp
2024-05-11 11:43:05 +02:00
dgaston 739cc4b8dc LibChess: Fix crash when importing PGN
Fix the incorrect parsing in `Chess::Move::from_algebraic`
of moves with a capture and promotion (e.g. gxf8=Q) due to
the promoted piece type not being passed through to the
`Board::is_legal` method. This addresses a FIXME regarding
this issue in `ChessWidget.cpp`.
2024-05-11 07:41:57 +01:00
Andrew Kaster 2bc51f08d9 LibWeb: Implement or stub FontFace interface's attribute getters/setters
We only support parsing half of these, so the ones we don't recognize
get a friendly exception thrown.
2024-05-11 07:30:29 +01:00
Andrew Kaster de98c122d1 LibWeb: Move CSS unicode-ranges parsing code into a common helper 2024-05-11 07:30:29 +01:00
Andreas Kling 7bdc207d81 LibJS/Bytecode: Make execute_impl() return void for non-throwing ops
This way we can't accidentally ignore exceptions.
2024-05-10 19:53:15 +02:00
Andreas Kling 01ec56f1ed LibJS/Bytecode: Fix register being freed too early in delete codegen
It wasn't actually possible for it to get reused incorrectly here, but
let's fix the bug anyway.
2024-05-10 15:03:24 +00:00
Andreas Kling 353e635535 LibJS/Bytecode: Grab at ThrowCompletionOr errors directly
The interpreter can now grab at the error value directly instead of
instantiating a temporary Completion to hold it.
2024-05-10 15:03:24 +00:00
Andreas Kling f5efc47905 LibJS: Make ThrowCompletionOr<T> smaller
Instead of storing a full JS::Completion for the "throw completion"
case, we now store a simple JS::Value (wrapped in ErrorValue for the
type system).

This shrinks TCO<void> and TCO<Value> (the most common TCOs) by 8 bytes,
which has a non-trivial impact on performance.
2024-05-10 15:03:24 +00:00
Andreas Kling ae11a4de1c LibJS: Remove unused target field from Completion
This shrinks Completion by 16 bytes, which has non-trivial impact
on performance.
2024-05-10 15:03:24 +00:00
Andreas Kling a77c6e15f4 LibJS/Bytecode: Streamline return/yield flow a bit in the interpreter 2024-05-10 15:03:24 +00:00
Andreas Kling 3e1a6fca91 LibJS/Bytecode: Remove exception checks from Return/Await/Yield
These instructions can't throw anyway.
2024-05-10 15:03:24 +00:00
Andreas Kling 8eccfdb98c LibJS/Bytecode: Cache a base pointer to executable constants
Instead of fetching it from the current executable whenever we fetch a
constant, just keep a base pointer to the constants array handy.
2024-05-10 15:03:24 +00:00
Andreas Kling 810a297626 LibJS/Bytecode: Remove Instruction::execute()
Just make sure everyone calls the instruction-specific execute_impl()
instead. :^)
2024-05-10 15:03:24 +00:00
Andreas Kling 601e10d50c LibJS/Bytecode: Make StringTableIndex be a 32-bit index
This makes a bunch of instructions smaller.
2024-05-10 15:03:24 +00:00
Andreas Kling b99f0a7e22 LibJS/Bytecode: Reorder Call instruction members to make it smaller 2024-05-10 15:03:24 +00:00
Andreas Kling 96511a7d19 LibJS/Bytecode: Avoid unnecessary copy of call expression callee
If the callee is already a temporary register, we don't need to copy it
to *another* temporary before evaluating arguments. None of the
arguments will clobber the existing temporary anyway.
2024-05-10 15:03:24 +00:00
Andreas Kling 56a3ccde1a LibJS/Bytecode: Turn UnaryMinus(NumericLiteral) into a constant 2024-05-10 15:03:24 +00:00
Andreas Kling e37feaa196 LibJS/Bytecode: Skip unnecessary exception checks in interpreter
Many opcodes cannot ever throw an exception, so we can just avoid
checking it after executing them.
2024-05-10 15:03:24 +00:00
Andreas Kling 34f287087e LibJS/Bytecode: Only copy call/array expression arguments when needed
We only need to make copies of locals here, in case the locals are
modified by something like increment/decrement expressions.

Registers and constants can slip right through, without being Mov'ed
into a temporary first.
2024-05-10 15:03:24 +00:00
Andreas Kling caf2e675bf LibJS/Bytecode: Don't emit GetGlobal undefined
We know that `undefined` in the global scope is always the proper
undefined value. This commit takes advantage of that by simply emitting
a constant undefined value instead.

Unfortunately we can't be so sure in other scopes.
2024-05-10 15:03:24 +00:00
Andreas Kling 448f837d38 LibJS/Bytecode: Round constant operands of bitwise binary expressions
This helps some of the Cloudflare Turnstile stuff run faster, since they
are deliberately screwing with JS engines by asking us to do a bunch of
bitwise operations on e.g 65535.56

By rounding such values in bytecode generation, the interpreter can stay
on the happy path while executing, and finish quite a bit faster.
2024-05-10 15:03:24 +00:00
Andreas Kling ca8dc8f61f LibJS/Bytecode: Turn JumpIf true/false into unconditional Jump 2024-05-10 15:03:24 +00:00
Andreas Kling 7654da3851 LibJS/Bytecode: Do basic compare-and-jump peephole optimization
We now fuse sequences like [LessThan, JumpIf] to JumpLessThan.
This is only allowed for temporaries (i.e VM registers) with no other
references to them.
2024-05-10 15:03:24 +00:00
Marios Prokopakis eecede20ac ping: Implement waittime
Specify the time in seconds to wait for a reply for each packet sent.
Replies received out of order will not be printed as replied but they
will be considered as replied when calculating statistics. Setting it
to 0 means infinite timeout.
2024-05-09 13:13:20 -06:00
Marios Prokopakis b3658c5706 ping: Implement flood ping mode
In flood ping mode, the time interval between each request is set
to zero to provide a rapid display of how many packets are being
dropped. For each request a period '.' is printed, while for every
reply a backspace is printed.
2024-05-09 13:13:20 -06:00
Marios Prokopakis 90f5e5139f ping: Implement adaptive ping mode
In adaptive ping mode, the interval between each ping request
adapts to the RTT.
2024-05-09 13:13:20 -06:00
Isaac 653f41336b SystemMonitor: Add dropped packets count to adapter table 2024-05-09 12:02:26 +02:00
Andreas Kling f164e18a55 LibJS/Bytecode: Bunch all tests together in switch statement codegen
Before this change, switch codegen would interleave bytecode like this:

    (test for case 1)
    (code for case 1)
    (test for case 2)
    (code for case 2)

This meant that we often had to make many large jumps while looking for
the matching case, since code for each case can be huge.

It now looks like this instead:

    (test for case 1)
    (test for case 2)
    (code for case 1)
    (code for case 2)

This way, we can just fall through the tests until we hit one that fits,
without having to make any large jumps.
2024-05-09 09:12:13 +02:00
Andreas Kling 18b8fae85c LibJS/Bytecode: Remove pointless basic block in SwitchStatement codegen 2024-05-09 09:12:13 +02:00
Andreas Kling 6873628317 LibJS/Bytecode: Make NewArray a variable-length instruction
This removes a layer of indirection in the bytecode where we had to make
sure all the initializer elements were laid out in sequential registers.

Array expressions no longer clobber registers permanently, and they can
be reused immediately afterwards.
2024-05-09 09:12:13 +02:00
Andreas Kling cea59b6642 LibJS/Bytecode: Reuse bytecode registers
This patch adds a register freelist to Bytecode::Generator and switches
all operands inside the generator to a new ScopedOperand type that is
ref-counted and automatically frees the register when nothing uses it.

This dramatically reduces the size of bytecode executable register
windows, which were often in the several thousands of registers for
large functions. Most functions now use less than 100 registers.
2024-05-09 09:12:13 +02:00
Andreas Kling f537d0b3cf LibJS/Bytecode: Allow all basic blocks to use cached this from block 0
The first block in every executable will always execute first, so if it
ends up doing a ResolveThisBinding, it's fine for all other blocks
within the same executable to use the same `this` value.
2024-05-09 09:12:13 +02:00
Andreas Kling 55a4b0a21e LibJS: Mark Value as a trivial type for AK collection purposes
It's perfectly fine to memcpy() a bunch of JS::Values around, and if
that helps Vector<Value> go faster, let's allow it.
2024-05-09 09:12:13 +02:00
Andreas Kling 161298b5d1 LibJS/Bytecode: Inline indexed property access in GetByVal better 2024-05-09 09:12:13 +02:00
Andreas Kling 3170ad2ee3 LibJS: Avoid string trimming in GlobalObject.parseInt() when possible
In the common case, parseInt() is being called with strings that don't
have leading whitespace. By checking for that first, we can avoid the
cost of trimming and multiple malloc/GC allocations.
2024-05-09 09:12:13 +02:00
Andreas Kling 0f70ff9a67 LibJS/Bytecode: Only emit ResolveThisBinding once per basic block
Once executed, this instruction will always produce the same result
in subsequent executions, so it's okay to cache it.

Unfortunately it may throw, so we can't just hoist it to the top of
every executable, since that would break observable execution order.
2024-05-09 09:12:13 +02:00
Timothy Flynn 323c9edbb9 LibJS: Increase the stack limit on macOS with ASAN enabled
The macOS 14 runners on GitHub Actions fail with a stack overflow
otherwise.
2024-05-08 14:46:39 -06:00
Hendiadyoin1 e1aecff2ab LibJS: Fail compilation earlier when trying to emit with wrong arguments
This makes the compilation backtraces a lot nicer, and allows clangd to
see the mistake as well.
2024-05-08 22:01:58 +02:00
Hendiadyoin1 af94e4c05d LibJS: Save and restore exceptions on yields in finalizers
Also removes a bunch of related old FIXMEs.
2024-05-08 22:01:58 +02:00
Dan Klishch b0b1817b06 LibELF: Make orders in which we store/call things explicit
While on it, add a few spec links and remove needless conversions
between DynamicLoader objects and their respective filesystem paths.
2024-05-08 09:53:58 -06:00
Nico Weber d988b6facc LibGfx/WebPWriter+TestImageWriter: Fix bugs writing VP8X header
Two bugs:

1. Correctly set bits in VP8X header.
   Turns out these were set in the wrong order.

2. Correctly set the `has_alpha` flag.

Also add a test for writing webp files with icc data. With the
additional checks in other commits in this PR, this test catches
the bug in WebPWriter.

Rearrange some existing functions to make it easier to write this test:

* Extract encode_bitmap() from get_roundtrip_bitmap().
  encode_bitmap() allows passing extra_args that the test uses to pass
  in ICC data.
* Extract expect_bitmaps_equal() from test_roundtrip()
2024-05-08 16:34:11 +02:00
Nico Weber 0805319d1e LibGfx/WebPLoader: Diagnose mismatch between VP8X and VP8L alpha bits
If this turns out to be too strict in practice, we can replace it with
a `dbgln("VP8X and VP8L headers disagree about alpha; ignoring VP8X");`
instead.

ALso update catdog-alert-13-alpha-used-false.webp to not trigger this.
I had manually changed the VP8L alpha flag at offset 0x2a in
da48238fbd to clear it, but I hadn't changed the VP8X flag.
This changes the byte at offset 0x14 from 0x10 (has_alpha) to 0x00
(no alpha) as well, to match.
2024-05-08 16:34:11 +02:00
Nico Weber 25e2e17218 LibGfx/WebPLoader: Diagnose ICCP flag / ICCP chunk presence mismatch
If this turns out to be too strict in practice, we can replace it with
a dbgln() with the same message, but with with ", ignoring header."
tacked on at the end.
2024-05-08 16:34:11 +02:00
Nico Weber 25be8f8ae7 LibGfx/WebPWriter: Add some debug logging 2024-05-08 16:34:11 +02:00
Andrew Kaster e10721f1b5 LibWeb: Add stub implementation of FontFaceSet and Document.fonts
This is now enough for duolingo to load and use its fallback fonts.
2024-05-08 10:39:16 +02:00
Andrew Kaster 2c31d7dddc LibWeb: Add stub implementation of CSS FontFace Web API 2024-05-08 10:39:16 +02:00
Andrew Kaster 3a5eabc43b LibWeb: Rename CSS::FontFace to CSS::ParsedFontFace
This implementation detail of CSSFontFaceRule is hogging the name of a
Web API from CSS Font Loading Module Level 3.
2024-05-08 10:39:16 +02:00
Jamie Mansfield 3f113e728f LibWeb/SVG: Stub SVGTransform.setSkewY 2024-05-07 17:33:27 -06:00
Jamie Mansfield dc6febaea6 LibWeb/SVG: Stub SVGTransform.setSkewX 2024-05-07 17:33:27 -06:00
Jamie Mansfield 0bac2d5fbd LibWeb/SVG: Stub SVGTransform.setRotate 2024-05-07 17:33:27 -06:00
Jamie Mansfield effb696eef LibWeb/SVG: Stub SVGTransform.setScale 2024-05-07 17:33:27 -06:00
Jamie Mansfield 5d5f043631 LibWeb/SVG: Stub SVGTransform.setTranslate 2024-05-07 17:33:27 -06:00
Jamie Mansfield c102630a59 LibWeb/SVG: Stub SVGTransform.angle 2024-05-07 17:33:27 -06:00
Jamie Mansfield 4406d06d26 LibWeb/SVG: Stub SVGTransform.type 2024-05-07 17:33:27 -06:00
Jamie Mansfield bc91c75481 LibWeb/SVG: Format SVGTransform.idl 2024-05-07 17:33:27 -06:00
Jamie Mansfield 74d90338b1 LibWeb/Fetch: Support setting request priority from JS 2024-05-07 17:27:37 -06:00
Jamie Mansfield 4387d12159 LibWeb/Fetch: Block ports 4190 and 6679
See:
- https://github.com/whatwg/fetch/commit/4c3750d
2024-05-07 17:27:37 -06:00
Jamie Mansfield 987198782c LibWeb/Fetch: Use "json" destination
See:
- https://github.com/SerenityOS/serenity/commit/da8d0d8
- https://github.com/whatwg/fetch/commit/49bff76
- https://github.com/whatwg/html/commit/37659e9
2024-05-07 17:27:37 -06:00
Jamie Mansfield e2f242a552 LibWeb/Fetch: Implement "fetch destination from module type" AO
See:
- https://github.com/whatwg/html/commit/37659e9
2024-05-07 17:27:37 -06:00
Jamie Mansfield 1b043d259a LibWeb: Implement ShadowRoot.onslotchange 2024-05-07 17:27:37 -06:00
Jamie Mansfield da0ca2f866 LibWeb: Implement ShadowRoot.delegatesFocus 2024-05-07 17:27:37 -06:00
Shannon Booth 71819153cb LibWeb: Implement Element::scroll(HTML::ScrollToOptions) 2024-05-07 17:21:52 -06:00
Shannon Booth 37ca32d62c LibWeb: Implement Element::scroll(x, y) closer to spec 2024-05-07 17:21:52 -06:00
Shannon Booth 31977cc0ac LibWeb: Implement Element::scroll_by(x, y) 2024-05-07 17:21:52 -06:00
Shannon Booth e640a68733 LibWeb: Implement Element::scroll_by(HTML::ScrollToOptions) 2024-05-07 17:21:52 -06:00
Shannon Booth e5d03e382e LibWeb: Add AO for "normalize non-finite values"
We had implemented this in two different ways. Add an AO to to align the
implementations.
2024-05-07 17:21:52 -06:00
Sönke Holz 116f82d21a LibDebug: Don't assume compilation unit index == line program index
Instead, use the `DW_AT_stmt_list` attribute of the compilation unit
entry to determine the corresponding line program.
2024-05-07 16:57:09 -06:00
Sönke Holz 14ae04075e LibDebug: Make LineProgram::create take DwarfInfo as a const reference
The m_dwarf_info is never mutated, so it can be const.
2024-05-07 16:57:09 -06:00
Sönke Holz bc7d067821 LibDebug: Remove m_stream member from LineProgram
The stream passed to LineProgram::create is a temporary, so rather than
keeping an (unused) dangling reference, pass this stream explicitly to
all functions used by LineProgram::create.
2024-05-07 16:57:09 -06:00
implicitfield f5a74d7141 Utilities: Add fusermount
This only contains the bare minimum amount of functionality required
by libfuse.
2024-05-07 16:54:27 -06:00
implicitfield a08d1637e2 Kernel: Add FUSE support
This adds both the fuse device (used for communication between the
kernel and the filesystem) and filesystem implementation itself.
2024-05-07 16:54:27 -06:00
Tim Ledbetter 57f0ea186e LibWeb: Update Element::directionality() to match current spec text
This fixes a crash that occurred when determining the directionality of
input elements.
2024-05-07 16:45:28 -06:00
Tim Ledbetter 23473d64ca LibWeb: Make HTMLSlotElement::assigned_{elements,nodes} methods const 2024-05-07 16:45:28 -06:00
Tim Ledbetter 398bf10b92 LibWeb: Use TraversalDecision for multi level Node traversal methods
This adds the `SkipChildrenAndContinue` option, where traversal
continues but child nodes are not included.
2024-05-07 16:45:28 -06:00
Tim Ledbetter c57d395a48 LibWeb: Use IterationDecision in single level Node iteration methods
`Node::for_each_child()` and `Node::for_each_child_of_type()` callbacks
now return an `IterationDecision`, which allows us to break early if
required.
2024-05-07 16:45:28 -06:00
Dan Klishch 5f33db9abe DynamicLoader+LibSanitizer: Link LibSanitizer to DynamicLoader properly 2024-05-07 16:39:17 -06:00
Dan Klishch da48a0ca5b LibC: Don't use assert in malloc.cpp 2024-05-07 16:39:17 -06:00