Commit graph

2029 commits

Author SHA1 Message Date
Tim Ledbetter c1d7a51391 LibGfx/ICC: Avoid buffer overrun when creating TextDescriptionTagData
We now validate that the offsets used cannot overflow, preventing
possible buffer overruns.
2023-11-08 09:37:30 +01:00
Tim Ledbetter f56ae8c0e9 LibGfx/ILBM: Ensure CMAP chunk size matches expected value
The color map should be 3 bytes per pixel and should contain
`2^nPlanes` pixels. We now return an error if the color map isn't the
size we expect.
2023-11-08 09:36:01 +01:00
Tim Ledbetter ae6c39e501 LibGfx/ILBM: Ensure decompressed body chunk data is the correct length 2023-11-08 09:36:01 +01:00
Tim Ledbetter 39f7f1e84c Tests: Use more representative test cases for ILBM regression tests
Previously, the regression tests for OSS-Fuzz issues 62033 and 63296
used test case files directly from OSS-Fuzz. These files are invalid
in multiple ways because they have been generated by a fuzzer. This
commit replaces these files with ones that only expose the issue being
tested.
2023-11-08 09:36:01 +01:00
Lucas CHOLLET 81794df280 LibGfx/TIFF: Add support for images with PackBits compression 2023-11-08 09:28:36 +01:00
Lucas CHOLLET ed8d82f3de Tests/LibGfx: Move the tiff image to its own folder 2023-11-08 09:28:36 +01:00
Timothy Flynn 99233776e6 test-js: Add a test helper to override the current time zone 2023-11-08 09:28:17 +01:00
Timothy Flynn ee7ab5d053 LibCore: Support wildcard-skipping characters in Core::DateTime::parse
For example, LibJS will need to parse date strings of the form:

    Wed Dec 31 1969 19:00:00 GMT-0500 (Eastern Standard Time)

This string contains both the time zone offset (-05:00) and a display
name for the time zone (Eastern Standard Time). Because we will already
handle time zone adjustments when we handle the offsets, we will want to
just skip the time zone name. This patch will let us use a format string
of the form "GMT%z (%+)" to do so.
2023-11-08 09:28:17 +01:00
Timothy Flynn 350fdf1e43 LibCore+LibTimeZone: Support time zone names in Core::DateTime::parse
LibCore currently cannot depend on LibTimeZone directly. All build-time
code generators depend on LibCore, so there'd be a circular dependency:
LibCore -> LibTimeZone -> GenerateTZData -> LibCore.

So to support parsing time zone names and applying their offsets, add a
couple of weakly-defined helper functions. These work similar to the way
AK::String declares some methods that LibUnicode defines. Any user who
wants to parse time zone names (from outside of LibCore itself) can link
against LibTimeZone to receive full support.
2023-11-08 09:28:17 +01:00
stelar7 2bab266ba9 Tests: Add test for button type attribute 2023-11-07 11:34:21 +01:00
Lucas CHOLLET 404093a42e Tests/LibGfx: Add a test for the TIFF decoder 2023-11-06 12:29:30 -07:00
Shannon Booth 1f8d72da8e LibWeb: Port HTMLToken::to_deprecated_string to new AK String 2023-11-06 11:37:08 +01:00
Andreas Kling 3ac77dac99 Tests/LibWeb: Remove the "scroll.html" layout test for now
This test is flaky, so let's remove it until we have a stable version.
2023-11-06 09:42:41 +01:00
Tim Ledbetter 2a1fc96650 AK: Avoid unnecessary String allocations for URL username and password
Previously, `URLParser` was constructing a new String for every
character of the URL's username and password. This change improves
performance by eliminating those unnecessary String allocations.

A URL with a 100,000 character password can now be parsed in ~30ms vs
~8 seconds previously on my machine.
2023-11-06 09:19:12 +01:00
Shannon Booth 4821d284c6 LibWeb: Add support for inline SVG element scripts 2023-11-05 11:16:16 +00:00
Shannon Booth e5d45eeeb1 LibWeb: Properly append attributes to element when creating an Element
The main behavioural difference here is that the full qualified name is
appended to the element, rather than just the local name and value.
2023-11-05 11:16:16 +00:00
Tim Ledbetter 438e9e146c LibGfx/JPEG: Refill reservoir if necessary when discarding bits
This condition was hit 157 times out of the 109,233 JPEG images in the
Govdocs1 corpus. This change allows all of these
images to load correctly.
2023-11-05 09:01:15 +01:00
MacDue 4c5d48f861 LibWeb: Support transforms, stroking, gradients, etc for SVG <text>
This makes use of the new Gfx::Path::text() to handle SVG text elements,
with this text is just a regular path, and can be manipulated like any
other graphics element.

This removes the SVGTextPaintable and makes both <text> and geometry
elements use a new (shared) SVGPathPaintable. This is identical to the
old SVGGeometryPaintable. This simplifies painting as once something is
resolved to a Gfx::Path, the painting logic is the same.
2023-11-05 02:46:46 +01:00
MacDue 50d33f79fa LibGfx: Allow extracting paths from fonts and add Gfx::Path::text()
This updates fonts so rather than rastering directly to a bitmap, you
can extract paths for glyphs. This is then used to implement a
Gfx::Path::text("some text", font) API, that if given a vector font
appends the path of the text to your Gfx::Path. This then allows
arbitrary manipulation of the text (rotation, skewing, etc), paving the
way for Word Art in Serenity.
2023-11-05 02:46:46 +01:00
Nico Weber 00f1a6cf86 Tests: Add a pdf file for testing color spaces
Covers DeviceGray, CalRGB, DeviceRGB, DeviceCMYK, Lab, CalGray for now.

Does not yet cover Indexed, Pattern, Separation, DeviceN, ICCBased.

Lovingly hand-written, with the xref table fixed up by mutool.
2023-11-04 17:02:37 -04:00
Dan Klishch b65d281bbb AK: Add GenericLexer::{consume_decimal_integer,peek_string} 2023-11-04 18:06:30 +01:00
circl 6b30847120 LibWeb: Don't add an extra glyph spacing to width of TextNode
When calculating the width of text using a bitmap font, a glyph spacing
is added at the end of each fragment, including the last one. This meant
that everything was 1 pixel too long. This bug did not affect vector
fonts.
2023-11-04 17:39:04 +01:00
Aliaksandr Kalenik 2660bbb94f LibWeb: Consider colgroups while calculating table grid size
We should take in account <col> elements in column groups while finding
number of columns in a table.
2023-11-04 17:37:38 +01:00
Andreas Kling f9cab320e6 LibWeb: Only propagate CSS overflow to the viewport once per tree build
Before this change, we were doing it after every layout, which meant
that already-propagated overflow could be propagated again, which led to
incorrect scrolling behavior.
2023-11-02 20:50:48 +01:00
Aliaksandr Kalenik 2fb0cede9a LibWeb: Account for box-sizing in grid-items width calculation
Visual improvement on (now there is a gap between grid items):
https://twinings.co.uk/collections/earl-grey-tea
2023-11-02 07:37:11 +01:00
Timothy Flynn f630a5ca71 AK+LibJS: Remove error-prone JsonValue constructor
Consider the following:

    JsonValue value { JsonValue::Type::Object };
    value.as_object().set("foo"sv, "bar"sv);

The JsonValue(Type) constructor does not initialize the underlying union
that stores its value. Thus JsonValue::as_object() will A) refer to an
uninitialized union member, B) deference that member.

This constructor only has 2 users, both of which initialize the type to
Type::Null. Rather than implementing unused functionality here, replace
those uses with the default JsonValue constructor, and remove the faulty
constructor.
2023-11-01 11:15:26 -04:00
Aliaksandr Kalenik 4676b288a2 LibWeb: Set table width to GRIDMAX if calculated value is max-content
If the width of the table container is specified as max-content, then
it seems sensible to resolve it as the sum of the maximum widths of the
columns.
2023-10-31 18:13:14 +01:00
networkException 387ab57eb1 LibWeb/Tests: Add test for a <script type=module> inside <head> 2023-10-31 18:09:14 +01:00
Aliaksandr Kalenik 141f56accc LibWeb: Position abspos items inside grid relative to their grid area
Since grid item's containing block is not grid container but
corresponding grid area, it affect positioning of abspos items.
2023-10-31 08:46:17 +01:00
Andreas Kling 9f50c2c718 Tests/LibWeb: Update test expectation after float serialization changes 2023-10-31 07:25:56 +01:00
Aliaksandr Kalenik 549dee4db1 LibWeb: Call prepare_for_replaced_layout() on replaced boxes in GFC
We need to call prepare_for_replaced_layout() on grid items to populate
their natural sizes and aspect ration.
2023-10-31 07:08:30 +01:00
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