Commit graph

65657 commits

Author SHA1 Message Date
Jelle Raaijmakers
bb618736e9 LibWeb: Use default paragraph separator in delete command 2024-11-30 17:35:45 +01:00
Jelle Raaijmakers
4a64557876 LibWeb: Implement document.execCommand("defaultParagraphSeparator") 2024-11-30 17:35:45 +01:00
Jelle Raaijmakers
7bb865052a LibWeb: Implement document.execCommand("delete")
To facilitate the implementation of "delete" and all associated
algorithms, split off this piece of `Document` into a separate
directory.

This sets up the infrastructure for arbitrary commands to be supported.
2024-11-30 17:35:45 +01:00
Jelle Raaijmakers
c87960f8f3 LibWeb: Use GC::Ref<Node> in Range for start/end containers
Let's propagate the GC'ness of it all to the users of Range.
2024-11-30 17:35:45 +01:00
Sam Atkins
bf724ba2f6 LibWeb: Bring HTMLHyperlinkElementUtils::hostname() closer to spec
Actually reinitialize the URL like we are supposed to, and then check if
it's null. Also add some missing spec links.
2024-11-30 12:07:39 +01:00
Sam Atkins
3ce81512dd LibWeb/HTML: Make WorkerLocation methods infallible
We stopped worrying about tiny OOMs a while ago.
2024-11-30 12:07:39 +01:00
Sam Atkins
900c131178 LibURL: Make URL::serialized_host() infallible
This can no longer fail, so update the return type to match.

This makes a few more methods now unable to return errors, but one thing
at a time. 😅
2024-11-30 12:07:39 +01:00
Sam Atkins
70c8535b8a LibWeb: Update "window open steps" to current spec
Corresponds to https://github.com/whatwg/html/pull/10683

As part of this, I noticed we incorrectly were setting the "is popup"
flag on the Navigable instead of the BrowsingContext. I've fixed that
and removed the erroneous flag from Navigable.
2024-11-30 12:07:39 +01:00
Sam Atkins
b83f015c70 LibURL: Implement Site concept 2024-11-30 12:07:39 +01:00
Sam Atkins
2e64e0b836 LibURL: Migrate Origin scheme from ByteString to String 2024-11-30 12:07:39 +01:00
Sam Atkins
7f7f6e490b LibURL: Implement Host::public_suffix() and registrable_domain()
These algorithms are used in following commits.
2024-11-30 12:07:39 +01:00
Sam Atkins
63688148b9 LibURL: Promote Host to a proper class
This lets us move a few Host-related functions (like serialization and
checks for what the Host is) into Host instead of having them dotted
around the codebase.

For now, the interface is still very Variant-like, to avoid having to
change quite so much in one go.
2024-11-30 12:07:39 +01:00
Sam Atkins
90e763de4c LibURL: Replace Host's Empty state with making Url's Host optional
A couple of reasons:
- Origin's Host (when in the tuple state) can't be null
- There's an "empty host" concept in the spec which is NOT the same as a
  null Host, and that was confusing me.
2024-11-30 12:07:39 +01:00
Sam Atkins
8b984c0c57 LibURL: Clarify whether an Origin is opaque
Origins are immutable and we know on construction whether an Origin is
opaque. This also removes an implicit reliance on Host's Empty state.
2024-11-30 12:07:39 +01:00
Sam Atkins
3124dca528 LibURL+LibWebView: Move public suffix data to LibURL 2024-11-30 12:07:39 +01:00
Sam Atkins
edcdcea92d LibWebView: Simplify string joining in GeneratePublicSuffixData
Super minor, but gets rid of a clangd warning about the builder name
already being used.
2024-11-30 12:07:39 +01:00
Shannon Booth
91007eb476 LibWeb: Ensure principal realm returned for nested Shadow Realms
Recently reported against the shadow realm proposal after running into
issues with WPT tests.

In a nested shadow realm, the associated realm is a shadow realm, not
the principal realm. One such issue this fixes is a crash when a nested
shadow realm performs an operation which requires the principal settings
object.
2024-11-30 11:55:11 +01:00
Shannon Booth
218ac86b67 LibWeb: Use relevant principal settings for HighResolutionTime
Fixes a crash when setting the timestamps when creating a DOM event
within a ShadowRealm.
2024-11-30 11:55:11 +01:00
Shannon Booth
6a668f27c7 LibWeb: Push promise rejection handling onto UniversalGlobalScopeMixin
This is needed for shadow realms which don't have a window or worker
global object. Fixes a crash for the attached test.
2024-11-30 11:55:11 +01:00
Shannon Booth
fb17f8ff66 LibWeb: Get document for cookies usage from principal realm
Needed for when a shadow realm does an HTTP fetch as part of an import.
2024-11-30 11:55:11 +01:00
Shannon Booth
bc10729af6 LibWeb: Add relevant principal helper abstract operations
These were recently added into the shadow realm merge request as
convenience helpers.
2024-11-30 11:55:11 +01:00
Shannon Booth
d5aaff818e LibWeb: Adjust 'resolve a module specifier' to shadow realm proposal 2024-11-30 11:55:11 +01:00
Shannon Booth
bb10b0e301 LibWeb: Always assert that principal realm returns a principal realm
There was a bug in the HTML proposal where a synthetic realm settings
object's principal realm was a shadow realm if there were nested shadow
realms, which this assertion catches more directly (rather than later
down the track, where it is used).

We were meant to also assert for this case, but we were previously
returning early.
2024-11-30 11:55:11 +01:00
Shannon Booth
27f1e3676f LibWeb: Visit proper base class in SyntheticHostDefined
This was a goof of mine from when I added a common HostDefined base
class.
2024-11-30 11:55:11 +01:00
Shannon Booth
b39f4f0b5a LibWeb: Add stub definition for WorkletGlobalScope 2024-11-30 11:19:35 +01:00
Shannon Booth
286c177896 LibWeb: Support 'Worklet' exposed 2024-11-30 11:19:35 +01:00
Shannon Booth
cc11dcc9a1 LibWeb: Add stubbed implementation for ServiceWorkerGlobalScope 2024-11-30 11:19:35 +01:00
Shannon Booth
4417f63ca0 LibWeb: Move ServiceWorker classes to ServiceWorker namespace
These are defined by the ServiceWorker spec, not the HTML one.
2024-11-30 11:19:35 +01:00
Shannon Booth
2918405360 LibWeb: Rename ServiceWorker::ServiceWorker to ServiceWorkerRecord
This is to resolve naming conflicts between the ServiceWorker JS exposed
object and the internal representation of a ServiceWorker which is going
to be stored cross process.
2024-11-30 11:19:35 +01:00
Shannon Booth
04508841e9 LibWeb: Fix indent of the IDL generator using namespace hack 2024-11-30 11:19:35 +01:00
Timothy Flynn
53a507303c LibJS: Prevent extensions of TypedArray exotic objects
This is a normative change in the ECMA-262 spec. See:
https://github.com/tc39/ecma262/commit/c1040ff
2024-11-30 11:18:26 +01:00
devgianlu
c6e684791f LibWeb: Remove useless bytes conversion in ECDH.exportKey
Using `generate_public_key_point` instead of `generate_public_key`
removes a bit of redundant code.
2024-11-30 11:17:44 +01:00
devgianlu
399b3d2430 LibCrypto+LibWeb: Parse EC public key in parse_subject_public_key_info
Replicate what we are doing with RSA and parse both the private and
public key when parsing the ASN1.

The only thing that changed in the tests is the error message.
2024-11-30 11:17:44 +01:00
devgianlu
1f7586ce14 LibCrypto: Use ASN1 macros for RSA key parsing
Improve error handling in `RSA::parse_rsa_key` by using ASN1 macros and
generalizing the parsing to both private and public keys.
2024-11-30 11:17:44 +01:00
devgianlu
ee50a8c0f7 LibCrypto: Do not parse PKCS#8 in RSA::parse_rsa_key
The decoding inside `RSA::parse_rsa_key` is quite complex because it
tries to understand if it's decoding PKCS#8 or PKCS#1. Simplify the code
 by moving the burden to the PEM decoder.
2024-11-30 11:17:44 +01:00
devgianlu
57ecd72256 LibCrypto: Return PEM type when decoding and sanity check footer
Improve PEM decoding by parsing the header and returning it along the
data. Also verify if the header is equal to the footer.
2024-11-30 11:17:44 +01:00
devgianlu
0280838944 LibCrypto: Use ASN1 macros for EC key parsing
Improve error handling in `EC::parse_ec_key` by using ASN1 macros and
generalizing the parsing to both private and public keys.
2024-11-30 11:17:44 +01:00
devgianlu
40f17d9260 LibCrypto: Move ASN1 macros to Crypto::ASN1
Makes more sense to have them in `Crypto::ASN1` rather than in
`Crypto::Certificate`.
2024-11-30 11:17:44 +01:00
devgianlu
51f69be51f LibCrypto: Move ASN1 constants to Crypto::ASN1
Makes more sense to have them in `Crypto::ASN1` rather than in
`Crypto::Certificate`.
2024-11-30 11:17:44 +01:00
devgianlu
ab2960e49f LibCrypto+LibWeb: Reorganize OID ASN1 constants
I have divided ANS1 constants by length so that they don't have
trailing zeros that need to be removed.

Also moved OIDs lists to the only place they are used for clarity.

Fixed a couple of WPT tests by adding SECP521r1 to the list of known
curves.
2024-11-30 11:17:44 +01:00
Tim Ledbetter
b39fdcfec2 LibWeb: Implement the HTMLInputElement.height attribute
This allows the height of an image button input to be set and queried.
2024-11-30 11:01:33 +01:00
Tim Ledbetter
45a2823e08 LibWeb: Implement the HTMLInputElement.width attribute
This allows the width of an image button input to be set and queried.
2024-11-30 11:01:33 +01:00
Sam Atkins
8e3adbe082 LibWeb: Serialize text-decoration closer to spec
This gets us 32 WPT subtest passes that I'm aware of. :^)
2024-11-30 11:01:12 +01:00
Sam Atkins
c405c4bcf1 LibWeb: Allow calling property_initial_value() without a Realm
In this situation we're only able to get initial values that have
already been parsed. It's a little sketchy but doesn't seem to break
anything.
2024-11-30 11:01:12 +01:00
Sam Atkins
671d3e8a48 LibWeb/CSS: Sort text-decoration-line values in spec order
This wins us 49 WPT subtest passes! :^)
2024-11-30 11:01:12 +01:00
Sam Atkins
fa1e102f3c Tests: Import text-decoration WPT tests 2024-11-30 11:01:12 +01:00
Sam Atkins
9453c25925 LibWeb/CSS: Don't repeat CSS-wide keywords when serializing shorthands
Regardless of what the shorthand property is, if all its longhands are
the same CSS-wide keyword such as "initial" or "inherit", then it's the
same as the shorthand being that value.

This gets us 2 WPT subtest passes.
2024-11-30 11:01:12 +01:00
Sam Atkins
0c39d07b4d LibWeb/CSS: Serialize overflow correctly
When the x and y values are the same, we only want to serialize one.

This gets us 10 local WPT subtest passes. :^)
2024-11-30 11:01:12 +01:00
Sam Atkins
e4d55a6037 LibWeb/CSS: Use ShorthandStyleValue to serialize shorthands
This wins us 65 new WPT subtest passes! It also shows up that we're
doing the wrong thing in ShorthandStyleValue in places, notably with
the grid properties. However, having one place to fix instead of two
will make it easier to correct them. :^)

In order to be fully correct, we should use the algorithm here:
https://drafts.csswg.org/cssom/#serialize-a-css-value

However, it's quite hand-wavy. What we do have in the meantime is
`ShorthandStyleValue::to_string()`, where we special-case the
serialization rules for shorthands with a generic fallback that's
equivalent to what the previous `get_property_value()` code was doing.
2024-11-30 11:01:12 +01:00
Sam Atkins
bc17a3c2eb LibWeb: Correctly skip "decimal" in counter() serialization
It's not a keyword, it's a custom-ident. The simplest way of comparing
is by serializing it as a string.

This gets us 2 subtest passes.
2024-11-30 11:01:12 +01:00