Commit graph

71492 commits

Author SHA1 Message Date
Aliaksandr Kalenik
87c7fb1d63 LibWeb: Use 0 as min-content size for items with overflow:hidden [GFC]
Some checks are pending
CI / Linux, x86_64, Sanitizer, GNU (push) Waiting to run
CI / macOS, arm64, Sanitizer, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer, Clang (push) Waiting to run
Package the js repl as a binary artifact / Linux, arm64 (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / Linux, x86_64 (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
This behavior is not specified but required to match other browsers.

Fixes https://github.com/LadybirdBrowser/ladybird/issues/5907
2025-08-30 15:57:45 +02:00
Erik Kurzinger
42339be999 LibWeb: Use intrinsic size for current_image_bitmap
Currently, ImageProvider::current_image_bitmap takes a Gfx::IntSize
argument which determines the size of the returned bitmap. The default
value of this argument is 0x0 which causes the function to return
nullptr. This behavior is evidently unintuitive enough that it has lead
to incorrect usage in multiple places. For example, the 2D canvas
drawImage method will never actually draw anything because it calls
current_image_bitmap with no arguments. And the naturalWidth and
naturalHeight of an image will always return 0 (even after the image has
loaded) for the same reason.

To correct this and hopefully avoid similar issues in the future,
ImageProvider::current_image_bitmap will be renamed to
current_image_bitmap_sized, and the default value for the size argument
will be removed. For consistency, a similar change will be made to
SVGImageElement::default_image_bitmap.

The existing current_image_bitmap function will no longer take a size
argument. Instead it will always return a bitmap of the image's
intrinsic size. This seems to be what most existing callers had already
assumed was the function's behavior.
2025-08-30 15:49:11 +02:00
Erik Kurzinger
0189553bed LibWeb/WebGL: Avoid freeing GL objects belonging to other contexts
The free_surface_resources() function in OpenGLContext.cpp is
responsible for freeing all GL and EGL objects tied to the lifetime of
the painting surface. It is called when the associated canvas is resized
or destroyed. However, if there are multiple WebGL canvases and another
canvas's context is current when the function is called, it will
unintentionally free GL objects belonging to that other context.

To fix this, we call eglMakeCurrent at the start of
free_surface_resources(). This ensures that we will be deleting the
intended objects.

Note that m_impl->surface could be EGL_NO_SURFACE if
free_surface_resources() is called before the painting surface has been
created, but that should be fine. EGL_KHR_surfaceless_context support is
ubiquitous at this point.
2025-08-30 15:49:11 +02:00
Erik Kurzinger
21ff66c6cb LibWeb/SVG: Parse comma-separated SVG viewBox
From the SVG spec

The value of the ‘viewBox’ attribute is a list of four numbers <min-x>,
<min-y>, <width> and <height>, separated by whitespace and/or a comma...

Currently try_parse_view_box will fail to parse the attribute if the
values are separated by commas.

This change replaces try_parse_view_box with a more correct
implementation. It will reside in the AttributeParser.cpp. This new
implementation correctly handles comma-separated viewBox values, and is
also more robust against invalid inputs.

Additionally, it adds a new test case to ensure viewBox values with
various syntax are parsed correctly and invalid values are rejected.
2025-08-30 15:49:11 +02:00
Tete17
c3aa8f0c8d LibWeb: Remove FIXME from attribute validity in HTMLFieldSetElement
Some checks are pending
CI / macOS, arm64, Sanitizer, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer, Clang (push) Waiting to run
Package the js repl as a binary artifact / Linux, arm64 (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / Linux, x86_64 (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
It already implements the function.
2025-08-29 19:27:30 +01:00
Tete17
70c3f203ef LibWeb: Implement validation_message for form associated elements
It wins us a quick WPT test as well as implement a bunch of IDL methods.
2025-08-29 19:27:30 +01:00
Tete17
8ab568bc76 LibWeb: Unify will_validate for form associated elements
We had the same implementation in quiet a few places. With this change
we unify them in a single place
2025-08-29 19:27:30 +01:00
Tete17
af88a43e9a LibWeb: Unify check_validity for form associated elements 2025-08-29 19:27:30 +01:00
Tete17
44053ed3c2 LibWeb: Unify report_validity for form associated elements
This function was implemented in a few classes but is a common element
in all form associated elements and the functionality should be there.

With these minimal changes we get to implement 4 idl functions for free.
2025-08-29 19:27:30 +01:00
Tete17
46b1466998 LibWeb: Remove extra whitespace in idl file 2025-08-29 19:27:30 +01:00
Luke Wilde
b17783bb10 Everywhere: Change west consts caught by clang-format-21 to east consts 2025-08-29 18:18:55 +01:00
Callum Law
829437c11d LibWeb: Implement autocorrect attribute 2025-08-29 15:47:17 +01:00
Callum Law
a6fb7c84e9 LibWeb: Implement the autocapitalize attribute 2025-08-29 15:47:17 +01:00
Callum Law
11457e533a LibWeb: Update is_autocapitalize_inheriting method name with spec
This was changed when the autocorrect attribute was introduced:
7bab05a
2025-08-29 15:47:17 +01:00
Callum Law
e539990c7f LibWeb: Implement writingSuggestions attribute 2025-08-29 15:47:17 +01:00
Callum Law
87e0523664 LibWeb: Implement the spellcheck attribute 2025-08-29 15:47:17 +01:00
Sam Atkins
7be645a091 LibWeb/CSS: Implement CSSNumericType.equals()
Some checks are pending
CI / macOS, arm64, Sanitizer, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer, Clang (push) Waiting to run
Package the js repl as a binary artifact / Linux, arm64 (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / Linux, x86_64 (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
2025-08-29 11:57:10 +02:00
Sam Atkins
d29084997e LibWeb/CSS: Reify math functions into CSSMathValue types 2025-08-29 11:57:10 +02:00
Sam Atkins
9264f540dd LibWeb/CSS: Correct definition of CSSNumericType
What I thought was a spec issue was actually a combination of my own
misunderstanding and a bug in our IDL generator. With that bug fixed, I
can correct this to how it is in the spec.
2025-08-29 11:57:10 +02:00
Sam Atkins
ffb236adbd IDLGenerators: Correctly treat optional enums as optional
Specifically, this makes enums in dictionaries not cause compile errors.
2025-08-29 11:57:10 +02:00
Sam Atkins
e174215845 LibGC: Add Ptr::as_nonnull()
Convert from a GC::Ptr to a GC::Ref directly, instead of having to write
`GC::Ref { *thing }`.
2025-08-29 11:57:10 +02:00
Sam Atkins
277117eed5 LibWeb/CSS: Implement CSSNumericValue.parse()
Reifying the result gets quite ad-hoc. Firstly because "parse a
component value" produces a ComponentValue, not a full StyleValue like
we need for math functions. And second, because not all math functions
can be reified as a CSSNumericValue:

Besides the fact that I haven't implemented CalculatedStyleValue
reification at all yet, there are a lot of math functions with no
corresponding CSSMathValue in the spec yet. If the calculation tree
contains any of those, the best we can do is reify as a CSSStyleValue,
and that isn't a valid return value from CSSNumericValue.parse(). So, I
made us throw a SyntaxError in those cases. This seems to match
Chrome's behaviour. Spec issue:
https://github.com/w3c/css-houdini-drafts/issues/1090
2025-08-29 11:57:10 +02:00
Sam Atkins
73d7d6b831 LibWeb: Generate a math_function_from_string() function
This will be used as a convenient way to see if a string is the name of
a math function.
2025-08-29 11:57:10 +02:00
Sam Atkins
177395155a LibWeb/CSS: Implement CSSMathClamp
As the final CSSMathFoo class, this makes the serialization test finally
run instead of crashing.
2025-08-29 11:57:10 +02:00
Sam Atkins
dd3007dcd7 LibWeb/CSS: Implement CSSMathMax
Basically the same as CSSMathMin.
2025-08-29 11:57:10 +02:00
Sam Atkins
1a35795f47 LibWeb/CSS: Implement CSSMathMin 2025-08-29 11:57:10 +02:00
Sam Atkins
8efd0639cd LibWeb/CSS: Implement CSSMathInvert
This is almost identical to CSSMathNegate.
2025-08-29 11:57:10 +02:00
Sam Atkins
f2ec04d20d LibWeb/CSS: Implement CSSMathNegate 2025-08-29 11:57:10 +02:00
Sam Atkins
e21610180f LibWeb/CSS: Implement CSSMathProduct
This is almost identical to CSSMathSum.
2025-08-29 11:57:10 +02:00
Sam Atkins
e17052a343 LibWeb/CSS: Implement CSSMathSum 2025-08-29 11:57:10 +02:00
Sam Atkins
a46c980629 LibWeb/CSS: Implement CSSNumericArray 2025-08-29 11:57:10 +02:00
Sam Atkins
6c8876cdb8 LibWeb/CSS: Implement CSSMathValue
This is a base class for the various math functions, so it's not used
directly anywhere.
2025-08-29 11:57:10 +02:00
Sam Atkins
ef8ca729cc IDLGenerators: Make 'operator' a reserved word
This is the name of an attribute of CSSMathValue.
2025-08-29 11:57:10 +02:00
Sam Atkins
4791f9e88f IDLGenerators: Make attribute names C++-safe 2025-08-29 11:57:10 +02:00
Sam Atkins
46b55f0f46 LibWeb/CSS: Implement rectify_a_numberish_value() 2025-08-29 11:57:10 +02:00
Tuur Martens
222ca9e2cd Documentation: Rectify incorrect preset name 2025-08-29 11:54:16 +02:00
Bernard Niset
de99dd42a2 Tests: Use 127.0.0.1 instead of localhost in HTTP test server
This fixes slow test execution on macOS where localhost resolution
has a 200ms delay due to IPv6 fallback behavior in libcurl.

The XMLHttpRequest-override-mimetype-blob.html test now runs in ~0.6s
instead of ~16s on macOS.

Fixes #4850
See also: https://github.com/curl/curl/issues/2281
2025-08-29 10:34:43 +01:00
Tim Ledbetter
d4f05bc4ef LibWeb: Implement <feImage> SVG filter 2025-08-29 10:15:24 +01:00
Tim Ledbetter
5eff541804 LibWeb: Construct filter chain at paint time
This allows us to use style and box metrics when applying filters.
2025-08-29 10:15:24 +01:00
Jelle Raaijmakers
054b4dace0 LibWeb: Hit test StackingContext's children before testing visibility
Some checks are pending
CI / macOS, arm64, Sanitizer, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer, Clang (push) Waiting to run
Package the js repl as a binary artifact / Linux, arm64 (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / Linux, x86_64 (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
If a node that establishes a StackingContext has `pointer-events: none`,
hit testing should first proceed with hit testing the SC's children
before deciding to bail. We were checking for `pointer-events` too
early, causing large parts of certain websites to be noninteractive.

Fixes #6017.
2025-08-29 01:25:01 +02:00
Jelle Raaijmakers
8bbb3429b4 LibWeb: Simplify reverse child traversal in StackingContext::hit_test()
No need for manual index fiddling, use Vector::in_reverse().
2025-08-29 01:25:01 +02:00
Timothy Flynn
2fa6655dcb LibJS: Ensure NudgeToCalendarUnit is given a non-zero duration sign
Otherwise, we trip internal Temporal spec assertions.

This is an editorial change in the Temporal spec. See:
30f8575
2025-08-29 01:14:20 +02:00
Timothy Flynn
0c038bf12e LibJS: Read user options in a Temporal AO sooner
This is a normative change in the Temporal proposal. See:
9924aa4
2025-08-29 01:14:20 +02:00
Timothy Flynn
355589a89e LibJS: Read user options in some Temporal toString methods sooner
This is a normative change in the Temporal proposal. See:
3eaaadf
2025-08-29 01:14:20 +02:00
Jelle Raaijmakers
d87b3030a7 LibWeb: Prevent creation of new UsedValues for nested inline nodes
Some checks are pending
CI / macOS, arm64, Sanitizer, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer, Clang (push) Waiting to run
Package the js repl as a binary artifact / Linux, arm64 (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / Linux, x86_64 (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
In LayoutState, used_values_per_layout_node should not be modified in
order to determine inline nodes' dimensions - all the required values
should already be in there. In 2585f2da0d
we did accidentally create new values, causing the code further down to
try and get a PaintableBox from an anonymous container and crashing.

Fixes #6015.
2025-08-28 22:38:15 +02:00
Tim Ledbetter
b23fd1f440 LibWeb: Update layout when view box properties are changed 2025-08-28 15:42:56 +02:00
Tim Ledbetter
ea41aba6c7 LibWeb: Move common SVGViewport code into an SVGFitToViewBox class
Special handling for SVGClipPathElement and SVGMaskElement, which use a
a ViewBox and PreserveAspectRatio value internally, has been moved to
`SVGFormattingContext`.
2025-08-28 15:42:56 +02:00
Jelle Raaijmakers
c8d24d4966 LibWeb: Correctly position absolute inline boxes in last line
Some checks are pending
CI / macOS, arm64, Sanitizer, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer, Clang (push) Waiting to run
Package the js repl as a binary artifact / Linux, arm64 (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / Linux, x86_64 (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
If we were calculating the static position for an absolutely positioned
inline box that resides in the last line of its containing block, we
would not have yet provided the fragments in that line with their
final positions. Additionally, we would always move the box beneath the
fragment, which was incorrect.

Fixes #5867.
2025-08-28 13:45:37 +02:00
Jelle Raaijmakers
349fdd9f47 LibWeb: Explicitly update LineBuilder's last line at end of IFC run
Currently we're relying on LineBuilder's destructor to handle updating
the last line, if required. In order to fix an issue with our absolute
positioning code, we need to be able to update the last line earlier
than that. Remove the destructor and replace it with an explicit call to
LineBuilder::update_last_line().

No functional changes.
2025-08-28 13:45:37 +02:00
Jelle Raaijmakers
90bc805cb0 LibWeb: Simplify UsedValues::static_position()
No functional changes.
2025-08-28 13:45:37 +02:00