Commit graph

1170 commits

Author SHA1 Message Date
MacDue 8283e8b88c AK: Don't store parts of URLs percent decoded
As noted in serval comments doing this goes against the WC3 spec,
and breaks parsing then re-serializing URLs that contain percent
encoded data, that was not encoded using the same character set as
the serializer.

For example, previously if you had a URL like:

https:://foo.com/what%2F%2F (the path is what + '//' percent encoded)

Creating URL("https:://foo.com/what%2F%2F").serialize() would return:

https://foo.com/what//

Which is incorrect and not the same as the URL we passed. This is
because the re-serializing uses the PercentEncodeSet::Path which
does not include '/'.

Only doing the percent encoding in the setters fixes this, which
is required to navigate to Google Street View (which includes a
percent encoded URL in its URL).

Seems to fix #13477 too
2023-04-12 07:40:22 +02:00
networkException 9915fa72fb AK+Everywhere: Use Optional for URLParser::parse's base_url parameter 2023-04-11 16:28:20 +02:00
Tim Ledbetter 72ea046b68 AK: Add option to the string formatter to use a digit separator
`vformat()` can now accept format specifiers of the form
{:'[numeric-type]}. This will output a number with a comma separator
every 3 digits.

For example:

`dbgln("{:'d}", 9999999);` will output 9,999,999.

Binary, octal and hexadecimal numbers can also use this feature, for
example:

`dbgln("{:'x}", 0xffffffff);` will output ff,fff,fff.
2023-04-11 13:03:30 +02:00
Fabian Dellwing 550635164d Tests+LibTLS: Use TRY_OR_FAIL for TestTLSHandshake 2023-04-11 06:40:33 -04:00
Cameron Youell 03008ec4e0 Tests: Use FileSystem instead of DeprecatedFile 2023-04-09 20:58:54 -06:00
Rodrigo Tobar 150ffc7336 Tests: Add tests for sed utility
While the tests for sed itself are simple to begin with, some
infrastructure was needed to make them simple.

Firstly, there was no home for tests for the applications under
Utilities, so I had to create a new subdirectory under Tests to host
them.

Secondly, and more importantly, there was previously no easy way to
launch an executable and easily feed it with data for its stdin, then
read its stdout/err and exit code. Looking around the repo I found that
the JS tests do a very similar thing though, so I decided to adapt that
solution for these tests, but with the higher purpose of someday moving
this new Process class to LibCore/Process, where the existing spawn
helpers are still very low level, and there is no representation of a
Process object that one can easily interact with.

Note that this Process implementation is very simple, offers limited
functionality, and it doesn't use the EventLoop, so it can break on long
inputs/outputs depending on the executable behavior.
2023-04-09 18:09:23 -06:00
Rodrigo Tobar 5a8373c6b9 LibCore: Fix corner case for files without newlines
When BufferedFile.can_read_line() was invoked on files with no newlines,
t incorrectly returned a false result for this single line that, even
though doesn't finish with a newline character, is still a line. Since
this method is usually used in tandem with read_line(), users would miss
reading this line (and hence all the file contents).

This commit fixes this corner case by adding another check after a
negative result from finding a newline character. This new check does
the same as the check that is done *before* looking for newlines, which
takes care of this problem, but only works for files that have at least
one newline (hence the buffer has already been filled).

A new unit test has been added that shows the use case. Without the
changes in this commit the test fails, which is a testament that this
commit really fixes the underlying issue.
2023-04-09 18:09:23 -06:00
stelar7 371974ed4a LibCrypto: Add PBKDF2 2023-04-09 17:05:18 -06:00
Tim Schumacher d4e48db1e1 Tests: Convert LZMA and XZ tests to TRY_OR_FAIL
This is very useful for tracking down a breakage without having to add
temporary dbgln manually.
2023-04-09 18:27:06 +02:00
Nico Weber 95e35b7f5e LibGfx: Correctly decode webp lossless with small palette and odd width
WebP lossless files that use a color indexing transform with <= 16
colors use pixel bundling to pack 2, 4, or 8 pixels into a single pixel.

If the image's width doesn't happen to be an exact multiple of the
bundling factor, we need to:

1. Use ceil_div() instead of just dividing the width by the bundling
   factor

2. Remember the original width and use it instead of computing
   reduced width times bundling factor

This does these changes, and adds a simple test for it -- it at least
checks that the decoded images have the right size.

(I created these images myself in Photoshop, and used the same
technique as for Tests/LibGfx/test-inputs/catdog-alert-*.webp
to create images with a certain number of colors.)
2023-04-09 00:14:15 +02:00
Nico Weber f2efb97578 Tests: Add webp lossless test with color index and < 16 colors
For the test files, I opened Base/res/icons/catdog/alert.png in Adobe
Photoshop 2023, used Image->Mode->Index Color...->
Palette: Local (Perceptive) to reduce the number of colors to 13, 8, and
3 with transparency, and 2 without transparency, then converted it back
to Image->Mode->RGB Color (else it can't be saved as webp), then
File->Save a Copy... to save a WebP (mode lossless) for every palette
size.
2023-04-08 19:24:13 +02:00
Nico Weber 6151a251f5 Tests: Add test for lossless webp file using a color indexing tranform
The image is https://quakewiki.org/wiki/File:Qpalette.png in lossless
webp format with a color indexing transform.

I've created Qpalette.webp by running

    examples/cwebp -z 0 ~/src/serenity/tmp.ppm -o Qpalette.webp

built at libwebp webmproject/libwebp@0825faa4c1 (without
png support, so I first ran

    Build/lagom/image ~/Downloads/Qpalette.png -o tmp.ppm

to convert it from png to a format my cwebp binary could read).

This file also happens to explicitly set max_symbol, so it serves
as a test for that code path as well.
2023-04-08 16:50:40 +02:00
Nico Weber 61b540e737 Tests: Add another test for webp lossless decoding 2023-04-07 20:49:39 +02:00
martinfalisse c839c51b0b LibWeb: Use max-width property in table formatting 2023-04-07 10:42:26 +02:00
martinfalisse 1440845aad LibWeb: Add table formatting tests
Creates some TableFormattingContext tests based on the tests in
/html/misc.
2023-04-07 10:42:26 +02:00
martinfalisse c421f1692c LibWeb: Move table tests to their own folder 2023-04-07 10:42:26 +02:00
Andreas Kling 7b4c76788b LibWeb: Don't put abspos grid/flex items in anonymous wrapper
Grid and flex containers have their own rules for abspos items, so we
shouldn't try to be clever and put them in the "current" anonymous
wrapper block. That behavior is primarily for the benefit of block &
inline layout.
2023-04-07 10:15:16 +02:00
Kenneth Myhra d6cf9f5329 AK: Add FlyString::is_one_of for variadic string comparison 2023-04-06 23:49:08 +02:00
Andreas Kling b97229c9b5 LibWeb: Ignore preferred width when calculating intrinsic width of block
When calculating the intrinsic width of a block-level box, we now ignore
the preferred width entirely, and not just when the preferred width
should be treated as auto.

The condition for this was both confused and wrong, as it looked at the
available width around the box, but didn't check for a width constraint
on the box itself.

Just because the available width has an intrinsic sizing constraint
doesn't mean that the box is undergoing intrinsic sizing. It could also
be the box's containing block!
2023-04-06 16:47:40 +02:00
Andreas Kling 68459d43e0 Tests/LibWeb: Move block & inline layout tests into own directory 2023-04-06 16:47:40 +02:00
matcool cc33a57620 LibWeb: Use intrinsic aspect ratio when calculating max content height 2023-04-05 16:23:56 +02:00
Nico Weber 09dd9c4fad Tests: Add test for webp lossless decoding 2023-04-05 13:24:00 +02:00
Fabian Dellwing 459dee1f86 LibTLS: Refactor CA loading into central function 2023-04-03 19:58:47 -06:00
Lucas CHOLLET 2812ef246d Tests: Add benchmarks for JPEGLoader
I'm the author of the image.
2023-04-03 20:58:49 +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
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
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
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
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
martinfalisse 57cdb0c972 LibWeb: Add display grid automated tests 2023-04-01 21:45:29 +02:00
martinfalisse 7028f75779 Tests: Use layout tests placed in subdirectories
Allows organizing layout tests into subdirectories.
2023-04-01 21:45:29 +02:00
Tim Schumacher ad31265e60 LibCompress: Implement block size validation for XZ streams 2023-04-01 13:57:54 +02:00
Tim Schumacher b451964bbc Tests: Document input of the xz_utils_good_1_block_header_1 test case 2023-04-01 13:57:54 +02:00
Andreas Kling 45f8542965 LibWeb: Actually visit rules and media queries in imported style sheets
Due to CSSImportRule::has_import_result() being backwards, we never
actually entered imported style sheets when traversing style rules or
media queries.

With this fixed, we no longer need the "collect style sheets" step in
StyleComputer, as normal for_each_effective_style_rule() will now
actually find all the rules. :^)
2023-03-30 16:54:15 +02:00
Tim Schumacher fe761a4e9b LibCompress: Use LZMA context from preexisting dictionary 2023-03-30 14:39:31 +02:00
Tim Schumacher c020ee8bfa LibCompress: Avoid overflowing the size of uncompressed LZMA2 chunks 2023-03-30 14:39:31 +02:00
Tim Schumacher 9ccb0fc1d8 LibCompress: Only require new LZMA2 properties after dictionary reset 2023-03-30 14:39:31 +02:00
Tim Schumacher 726963edc7 LibCompress: Implement support for multiple concatenated XZ streams 2023-03-30 14:38:47 +02:00
Tim Schumacher 00332c9b7d LibCompress: Move XZ header validation into the read function
The constructor is now only concerned with creating the required
streams, which means that it no longer fails for XZ streams with
invalid headers. Instead, everything is parsed and validated during the
first read, preparing us for files with multiple streams.
2023-03-30 14:38:47 +02:00
Tim Schumacher 8ff36e5910 LibCompress: Implement proper handling of LZMA end-of-stream markers 2023-03-30 08:45:35 +02:00
Andreas Kling e4b71495f5 LibWeb: Resolve percentage vertical-align values against line-height
...instead of not resolving them at all. :^)
2023-03-29 18:38:29 +02:00
Andreas Kling c0a7a61288 LibWeb: Clamp fit-content widths in flex layout to min/max-width
In situations where we need a width to calculate the intrinsic height of
a flex item, we use the fit-content width as a stand-in. However, we
also need to clamp it to any min-width and max-width properties present.
2023-03-28 21:08:54 +02:00
Luke Wilde 4c090a9a35 Tests/LibWeb: Add layout test for layout fix in PR #15780
Adds a layout test for the fix in 488a979.
2023-03-28 19:45:00 +01:00
Andreas Kling af118abdf0 LibWeb: Use fit-content width in place of indefinite flex item widths
In `flex-direction: column` layouts, a flex item's intrinsic height may
depend on its width, but the width is calculated *after* the intrinsic
height is required.

Unfortunately, the specification doesn't tell us exactly what to do here
(missing inputs to intrinsic sizing is a common problem) so we take the
solution that flexbox applies in 9.2.3.C and apply it to all intrinsic
height calculations within FlexFormattingContext: if the used width of
an item is not yet known when its intrinsic height is requested, we
substitute the fit-content width instead.

Note that while this is technically ad-hoc, it's basically extrapolating
the spec's suggestion in one specific case and using it in all cases.
2023-03-27 23:28:07 +02:00
Aliaksandr Kalenik 1ee99017e2 LibWeb: Fix intrinsic sizing early return condition in TFC
Early return before running full TFC algorithm is only possible when
just table width need to be calculated.
2023-03-27 23:10:16 +02:00
Fabian Dellwing ee0ae18386 LibTLS: Check if certificate is self signed before importing it as CA 2023-03-27 15:34:28 +03:30
Andreas Kling 949483fb01 Tests/LibWeb: Test flex column item with auto height and max-width
This case is important because we have to clamp the width before using
it to determine the auto height.
2023-03-26 15:14:35 +02:00