Commit graph

52686 commits

Author SHA1 Message Date
Lucas CHOLLET
89e2431517 Tests/LibGfx: Add a first test for JPEG XL images
This image uses the modular encoding with a very simple prediction tree.
It also makes use of two features: upsampling (x2 factor) and a
non-standard bit depth (10 bits). The file has been generated on
https://jxl-art.surma.technology/ , with the following input:

Width 64
Height 64
Upsample 2
Bitdepth 10

if N > 300
  - NE -6
  - W 6
2023-07-22 08:52:57 -04:00
Lucas CHOLLET
9975bdb2d1 LibGfx/JPEGXL: Align the stream to byte boundary before reading a frame
As this is stated in the spec, all frames are byte-aligned.
2023-07-22 08:52:57 -04:00
Xexxa
ea88242d1c Base: Add more emoji
🐹 - U+1F439 HAMSTER
🦂 - U+1F982 SCORPION
🥐 - U+1F950 CROISSANT
🫕 - U+1FAD5 FONDUE
🏫 - U+1F3EB SCHOOL
🚑 - U+1F691 AMBULANCE
🛺 - U+1F6FA AUTO RICKSHAW
🧧 - U+1F9E7 RED ENVELOPE
🥍 - U+1F94D LACROSSE
🤿 - U+1F93F DIVING MASK
🥽 - U+1F97D GOGGLES
🩺 - U+1FA7A STETHOSCOPE
2023-07-22 08:50:46 -04:00
Xexxa
ad645c7103 Base: Add more emoji
🏵️ - U+1F3F5 ROSETTE
🦠 - U+1F9A0 MICROBE
🪽 - U+1FABD WING

Co-authored-by: Ryan Liptak <squeek502@hotmail.com>
2023-07-22 08:50:46 -04:00
Andreas Kling
5d6169793a Ladybird+LibWebView: Respawn with same JS interpreter after crash
WebView::ViewImplementation now remembers which JS interpreter it
started with, and uses the same setting if the WebContent process
crashes and we have to spawn a new one.
2023-07-22 08:49:59 -04:00
Timothy Flynn
8b23bbf58e LibJS: Read properties from the Intl.DateTimeFormat options object once
This is a normative change in the ECMA-402 spec. See:
https://github.com/tc39/ecma402/commit/02bd03a

This is observable just due to reading the properties one less time. It
would have been possible for e.g. the property values to change between
those invocations.
2023-07-22 10:18:55 +02:00
Timothy Flynn
3a4cdf77ba LibJS: Move Intl.DateTimeFormat creation to CreateDateTimeFormat AO
This is an editorial change in the ECMA-402 spec. See:
https://github.com/tc39/ecma402/commit/b6ed64b
https://github.com/tc39/ecma402/commit/6e3b70d

This moves Intl.DateTimeFormat creation to InitializeDateTimeFormat and
renames that AO to CreateDateTimeFormat.
2023-07-22 10:18:55 +02:00
Timothy Flynn
ea774111e8 LibJS: Raise the upper minimum/maximum fraction digit limit to 100
This is a normative change in the ECMA-402 spec. See:
https://github.com/tc39/ecma402/commit/f6d2945
2023-07-22 10:18:55 +02:00
Lucas CHOLLET
3fdf5072ec LibCompress/Brotli: Remove CanonicalCode::clear()
This function was used in a single place and don't provide a huge
benefit over simply recreating the object.
2023-07-22 07:10:47 +02:00
Andi Gallo
63e72feee1 LibWeb: Add additional term to the table cell min contribution
Align with specification.
2023-07-22 07:06:50 +02:00
Andi Gallo
6104e4ecb5 LibWeb: Simplify specified size formulas when computing cell measures
Make it clearer how it's supposed to work relative to specification.
2023-07-22 07:06:50 +02:00
Andi Gallo
6dfa1c2548 LibWeb: Distribute excess width to columns as in specification 2023-07-22 07:06:50 +02:00
Andi Gallo
eb20eeb54c LibWeb: Use column and row size for cell outer sizes
Better aligns our implementation with the specification, which requires
that we check columns and column groups too.
2023-07-22 07:06:50 +02:00
Andi Gallo
28509e3edd LibWeb: Check column or row size attributes for constrainedness
Better aligns our implementation with the specification, which requires
that columns and groups of columns are checked too.
2023-07-22 07:06:50 +02:00
Andi Gallo
19a26533a9 LibWeb: Make the type of column whether it's percent or not
Change how we store type of columns. It was used where the specification
only distinguishes between percent and everything else, so it makes more
sense to store and use it as a boolean.
2023-07-22 07:06:50 +02:00
Andi Gallo
0314e26ef4 LibWeb: Linear interpolation between table width sizing guesses
Make used widths of the columns a linear combination of two consecutive
sizing-guesses when the assignable table width is less than or equal to
the max-content sizing-guess, as the specification describes.
2023-07-22 07:06:50 +02:00
Andi Gallo
030b1a197b LibWeb: Don't use the preferred increment as reference for distribution
The specification says we should distribute excess width proportionally
to the width of the cell, not to the preferred increment. Doing the
latter leads to distributing all excess width to just the cells which
demand some increment, even if it's very modest. Moreover, there's code
which partially implements the correct criteria just below the one we
remove here.
2023-07-22 07:06:50 +02:00
Andi Gallo
13687085dd LibWeb: Better align outer max sizes for cells with the specification
The formulas are different between the constrained and non-constrained.
2023-07-22 07:06:50 +02:00
Andi Gallo
81d0b17987 LibWeb: Rework the computation of {min, max-}size and size for cells
Follow the specification more closely when computing the cell measures.
2023-07-22 07:06:50 +02:00
Andi Gallo
a9a5224132 LibWeb: Add 'outer' prefix to {min, max}_{width, height}
Follow the specification terminology.
2023-07-22 07:06:50 +02:00
Andreas Kling
1768d70823 Revert "LibJS: Remove "uprooting" mechanism from garbage collector"
This reverts commit 6232ad3a0d.

Unfortunately this introduced some flakiness on CI, so it wasn't
quite this simple.
2023-07-22 06:53:26 +02:00
Lucas CHOLLET
a2955501d3 LibGfx/JPEGXL: Don't decode the header twice
This is something I missed when I ported the JPEG XL decoder to the new
plugin interface (decoding the header at creation). First sorry because
that's entirely my fault, second sorry because a test should have caught
that.
2023-07-21 22:25:56 -04:00
Lucas CHOLLET
65565d377b LibGfx/JPEGXL: Accept images with high bit depth
Instead of rejecting them, we truncate each value to 8 bits. This is
clearly a hack, but given the lack of support of variable bit-depth in
`Bitmap` this is the only sensible change.

This allows us to display "Iceberg" on https://jpegxl.info/art/.
2023-07-21 19:34:21 -04:00
Tim Ledbetter
6710622bf7 file: Add -b option to omit file name from output 2023-07-21 19:32:43 -04:00
Aliaksandr Kalenik
fd9b3bdc94 LibWeb: Support auto vertical margins for grid items 2023-07-21 21:09:45 +02:00
Andreas Kling
9f06e130a2 LibJS/Bytecode: Keep saved return value in call frame register
This fixes an issue where returning inside a `try` block and then
calling a function inside `finally` would clobber the saved return
value from the `try` block.

Note that we didn't need to change the base of register allocation,
since it was already 1 too high.

With this fixed, https://microsoft.com/edge loads in bytecode mode. :^)

Thanks to Luke for reducing the issue!
2023-07-21 19:15:33 +02:00
Lucas CHOLLET
475f1b6083 LibCore+LibGfx+LibGUI: Consider JPEG XL files as images
This includes registering the mime type and adding it to both the list
of supported image format and the filter for images type in LibGUI.
2023-07-21 10:47:34 -06:00
Lucas CHOLLET
e8a63eeb0e LibGfx/JPEGXL: Add a JPEG-XL decoder :^)
JPEG-XL is a new image format standardized by the same committee as the
original JPEG image format. It has all the nice feature of recent
formats, and great compression ratios. For more details, look at:
https://jpegxl.info/

This decoder is far from being feature-complete, as it features a grand
total of 60 FIXMEs and TODOs but anyway, it's still a good start.

I developed this decoder in the Serenity way, I just try to decode a
specific image while staying as close as possible to the specification.

Considering that the format supports a lot of options, and that we
basically support only one possibility for each of them, I'm pretty sure
that we can only decode the image I've developed this decoder for.

Which is:
0aff 3ffa 9101 0688 0001 004c 384b bc41
5ced 86e5 2a19 0696 03e5 4920 8038 000b
2023-07-21 10:47:34 -06:00
Lucas CHOLLET
bb834ed765 LibCompress: Add a constructor to Brotli::CanonicalCode
This constructor will be used by the JPEG-XL decoder to support a
non-standard special case. Other user should only use other
constructors.
2023-07-21 10:47:34 -06:00
Lucas CHOLLET
96eace8390 LibCompress: Move CanonicalCode in the Brotli namespace
The class was an inner class of `BrotliDecompressionStream`, let's move
it outside the `Stream` object in order to ease the access to user only
interested in this part.
2023-07-21 10:47:34 -06:00
Lucas CHOLLET
9248fd7f33 LibCompress: Move CanonicalCode's initializers inside CanonicalCode
These routines:
 - read_prefix_code
 - read_simple_prefix_code
 - read_complex_prefix_code

 were methods of `BrotliDecompressionStream` taking a `CanonicalCode` as
 an out parameter. This patch puts them in `CanonicalCode` as static
 methods.
2023-07-21 10:47:34 -06:00
Lucas CHOLLET
d2dd4142d1 LibCompress: Make CanonicalCode::read_symbol const 2023-07-21 10:47:34 -06:00
Lucas CHOLLET
f79165cefe AK: Make FixedArray movable 2023-07-21 10:47:34 -06:00
Timothy Flynn
77d7f715e3 LibJS+CI: Remove bytecode optimization passes for now
These passes have not been shown to actually optimize any JS, and tests
have become very flaky with optimizations enabled. Until some measurable
benefit is shown, remove the optimization passes to reduce overhead of
maintaining bytecode operations and to reduce CI churn. The framework
for optimizations will live on in git history, and can be restored once
proven useful.
2023-07-21 19:47:36 +03:30
Nico Weber
164c132928 LibPDF: Fix dumping of toplevel indirects
An indirect object starts `42 0 obj`, not `obj 42 0`.
2023-07-21 10:44:50 -04:00
Andreas Kling
6232ad3a0d LibJS: Remove "uprooting" mechanism from garbage collector
The Heap::uproot_cell() API was used to implement markAsGarbage() which
was used in 3 tests to forcibly destroy a value, even if it had
references on the stack or elsewhere.

This patch rewrites the 3 tests that used this mechanism to be
structured in a way that allows garbage collection to collect the values
as intended without hacks. And now that the uprooting mechanism is no
longer needed, it's uprooted as well.

This fixes 3 test-js tests in bytecode mode. :^)
2023-07-21 14:14:00 +02:00
Andreas Kling
9054b1bc14 LibJS: Always taint parsing environment on call to eval()
We had an edge case where calls to eval() left the environment untainted
*if* `eval` had also been declared as a local variable in the same
parsing context.

This broke the expected direct eval behavior when the variable `eval`
was still pointing at the global `eval` function.

This patch fixes the issue by simply always tainting the environment
when a call to something named `eval` is encountered. It doesn't seem
worth worrying about optimizing the case where someone is calling their
own function named `eval`..

Fixes 1 test-js test in bytecode mode. :^)
2023-07-21 14:14:00 +02:00
Andreas Kling
c90bf22d29 LibJS/Bytecode: Use primitive this for strict mode GetByValue
GetByValue now shares code with GetById to elide the synthetic wrapper
objects for primitive values in strict mode.

Fixes 2 test-js tests in bytecode mode. :^)
2023-07-21 14:14:00 +02:00
Andreas Kling
7253d021fc LibJS/Bytecode: Factor out determining the base object from GetById
This will allow us to use the same logic in GetByValue (in a subsequent
commit.)
2023-07-21 14:14:00 +02:00
Andreas Kling
6de22ec789 LibJS/Bytecode: Rename RegisterWindow to CallFrame
This is a better name for what it actually represents.
2023-07-21 14:14:00 +02:00
Liav A
061ebd0b15 Ports: Update acpica-tools to use other upstream
Also, update it to the latest revision, which makes it possible to build
without most of the patches we needed before, but now we need our own
definitions for LibC includes and to disable errors for the warning
bad-function-cast.
2023-07-21 12:48:24 +02:00
Nico Weber
f956cd6e6a LibPDF: Fix an off-by-one in computing_a_hash_r6_and_later()
With this, `pdf` can print info for CIPA_DC-003-2020_E.pdf
(from https://cipa.jp/e/std/std-sec.html), as well as all other
files I've tried.

CIPA_DC-003-2020_E.pdf is special because it quits this loop after
exactly 64 interations, at round_number 63.

While here, also update a comment to use the non-spec-comment style
I'm now using elsewhere in the file.
2023-07-21 11:55:20 +02:00
Nico Weber
f26783596d LibPDF: Implement StandardSecurityHandler::crypt for AESV3
With this, AESV3 support is complete and CIPA_DC-007-2021_E.pdf
can be opened :^)

(CIPA_DC-003-2020_E.pdf incorrectly cannot be opened yet. This
is due to a minor bug in computing_a_hash_r6_and_later() that
I'll fix a bit later. But except for this minor bug, all AESV3
files I've found so far seem to work.)
2023-07-21 11:55:20 +02:00
Nico Weber
12e77cba0a LibPDF: Move "7.6.2 General Encryption Algorithm" comment down a bit
The algorithm really only starts a bit later in the function,
so move the comment to there.
2023-07-21 11:55:20 +02:00
Nico Weber
6d0dbaf9d7 LibPDF: Extract aes helper in StandardSecurityHandler::crypt()
No behavior change, pure code move.

We'll use this for AESV3.
2023-07-21 11:55:20 +02:00
Nico Weber
9cbdb334ab LibPDF: Make try_provide_user_password() work for R6+ files
try_provide_user_password() calls compute_encryption_key_r6_and_later()
now. This checks both owner and user passwords. (For pre-R6 files,
owner password checking isn't yet implemented, as far as I can tell.)

With this, CIPA_DC-007-2021_E.pdf (or other AESV3-encrypted files)
successfully compute a file encryption key (...and then hit the
TODO() in StandardSecurityHandler::crypt() for AESV3, but it's
still good progress.)
2023-07-21 11:55:20 +02:00
Nico Weber
0428308420 LibPDF: Implement 7.6.4.3.3 Algorithm 2.A: Retrieve file encryption key
...for handlers of revision 6.

The spec for this algorithm has several quirks:

1. It describes how to authenticate a password as an owner password,
   but it redundantly inlines the description of algorithm 12 instead
   of referring to it. We just call that algorithm here.

2. It does _not_ describe how to authenticate a password as a user
   password before using the password to compute the file encryption
   key using an intermediate user key, despite the latter step that
   computes the file encryption key refers to the password as
   "user password". I added a call to algorithm 11 to check if the
   password is the user password that isn't in the spec. Maybe I'm
   misunderstanding the spec, but this looks like a spec bug to me.

3. It says "using AES-256 in ECB mode with an initialization vector
   of zero". ECB mode has no initialization vector. CBC mode with
   initialization vector of zero for message length 16 is the same
   as ECB mode though, so maybe that's meant? (In addition to the
   spec being a bit wobbly, using EBC in new software isn't
   recommended, but too late for that.)

SASLprep / stringprep still aren't implemented. For ASCII passwords
(including the important empty password), this is good enough.
2023-07-21 11:55:20 +02:00
Nico Weber
f8a3022ca2 LibPDF: Plumb OE, UE, Perms values to StandardSecurityHandler 2023-07-21 11:55:20 +02:00
Nico Weber
57768325cc LibPDF: Implement 7.6.4.4.11 Algorithm 12: Authenticating owner password
...for handlers of revision 6.

Since this adds U to the hash input, also trim the size of U and O to
48 bytes. The spec requires them to be 48 bytes, but all the newer PDFs
on https://cipa.jp/e/std/std-sec.html have 127 bytes -- 48 real bytes
and 79 nul padding bytes. These files were created by:

    Creator: Word 用 Acrobat PDFMaker 17
    Producer: Adobe PDF Library 15.0

and

    Creator: Word 用 Acrobat PDFMaker 17
    Producer: Adobe PDF Library 17.11.238
2023-07-21 11:55:20 +02:00
Nico Weber
8f6c67a71c LibPDF: Implement 7.6.4.4.10 Algorithm 11: Authenticating user password
...for handlers of revision 6.
2023-07-21 11:55:20 +02:00