Commit graph

68644 commits

Author SHA1 Message Date
Shannon Booth
ba93e2a8a3 LibWeb/URLPattern: Implement the URLPattern constructors
The underlying URL::Pattern implementation still has to be fully
implemented, but this does complete the IDL wrapper layer of the
implementation.
2025-03-04 16:32:09 -05:00
Shannon Booth
ff07cc1a6c LibURL/Pattern: Add some scaffolding for the URLPattern constructor 2025-03-04 16:32:09 -05:00
Shannon Booth
873f7e4b3d LibURL/Pattern: Add a representation of a URL Pattern error
As the comment in this file explains the caller of LibURL APIs are
meant to assume if they see any error, that it is a TypeError since
that is all the spec throws at the moment.

A custom error type exists here so that we can include more
information in TypeError's which are thrown.
2025-03-04 16:32:09 -05:00
Shannon Booth
de89f5af6d LibURL: Remove the implicit URL constructors
All URLs are now either constucted through the URL Parser or by
default constructing a URL, and setting each of the fields of that
URL manually. This makes it much more difficult to create invalid
URLs.
2025-03-04 16:24:19 -05:00
Shannon Booth
1a47cfe3b9 Meta: Use URL basic parse for URL Fuzzer 2025-03-04 16:24:19 -05:00
Shannon Booth
3fb9c37783 UI/Qt: Do not rely on the URL implicit constructors 2025-03-04 16:24:19 -05:00
Shannon Booth
0f495421f1 UI/AppKit: Do not rely on the implicit URL constructors 2025-03-04 16:24:19 -05:00
Shannon Booth
097f7fe169 LibWeb/Loader: Explicitly parse URL generating directory response
Removing one more caller of the implicit URL constructors.
2025-03-04 16:24:19 -05:00
Shannon Booth
277aceac98 LibWeb/HTML: Parse URL track URL before creating fetch request
This is a bit weird in the spec in it passing through a string here
instead of a URL record. However, the string being used in this
case should only ever be a valid URL string if it is not the empty
string.
2025-03-04 16:24:19 -05:00
Shannon Booth
1257d0c1a8 LibWeb/HTML: Explicitly basic parse URL when following the hyperlink
Instead of relying on the implicit URL constuctor. Parsing should
never fail here as urlString before adding the suffix is already
parsed above, and the suffix should only be a valid query string.
2025-03-04 16:24:19 -05:00
Shannon Booth
2827374edc LibWebView: Handle missing URL for view source
Instead of potentially passing through an invalid URL.
2025-03-04 16:24:19 -05:00
Shannon Booth
f857c6a6e6 LibWeb/HTML: Make HTMLImageRequests currentURL a String
This is the same type as what is spec'd. We cannot use a URL record
for this member as the spec in some scenarios will set and compare
the URL string to an invalid URL value, such as the empty string.

With implicit string constructors for the URL class removed
explicitly using URL::Parser::basic_parse makes the code look
quite silly in those places.
2025-03-04 16:24:19 -05:00
Sam Atkins
9b7fb0850d LibJS+LibWebView: Treat trivia tokens as comments
Trivia is whatever whitespace and comments appear before a token.
Previously this was always given a TokenCategory of Invalid, so it
would be displayed as an error in the view-source page, with red wiggly
underlines. Instead, treat it as what it actually is: whitespace and
comments!
2025-03-04 15:54:03 -05:00
Timothy Flynn
38c1ac767d Documentation: Describe how to sniff the DevTools protocol with Firefox
For developing new LibDevTools features, it's easiest to snoop Firefox's
communication on the DevTools port to see what messages are being sent.
2025-03-04 15:42:39 -05:00
Timothy Flynn
491d1621d4 Documentation: Update the DevTools document with console.log support 2025-03-04 15:33:39 -05:00
Timothy Flynn
ffdce78b7b LibWebView+WebContent: Implement basic DevTools console support 2025-03-04 15:33:39 -05:00
Timothy Flynn
c5a22a1a97 LibDevTools+LibWebView: Implement basic support for console logging
This implements support for basic usage of console.log and friends. It
does not implement console.assert, console.trace, console.group, etc.
2025-03-04 15:33:39 -05:00
Timothy Flynn
848ac11495 LibWebView: Rename a couple of console-related callbacks for clarity
The "on_received_console_message" and "on_received_console_messages"
were indistinguishable in purpose based on their name. This renames them
to:

on_console_message_available - WebContent has output a console message
and it is available for the client to retrieve.

on_received_styled_console_messages - WebContent has replied to a
request for the available console messages.

The "styled" qualifier is used here to indicate that the messages have
been styled with CSS for display in a WebView. This is to prepare for
an upcoming patch where DevToolsConsoleClient will not stylize the
output; DevTools will want the raw JS values.
2025-03-04 15:33:39 -05:00
Timothy Flynn
14a8ffa867 WebContent: Move console handling from WebContentCC to InspectorCC
The idea originally was that the WebContentConsoleClient would perform
some amount of console handling that both InspectorConsoleClient and
DevToolsConsoleClient needed. But in implementing the DevTools console,
it's become clear that these implementations will not overlap at all. So
this patch moves the existing Inspector functionality away from
WebContentConsoleClient.
2025-03-04 15:33:39 -05:00
Timothy Flynn
1adcaf7181 AK: Fix the JsonArray constructor for accepting an iterable type
There were a couple of issues here. First, the IterableContainerOf
concept was testing if dereferencing an iterator of ContainerType<T>
returns a value of type T. However, it should return a T&.

Second, the constructor was trying to move values out of a constant
reference to the container. We now accept both lvalue and rvalue
containers.
2025-03-04 15:33:39 -05:00
sideshowbarker
38197916c3 LibWeb: Implement HTMLInputElement type=url constraint validation
This change implements HTMLInputElement type=url constraint validation
in such a way as to match the behavior in other existing engines (which
is, however, very different from what the spec currently requires).
2025-03-04 19:15:40 +00:00
Andreas Kling
6606eecce5 LibWeb: Invalidate style (and rule cache) on MediaList changes
This makes dynamic changes to a style sheet's media attribute actually
take effect immediately.
2025-03-04 19:07:40 +01:00
Aliaksandr Kalenik
80c0a16597 LibWeb: Don't invalidate style for animations in idle state 2025-03-04 18:06:46 +01:00
Aliaksandr Kalenik
b92a8553c7 LibWeb: Cancel animations when element is moved in display none subtree
We already have logic to play or cancel animations in an element's
subtree when the display property changes to or from none. However,
this was not sufficient to cover the case when an element starts/stops
being nested in display none after insertion.
2025-03-04 18:06:46 +01:00
Sam Atkins
f148af0a93 LibWeb: Move XMLSerializer into HTML directory
The DOMParsing spec is in the process of being merged into the HTML one,
gradually. The linked spec change moves XMLSerializer, but many of the
algorithms are still in the DOMParsing spec so I've left the links to
those alone.

I've done my best to update the GN build but since I'm not actually
using it, I might have done that wrong.

Corresponds to 2edb8cc7ee
2025-03-04 16:44:41 +00:00
Sam Atkins
a11848f163 IDLGenerators: Allow DOMString? reflection on non-enumerated attributes
Corresponds to ef2fba2a3b
2025-03-04 16:44:41 +00:00
Sam Atkins
d970748eed LibWeb/HTML: Assert that a finished promise has a committed-to-entry
Corresponds to 12c6ce02d8
2025-03-04 16:44:41 +00:00
Totto16
4c54fa10ed LibWeb: Improve Enum generation in IDLGenerator
Generated enums have no underlying type specifier, this adds one
It uses the smallest available, which is mostly u8
2025-03-04 16:35:04 +00:00
NotAShelf
c276cc43f0 Nix: Expose ladybird package in flake; reuse in shell
Add and expose a `ladybird` package in the Nix flake. Allows building
Ladybird only using Nix, and without relying on the dev shell. Other
users will be able to build Ladybird from source using nix3 CLI via
`nix build github:LadybirdBrowser/ladybird` or add it as a flake input
to consume the package.

We also re-use the package in the devshell, to keep dependencies in-sync
between the bleeding-edge source package, and the dev shell. This is an
upgrade to how we previously inferred dependencies to Nixpkgs package
for Ladybird, which had a chance to lack dependencies required to build
the latest commit.
2025-03-04 08:19:54 -07:00
NotAShelf
41622eaf51 Nix: Remove flake-utils from inputs
Motive: flake-utils is an unnecessary abstraction library that manages
to creep into every project under the guise of making things "easier."
There is no reason to use flake-utils here, as Nix is a powerful enough
DSL to handle system abstractions in-house without relying on more 3rd
party code, especially in a flake as small as Ladybird's.

We are not re-inventing the wheel; we are merely going back to circle
wheels.
2025-03-04 08:19:54 -07:00
Luke Wilde
e34a6c86b9 LibWeb: Introduce Content Security Policy policies and directives
These form the basis of Content Security Policy. A policy is a
collection of directives that are parsed from either the
Content-Security-Policy(-Report-Only) HTTP header, or the `<meta>`
element.

The directives are what restrict the operations can be performed in the
current global execution context. For example, "frame-ancestors: none"
tells us to prevent the page from being loaded in an embedded context,
such as `<iframe>`.

You can see it a bit like OpenBSD's pledge() functionality, but for the
web platform: https://man.openbsd.org/pledge.2
2025-03-04 14:27:19 +01:00
Rok Povsic
d17bd2c5f1 Documentation: Add instructions to uncheck 'Enable profile' for Debug 2025-03-04 06:08:43 -07:00
Rok Povsic
cff48febf0 LibWeb: Fix moving through tabs with keyboard shortcuts
Previously, despite CTRL being held, the webpage elements such as
checboxes (if existing) could 'hijact' moving to the next and previous
tab with CTRL+TAB and CTRL+SHIFT+TAB.
2025-03-04 07:37:36 -05:00
Timothy Flynn
532f156f4a LibJS: Remove some single-use Intl.DurationFormat variables
This is an editorial change in the ECMA-402 spec. See:
https://github.com/tc39/ecma402/commit/4c139f1
https://github.com/tc39/ecma402/commit/da498c2
https://github.com/tc39/ecma402/commit/ed5c716
2025-03-04 07:36:10 -05:00
Timothy Flynn
1e462daa9b LibJS: Simplify the Intl.DurationFormat GetDurationUnitOptions AO
This is an editorial change in the ECMA-402 spec. See:
https://github.com/tc39/ecma402/commit/d097048
2025-03-04 07:36:10 -05:00
Timothy Flynn
2f023c2d9c LibJS: Simplify Intl.DurationFormat.prototype.resolvedOptions
This is an editorial change in the ECMA-402 spec. See:
https://github.com/tc39/ecma402/commit/e3d3406
2025-03-04 07:36:10 -05:00
Timothy Flynn
56a6daee4d LibJS: Standardize the spec-order of Intl.DurationFormat definitions
This is an editorial change in the ECMA-402 spec. See:
https://github.com/tc39/ecma402/commit/54ca35d
https://github.com/tc39/ecma402/commit/6cdcab3
https://github.com/tc39/ecma402/commit/e4cbfba
2025-03-04 07:36:10 -05:00
Timothy Flynn
aa61307392 LibJS: Re-arrange and rename a few Intl properties
This is an editorial change in the ECMA-402 spec. See:
https://github.com/tc39/ecma402/commit/a46e37d
https://github.com/tc39/ecma402/commit/e102741
https://github.com/tc39/ecma402/commit/67a8417
https://github.com/tc39/ecma402/commit/ecb086c
2025-03-04 07:36:10 -05:00
sideshowbarker
8b0f6cb876 LibWeb: Implement “convert a string to a number” for type=time inputs 2025-03-04 12:33:09 +00:00
Totto16
678f531fe5 LibWeb: Fix IDL Generation error for enums
In the case, where IDL enums start with a character, that is an invalid
start character for C++ identifiers (e.g. a number), the C++ generaion
for enums fails. An example would be "2d" see #3788
2025-03-04 08:31:26 +00:00
Totto16
1182ee6c69 LibIDL: Report empty types with a separate error
Previously the IDL Parser Complained, that a type with the name ''
(an empty string) couldn't be found. It wasn't that easy to see the
mistake, as the not named type is printed without '' around it, so the
message seemed to miss a type. This now catches this specify error
earlier and reports it cleanly to the user. An example of this
occurring would be ''typedef A (B or //FIXME: C )
2025-03-04 08:31:26 +00:00
sideshowbarker
d14856e3c5 LibWeb: Implement “suffering from a step mismatch” constraint validation 2025-03-04 08:21:51 +00:00
Andreas Kling
12f5e9c5f8 LibWeb: Only put connected elements into document's by-name-or-id cache
This fixes an issue where disconnected elements were incorrectly
accessible as named properties on the document.
2025-03-04 00:51:50 +01:00
InvalidUsernameException
5f1a146afd LibWeb: Draw floating replaced elements more correctly
Previously floating replaced elements were drawn incorrectly and also
twice.
2025-03-03 21:49:44 +01:00
aplefull
80b2c11c81 LibJS: Implement Math.sumPrecise 2025-03-03 21:46:22 +01:00
Aliaksandr Kalenik
c769271e82 LibWeb: Don't invalidate display list in update_animated_style_if_needed
All necessary invalidations are issued while invalidating animated
style. There is no need to drop display list simply because there are
some animations that might need an update.
2025-03-03 21:45:23 +01:00
Aliaksandr Kalenik
1ce1a8f8f1 LibWeb: Reset and update animated style in a single pass
...and skip resetting animated style of finished animations.
2025-03-03 21:45:23 +01:00
Aliaksandr Kalenik
8e481f65f5 LibWeb: Don't invalidate style of finished animations
Removes lots of completely unnecessary work, especially when animated
property affects layout.
2025-03-03 21:45:23 +01:00
R-Goc
94de31ff3b AK: Remove fast_u32_xxx apis from Memory.h
This commit removes the fast_u32_fill and fast_u32_copy functions,
as they were only used in one place, and are not optimal.
2025-03-03 15:58:27 +01:00
Andreas Kling
fe2b752083 LibWeb: Don't begin link element fetch until browsing-context connected
Note that "becomes browsing-context connected" is defined as:

> When the insertion steps are invoked with it as the argument and it is
> now browsing-context connected.

This fixes an issue where WPT editing tests would clone the entire DOM
thousands of times and re-fetch all the linked CSS files once per clone.
2025-03-03 14:49:20 +01:00