Commit Graph

422 Commits

Author SHA1 Message Date
Shannon Booth
f320406a4c LibWeb: Make Bindings::dom_exception_to_throw_completion public API
I found myself needing to call this method when attempting to implement
Blob::text and Blob::array_buffer. Turns out that the only caller
outside of the Detail namespace  already had a FIXME to make this a
public API - so let's do that.
2023-06-18 08:34:02 +02:00
Matthew Olsson
39d8c8d2a9 LibJS+LibWeb: Add missing visit calls in visit_edges implementations 2023-04-30 06:04:33 +02:00
Sam Atkins
6d93e03211 LibWeb+Browser+Ladybird: Use JS::SafeFunction for EventLoop callbacks
This automatically protects captured objects from being GC'd before the
callback runs.
2023-04-21 20:44:47 +01:00
Linus Groh
b84f8fb55b LibJS: Make intrinsics getters return NonnullGCPtr
Some of these are allocated upon initialization of the intrinsics, and
some lazily, but in neither case the getters actually return a nullptr.

This saves us a whole bunch of pointer dereferences (as NonnullGCPtr has
an `operator T&()`), and also has the interesting side effect of forcing
us to explicitly use the FunctionObject& overload of call(), as passing
a NonnullGCPtr is ambigous - it could implicitly be turned into a Value
_or_ a FunctionObject& (so we have to dereference manually).
2023-04-13 14:29:42 +02:00
Ben Wiederhake
560133a0c6 Everywhere: Remove unused DeprecatedString includes 2023-04-09 22:00:54 +02:00
Kenneth Myhra
fb96966f1e LibWeb: Add WebGL::EventNames 2023-04-09 17:27:27 +02:00
Kenneth Myhra
4d87072201 LibWeb: Port {HTML,UIEvents,XHR}::EventNames to new String 2023-04-06 23:49:08 +02:00
Luke Wilde
034aaf3f51 LibWeb: Introduce CustomElementRegistry and creating custom elements
The main missing feature here is form associated custom elements.
2023-04-06 11:36:56 +02:00
Luke Wilde
89ebef9730 LibWeb: Add a list of the entry names in the PerformanceTiming interface
Required for the PerformanceMark constructor, which doesn't allow any
mark names that have the same name as an attribute in the
PerformanceTiming interface in a Window context.
2023-03-23 21:00:43 +00:00
Luke Wilde
31b507afbf LibWeb: Introduce Performance Timeline and its Performance functions 2023-03-23 21:00:43 +00:00
Timothy Flynn
db2ba5f1d9 LibWeb: Initialize static web strings during main-thread VM creation
These are currently initialized in a [[gnu::constructor]], which has a
weird initialization order. These constructors are invoked before main()
and, incidentally, before any user-defined default constructors of the
static strings they are initializing.

This will become an issue when these strings are ported to FlyString,
which has a user-defined default constructor. In that scenario, when the
FlyString constructor is executed after the [[gnu::constructor]], the
strings will be "reset" to the empty string.

Instead of relying on a non-standard compiler extension here, let's just
initialize these strings explicitly during main-thread VM creation, as
this now happens in WebContent's main().
2023-03-18 19:50:45 +01:00
Timothy Flynn
6e1b5b541a LibWeb: Move initialization of the MainThreadVM to WebContent's main()
It is a fallible operation, so this lets us abort early if it fails.
2023-03-17 16:39:08 +00:00
Timothy Flynn
13dfadba79 LibJS: Propagate errors from VM creation 2023-03-17 16:39:08 +00:00
Timothy Flynn
2d45e1fca5 LibWeb: Port the CSS namespace to IDL 2023-03-15 12:48:25 -04:00
Timothy Flynn
020c2b59c4 LibWeb: Support generating IDL namespaces
These are similar to prototypes and constructors in that they will now
be lazily instantiated when they are first requested.
2023-03-15 12:48:25 -04:00
Matthew Olsson
7c0c1c8f49 LibJS+LibWeb: Wrap raw JS::Cell*/& fields in GCPtr/NonnullGCPtr 2023-03-15 08:48:49 +01:00
Linus Groh
d4d49e00a2 LibWeb/Bindings: Remove now unused REPLACEABLE_PROPERTY_SETTER() macro 2023-03-07 23:33:34 +00:00
Linus Groh
5cc6b1c4db LibWeb/HTML: Port Window.fetch() to IDL 2023-03-07 23:33:34 +00:00
Linus Groh
de83f5422d LibWeb: Generate Window{Constructor,Prototype} from IDL
The Window object is massive, so let's do the conversion to IDL step
by step. First up: getting rid of the manual constructor and prototype
definitions, which can be generated from an empty `interface Window`.
2023-03-07 23:33:34 +00:00
Luke Wilde
9aca54091a LibWeb: Remove the dummy execution context 2023-03-07 11:51:12 +00:00
Luke Wilde
f7ff1fd985 LibWeb: Remove CSS::Parser::ParsingContext's default constructor
This relied on pulling the current realm from the main thread VM, which
requires an execution context to be on the VM's stack. This heavily
relied on the dummy execution context that is always on the stack, for
example, when parsing the UA style sheets where no JavaScript is
running.
2023-03-07 11:51:12 +00:00
Andreas Kling
689ca370d4 Everywhere: Remove NonnullRefPtr.h includes 2023-03-06 23:46:35 +01:00
Matthew Olsson
c0b2fa74ac LibWeb: Fix a few const-ness issues 2023-03-06 13:05:43 +00:00
Kenneth Myhra
dd2d029952 LibWeb: Port PromiseRejectionEvent to new String 2023-03-05 18:25:59 +00:00
Linus Groh
11b40dbcf5 LibWeb/WebIDL: Store SimpleException message as a String{,View} variant 2023-03-03 19:50:36 +00:00
Linus Groh
7f9ddcf420 LibWeb/Fetch: Port JS interfaces to new String
Since BodyInit and Headers are tightly coupled to both Request and
Response, I chose to do all of them at once instead of introducing a
bunch of temporary conversion glue code.
2023-03-03 09:25:34 +00:00
Linus Groh
9afcbdf452 LibWeb: Update generated code in Bindings/FetchMethod.cpp
Also update the incomplete and slightly incorrect dummy interface code
snippet I used to generate this.
2023-03-03 09:25:34 +00:00
Luke Wilde
54f58e2662 LibWeb: Restore proper functionality of legacy platform objects
With the GC heap conversion, the functionality of legacy platform
objects was broken. This is because the generated implementation of one
of them was used for all of them, removing functionality such as
deletion.

This re-adds all functionality, where questions such as "does the
object support indexed properties?" is instead answered by virtual
functions instead of by the IDL generator checking the presence of
certain keywords/attributes.
2023-02-28 12:36:14 +01:00
Kenneth Myhra
ff92324fa5 LibWeb: Make factory method of DOM::ElementFactory fallible 2023-02-22 09:55:33 +01:00
Kenneth Myhra
3941e64fde LibWeb: Make factory method of HTML::PromiseRejectionEvent fallible 2023-02-18 00:52:47 +01:00
Timothy Flynn
88814acbd3 LibJS+Everywhere: Convert JS::Error to String
This includes an Error::create overload to create an Error from a UTF-8
StringView. If creating a String from that view fails, the factory will
return an OOM InternalError instead. VM::throw_completion can also make
use of this overload via its perfect forwarding.
2023-02-17 09:14:23 -05:00
Timothy Flynn
527edb55ad LibWeb: Convert usages of Value::TDSWOSE to Value::TSWOSE 2023-02-16 14:32:22 +01:00
Timothy Flynn
b245300ba1 LibJS+Everywhere: Deprecate Value::to_string_without_side_effects 2023-02-16 14:32:22 +01:00
Sam Atkins
85f3de6331 LibWeb: Port CSS/Serialize.{h,cpp} to new Strings, and propagate errors 2023-02-15 12:48:26 -05:00
Timothy Flynn
b75b7f0c0d LibJS+Everywhere: Propagate Cell::initialize errors from Heap::allocate
Callers that are already in a fallible context will now TRY to allocate
cells. Callers in infallible contexts get a FIXME.
2023-01-29 00:02:45 +00:00
Timothy Flynn
2692db8699 LibJS+Everywhere: Allow Cell::initialize overrides to throw OOM errors
Note that as of this commit, there aren't any such throwers, and the
call site in Heap::allocate will drop exceptions on the floor. This
commit only serves to change the declaration of the overrides, make sure
they return an empty value, and to propagate OOM errors frm their base
initialize invocations.
2023-01-29 00:02:45 +00:00
Linus Groh
afc055c088 LibWeb: Convert the Location object to IDL
This includes:

- Moving it from Bindings/ to HTML/
- Renaming it from LocationObject to Location
- Removing the manual definitions of the constructor and prototype
- Removing special handling of the Location interface from the bindings
  generator
- Converting the JS_DEFINE_NATIVE_FUNCTIONs to regular functions
  returning DeprecatedString instead of PrimitiveString
- Adding missing (no-op) setters for the various attributes, which are
  expected to exist by the bindings generator
2023-01-18 17:36:39 -05:00
Timothy Flynn
afeb7273cc LibJS+Everywhere: Rename Value::to_string to to_deprecated_string 2023-01-15 01:00:20 +00:00
Timothy Flynn
6e93d89ee3 LibWeb: Generate exposed Window/Worker interfaces as lazy objects
We now lazily create these instances on-demand rather than all at once
when a Window/Worker object is created.
2023-01-10 16:08:14 +01:00
Timothy Flynn
3deb8e322f LibWeb: Remove Intrinsics::cached_web_prototype
It's now unused, and won't be safe to use once Web constructors and
prototypes are lazily created.
2023-01-10 16:08:14 +01:00
Timothy Flynn
c2939d58c7 LibWeb: Convert uses of cached_web_prototype to ensure_web_prototype
Once the construction of these objects is lazy, we cannot assume they
exist.
2023-01-10 16:08:14 +01:00
Timothy Flynn
af75493883 LibWeb: Move passing of Web object prototypes out of constructors 2023-01-10 16:08:14 +01:00
Timothy Flynn
834202aeb9 LibWeb: Move setting of Web object prototypes to initialize()
This needs to happen before prototype/constructor intitialization can be
made lazy. Otherwise, GC could run during the C++ constructor and try to
collect the object currently being created.
2023-01-10 16:08:14 +01:00
Timothy Flynn
7bd8fd000f LibWeb: Generate dedicated methods to create Web constructors/prototypes
Currently, for each exposed interface, we generate one massive function
to create every Web constructor and prototype. In an effort to lazily
create these instead, this first step is to extract the creation of each
of these into its own method.

First, this generates a forwarding header for all IDL types. This is to
allow callers to remain unchanged without forcing them to include the
(very heavy) generated IDL headers. This header is included by LibWeb's
forwarding header.

Next, this defines a base template method on Web::Bindings::Intrinsics
to create a prototype/constructor pair. Specializations of this template
are now generated in a new .cpp file, IntrinsicDefinitions.cpp. The base
Intrinsics class is updated to use this new method, and will continue to
cache the result.

Last, some WebAssembly classes are updated to use this new mechanism.
They were using some ad hoc cache keys that are now in line with the
generated specializations.

That one massive function is still used to invoke these specializations,
so they are not lazy as of this commit.
2023-01-10 16:08:14 +01:00
Timothy Flynn
f3db548a3d AK+Everywhere: Rename FlyString to DeprecatedFlyString
DeprecatedFlyString relies heavily on DeprecatedString's StringImpl, so
let's rename it to A) match the name of DeprecatedString, B) write a new
FlyString class that is tied to String.
2023-01-09 23:00:24 +00:00
Ben Wiederhake
c2a900b853 Everywhere: Remove unused includes of AK/StdLibExtras.h
These instances were detected by searching for files that include
AK/StdLibExtras.h, but don't match the regex:

\\b(abs|AK_REPLACED_STD_NAMESPACE|array_size|ceil_div|clamp|exchange|for
ward|is_constant_evaluated|is_power_of_two|max|min|mix|move|_RawPtr|RawP
tr|round_up_to_power_of_two|swap|to_underlying)\\b

(Without the linebreaks.)

This regex is pessimistic, so there might be more files that don't
actually use any "extra stdlib" functions.

In theory, one might use LibCPP to detect things like this
automatically, but let's do this one step after another.
2023-01-02 20:27:20 -05:00
Linus Groh
6ae79a84df LibJS: Convert Object::construct() to NonnullGCPtr 2022-12-15 06:56:37 -05:00
Linus Groh
22089436ed LibJS: Convert Heap::allocate{,_without_realm}() to NonnullGCPtr 2022-12-15 06:56:37 -05:00
Andreas Kling
4abdb68655 LibJS: Remove Object(Object& prototype) footgun
This constructor was easily confused with a copy constructor, and it was
possible to accidentally copy-construct Objects in at least one way that
we dicovered (via generic ThrowCompletionOr construction).

This patch adds a mandatory ConstructWithPrototypeTag parameter to the
constructor to disambiguate it.
2022-12-14 15:11:57 +01:00
Linus Groh
ddc6e139a6 LibJS: Convert Object::create() to NonnullGCPtr 2022-12-14 09:59:45 +00:00