Commit graph

51128 commits

Author SHA1 Message Date
Andreas Kling
427cf14d71 Tests/LibWeb: Import my test rebaselining script
This is not a beautiful program, but it does allow you to regenerate
the baseline expectation for a given layout or text test with a single
command. :^)
2023-06-01 08:26:33 +02:00
Andreas Kling
fde86350e3 LibWeb: Put debug spam about indefinitely sized SVGs behind a flag 2023-06-01 07:34:37 +02:00
Andreas Kling
c62c714764 LibWeb: Put debug spam about negative content sizes behind a flag
We already clamp these values to zero, so it's actually pretty harmless
when this happens. If someone wants to investigate these issues deeper
and see if they can be fixed earlier in the layout pipeline, they can
enable the spam locally.
2023-06-01 07:34:37 +02:00
Andi Gallo
827936cf7b LibWeb: Invalidate layout tree in textContent setter
The textContent setter changes the structure of the DOM, therefore the
layout tree becomes invalid.
2023-06-01 07:22:50 +02:00
Caoimhe
617edafbf2 LibGUI: Add support for jumping to a line and column in TextEditor
We had support for going to a specific line before, but now we support
jumping around using the `line:column` format :^)
2023-06-01 06:26:40 +02:00
Jelle Raaijmakers
75c8e07cc3 AK: Remove conditional noexcept from Complex
C++11 has been a requirement for some time now, no need to bother the
preprocessor with it.
2023-06-01 06:26:08 +02:00
MacDue
6685656d2d LibGfx: Fix winding order of segments on elliptical arcs
for_each_line_segment_on_elliptical_arc() flips the start/end points
for negative theta deltas. When doing this we have to make sure the
line segments emitted swap the start/end points back, so that the
(correct) winding order can be calculated from them.

This makes nonzero fills not totally broken for a lot of SVGs.
2023-06-01 06:25:00 +02:00
MacDue
48fa8f97d3 LibGfx: Implement new antialiased filled path rasterizer
This is an implementation of the scanline edge-flag algorithm for
antialiased path filling described here:
https://mlab.taik.fi/~kkallio/antialiasing/EdgeFlagAA.pdf

The initial implementation does not try to implement every possible
optimization in favour of keeping things simple. However, it does
support:

   - Both evenodd and nonzero fill rules
   - Applying paint styles/gradients
   - A range of samples per pixel (8, 16, 32)
   - Very nice antialiasing :^)

This replaces the previous path filling code, that only really applied
antialiasing in the x-axis.

There's some very nice improvements around the web with this change,
especially for small icons. Strokes are still a bit wonky, as they don't
yet use this rasterizer, but I think it should be possible to convert
them to do so.
2023-06-01 06:25:00 +02:00
MacDue
e4adaa2d20 LibGfx: Make PaintStyle::paint() a public function
It's a pain (and silly) to make this private and add every user as a
friend.
2023-06-01 06:25:00 +02:00
MacDue
81ff242e86 AK: Mark generic shorthand functions as constexpr 2023-06-01 06:25:00 +02:00
Jelle Raaijmakers
5339b54b5d LibGfx: Improve glyph rendering speed for vector fonts
The glyph bitmap is a grayscale image that is multiplied with the
requested color provided to `Gfx::Painter::draw_glyph()` to get the
final glyph bitmap that can be blitted.

Using `Gfx::Color::multiply()` is unnecessary however: by simply taking
the destination color and copying over the glyph bitmap's alpha value,
we can prevent four multiplications and divisions per pixel.

In an artifical benchmark I wrote, this improved glyph rendering
performance by ~9%.
2023-06-01 06:18:57 +02:00
Nico Weber
8a40b49b8b WebP/Lossy: Use 8-bit buffers for prediction and YUV data
This is safe because:

* prediction only computes averages, or explicitly clamps for
  TM_PRED / B_TM_PRED. Since the inputs are in [0, 255], so will the
  outputs.
* Addition of IDCT and prediction buffer is immediately clamped back
  to [0, 255]

No behavior change, and matches what both libwebp and the reference
implementation in rfc6386 do.
2023-05-31 22:38:36 +02:00
Nico Weber
ffae065593 WebP/Lossy: Clamp right after summing IDCT output, instead of later
https://datatracker.ietf.org/doc/html/rfc6386#section-14.5 says:

"""
The summing procedure is fairly straightforward, having only a couple
of details.  The prediction and residue buffers are both arrays of
16-bit signed integers.  Each individual (Y, U, and V pixel) result
is calculated first as a 32-bit sum of the prediction and residue,
and is then saturated to 8-bit unsigned range (using, say, the
clamp255 function defined above) before being stored as an 8-bit
unsigned pixel value.
"""

It's IMHO not 100% clear if the clamping is supposed to happen
immediately (so that it affects prediction inputs for the next
macroblock) or later.

But vp8_dixie_idct_add() on page 173 in
https://datatracker.ietf.org/doc/html/rfc6386#section-20.8 does:

    recon[0] = CLAMP_255(predict[0] + ((a1 + d1 + 4) >> 3));

So it does look like it should happen immediately.

(I'm a bit confused why the spec then says "The prediction and residue
buffers are both arrays of 16-bit signed integers", since the
prediction buffer can just be an u8 buffer now, without changing
behavior.
2023-05-31 22:38:36 +02:00
Timon Kruiper
dfba998d00 Kernel/aarch64: Make sure stack pointer is always 16 byte aligned
This is enforced by the hardware and an exception is generated when the
stack pointer is not properly aligned. This brings us closer to booting
the aarch64 Kernel on baremetal.
2023-05-31 22:36:44 +02:00
Sam Atkins
7c95117d93
Documentation: Add qt6-qtsvg-devel to Ladybird dependencies for Fedora 2023-05-31 15:56:47 +01:00
Oskar Skog
a05f610278 Base: Extend the Finnish keymap and make capital Å type what it should 2023-05-31 16:42:09 +02:00
Nico Weber
cf934f9bfc WebP/Lossy: Move two enums closer to the struct that uses them
I accidentally inserted a bunch of code in between.

No behavior change.
2023-05-31 16:40:40 +02:00
Jelle Raaijmakers
13086d3c97 KeyboardMapper: Do not drop the unix pledge
Without it, KeyboardMapper crashes as soon as you try to open a file.
2023-05-31 16:25:01 +02:00
kleines Filmröllchen
9e496a96a6 LibAudio: Load WAV metadata
This is quite straightforward with our new RIFF infrastructure.
2023-05-31 16:23:07 +02:00
kleines Filmröllchen
70970b2fa9 LibAudio: Modernize WAV loader
With this, the WAV loader is a completely modern LibAudio loader:
- Own type header for RIFF data structures
- custom stream read functions for the types
- Final removal of legacy I/O error checking
- clearer error messages
- clean handling of header chunks

The latter will allow proper handling of other chunks (before "data") in
the future, such as metadata :^)
2023-05-31 16:23:07 +02:00
Nico Weber
830a3a25dc WebP/Lossy: Add a missing clamp() in TM_PRED prediction
The spec has that clamp at the end of
https://datatracker.ietf.org/doc/html/rfc6386#section-12.2:

    The exact algorithm is as follows:
    [...]
               b[r][c] = clamp255(L[r]+ A[c] - P);

For the test images I'm looking at, it doesn't seem to make a
dramatic difference, but omitting it in `B_TM_PRED` did make
a dramatic difference, so add it. (Also, the spec demands it.)
2023-05-31 16:22:49 +02:00
Nico Weber
40e1ec6cf9 WebP/Lossy: Remove an unnecessary branch
`predicted_y_above` is initialized to a row of 127s, so we can just
read from it even in the first macroblock row.

No behavior change.
2023-05-31 15:28:41 +02:00
Rummskartoffel
47d1b45583 NotificationServer: Stop notifications showing in the top left at first
Before this commit, notifications would appear in the top left of the
screen when created, then move to the top right once hovered by the
mouse. This happened because the first notification would use its own
default-constructed position of 0,0 as a point of reference.
2023-05-31 14:45:54 +02:00
Nico Weber
a2d8de180c WebP/Lossy: Add support for images with more than one partition
Each secondary partition has an independent BooleanDecoder.
Their bitstreams interleave per macroblock row, that is the first
macroblock row is read from the first decoder, the second from the
second, ..., until it wraps around again.

All partitions share a single prediction state though: The second
macroblock row (which reads coefficients off the second decoder) is
predicted using the result of decoding the frist macroblock row (which
reads coefficients off the first decoder).

So if I understand things right, in theory the coefficient reading could
be parallelized, but prediction can't be. (IDCT can also be
parallelized, but that's true with just a single partition too.)

I created the test image by running

    examples/cwebp -low_memory -partitions 3 -o foo.webp \
        ~/src/serenity/Tests/LibGfx/test-inputs/4.webp

using a cwebp hacked up as described in #19149. Since creating
multi-partition lossy webps requires hacking up `cwebp`, they're likely
very rare in practice. (But maybe other programs using the libwebp API
create them.)

Fixes #19149.

With this, webp lossy support is complete (*) :^)

And with that, webp support is complete: Lossless, lossy, lossy with
alpha, animated lossless, animated lossy, animated lossy with alpha all
work.

(*: Loop filtering isn't implemented yet, which has a minor visual
effect on the output. But it's only visible when carefully comparing
a webp decoded without loop filtering to the same decoded with it.
But it's technically a part of the spec that's still missing.

The upsampling of UV in the YUV->RGB code is also low-quality. This
produces somewhat visible banding in practice in some images (e.g.
in the fire breather's face in 5.webp), so we should probably improve
that at some point. Our JPG decoder has the same issue.)
2023-05-31 14:07:15 +02:00
Sigmund Lahn
3bc0e7a7ca Ladybird: Look for helper processes at {app_dir}/{helper}/{helper}
Currently, we only look at the relative path `./{helper}/{helper}`,
which fails if the working directory is not the same as the directory
where the ladybird binary lives.
2023-05-31 13:24:49 +02:00
Zaggy1024
ce9f4c3215 LibVideo/PlaybackManager: Return duration zero when an error occurs
Previously, we would unwrap the duration value even when it contained
an error, causing an assertion failure.

Later, we should change it to return the last known sample timestamp
in the media data, allowing for example live-streamed video to have
a semi-useful duration. In general, though, this is not used by
players in the wild, so we can leave it for now.
2023-05-31 13:08:48 +02:00
Andreas Kling
4fed7beb7b LibWeb: Make solve_replaced_size_constraint() into FormattingContext 2023-05-31 11:38:05 +02:00
Andreas Kling
42470d837e LibWeb: Move layout box rect helpers into FormattingContext
These are only used during layout, and always within formatting context
code, so we might as well put them in FormattingContext and avoid having
to pass the LayoutState around all the time.
2023-05-31 11:38:05 +02:00
Andreas Kling
4f08fcde29 LibWeb: Remove unnecessary static formatting context functions
At one point in the past, we had some functions that were called across
different formatting context types, which necessitated making them
static and taking the LayoutState as a parameter.

In all cases, those functions were used to do incorrect hacks, all of
which we've replaced with more correct solutions. :^)
2023-05-31 11:38:05 +02:00
stelar7
421559d725 LibWeb: Change calc node representation from float to double 2023-05-31 10:56:32 +02:00
Tim Ledbetter
f5da6d61b4 pgrep: Add -x option to only select exact matches 2023-05-31 06:04:48 +02:00
Tim Ledbetter
821bf5e071 pgrep: Add -U option to filter matches by UID or login name 2023-05-31 06:04:48 +02:00
Tim Ledbetter
cb6a2d60d3 pgrep: Add -l option to list the process name as well as its pid 2023-05-31 06:04:48 +02:00
Tim Ledbetter
ad851706ab pgrep: Add -c option to show the number of matches 2023-05-31 06:04:48 +02:00
Tim Ledbetter
f95e6ee849 pgrep: Add --ignore-case as an alias for the -i option 2023-05-31 06:04:48 +02:00
Tim Ledbetter
8706c88370 pgrep: Return 1 rather than 0 if there are no matches
This matches the behavior of `pgrep` on Linux.
2023-05-31 06:04:48 +02:00
Tim Ledbetter
cd08870a64 killall: Continue killing processes if kill() call fails 2023-05-31 06:00:45 +02:00
Tim Ledbetter
d97614a31e killall: Don't parse SIGINVAL as signal 0 2023-05-31 06:00:45 +02:00
Tim Ledbetter
4934a1b702 killall: Prefer StringView over DeprecatedString 2023-05-31 06:00:45 +02:00
stelar7
344f37986f LibWeb: Allow calculated values in transform 2023-05-31 05:57:53 +02:00
stelar7
e23d31ae83 LibWeb: Lazy evaluate optional to avoid crash 2023-05-31 05:56:46 +02:00
stelar7
5cdeb994b2 LibWeb: Serialize Resolution according to spec 2023-05-31 05:56:25 +02:00
stelar7
b6d767fbb0 LibWeb: Serialize Frequency according to spec 2023-05-31 05:56:25 +02:00
stelar7
5dc82db0cb LibWeb: Serialize Angle according to spec 2023-05-31 05:56:25 +02:00
stelar7
e72b7c5de2 LibWeb: Serialize Time according to spec 2023-05-31 05:56:25 +02:00
Simon Wanner
b5ba479d65 LibWeb: Render svg-as-image with 1:1 scaling factor
We're passing the SVGDecodedImageData a size in device pixels, so it's
incorrect to apply the host page's device_pixels_per_css_pixels on top
of that.
2023-05-30 21:28:18 +02:00
Simon Wanner
29088f58ed LibWeb/Tests: Add missing newline in inset-shorthand-property.txt 2023-05-30 21:28:18 +02:00
Aliaksandr Kalenik
393068afba WebContent: Wait for Resource to load in wait_for_navigation_to_complete
Fixes wait_for_navigation_to_complete() so it actually waits for
ongoing page loading request in FrameLoader to complete.
2023-05-30 20:40:23 +02:00
Aliaksandr Kalenik
31b9729333 LibWeb: Add Page::has_ongoing_navigation()
Introduce has_ongoing_navigation() that allows to check if resource
state in FrameLoading is pending. This API is going to be used in
upcoming fix for wait_for_navigation_to_complete() in WebDriver.
2023-05-30 20:40:23 +02:00
Nico Weber
d1d9d7a4f3 WebP/Lossy: Use correct test image for coefficient skipping
I somehow added the wrong image here. 4.webp is the one described
by the comment in the test. Now test actually uses the image it
claims to use.

No behavior change.
2023-05-30 18:56:03 +02:00