Commit graph

1981 commits

Author SHA1 Message Date
Aliaksandr Kalenik
d1a01c4c65 LibWeb: Fix box alignment when it has min-width or max-width in GFC
Changing `try_compute_width()` to return width and margins, instead of
mutating them in the box's state makes it works in cases when box has
min-width or max-width and this function needs to be called multiple
times.

Fixes https://github.com/SerenityOS/serenity/issues/21598
2023-10-27 07:14:34 +02:00
Martin Janiczek
7c2a569fca LibTest: Add a suite of tests for the generators 2023-10-26 17:26:52 -06:00
Shannon Booth
3748f1d290 AK: Check for overflow parsing IPv4 number in URL
Fixes OSS fuzz issue:
https://oss-fuzz.com/download?testcase_id=6045676088459264
2023-10-26 11:11:41 +02:00
Shannon Booth
453dd0cf44 AK: Properly implement steps for shortening a URLs path
Instead of implementing this inline, put it into a function. Use this
new function to correctly implement shortening paths for some places
where this logic was previously missing.

Before these changes, the pathname for the included test was incorrectly
being set to '/' as we were not considering the windows drive letter.
2023-10-26 11:11:41 +02:00
Shannon Booth
bfdf7779ce AK: Correctly set host when parsing URL with a base file:// host
We were completely missing this spec step here. Also leave a FIXME for
the pre-existing implementation of this step, as this doesn't match the
spec.
2023-10-26 11:11:41 +02:00
Shannon Booth
791ad12031 LibWeb/Tests: Support URL tests with an input base 2023-10-26 11:11:41 +02:00
Tim Ledbetter
b4296e1c9b LibPDF: Don't use unsanitized values in error messages
Previously, constructing error messages with unsanitized input could
fail because error message strings must be UTF-8.
2023-10-26 11:05:32 +02:00
Tim Ledbetter
1a4df4ffe7 LibGfx/ICC: Avoid overflow when constructing NamedColor2TagData 2023-10-26 10:59:22 +02:00
Aliaksandr Kalenik
9f1e0209e8 Tests/LibWeb: Add missing test-shadow.html
Missing input file for e48b3b39cf
2023-10-26 10:56:30 +02:00
Tim Ledbetter
52f78d07b8 LibGfx/WOFF2: Ensure numTables is within expected range
An error is now returned if `numTables` is zero or greater than 4096.
While this isn't explicitly mentioned in the specification, subsequent
calculations will be incorrect if the value falls outside this range.
2023-10-26 08:39:26 +02:00
Aliaksandr Kalenik
e48b3b39cf Tests/LibWeb: Add ref test for text-shadow
Based on Base/res/html/misc/text-shadow.html demo page.
2023-10-26 08:38:16 +02:00
Aliaksandr Kalenik
58f8068853 LibWeb: Handle fit-content in calculate_max_content_contribution in GFC
Fixes https://github.com/SerenityOS/serenity/issues/21569
2023-10-26 08:37:42 +02:00
Tim Ledbetter
2311e28d63 LibGfx/BMPLoader: Mitigate potential overflows when decoding bitmap DIB 2023-10-25 05:52:29 +02:00
Tim Ledbetter
e9be1bcd09 LibGfx/WOFF2: Reject fonts with a compressed size larger than 10MiB
This prevents a potential OOM condition when the header is malformed.
2023-10-24 13:45:01 +02:00
Tim Ledbetter
af633523af LibGfx/WOFF2: Tolerate incorrect totalSfntSize in WOFF2 header
The specification says that this value is for reference only, so we
should be able to load a file where this value is incorrect.
2023-10-24 13:45:01 +02:00
Tim Ledbetter
cb16c217b8 Tests: Add regression tests for fixed OSS-Fuzz test cases 2023-10-24 07:30:04 +02:00
Tim Ledbetter
c62dded5cc Tests: Move image decoder test PNG to its own folder 2023-10-24 07:30:04 +02:00
Tim Ledbetter
c2112cde76 LibGfx/WOFF: Ensure header totalSfntSize matches expected value 2023-10-24 07:29:09 +02:00
Aliaksandr Kalenik
4dab17427f LibWeb: Use max content contribution in flex_fraction in GFC
As spec comment in the code says we should use item’s max-content
contribution to calculate flex fraction.

Likely, it was calculate_max_content_size() because we didn't have
calculate_max_content_contribution() when this function was implemented
initially.
2023-10-24 07:26:25 +02:00
Aliaksandr Kalenik
802b58d7e1 LibWeb: Resolve grid item's min-width and max-width in GFC
Now min-width and max-width properties affect resulting width of grid
item instead of being ignored.
2023-10-24 07:25:20 +02:00
Tim Ledbetter
db929e0fcf Kernel/Ext2: Avoid overflow when updating UID and GID values
Previously, attempting to update an ext2 inode with a UID or GID
larger than 65535 would overflow. We now write the high bits of UIDs
and GIDs to the same place that Linux does within the `osd2` struct.
2023-10-24 07:21:11 +02:00
Andrew Kaster
3b733ff7bc WPT: Update metadata for current WPT master and ladybird results 2023-10-24 01:43:31 +02:00
Andrew Kaster
5a334ae958 WPT: Update to latest master and remove unnecessary patch 2023-10-24 01:43:31 +02:00
Aliaksandr Kalenik
122d847720 LibWeb: Fix building of areas spanning multiple rows in GFC
Rewrites the grid area building to accurately identify areas that span
multiple rows. Also now we can recognize invalid areas but do not
handle them yet.
2023-10-22 19:38:18 +02:00
MacDue
8eab44896a Tests/LibWeb: Add outer box-shadow ref test
This is a screenshot test based on a cut-down version of the box-shadow
demo page.
2023-10-22 18:38:22 +02:00
hanaa12G
54e1470467 AK: Pass correct length to StringUtils::convert_to_floating_point()
Fixed the issue in StringUtils::convert_to_floating_point() where the
end pointer of the trimmed string was not being passed, causing the
function to consistently return 'None' when given strings with trailing
whitespaces.
2023-10-22 00:22:29 +02:00
MacDue
f0be812fc2 Tests/LibWeb: Add border-radius ref test
This is based on the border-radius.html demo page with text and most
assets removed. This has to be a screenshot based test as there's not
really something else that can be used for comparison.

This also makes the test a little incomplete as things like text
overflow clipping are not tested, but I'd like to avoid this test being
too brittle.
2023-10-21 23:16:17 +02:00
Aliaksandr Kalenik
719b12b19d LibWeb: Support alignment of abspos grid items
Grid items should respect alignment properties if top/right/bottom/left
are not specified.

This change adds a separate implementation of
layout_absolutely_positioned_element that is extended with support for
alignment.
2023-10-21 09:08:51 +02:00
Aliaksandr Kalenik
2def1de4be LibWeb: Rerun rows sizings if grid auto height is less than min-height
If the first pass of rows sizing results in the container's automatic
height being less than the specified min-height, we need to run a
second pass using the updated available space.
2023-10-21 09:08:11 +02:00
Bastiaan van der Plaat
b640747116 LibWeb: Add canvas context2d roundRect 2023-10-20 07:20:29 +02:00
circl
d76ad23492 Tests/LibGfx: Add test for top-down BMP files 2023-10-19 08:31:36 +02:00
Jelle Raaijmakers
b015926f8e AK: Improve floating point decimals formatting
There were 2 issues with the way we formatted floating point decimals:
if the part after the decimal point exceeded the max of an u64 we would
generate wildly incorrect decimals, and we applied no rounding.

With this new code, we emit decimals one by one and perform a simple
reverse string walk to round the number up if required.
2023-10-18 19:39:30 -04:00
Aliaksandr Kalenik
c2eaa0eb1c LibGfx: Fix crash during rasterizing glyphs containing only one point
Fixes https://github.com/SerenityOS/serenity/issues/20179
2023-10-18 01:16:21 +02:00
Andrew Kaster
09e3921ff8 Tests: Load Resources via Core::Resource URIs in FontHandling tests 2023-10-17 11:02:01 -06:00
Aliaksandr Kalenik
c41e742de4 LibWeb: Fix min-content width calculation in dimension_box_on_line()
If inline-block is sized under min-content width constraint we should
use its min-content width instead of max-content width like it was
before.
2023-10-16 21:44:48 +02:00
MacDue
95bf6ddb8e LibGfx: Fix serializing Gfx::Bitmaps
a396bb0 removed the palette field but did not update the allocation size
in `Bitmap::serialize_to_byte_buffer()`. This led to a few crashes (I
noticed this from a drag/drop crash in the file manager).

Fixes #21434
2023-10-15 20:34:29 +02:00
Sam Atkins
c9c99b3c42 LibWeb: Produce resolved transform value according to spec algorithm
We now produce a `matrix3d()` value when appropriate.

Some sites (such as gsap.com) request the resolved style for `transform`
when there's no viewport paintable, but the element itself does already
have a stacking context. This fixes crashes in that case, because we now
do not access the stacking context at all.

We also do not wrap the result as a StyleValueList any more. The
returned StyleValue is only serialized and exposed to JS, so making it a
StyleValueList has no effect.
2023-10-15 07:14:39 +02:00
Sam Atkins
c65d6964ea LibWeb: Update layout if we lack a node when getting computed style
As noted, there are two situations where an element will have no layout
node here:
1. The element is invisible in a way that it generates no layout node.
2. We haven't built the layout yet.

This protects against the second case, which would otherwise incorrectly
send us down the path of looking directly at the computed style.
2023-10-15 07:14:39 +02:00
Ali Mohammad Pur
aeee98b3a1 AK+Everywhere: Remove the null state of DeprecatedString
This commit removes DeprecatedString's "null" state, and replaces all
its users with one of the following:
- A normal, empty DeprecatedString
- Optional<DeprecatedString>

Note that null states of DeprecatedFlyString/StringView/etc are *not*
affected by this commit. However, DeprecatedString::empty() is now
considered equal to a null StringView.
2023-10-13 18:33:21 +03:30
Martin Janiczek
efa5fb5c3a AK: Fix one-off error in BitmapView::find_first and find_one_anywhere
The mentioned functions used m_size / 8 instead of size_in_bytes()
(division with ceiling rounding mode), which resulted in an off-by-one
error such that the functions didn't search in the last not-fully-8-bits
byte.

Using size_in_bytes() instead of m_size / 8 fixes this.
2023-10-11 15:58:16 +02:00
Tim Ledbetter
e6d9bb0774 LibTLS: Don't attempt to read past EOF when parsing TBSCertificate
This allows the decoder to fail gracefully when reading a partial or
malformed TBSCertificate. We also now ensure that the certificate data
is valid before making a copy of it.
2023-10-11 07:08:22 +02:00
Aliaksandr Kalenik
65b50ecc1a LibWeb/CSS: Parser should treat calc() with flex values as invalid
Fixes crash on https://signal.org/
2023-10-11 07:07:29 +02:00
Sam Atkins
1132c858e9 LibWeb: Stop inserting inline nodes into a generated wrapper box
493dd5d93c caused the `::before`
pseudo-element node to be inserted before the element's content, which
caused issues with how we determine where to insert inline nodes into
the layout tree. At the time, I noticed the issue with contents of flex
containers, and prevented them from merging into a `::before` box.

However, a similar situation happens when we're not in a flex container,
but the pseudo-element has `display: block`. This commit fixes that
situation by using the same logic in both places, so a similar mistake
can't be made again.

This fixes the tab text being invisible on GitHub project pages. :^)
2023-10-11 07:05:23 +02:00
Sam Atkins
253a96277e AK: Add FixedMemoryStream methods for reading values "in place"
When working with FixedMemoryStreams, and especially MappedFiles, you
may don't want to copy the underlying data when you read from the
stream. Pointing into that data is perfectly fine as long as you know
the lifetime of it is long enough.

This commit adds a couple of methods for reading either a single value,
or a span of them, in this way. As noted, for single values you sadly
get a raw pointer instead of a reference, but that's the only option
right now.
2023-10-10 14:36:25 +02:00
Sam Atkins
a1c24ef3ad LibGfx: Remove infallible BitmapFont::create() factory function
This was only used in TestFontHandling. So, let's remove it, and use
the "create" name for the fallible one.
2023-10-10 14:36:25 +02:00
Tim Ledbetter
2f26a7bb12 LibCompress: Avoid buffer overrun when building canonical Huffman code
Previously, decompressing a DEFLATE stream an invalid canonical
Huffman code could cause a buffer overrun. We now return an error in
this case.
2023-10-10 13:24:05 +02:00
Tim Ledbetter
f10db48bab AK: Avoid overflow when passing i64 minimum value to vformat() 2023-10-09 09:39:02 +03:30
MacDue
43177fd2a1 Tests/LibWeb: Add a ref test for SVG mask with maskUnits=userSpaceOnUse 2023-10-09 07:28:18 +02:00
MacDue
e9fd7c96af Tests/LibWeb: Add ref test for an SVG mask with mask-type: alpha 2023-10-09 07:28:18 +02:00
MacDue
479451498b LibWeb: Implement mask-type CSS property
This property allows specifying if a mask is an alpha or luminance mask.

See: https://drafts.fxtf.org/css-masking/#the-mask-type
2023-10-09 07:28:18 +02:00