Commit graph

48881 commits

Author SHA1 Message Date
Lucas CHOLLET 261d36351d LibGfx/JPEG: Replace C-style array by Array 2023-04-03 17:12:27 +01:00
Lucas CHOLLET df12e70541 LibGfx/JPEG: Bring IDCT and YCbCr conversion closer to specification
As mentioned in F.2.1.5 - Inverse DCT (IDCT), the decoder needs to
perform a level shift by adding 128. This used to be done in
`ycbcr_to_rgb` after the conversion. Now, we do it in `inverse_dct` in
order to ensure that the task is done unconditionally.

Consequences of this are that we are no longer required to explicitly
do it for RGB images and also, the `ycbcr_to_rgb` function is exactly
like the specification.
2023-04-03 17:12:27 +01:00
Lucas CHOLLET 62290d57f7 Tests: Add a test for SOF2 JPEGs with successive approximations
This image was generated using `cjpeg` with the following scan file:

0 1 2: 0 0 0 2;
0: 1 63 0 1;
1: 1 63 0 1;
2: 1 63 0 1;
0 1 2: 0 0 2 1;
0: 1 63 1 0;
1: 1 63 1 0;
2: 1 63 1 0;
0 1 2: 0 0 1 0;
2023-04-03 17:06:21 +01:00
Lucas CHOLLET f42d850211 LibGfx/JPEG: Don't reject SOF2 image with successive approximations
It means full SOF2 JPEG support, yay!
2023-04-03 17:06:21 +01:00
Lucas CHOLLET fbad9a70fc LibGfx/JPEG: Support refinement scans
These scans are only present in progressive JPEGs and contains bits to
increase the precision of values acquired in previous scans.
2023-04-03 17:06:21 +01:00
Lucas CHOLLET 8806e66f66 LibGfx/JPEG: Handle ZRL as a special case
When reading the stream, interpreted as a normal value 0xF0 means skip
15 values and assign the 16th to 0. On the other hand, the marker ZRL
- which has the value 0xF0, means skip 16 values. For baseline JPEGs,
ZRL doesn't need to be interpreted differently as writing the 16th value
has no consequence. This is no longer the case with refining scans.
That's why this patch implement correctly ZRL.
2023-04-03 17:06:21 +01:00
Lucas CHOLLET 731c876ff7 LibGfx/JPEG: Change the loop over AC coefficients
We used to skip over zero coefficient by modifying the loop counter. It
is unfortunately impossible to perform this with SOF2 images as only
coefficients with a zero-history should be skipped.
This induces no behavior change for the user of the function.
2023-04-03 17:06:21 +01:00
Lucas CHOLLET 902d0ab58e LibGfx/JPEG: Still iterate over AC coefficients of a EOB targeted block
This commit is nonsense for anything else than SOF2 images with spectral
approximation. For this particular case, skips like EOB or ZRL only
apply to coefficients with a zero-history. This commit prepares the code
to handle this behavior.
2023-04-03 17:06:21 +01:00
Lucas CHOLLET ef98b06dff LibGfx/JPEG: Split spectral_approximation
This `u8` is actually two values of 4 bits. Let's store them separately
to avoid confusion.
2023-04-03 17:06:21 +01:00
Sam Atkins 5c76b63f79 PDFViewer: Add list of recently-opened files 2023-04-03 16:32:03 +02:00
Timothy Flynn 15532df83d AK+Everywhere: Change AK::fill_with_random to accept a Bytes object
Rather than the very C-like API we currently have, accepting a void* and
a length, let's take a Bytes object instead. In almost all existing
cases, the compiler figures out the length.
2023-04-03 15:53:49 +02:00
Timothy Flynn 5c045b6934 AK: Add templated Span<u8> and Span<u8 const> constructors for C-arrays
This helper constructor exists on the unspecialized Span<T> class also,
and is convenient for e.g. creating Bytes from:

    u8 buffer[64];
    Bytes bytes { buffer };
2023-04-03 15:53:49 +02:00
Timothy Flynn f7960ffbe3 AK: Prevent passing lengths greater than 256 to getentropy()
From the getentropy() man page, "The maximum permitted value for the
length argument is 256". Several of our tests were passing lengths of
several thousand bytes, causing getentropy() to fail with EIO, which we
were completely ignoring. This caused these tests to only test long
sequences of 0x00.

We now loop over the provided buffer to fill it 256 bytes at a time. If
getentropy() fails for any reason, we fall back to the default method of
filling it with one random byte at a time.
2023-04-03 15:53:49 +02:00
Lucas CHOLLET cb0c8634d4 LibGfx/JPEG: Use a basic Stream instead of a SeekableStream
Only one use `seek` remains, as it is a bit more complex to remove.
2023-04-03 09:19:15 -04:00
Lucas CHOLLET dc9e783608 LibGfx/JPEG: Remove the ensure_bounds_okay function
This function has probably been added when we weren't as good with error
propagations as we are now. We can safely remove it and let future
calls to `read` fail if the file is corrupted.

This can be tested with the following bytes (already used in 9191829a):
ffd8ffc000000800080ef701101200ffda00030100
2023-04-03 09:19:15 -04:00
Idan Horowitz 402c9e5e23 Kernel: Implement Processor::assume_context for AArch64
With this implemented sys$execve should be fully working on AArch64.
2023-04-03 02:59:37 -06:00
Idan Horowitz 0dc5c49938 Kernel: Call exit_trap in AArch64 restore_context_and_eret
This matches x86_64's behaviour in common_trap_exit. (called from
thread_context_first_enter)
Currently thread_context_first_enter is only called when creating new
processes from scratch, in which case this doesn't change the actual
behaviour. But once thread_context_first_enter is called as part of
execve support, this will ensure the Thread's m_current_trap is set
correctly to the new trap frame.
2023-04-03 02:59:37 -06:00
Idan Horowitz a349570a04 Kernel: Abstract Processor::assume_context flags using InterruptsState
The details of the specific interrupt bits that must be turned on are
irrelevant to the sys$execve implementation. Abstract it away to the
Processor implementations using the InterruptsState enum.
2023-04-03 02:59:37 -06:00
Idan Horowitz 6ad8f4bb11 Kernel: Stop overwriting AArch64 link register in forked processes
Forked processes already have an existing value for the link register,
which we can't overwrite. But since they're forked the original link
register value that points to exit_kernel_thread was already saved
somewhere on the stack, so it's ok not to set it.
2023-04-03 02:59:37 -06:00
Idan Horowitz 8669f4ce45 Kernel: Add AArch64 support to sys$fork 2023-04-03 02:59:37 -06:00
Tim Ledbetter 3fa9c9bda4 PixelPaint: Update recent files list on project save
This is consistent with the behavior of other applications.
2023-04-03 07:13:27 +02:00
matcool 1bd8f4eb03 PixelPaint: Make Bloom use InplaceFilter instead of Filter
This change affects the filter preview widget, which would get the bloom
filter applied over the same bitmap, leading to an incorrect preview.
2023-04-03 07:13:13 +02:00
justus2510 2259ddf937 ImageViewer: Fix crash when setting wallpaper
When trying to set the wallpaper from the menu, ImageViewer would
crash because setting the wallpaper requires the program to pledge
to the WindowManager domain. This patch adds that pledge.
2023-04-03 07:11:28 +02:00
MacDue 0abd469d24 Base: Add background-position-x/y test page 2023-04-03 07:10:33 +02:00
MacDue bed55ac669 LibWeb: Parse and plumb background-position-x/y
This parses the new background-position-x/y longhands and properly
hooks up them up. This requires converting PositionStyleValue to
just contain two EdgeStyleValues so that it can be easily expanded
into the longhands.
2023-04-03 07:10:33 +02:00
MacDue 2a659693bc LibWeb: Add EdgeStyleValue
This represents a single edge and offset, this will be needed for
the values of background-position-x/y.
2023-04-03 07:10:33 +02:00
MacDue d5e61168b2 LibWeb: Add longhand properties for background-position
If background-position was not longhand enough for you, we've
now got background-position-x and background-position-y :^)
2023-04-03 07:10:33 +02:00
MacDue de4ab4f69e Meta: Lazily initialize initial property values
This solves the longhands must be initialized before shorthands
problem by just initializing the value when it is first requested.

This will be needed for background-position-x/y which is a longhand
of a longhand, which otherwise breaks the longhands before shorthands
rule.
2023-04-03 07:10:33 +02:00
Andrew Kaster 875c3d109f Meta: Check if SERENITY_USE_SDCARD is set before checking its value
This avoids a bash complaint for the new option
2023-04-02 13:07:31 -06:00
Marco Cutecchia f7608ba269 Meta: Add SERENITY_USE_SDCARD to boot from an SD card 2023-04-02 12:43:17 -06:00
Marco Cutecchia 425acb513e Kernel: Allow booting from an SD card 2023-04-02 12:43:17 -06:00
Marco Cutecchia 5fe6c6fc24 Kernel: Add support for SD host controllers on the PCI bus 2023-04-02 12:43:17 -06:00
Marco Cutecchia 47cae8005f Kernel: Add support for version 2 SD host controllers 2023-04-02 12:43:17 -06:00
Marco Cutecchia 1b04c43690 Kernel: Initialize DiskCache's buffer before the dirty&clean lists
This commit fixes a kernel panic that happened when unmounting
a disk due to an invalid memory access.
This was because `DiskCache` initializes two linked lists that use
an argument `KBuffer` as the storage for their elements.
Since the member `KBuffer` was declared after the two lists,
when `DiskCache`'s destructor was called, then `KBuffer`'s destructor
was called before the ones of the two lists, causing a page fault in
the kernel.
2023-04-02 12:43:17 -06:00
Ali Mohammad Pur 7375beced3 LookupServer: Put upstream DNS responses in cache 2023-04-02 20:42:39 +02:00
Ali Mohammad Pur c7409af627 LibHTTP: Tolerate extra \r\n in chunked-encoding last block size
Some servers put CR/LF there, so let's tolerate that behaviour.
Fixes #18151.
2023-04-02 20:42:39 +02:00
martinfalisse 289285cd6e LibWeb: Add borders functionality to CSS Grid 2023-04-02 19:08:04 +02:00
martinfalisse 6f52272d34 LibWeb: Fix regression in definite grid row heights
Fixes a row height bug when a grid item in a row has a definite height.
2023-04-02 19:08:04 +02:00
martinfalisse e65f4b3dc5 LibWeb: Rename PositionedBox to GridItem
This seems like a more accurate description of what this class really
is, and easier to understand in my opinion.
2023-04-02 19:08:04 +02:00
Idan Horowitz 8da31764b9 Meta: Enable asm-view symbol demangling in the gdb kernel debug script
This makes sure that symbol names are demangled in the assembly view.
2023-04-02 20:05:17 +03:00
Idan Horowitz b8437a03e7 Meta: Update AArch64 kernel base address in the gdb kernel debug script
The correct value for now is 0, since the AArch64 linker script uses
a hard-coded memory layout, so the offset is already automatically
applied.
2023-04-02 20:05:17 +03:00
Andreas Kling 8bb0be7d4f LibWeb: Don't apply presentational hints to associated pseudo elements
CSS properties generated by presentational hints in content attributes
should not leak into pseudo elements.
2023-04-02 15:00:06 +02:00
Andreas Kling 620a34a463 LibWeb: Don't apply element inline style to associated pseudo elements
An element's inline style, if present, should not leak into any pseudo
elements generated by that element.
2023-04-02 15:00:06 +02:00
Timothy Flynn eed956b473 AK: Increase LittleEndianOutputBitStream's buffer size and remove loops
This is very similar to the LittleEndianInputBitStream bit buffer change
from 8e834d4bb2.

We currently buffer one byte of data for the underlying stream. And when
we put bits onto that buffer, we do so 1 bit at a time.

This replaces the u8 buffer with a u64. And instead of looping at all,
we perform bitwise operations to write the desired number of bits.

Using the "enwik8" file as a test (100MB uncompressed, commonly used in
benchmarks: https://www.mattmahoney.net/dc/enwik8.zip), compression time
decreases from:

    13.62s to 10.9s on Serenity (cold)
    13.62s to 9.22s on Serenity (warm)
    2.93s to 2.32s on Linux

One caveat is that this requires explicitly flushing any leftover bits
when the caller is done with the stream. The byte buffer implementation
implicitly flushed its data every time the buffer was byte-aligned, as
doing so would always fill the byte. This is no longer the case. But for
now, this should be fine as the one user of this class, DEFLATE, already
has a "flush everything now that we're done" finalizer.
2023-04-02 10:54:37 +02:00
Andrew Kaster d74fa5e283 Toolchain: Allow many patches for gdb and add clang workaround
This ports https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=ae61525fcf456ab395d55c45492a106d1275873a
from upstream binutils, which enables building with the newest host
clang versions.
2023-04-02 10:52:28 +02:00
Andrew Kaster af01203733 Toolchain: Update gdb to version 13.1 2023-04-02 10:52:28 +02:00
Tim Schumacher 57516c3a9e Toolchain: Create an nm symlink for Clang
This is required for building the QEMU port using Clang.
2023-04-02 00:05:03 -06:00
Andreas Kling 9cded6e1b5 LibWeb: Fix application of intrinsic aspect ratio to flex column items
The intrinsic aspect ratio of a box is a width:height ratio, so if we
have the width and need the height, we should divide, not multiply. :^)
2023-04-02 06:45:44 +02:00
Andreas Kling 2413de7e10 LibWeb: Make HTMLImageElement loads delay the document load event
This is something we're supposed to do according to the HTML spec.
Note that image loading is currently completely ad-hoc, and this just
adds a simple DocumentLoadEventDelayer to the existing implementation.

This will allow us to use images in layout tests, which rely on the
document load event firing at a predictable time.
2023-04-02 06:45:44 +02:00
Linus Groh 3709d11212 LibJS: Parse secondary expressions with the original forbidden token set
Instead of passing the continuously merged initial forbidden token set
(with the new additional forbidden tokens from each parsed secondary
expression) to the next call of parse_secondary_expression(), keep a
copy of the original set and use it as the base for parsing the next
secondary expression.

This bug prevented us from properly parsing the following expression:

```js
0 ?? 0 ? 0 : 0 || 0
```

...due to LogicalExpression with LogicalOp::NullishCoalescing returning
both DoubleAmpersand and DoublePipe in its forbidden token set.

The following correct AST is now generated:

Program
  (Children)
    ExpressionStatement
      ConditionalExpression
        (Test)
          LogicalExpression
            NumericLiteral 0
            ??
            NumericLiteral 0
        (Consequent)
          NumericLiteral 0
        (Alternate)
          LogicalExpression
            NumericLiteral 0
            ||
            NumericLiteral 0

An alternate solution I explored was only merging the original forbidden
token set with the one of the last parsed secondary expression which is
then passed to match_secondary_expression(); however that led to an
incorrect AST (note the alternate expression):

Program
  (Children)
    ExpressionStatement
      LogicalExpression
        ConditionalExpression
          (Test)
            LogicalExpression
              NumericLiteral 0
              ??
              NumericLiteral 0
          (Consequent)
            NumericLiteral 0
          (Alternate)
            NumericLiteral 0
        ||
        NumericLiteral 0

Truth be told, I don't know enough about the inner workings of the
parser to fully explain the difference. AFAICT this patch has no
unintended side effects in its current form though.

Fixes #18087.
2023-04-02 06:45:37 +02:00