Commit graph

33531 commits

Author SHA1 Message Date
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
Dan Klishch
d510d2aeb2 LibC: Remove now redundant NO_TLS guards
Since DynamicLoader is compiled with -fdata-sections and --gc-sections,
unused thread_local variables won't create TLS section in it anymore.
2024-05-07 16:39:17 -06:00
Dan Klishch
5963b785e7 LibELF: Unbreak dynamic loader on riscv64
It turns out riscv64 indeed requires -fno-stack-protector for
perform_relative_relocations, oopsie :^)
2024-05-07 16:39:17 -06:00
Dan Klishch
61cf20582c DynamicLoader+LibC: Link LibC into DynamicLoader --as-sane-people
In particular, define a static LibC library *in LibC's CMakeLists* and
use it in DynamicLoader. This is similar to the way LibELF is included
in DynamicLoader.

Additionally, compile DynamicLoader with -ffunction-sections,
-fdata-sections, and -Wl,--gc-sections. This brings the loader size from
~2Mb to ~1Mb with debug symbols and from ~500Kb to ~150Kb without. Also,
this makes linking DynamicLoader with LibTimeZone unnecessary.
2024-05-07 16:39:17 -06:00
Dan Klishch
0b6c08c9a2 LibSystem: Slightly simplify CMakeLists.txt
LibSystem's source directory is included project-wide in
/CMakeLists.txt.
2024-05-07 16:39:17 -06:00
Dan Klishch
e3e98ed3eb LibC: Modernize and simplify LibC/CMakeLists.txt 2024-05-07 16:39:17 -06:00
Dan Klishch
ce5813d6ab LibC: Remove libssp_nonshared.a
__stack_chk_fail_local, which libssp_nonshared.a provides, is a relic of
i386 times and is not used on modern architectures.
2024-05-07 16:39:17 -06:00
Dan Klishch
f60a02fc78 LibC: Move architecture detection from fenv.h to arch/fenv.h
This is similar to how it is done in sys/arch/regs.h.
2024-05-07 16:39:17 -06:00
Dan Klishch
4439b4afcf LibC+LibSanitizer+LibSystem: Remove static libc
Static libc on Serenity is broken in a more than one way and requires a
lot of patches to bring it to a usable and useful state. Therefore,
instead of keeping it around (and breaking even more) during the
upcoming libc build refactor, let's just delete it.
2024-05-07 16:39:17 -06:00
Dan Klishch
028f979916 DynamicLoader: Allow syscalls from dynamic loader more often
Previously, if DynamicLoader was invoked directly, it wouldn't be able
to perform syscalls after the point just before the call to the main
executable entry. This made dlopen to crash if it was invoked from
within an executable that was itself executed using
`/usr/lib/Loader.so <executable>`.

The fix can be tested by executing
`cd /usr/Tests/LibELF; /usr/lib/Loader.so /usr/Tests/LibELF/TestDlOpen`
in Serenity's terminal.
2024-05-07 16:36:38 -06:00
Sam Atkins
926a275794 HexEditor: Move endianness selector to Value Inspector panel
It's clearer to have the choice here than hidden away in a menu. It also
means we don't need the column heading to say the endianness.
2024-05-07 16:33:59 -06:00
Jamie Mansfield
8c4dc9476b LibWeb: Precision when using background-size: contain
This ensures that precision is maintained when calculating the image
size when using `background-size: contain`.
2024-05-07 11:15:04 -04:00
Jamie Mansfield
e48cb80a66 LibWeb: Precision when using background-size: cover
This ensures that precision is maintained when calculating the image
size when using `background-size: cover`.
2024-05-07 11:15:04 -04:00
Nico Weber
51fc51d0b5 LibGfx/WebPWriter: Use one-element huffman tree for opaque images
That way, we can write 0 instead of 8 bits for every alpha byte.
Reduces the size of sunset-retro.png when saved as a webp file
from 3 MiB to 2.25 MiB, without affecting encode speed.

Once we use CanonicalCodes we'll get this for free for all channels,
but opaque images are common enough that it feels worth it to do this
before then.
2024-05-07 11:13:01 -04:00
Nico Weber
7d93f7fc99 LibGfx/WebPWriter: Correctly fill in alpha_is_used hint 2024-05-07 11:13:01 -04:00
Nico Weber
0e2e7cd1be LibGfx/WebPWriter: Rename alpha_hint to alpha_is_used_hint
No behavior change.
2024-05-07 11:13:01 -04:00
Nico Weber
5b335d51e1 LibGfx/WebPWriter: Implement ICC color profile data writing
Most of this code (VP8X chunk writing) will be used for writing
animated webp files too.
2024-05-07 11:11:41 -04:00
Nico Weber
c174adc6b1 LibGfx/WebPLossless: Remove a useless non-spec comment
There's already a spec comment saying the same thing a few lines
further down, just move that up.

No behavior change.
2024-05-07 11:10:06 -04:00
Nico Weber
7b3cc2e055 LibGfx/WebPLossless: Add spec ref about color indexing modifying width
No behavior change. This got clarified here:
https://chromium-review.googlesource.com/c/webm/libwebp/+/4688320
2024-05-07 11:10:06 -04:00
Nico Weber
26b3e31f2e LibGfx/WebPLossless: Make width_bits reading look more like in the spec
No behavior change.
2024-05-07 11:10:06 -04:00
Nico Weber
c1b289c144 LibGfx/WebPLossless: Add spec note about combining predicted values
No behavior change. This got clarified in the spec in
https://chromium-review.googlesource.com/c/webm/libwebp/+/4638649
2024-05-07 11:10:06 -04:00
Nico Weber
3662eea0ac LibGfx/WebPLossless: Update spec comments for reading max_symbol
This used to be misleading in the spec, but that was fixed in
https://chromium-review.googlesource.com/c/webm/libwebp/+/4674031

Update the comments to match.

Also, a check we already had got added to the spec in
https://chromium-review.googlesource.com/c/webm/libwebp/+/4674032
so add a citation for that.

No behavior change.
2024-05-07 11:10:06 -04:00
Nico Weber
a511f5507c LibGfx/WebPLossless: Add spec comment about transform order
This used to not be mentioned in the spec, but it got added
based on our feedback:
https://chromium-review.googlesource.com/c/webm/libwebp/+/4637757
2024-05-07 11:10:06 -04:00
Nico Weber
e69a0fa7d3 LibGfx/WebPLossless: Add a spec comment
No behavior change. Makes things flow better with the comment I'm
about to add in the next commit.
2024-05-07 11:10:06 -04:00
Nico Weber
5897e9bd29 LibGfx/WebPLossless: Move around a spec comment
That way, we don't need a comment that wasn't from the spec.
No behavior change.
2024-05-07 11:10:06 -04:00
Nico Weber
076a8e5d0b LibGfx/WebPLossless: Remove "AMENDED" in spec comments
No behavior change. This corresponds to this spec change:
https://chromium-review.googlesource.com/c/webm/libwebp/+/4567695
2024-05-07 11:10:06 -04:00
Nico Weber
05bb657b8b LibGfx/WebPLossless: Replace num_code_lengths check with VERIFY
No behavior change. This corresponds to this spec change:
https://chromium-review.googlesource.com/c/webm/libwebp/+/4779444
2024-05-07 11:10:06 -04:00
matjojo
cd1eeb3cdd LibWeb: Do not consume scroll event in PaintableBox without overflow
Specifically, without scrollable overflow.

Fixes #24009, both on brave.com and on the reduction.
2024-05-07 14:04:02 +00:00
Andreas Kling
a020a0779d LibJS/Bytecode: Do a stack check when entering run_bytecode()
If we don't have enough stack space, throw an exception while we still
can, and give the caller a chance to recover.

This particular problem will go away once we make calls non-recursive.
2024-05-07 09:15:40 +02:00
Andreas Kling
7b93b8cea7 LibJS/Bytecode: Flatten the interpreter main loop (Clang only)
This means inlining all the things. This yields a 40% speedup on the for
loop microbenchmark, and everything else gets faster as well. :^)

This makes compilation take foreeeever with GCC, so I'm only enabling it
for Clang in this commit. We should figure out how to make GCC compile
this without timing out CI, since the speedup is amazing.
2024-05-07 09:15:40 +02:00
Andreas Kling
f4af056aa9 LibJS/Bytecode: Thread the bytecode interpreter
This commit converts the main loop in Bytecode::Interpreter to use a
label table and computed goto for fast instruction dispatch.

This yields roughly 35% speedup on the for loop microbenchmark,
and makes everything else faster as well. :^)
2024-05-07 09:15:40 +02:00
Andreas Kling
b45f55b199 LibJS/Bytecode: Fix wonky serialization of instruction value lists 2024-05-07 09:15:40 +02:00
Andreas Kling
9cbf17f181 LibJS/Bytecode: Emit do...while body before test in codegen
This makes the code flow naturally and allows jump elision to work.
2024-05-07 09:15:40 +02:00
Andreas Kling
68507b7e55 LibJS/Bytecode: Store SetLocal's local index as a u32
Same size as local indexes everywhere else.
2024-05-07 09:15:40 +02:00
Andreas Kling
e43d96f310 LibJS/Bytecode: Remove Instruction::m_length field
Now that the interpreter is unrolled, we can advance the program counter
manually based on the current instruction type.

This makes most instructions a bit smaller. :^)
2024-05-07 09:15:40 +02:00
Andreas Kling
ce93000757 LibJS/Bytecode: Unroll the bytecode interpreter
This commit adds a HANDLE_INSTRUCTION macro that expands to everything
needed to handle a single instruction (invoking the handler function,
checking for exceptions, and advancing the program counter).

This gives a ~15% speed-up on a for loop microbenchmark, and makes
basically everything faster.
2024-05-07 09:15:40 +02:00
Andreas Kling
fae1527a18 LibJS/Bytecode: Turn JumpIf condition,@a,@next into JumpTrue/JumpFalse
If one of the jump targets is the very next block, we can convert the
jump instruction into a smaller JumpTrue or JumpFalse.
2024-05-07 09:15:40 +02:00
Andreas Kling
37d722f4a6 LibJS/Bytecode: Make IdentifierTableIndex a 32-bit index
This makes a bunch of instructions smaller.
2024-05-07 09:15:40 +02:00
Andreas Kling
95759dcc6d LibJS/Bytecode: Put end block last in for statement codegen 2024-05-07 09:15:40 +02:00
Andreas Kling
f3d57db774 LibJS/Bytecode: Stop emitting unnecessary jump at end of for statement 2024-05-07 09:15:40 +02:00
Andreas Kling
69cc64e94c LibJS/Bytecode: Emit for condition check before update statement
This allows jump elision to eliminate an unnecessary jump since things
now get laid out naturally in memory (normal execution order).
2024-05-07 09:15:40 +02:00
Andreas Kling
24d8b056c7 LibJS/Bytecode: Elide jumps that land in the very next block
Jumping to the next block is effectively a no-op, so let's save time and
space by just not emitting those jumps.
2024-05-07 09:15:40 +02:00
Andreas Kling
3a73eb99ac LibJS/Bytecode: Store labels as basic block index during compilation
Instead of storing a BasicBlock* and forcing the size of Label to be
sizeof(BasicBlock*), we now store the basic block index as a u32.

This means the final version of the bytecode is able to keep labels
at sizeof(u32), shrinking the size of many instructions. :^)
2024-05-07 09:15:40 +02:00
Andreas Kling
5a08544138 LibJS/Bytecode: Keep instruction source mappings in Executable
Instead of storing source offsets with each instruction, we now keep
them in a side table in Executable.

This shrinks each instruction by 8 bytes, further improving locality.
2024-05-07 09:15:40 +02:00
Andreas Kling
4cf4ea92a7 LibJS/Bytecode: Store Instruction length as u32
This makes every instruction 8 bytes smaller.
2024-05-07 09:15:40 +02:00
Andreas Kling
f6aee2b9e8 LibJS/Bytecode: Flatten bytecode to a contiguous representation
Instead of keeping bytecode as a set of disjoint basic blocks on the
malloc heap, bytecode is now a contiguous sequence of bytes(!)

The transformation happens at the end of Bytecode::Generator::generate()
and the only really hairy part is rerouting jump labels.

This required solving a few problems:

- The interpreter execution loop had to change quite a bit, since we
  were storing BasicBlock pointers all over the place, and control
  transfer was done by redirecting the interpreter's current block.

- Exception handlers & finalizers are now stored per-bytecode-range
  in a side table in Executable.

- The interpreter now has a plain program counter instead of a stream
  iterator. This actually makes error stack generation a bit nicer
  since we just have to deal with a number instead of reaching into
  the iterator.

This yields a 25% performance improvement on this microbenchmark:

    for (let i = 0; i < 1_000_000; ++i) { }

But basically everything gets faster. :^)
2024-05-07 09:15:40 +02:00
Andreas Kling
c2d3d9d1d4 LibJS/Bytecode: Make each Jump instruction inherit Instruction directly
Before this change, all JumpFoo instructions inherited from Jump, which
forced the unconditional Jump to have an unusued "false target" member.
Also, labels were unnecessarily wrapped in Optional<>.

By defining each jump instruction separately, they all shrink in size,
and all ambiguity is removed.
2024-05-07 09:15:40 +02:00
Timothy Flynn
464d7d5858 LibGfx+LibWeb: Allow inexact size lookups when requesting scaled fonts
For bitmap fonts, we will often not have an exact match for requested
sizes. Return the closest match instead of a nullptr.

LibWeb is currently the only user of this API. If it needs to be
configurable in the future to only allow exact matches, we can add a
parameter or another method at that time.
2024-05-06 23:26:42 +00:00
dgaston
8f784243a1 Chess: Improve PGN importing
This commit replaces the `import_pgn` implementation
with a more resiliant parser to handle various edge
cases and give helpful error messages instead of crashing.
2024-05-06 19:25:07 +01:00
Lucas CHOLLET
3c138b9580 LibGfx/TIFF: Support bilevel images missing baseline tags
Bilevel images are not required to have a BitsPerSample or a
SamplesPerPixel tag.
2024-05-06 17:33:25 +02:00
Lucas CHOLLET
eb142b1d28 LibGfx/TIFF: Put code to check for bilevel images in its own function 2024-05-06 17:33:25 +02:00
Lucas CHOLLET
8fb9c72c56 LibGfx/TIFF: Manually check for the presence of two baseline tags
Namely: BitsPerSample and SamplesPerPixel.
2024-05-06 17:33:25 +02:00
MacDue
23d8d217ed LibWeb: Ignore setting zero, negative, or non-finite CRC2D.lineWidths
This is part of the spec but was missed. This fixes a crash on:
https://www.kevs3d.co.uk/dev/phoria/test1d.html
2024-05-06 17:33:04 +02:00
Nico Weber
d0a2cf2dce LibGfx/WebPWriter: Implement basic lossless webp writing
This doesn't use any transforms yet (in particular not the predictor
transform), and doesn't do anything else that actually compresses the
data.

It also give all 256 values code length 8 unconditionally. This means
the huffman trees are not data-dependent at all and provide no
compression. It also means we can just write out the image data
unmodified.

So the output is fairly large. But it _is_ a valid lossless webp file.

Possible follow-ups, to improve compression later:
1. Use actual byte distributions to create huffman trees, to get
   huffman compression.
2. If the distribution has just 1 element, write a simple code length
   code (that way, images that have alpha 0xff everywhere need to store
   no data for alpha).
3. Add backref support, to get full deflate(ish) compression of pixels.
4. Add predictor transform.
5. Consider writing different sets of prefix codes for every 16x16 tile
   (by writing a meta prefix code image).

(It might be nice to make the follow-ups optional, so that this can also
be used as a webp example file generator.)
2024-05-06 17:32:19 +02:00
Nico Weber
d04f9cf3c8 LibGfx+image: Add scaffolding for writing webp files 2024-05-06 17:32:19 +02:00
Nico Weber
65d166e570 LibGfx: Add const overloads of Bitmap::begin() / end() 2024-05-06 17:32:19 +02:00
Aliaksandr Kalenik
f21c0f9dcd LibJS: Skip some declarative env allocations in function instantiation
If all lexical declaration use local variables then there is no need
to allocate declarative environment.

With this change we skip ~3x more environment allocations on Github.
2024-05-06 15:09:20 +02:00
Daniel La Rocque
9065b0b0f6 LibJS: Truncate roundingIncrement before range check
This is a normative change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/8fc8130
2024-05-05 19:59:26 +01:00
Aliaksandr Kalenik
7f0bafdbd0 LibWeb: Log error instead of crashing if stacking context painted twice
Turns out this mistake happens fairly often, so it is more preferable to
log message and proceed instead of crashing.
2024-05-05 18:23:41 +02:00
MacDue
130aff12b1 LibWeb: Fix null layout node dereference in SVGMaskable
This makes sure `get_mask_type_of_svg()` finds the mask or clipPath by
looking at its child layout nodes. Previously, it went via the DOM node
of the mask or clipPath, which is not always correct as there is not a
1-to-1 mapping from mask DOM node to SVGMaskBox (or SVGClipBox).

Fixes #24186
2024-05-05 13:35:14 +00:00
Ava Rider
3a7bea7402 LibPDF: Added empty read check to parse_hex_string 2024-05-05 06:45:42 +01:00