Commit graph

63039 commits

Author SHA1 Message Date
dependabot[bot]
0743afbb3c CI: Bump gradle/actions from 3 to 4
Bumps [gradle/actions](https://github.com/gradle/actions) from 3 to 4.
- [Release notes](https://github.com/gradle/actions/releases)
- [Commits](https://github.com/gradle/actions/compare/v3...v4)

---
updated-dependencies:
- dependency-name: gradle/actions
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-08-06 17:06:40 -06:00
Shannon Booth
6cac2981fb LibURL: Fail parsing IPV4 URLs starting with 0x that overflow
Parsing last as an IPV4 number was not returning true in "ends with a
number" as the parsing of that part was overflowing. This means that the
URL is not considered to be an IPv4 address, and is treated as a valid
domain.

Helpfully, the spec also points out in a note that this step is
equivalent to simply checking that the last part ends with 0x followed
by only hex digits - which doesn't suffer from any overflow problem!

Arguably this is an editorial issue in the spec where this should be
clarified a little bit. But for now, fixing this fixes 3 sub tests in
WPT for:

https://wpt.live/url/url-constructor.any.html
2024-08-06 23:08:12 +01:00
Shannon Booth
db3f118046 LibURL: Fix heuristic for URL domain parsing IDNA fast path
Our heuristic was a bit too simplistic and would not run through the
ToASCII unicode algorithm which performs some extra validation. This
would cause invalid URLs that should fail to be parsed be mistakenly
accepted.

This fixes 8 tests in: https://wpt.live/url/url-constructor.any.html
2024-08-06 23:08:12 +01:00
Shannon Booth
fd4e943e12 LibWeb: Don't strip leading '?' in query initializing a URL
In our implementation of url-initialize, we were invoking the
constructor of URLSearchParams:

https://url.spec.whatwg.org/#dom-urlsearchparams-urlsearchparams

Instead of the 'initialize' AO:

https://url.spec.whatwg.org/#urlsearchparams-initialize

This has the small difference of stripping any leading '?' from the
query (which we are not meant to be doing!).
2024-08-06 23:08:12 +01:00
Shannon Booth
d7b19b3278 LibWeb/Tests: Also verify URL search params in constructor tests 2024-08-06 23:08:12 +01:00
Shannon Booth
1dc4959e91 LibURL: Don't return early parsing a URL with an empty input
We can't simply use the base URL as it may need to be modified in some
form. For example - for the included test, the fragment was previously
being included in the resulting URL.

This fixes 1 test on https://wpt.live/url/url-constructor.any.html
2024-08-06 23:08:12 +01:00
Shannon Booth
d161602b6d LibURL: Fix method name in debug logging 2024-08-06 23:08:12 +01:00
Shannon Booth
d9927d128c LibURL: Remove unused URL::create_with_help_scheme
This is unused since the SerenityOS split.
2024-08-06 23:08:12 +01:00
Aliaksandr Kalenik
672ff7e45e LibWeb: Define bounding rect for AddMask display list item
This allows display list player to skip masks that would not be visible.
2024-08-06 22:16:17 +02:00
Aliaksandr Kalenik
9f4deb57c8 LibWeb: Skip AddMask in display list player if destination rect is empty
...because otherwise Skia will fail to allocate empty surface.

Fixes crashing on https://null.com/games/chainstaff
2024-08-06 22:16:17 +02:00
Aliaksandr Kalenik
a8f4ea5226 LibWeb: Fix "background-clip: text" for elements nested in scrollable
Instead of carrying the display list for a mask in each command that
might potentially be affected by "background-clip: text", this change
introduces a new AddMask command that is applied once for all
background layers within one box.

The new AddMask command includes a rectangle for the mask destination
that is translated by the corresponding scroll offset.

Fixes https://github.com/LadybirdBrowser/ladybird/issues/857
2024-08-06 21:14:47 +02:00
Andreas Kling
861d46be3e LibWeb: Use a HashTable when querying SessionHistoryTraversalQueue
Instead of asking "do you have an entry not in this Vector", let's ask
"do you have an entry not in this HashTable".
2024-08-06 16:33:23 +02:00
Andreas Kling
a1519e67fb LibWeb: Fire navigation event as required in History.pushState() 2024-08-06 16:33:23 +02:00
Andreas Kling
e3408c4a7f LibWeb: Allow changing the query of file:// URL via history.pushState()
The spec didn't match how other browsers behave, and we dutifully did
what the spec said. A spec bug has been filed, so let's fix this locally
for now with a FIXME.
2024-08-06 16:33:23 +02:00
Andreas Kling
faf097bb41 LibWeb: Sync with spec in "destroy a document and its descendants"
The only real change here is that we make the document unsalvageable.
Everything else is fixing up spec comments.
2024-08-06 16:33:23 +02:00
Aliaksandr Kalenik
0fe84e89b2 LibWeb: Use padding box to get background rect for inline paintable
Fixes regression introduced by f574e2b03a
2024-08-06 16:25:45 +02:00
Jamie Mansfield
c891b83fc0 LibWeb: Don't crash with invalid import maps
See:
 - http://wpt.live/import-maps/multiple-import-maps/with-errors.html
2024-08-06 09:40:44 +02:00
Aliaksandr Kalenik
040653311e LibWeb: Fix background clip for elements nested into scrollable boxes
add_clip_rect() accepts a rectangle in viewport-relative coordinates,
so it must be translated by the enclosing scroll offset to be displayed
correctly inside a scrollable box.
2024-08-06 09:40:34 +02:00
Aliaksandr Kalenik
f574e2b03a LibWeb: Resolve background size and offset only after style invalidation
This change fixes layering violation by moving to_px() calls to happen
before display list recording. Also it should make display list
recording a bit faster by resolving background properties beforehand.
2024-08-06 09:40:34 +02:00
Shannon Booth
2995a57f63 LibHTTP: Don't double percent encode path in HTTPRequst::to_raw_request
This was a goof in cc55732332 which
resulted in the URL path getting double percent encoded. Since the path
already comes out percent encoded following the rules in the URL spec -
we don't need to percent encode again.

Fixes: #978
2024-08-06 08:18:20 +01:00
Shannon Booth
8723f72f0f LibURL: Remove unspecified steps in URL file slash parsing state
There were some extra steps in there which produced wrong results for
relative file URLs.

Fixes 7 test cases in: https://wpt.live/url/url-constructor.any.html

We also need to adjust the test results in TestURL. The behaviour tested
does not match how URL is specified to work as an absolute relative is
given.
2024-08-06 07:58:07 +01:00
Jamie Mansfield
1d12cb69d4 LibWeb: Implement HTMLTrackElement.readyState 2024-08-06 07:57:33 +01:00
Will Hawkins
4f4fdce62a Meta: Script to configure clangd according to build type
Add a simple shell script to update the local clangd configuration
according to the type of build selected by the user. Include
documentation on where the script might be useful when building
under different configurations.
2024-08-05 23:44:03 -06:00
Shannon Booth
d6af5bf5eb LibURL: Allow inputs containing only whitespace
The check for:

```
    if (start_index >= end_index)
        return {};
```

To prevent an out of bounds when trimming the start and end of the input
of whitespace was preventing valid URLs (only having whitespace in the
input) from being parsed.

Instead, prevent start_index from ever getting above end_index in the
first place, and don't treat empty inputs as an error.

Fixes one WPT test on:

https://wpt.live/url/url-constructor.any.html
2024-08-05 17:21:26 +01:00
Shannon Booth
4f5af3e90e LibURL: Remove FIXME for stripping c0 control or space
The FIXME was not correct - this was done correctly. But let's use a
helper to make the implementation slightly more readable.
2024-08-05 17:21:26 +01:00
Shannon Booth
670ce3ebb1 LibURL: Remove not particuarly useful NOTE
This doesn't seem like something we will neccessarily do in the URL
class anyway due to performance reasons - unless strictly needed (like
for the DOMURL implementation).
2024-08-05 17:21:26 +01:00
Shannon Booth
cfa8a8cea2 AK: Add is_ascii_c0_control_or_space 2024-08-05 17:21:26 +01:00
Andreas Kling
1e7b17f150 LibWeb: Don't crash on getClientRects() in document without navigable
I previously believed there was no way a detached document should have
layout information, but it turns out there is a way: getComputedStyle().

So we need to account for cases where we have a layout node, but no
navigable, since that is a state we can get into at this moment.

Fixes #354
2024-08-05 14:56:04 +02:00
Shannon Booth
41cf9f6fe3 LibURL: Also remove carriage returns from URL input
The definition of an "ASCII tab or newline" also includes U+000D CR.

This fixes 3 subtests in:

https://wpt.live/url/url-constructor.any.html
2024-08-05 11:27:05 +02:00
Shannon Booth
a342370dfb LibWeb: Rename SharedImageRequest to SharedResourceRequest
For the SVG <use> element, we want to support loading HTML documents
that have a SVG element inside of it pointed to by the URL fragment.

In this situation we would need to fetch and parse the entire document
in SharedImageRequest (so that we can still cache the SVGs). Rename
SharedImageRequest to SharedResourceRequest to make the class a little
more generic for future usecases.
2024-08-05 11:26:41 +02:00
Shannon Booth
2fb5054603 LbiWeb: Add and use SharedImageRequest::handle_successful_resource_load
This closer mirrors handle_failed_fetch, making the handling slightly
more clear to understand. It also means that we don't need to take a
strong reference to this on a successful SVG resource load.
2024-08-05 11:26:41 +02:00
Shannon Booth
e0f2e42687 LibWeb: Use handle_failed_fetch to implement handle_failed_decode
...When loading images through SharedImageRequest.

There is a small behavioural difference here - handle_failed_fetch
clears the pending callbacks whereas handled_failed_decode was
previously not. This does not seem intentional, and appears like a bug.

Implementing it this way is _slightly_ simpler - and also means we
don't need to take a strong handle to this in the case of loading an
SVG image.
2024-08-05 11:26:41 +02:00
Shannon Booth
85e8e7ec23 LibWeb: Add support for fetching SVG use elements from external docs
This allows SVG elements to refer to elements which are in other
documents, such as https://www.neogaf.com/forums/gaming-discussion.2/
or on lemmy.ml

Fixes: #141
Progress towards: #350
2024-08-05 11:26:41 +02:00
Shannon Booth
e11a7b668f LibWeb: Do not const qualify clone_element_tree_as_our_shadow_tree
We are mutating the shadow root of the element.
2024-08-05 11:26:41 +02:00
Shannon Booth
cf7f07b822 LibWeb: Pass Element const& to is_valid_reference_element
The element can't be null - and we don't need to mutate it either.
2024-08-05 11:26:41 +02:00
Shannon Booth
ab70932681 LibWeb: Factor out "process the URL" AO for SVGUseElement 2024-08-05 11:26:41 +02:00
Jamie Mansfield
5151f94d39 LibWeb/Fetch: Correct check for X-Method-Override
Previously the code was checking for X-Method.

See:
 - http://wpt.live/fetch/api/basic/request-forbidden-headers.any.html
2024-08-05 10:01:34 +02:00
Jamie Mansfield
f88e7bc5ee LibWeb/Fetch: Add Set-Cookie as a forbidden header name
See:
 - https://github.com/whatwg/fetch/commit/50d77e6
 - http://wpt.live/fetch/api/request/request-headers.any.html
2024-08-05 10:01:34 +02:00
Shannon Booth
cc55732332 LibURL+Everywhere: Only percent decode URL paths when actually needed
Web specs do not return through javascript percent decoded URL path
components - but we were doing this in a number of places due to the
default behaviour of URL::serialize_path.

Since percent encoded URL paths may not contain valid UTF-8 - this was
resulting in us crashing in these places.

For example - on an HTMLAnchorElement when retrieving the pathname for
the URL of:

http://ladybird.org/foo%C2%91%91

To fix this make the URL class only return the percent encoded
serialized path, matching the URL spec. When the decoded path is
required instead explicitly call URL::percent_decode.

This fixes a crash running WPT URL tests for the anchor element on:

https://wpt.live/url/a-element.html
2024-08-05 09:58:13 +02:00
Shannon Booth
ffe070d7f9 LibWeb+LibURL: Use URL paths directly for comparison
This matches the text of the spec a little more closely in many cases
and is also more efficient than serializing the URL path.
2024-08-05 09:58:13 +02:00
Tim Ledbetter
ea68bdef26 LibWeb: Return error on modification of a computed CSS style declaration
Previously, calling `setProperty` or `removeProperty` from JS on a
CSSStyleDeclaration returned from `getComputedStyle()` would return
null. We now return a NoModificationAllowedError instead, which aligns
our implementation with the specification.
2024-08-05 09:55:50 +02:00
Andreas Kling
08d60d7521 LibWeb: Make HTML::Task IDs a sequential, distinct numeric type
This also fixes a bug where task IDs were being deallocated from the
wrong IDAllocator. I don't know if it was actually possible to cause any
real trouble with that mistake, nor do I know how to write a test for
it, but this makes the bug go away.
2024-08-05 09:12:07 +02:00
Andreas Kling
0e1256e5a4 LibWeb: Make requestAnimationFrame() callback IDs sequential
This is required by the spec, so let's stop returning random IDs in
favor of a simple sequential integer sequence.
2024-08-05 09:12:07 +02:00
Jamie Mansfield
a034d1e675 LibWeb/HighResolutionTime: Add missing visit to Performance
This should fix the CI :^)
2024-08-04 20:33:22 +02:00
Jamie Mansfield
bedb626c29 LibWeb: Set script force async to false when async changes 2024-08-04 19:25:29 +01:00
Jamie Mansfield
77c41a82be LibWeb: Script force async flag should default to true
See:
 - http://wpt.live/html/semantics/scripting-1/the-script-element/async_001.htm
2024-08-04 19:25:29 +01:00
Shannon Booth
fdf4f1e887 LibURL: Validate for invalid _domain_ code points for non-opaque domains
We were previously not checking for C0 control, U+0025 (%), or U+007F
DELETE.

This makes another good set of URL tests in WPT pass :^)
2024-08-04 18:29:06 +01:00
Shannon Booth
f511c0b441 LibURL+LibWeb: Do not percent decode in password/username getters
Doing it is not part of the spec. Whenever needed, the spec will
explicitly percent decode the username and password.

This fixes some URL WPT tests.
2024-08-04 12:59:02 +01:00
Andreas Kling
a10610a1ca LibWeb: Don't crash on CSS all: revert
Not every value in a StyleProperties will be non-null by the time we
perform `revert`, so let's make a specialized function for reverting a
property instead of using the path that requires the value to be
non-null.
2024-08-04 11:49:44 +02:00
Tim Ledbetter
96c0cbf584 LibWeb: Ensure ParentNode.getElementsByClassName() matches all classes 2024-08-04 10:39:17 +02:00