Commit graph

33699 commits

Author SHA1 Message Date
Diego cf6aa77816 LibWasm: Fix memory limits validator discrepancy
The spec allows the maximum size of the linear memory to be 2^16.
However, we previously only allowed 2^16-1, which caused a spec
compliance issue.
2024-06-01 00:28:48 +02:00
Andrew Kaster a9fdd819c3 LibCore: Don't leak EventLoopImplementationUnix's ThreadData
The ThreadData still has a lifetime a longer than the thread it was
created for, but at least now it's not leaked at process exit.
2024-05-31 15:24:46 -06:00
Nico Weber 8a21992030 image: Add a --webp-allowed-transforms switch
This is mainly useful for testing.
2024-05-31 22:39:25 +02:00
Nico Weber 533b29dde7 LibGfx/WebPWriter: Add a toggle for disabling individual transforms 2024-05-31 22:39:25 +02:00
Nico Weber 47d3245ea7 LibGfx/WebPWriter: Do not convert -inf to unsigned
Else UBSan complains about the color indexing test in this PR.
2024-05-31 22:39:25 +02:00
Nico Weber 9e61912f64 LibGfx/WebPWriter: Fix bug computing max_symbol bit length
Storing a number n needs floor(log2(n) + 1) bits, not ceil(log2(n)).
(The two expressions are identical except for when n is a power of 2.)

Serendipitously covered by the indexed color transform tests in this PR.
2024-05-31 22:39:25 +02:00
Nico Weber 5c990e87f4 LibGfx/WebPWriter: Add a dbgln_if() 2024-05-31 22:39:25 +02:00
Nico Weber e212c20228 LibGfx/WebPWriter: Implement pixel bundling for color indexing
If an image has <= 16 colors, WebP lossless files pack multiple
color table indexes into a single pixel's green channel, further
reducing file size. This adds support for that.

My current test files all have more than 16 colors. For a 16x16
black-and-white bitmap that contains a little smiley face in the
middle, this reduces the output size from 128B to 54B.
2024-05-31 22:39:25 +02:00
Nico Weber cae672e1f9 LibGfx/WebPWriter: Implement color indexing transform
If an image has 256 or fewer colors, WebP/Lossless allows storing
the colors in a helper image, and then storing just indexes into that
helper image in the main image's green channel, while setting
r, b, and a of the main image to 0.

Since constant-color channels need to space to store in WebP,
this reduces storage needed to 1/4th (if alpha is used) or 1/3rd
(if alpha is constant across the image).

If an image has <= 16 colors, WebP lossless files pack multiple
color table indexes into a single pixel's green channel, further
reducing file size. This pixel packing is not yet implemented in
this commit.

GIFs can store at most 256 colors per frame, so animated gifs
often have 256 or fewer colors, making this effective when
transcoding gifs.

(WebP also has a "subtract green" transform, which can be used
to need to store just a single channel for grayscale images, without
having to store a color table. That's not yet implemented -- for now,
we'll now store grayscale images using this color indexing transform
instead, which wastes to storage for the color table.)

(If an image has <= 256 colors but all these colors use only a single
channel, then storing a color table for these colors is also wasteful,
at least if the image has > 16 colors too. That's rare in practice,
but maybe we can add code for it later on.)

(WebP also has a "color cache" feature where the last few used colors
can be referenced using very few bits. This is what the webp spec says
is similar to palettes as well. We don't implement color cache writing
support yet either; maybe it's better than using a color indexing
transform for some inputs.)

Some numbers on my test files:

sunset-retro.png: No performance or binary size impact. The input
quickly uses more than 256 colors.

giphy.gif (184k): 4.1M -> 3.9M, 95.5 ms ± 4.9 ms -> 106.4 ms ± 5.3 ms
Most frames use more than 256 colors, but just barely. So fairly
expensive runtime wise, with just a small win.

(See comment on #24454 for the previous 4.9 MiB -> 4.1 MiB drop.)

7z7c.gif (11K): 118K -> 40K
Every frame has less than 256 colors (but more than 16, so no packing),
and so we can cut filesize roughly to 1/3rd: We only need to store an
index per channel. From 10.7x as large as the input to 3.6x as large.
2024-05-31 22:39:25 +02:00
Nico Weber 633f509eb4 LibGfx/WebP: Move TransformType to WebPSharedLossless.h 2024-05-31 22:39:25 +02:00
Nico Weber 804e85265e LibGfx/WebPWriter: Use an IsOpaque struct for tracking opacity
No behavior change, but this makes it easy to correctly set this
flag when adding an indexing transform: Opacity then needs to be
determined based on if colors in the color table have opacity,
not if the indexes into the color table do.

With this struct, only the first time something sets opacity is
honored, giving us those semantics.
2024-05-31 22:39:25 +02:00
Nico Weber c5dedbc54a LibGfx/WebPWriter: Give write_VP8L_coded_image() a kind parameter
This way, it can be used to write entropy-coded-images too,
which will be used when writing transforms.
2024-05-31 22:39:25 +02:00
Nico Weber b50702f490 LibGfx/WebP: Move ImageKind to WebPSharedLossless.h 2024-05-31 22:39:25 +02:00
Nico Weber 9dfb254c73 LibGfx/WebPWriter: Extract write_VP8L_coded_image() 2024-05-31 22:39:25 +02:00
Nico Weber d9aa594e86 LibGfx/WebPWriter: Add comment for image-stream production 2024-05-31 22:39:25 +02:00
Nico Weber 286cc6f905 LibGfx/WebPLoader: Prefix a few dbgln_if()s with chunk name 2024-05-31 22:39:25 +02:00
Nico Weber a2ddf054f2 LibGfx/WebPWriter: Remove two obsolete comments
In an early version of the huffman writing code, we always used 8 bits
here, and the comments still reflected that. Since we're now always
writing only as many bits as we need (in practice, still almost always
8), the comments are misleading.
2024-05-31 22:39:25 +02:00
Andreas Kling 391c53025e Revert "LibProtocol: Retry reading if read errors with EAGAIN"
This reverts commit d0f88d4958.

This made us hang when loading GitHub repo pages.
2024-05-31 17:17:24 +02:00
Andreas Kling a48fc971c6 LibJS: Rearrange ExecutionContext members to shrink the class
Just a minor tweak to make the class 8 bytes smaller.
2024-05-31 16:31:33 +02:00
Andreas Kling a3782782fa LibJS: Remove two unused members from ExecutionContext 2024-05-31 16:31:33 +02:00
Romain Chardiny f5cacf25e1 Utilities: Add shred utility 2024-05-31 13:49:34 +01:00
Romain Chardiny 892da127d0 LibCore: Add wrapper for fsync() 2024-05-31 13:49:34 +01:00
Simon Wanner 11bb216912 LibTextCodec: Add replacement decoder 2024-05-31 07:56:26 +02:00
Simon Wanner 7f3b457e62 LibTextCodec: Add EUC-KR decoder 2024-05-31 07:56:26 +02:00
Simon Wanner ded6512ca8 LibTextCodec: Add Shift_JIS decoder 2024-05-31 07:56:26 +02:00
Simon Wanner 06f7c393b2 LibTextCodec: Add ISO-2022-JP decoder 2024-05-31 07:56:26 +02:00
Simon Wanner 45f0ae52be LibTextCodec: Add EUC-JP decoder 2024-05-31 07:56:26 +02:00
Simon Wanner 9943bb1d8e LibTextCodec: Add Big5 decoder 2024-05-31 07:56:26 +02:00
Simon Wanner 2ce61fe6ea LibTextCodec: Add GBK/GB18030 decoder
Includes changes from GB-18030-2022, which are not yet included in the
Encoding Specification, but WebKit, Blink and WPT are already updated.
2024-05-31 07:56:26 +02:00
Simon Wanner 9ed52504ab LibTextCodec: Delegate to process() in default validate() implementation 2024-05-31 07:56:26 +02:00
Simon Wanner 88c2586f25 LibTextCodec: Remove unused decoder classes 2024-05-31 07:56:26 +02:00
Andrew Kaster 46e00a8f5e LibWeb: Parse TokenizedFeatures from window.open 2024-05-30 16:16:33 -04:00
Andrew Kaster e2d50dc5dd LibWeb: Move window.open TokenizedFeature parsing into its own file 2024-05-30 16:16:33 -04:00
Tim Ledbetter 79143833b6 LibWeb/WebDriver: Ensure error responses are serialized correctly 2024-05-30 13:53:24 -04:00
stelar7 a4e97c1598 WebDriver: Dont assume the pageLoad is an i64 2024-05-30 11:46:02 -04:00
stelar7 fa9c234976 WebDriver: Parse webSocketUrl capability 2024-05-30 11:46:02 -04:00
Matthew Olsson 9ea6ab0ad4 LibJS+LibWeb: Fix a ton of JS_CELL-like macro issues 2024-05-30 09:29:20 -06:00
Tim Ledbetter 7aea87c9df LibWeb+LibWebView+WebContent: Add basic find in page functionality
This allows the browser to send a query to the WebContent process,
which will search the page for the given string and highlight any
occurrences of that string.
2024-05-30 16:30:11 +02:00
Diego 4eaabdad34 LibWasm: Properly read blocktypes
This works for now, but is technically still not spec compliant. Right
now, we're (potentially) missing one bit when reading function indices.
See the relevant issue: #24462.
2024-05-29 22:33:15 +02:00
Daniel Bertalan 9d3b73743e sql: Work around Clang 17/18 run-time call to consteval function
There was an issue with Clang that causes `consteval` function calls
from default initializers of fields to be made at run-time. This
manifested itself in the case of `ByteString::formatted` as an undefined
reference to `check_format_parameter_consistency` once format string
checking was enabled for Clang builds. The workaround is simple (just
move it to the member initializer list), and unblocks a useful change.
2024-05-29 13:34:15 -06:00
Andrew Kaster ca806a3e18 WebDriver+WebContent: Add /session/🆔/window/consume-user-activation
This extension to the WebDriver spec is defined in the HTML spec, how
fun.
2024-05-29 21:30:15 +02:00
Andrew Kaster 9bc1318a78 LibWeb: Consume user activation when showing a picker dialog 2024-05-29 21:30:15 +02:00
Andrew Kaster a3a74245d6 LibWeb: Implement consume user activation AO 2024-05-29 21:30:15 +02:00
Andrew Kaster 45860e3878 LibWeb: Move consume history-action user activation to Window 2024-05-29 21:30:15 +02:00
Andrew Kaster 9c6ebe21d2 LibWeb: Remove get prefix from activation timestamp getters 2024-05-29 21:30:15 +02:00
Andrew Kaster 2fde20993b LibWeb: Update show the picker if applicable to latest spec text 2024-05-29 21:30:15 +02:00
Jamie Mansfield 7da449ce01 LibWeb: Check correct activation (spec fix)
See:
- https://github.com/whatwg/html/commit/d28284f
2024-05-29 09:32:59 -06:00
Jamie Mansfield 34b2a4f7ca LibWeb: Add getter for history-action activation 2024-05-29 09:32:59 -06:00
Jamie Mansfield a741f68eb9 LibWeb: Implement "consume history-action user activation" 2024-05-29 09:32:59 -06:00
Jamie Mansfield 30539db2fc LibWeb: Use Infinity<double> for infinity
Co-authored-by: Matthew Olsson <matthewcolsson@gmail.com>
2024-05-29 09:32:59 -06:00