Commit graph

1998 commits

Author SHA1 Message Date
Tobias Christiansen
3c41ac5ae4 Tests/LibWeb: Add object-{fit,position} test 2023-10-31 07:03:05 +01:00
Tobias Christiansen
3b1083c4cb Tests/LibWeb: Add object-position to the getComputedStyle test
The test was failing because we now support the new and shiny
object-position property.
2023-10-31 07:03:05 +01:00
Ali Mohammad Pur
78c04cb8b2 AK+LibPDF: Make Format print floats in a roundtrip-safe way by default
Previously we assumed a default precision of 6, which made the printed
values quite odd in some cases.
This commit changes that default to print them with just enough
precision to produce the exact same float when roundtripped.

This commit adds some new tests that assert exact format outputs, which
have to be modified if we decide to change the default behaviour.
2023-10-31 09:12:35 +03:30
MacDue
c93d367d95 LibWeb: Layout SVG <text> elements during layout (not while painting)
Previously, all SVG <text> elements were zero-sized boxes, that were
only actually positioned and sized during painting. This led to a number
of problems, the most visible of which being that text could not be
scaled based on the viewBox.

Which this patch, <text> elements get a correctly sized layout box,
that can be hit-tested and respects the SVG viewBox.

To share code with SVGGeometryElement's the PathData (from the prior
commit) has been split into a computed path and computed transforms.
The computed path is specific to geometry elements, but the computed
transforms are shared between all SVG graphics elements.
2023-10-30 19:44:54 +01:00
MacDue
dc9cb449b1 LibWeb: Store computed SVG path data/transforms in LayoutState
This removes the awkward hack to recompute the layout transform at paint
time, and makes it possible for path sizes to be computed during layout.

For example, it's possible to use relative units in SVG shapes (e.g.
<rect>), which can be resolved during layout, but would be hard to
resolve again during painting.
2023-10-30 19:44:54 +01:00
Gurkirat Singh
f1b79e0cd3 AK: Implement slugify function for URL slug generation
The slugify function is used to convert input into URL-friendly slugs.
It processes each character in the input, keeping ascii alpha characters
after lowercase and replacing non-alphanum characters with the glue
character or a space if multiple spaces are encountered consecutively.
The resulting string is trimmed of leading and trailing whitespace, and
any internal whitespace is replaced with the glue character.

It is currently used in LibMarkdown headings generation code.
2023-10-30 10:39:59 +00:00
Tim Schumacher
25642dfe87 LibCompress: Implement correct validation of last filters 2023-10-29 22:00:59 +01:00
Tim Schumacher
786e654dfd LibCompress: Implement the XZ delta filter 2023-10-29 22:00:59 +01:00
Bastiaan van der Plaat
0104225d9b LibWeb: Add TextEncoder encodeInto 2023-10-29 21:44:53 +01:00
Andrew Kaster
1567332e34 Userland+Tests: Remove uses of direct file loading for BitmapFont
Route them through Core::Resource APIs instead.
2023-10-29 13:12:28 -06:00
FalseHonesty
2285dfb80e LibWeb: Resolve block max-width percentage against containing block 2023-10-29 19:35:02 +01:00
Karol Kosek
bf16ddfbb0 LibWeb: Bail parsing transform-origin if the parsed value is null
Passing a value of a type different than number or length-percentage
to transform-origin returned a null pointer, and we didn't take care
of that path before.

This patch fixes a crash caused by an incorrect CSS declaration, such as
`transform-origin: "center"`.

Fixes #21609
2023-10-29 11:22:53 +01:00
Aliaksandr Kalenik
d22aa851cf LibWeb: Float property should be ignored for grid items 2023-10-29 09:43:13 +01:00
Aliaksandr Kalenik
f75186ec8f LibWeb: Add support for grid item's min-height and max-height in GFC 2023-10-29 08:46:51 +01:00
MacDue
3659149888 LibWeb: Fix stroke-opacity for stroked paths that use PaintStyles
Ref test included :)
2023-10-28 19:06:12 +02:00
Timothy Flynn
8dc25dffc2 LibWebView: Protect URL highlighting against partially-typed URLs
The current helpers assume that a valid URL is a full URL (i.e. contains
the "://" separator between the scheme and domain). This isn't true, as
"file:" alone is parsed as a valid URL.

We must also avoid simply searching for the parsed public suffix in the
original URL string. For example, "com" is a public suffix. If we search
for that in the URL "com.com", we will think the public suffix starts at
index 0.
2023-10-28 19:03:19 +02:00
Tim Ledbetter
e4715aa82a AK: Use correct type when calculating integral exp2()
Previously, integral `exp2()` would produce the incorrect result for
exponents above 31.
2023-10-27 21:59:44 -04:00
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