Commit Graph

81 Commits

Author SHA1 Message Date
Ali Mohammad Pur
5e1499d104 Everywhere: Rename {Deprecated => Byte}String
This commit un-deprecates DeprecatedString, and repurposes it as a byte
string.
As the null state has already been removed, there are no other
particularly hairy blockers in repurposing this type as a byte string
(what it _really_ is).

This commit is auto-generated:
  $ xs=$(ack -l \bDeprecatedString\b\|deprecated_string AK Userland \
    Meta Ports Ladybird Tests Kernel)
  $ perl -pie 's/\bDeprecatedString\b/ByteString/g;
    s/deprecated_string/byte_string/g' $xs
  $ clang-format --style=file -i \
    $(git diff --name-only | grep \.cpp\|\.h)
  $ gn format $(git ls-files '*.gn' '*.gni')
2023-12-17 18:25:10 +03:30
Shannon Booth
04c094343f LibWeb+Meta: Add wrapper for the BufferSource/ArrayBufferView IDL types
These wrappers will make it much easier to do various operations on the
different ArrayBuffer-related classes in LibWeb compared to the current
solution, which is to just accept a Handle<Object> everywhere (and use
"any" in the *.idl files).

Co-Authored-By: Matthew Olsson <mattco@serenityos.org>
2023-11-24 08:43:35 +01:00
Andreas Kling
bfd354492e LibWeb: Put most LibWeb GC objects in type-specific heap blocks
With this change, we now have ~1200 CellAllocators across both LibJS and
LibWeb in a normal WebContent instance.

This gives us a minimum heap size of 4.7 MiB in the scenario where we
only have one cell allocated per type. Of course, in practice there will
be many more of each type, so the effective overhead is quite a bit
smaller than that in practice.

I left a few types unconverted to this mechanism because I got tired of
doing this. :^)
2023-11-19 22:00:48 +01:00
Andreas Kling
2b343c9508 LibWeb: Don't crash in XHR.response{,XML} for empty XML document
There were some unhandled paths due to the liberally typed XHR response
object. This patch flushes out those issues by using a tighter type set
in the Variant. (NonnullGCPtr<Object> instead of Value)
2023-10-07 10:19:18 +02:00
Bastiaan van der Plaat
222cc29c5c LibWeb: Add XMLHttpRequest Document response type 2023-09-14 22:58:42 +02:00
Aliaksandr Kalenik
bdd3a16b16 LibWeb: Make Fetch::Infrastructure::Body be GC allocated
Making the body GC-allocated allows us to avoid using `JS::Handle`
for `m_stream` in its members.
2023-08-19 15:12:00 +02:00
Andreas Kling
18c54d8d40 LibJS: Make Cell::initialize() return void
Stop worrying about tiny OOMs.

Work towards #20405
2023-08-08 07:39:11 +02:00
Timothy Flynn
c911781c21 Everywhere: Remove needless trailing semi-colons after functions
This is a new option in clang-format-16.
2023-07-08 10:32:56 +01:00
Kenneth Myhra
bf048da8cb LibWeb: Port fire_progress_event() + request_error_steps() to new String
This ports XHR's fire_progress_event() and request_error_steps() to new
FlyString.

Signature of fire_progress_event() parameter event_name  was changed
from 'String const&' to 'FlyString const&'.
2023-04-09 17:27:27 +02:00
Kenneth Myhra
1120011de4 LibWeb: Add FormData support to XHR
This adds FormData support to XHR so that it can post
multipart/form-data encoded data.
2023-04-05 09:43:52 +01:00
Luke Wilde
d036862f2b LibWeb: Refactor XHR (almost) exactly to the spec
This makes XHR now rely on Fetch, which allows it to correct send
Origin and Referer headers, CORS-preflight and filtering and many other
goodies.

The main thing that's missing is Streams, which means we can't properly
produce progress events or switch to the Loading ready state.

This also doesn't implement the Document responseType just yet.
2023-03-07 11:51:12 +00:00
Linus Groh
ad4b4046f4 LibWeb/Fetch: Propagate OOM errors from HeaderList::extract_mime_type() 2023-03-03 11:02:21 +00:00
Kenneth Myhra
f28b8431bf LibWeb: Make factory method of XHR::XMLHttpRequest fallible 2023-02-18 00:52:47 +01: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
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
Linus Groh
6e19ab2bbc AK+Everywhere: Rename String to DeprecatedString
We have a new, improved string type coming up in AK (OOM aware, no null
state), and while it's going to use UTF-8, the name UTF8String is a
mouthful - so let's free up the String name by renaming the existing
class.
Making the old one have an annoying name will hopefully also help with
quick adoption :^)
2022-12-06 08:54:33 +01:00
Linus Groh
93c0c73b9e LibWeb: Implement XMLHttpRequest.withCredentials 2022-11-14 10:00:11 +00:00
Linus Groh
bfa378660b LibWeb: Add a clarifying comment to XHR::m_response_object
Trying to change this to a JS::Object didn't quite work, so let's add
a helpful comment instead.
2022-11-14 10:00:11 +00:00
Linus Groh
fb57500394 LibWeb: Use HeaderList from Fetch for XHR author request headers 2022-11-14 10:00:11 +00:00
Linus Groh
c8184d85c1 LibWeb: Rename XHR::{m_request_headers => m_author_request_headers} 2022-11-14 10:00:11 +00:00
Linus Groh
6e53dd8767 LibWeb: Rename XHR::{m_url => m_request_url} 2022-11-14 10:00:11 +00:00
Linus Groh
29a8414a05 LibWeb: Rename XHR::{m_method => m_request_method} 2022-11-14 10:00:11 +00:00
Linus Groh
338ada66fa LibWeb: Add spec comments and links to XHR members 2022-11-14 10:00:11 +00:00
Linus Groh
04eaff3bb4 LibWeb: Rename XHR's ReadyState / m_ready_state to just State / m_state
This is what the spec calls it.
2022-11-14 10:00:11 +00:00
Kenneth Myhra
d11d26ef91 LibWeb: Implement support for DOM::Document in XHR::send()
Co-authored-by: Linus Groh <mail@linusgroh.de>
2022-11-11 00:39:12 -07:00
Luke Wilde
6c21c72492 LibWeb: Stub XMLHttpRequest.abort 2022-11-07 14:10:41 +01:00
Andreas Kling
455167008d LibWeb: Implement XMLHttpRequest.requestType setter according to spec 2022-10-24 18:06:55 +02:00
Andreas Kling
e448c74736 LibWeb: Protect XMLHttpRequest from GC in special circumstances
The XHR gives us a set of conditions where XHR objects must survive
garbage collection, even when there are no pointers to them on the heap.
This patch implements those conditions using the new cell
self-protection mechanism in LibJS.
2022-10-24 18:06:55 +02:00
Kenneth Myhra
ebd93c8d57 LibWeb: Revert support for DOM::Document in XHR::send()
This is a manual revert of commit: 7831e62

Let's revert this until we got nested union support in our IDL
generator/parser.
2022-10-20 17:57:52 +02:00
Kenneth Myhra
7831e62955 LibWeb: Add support for DOM::Document to XHR::send()
This patch adds support for posting a DOM::Document using XHR::send().
2022-10-16 02:06:29 +03:30
Andrew Kaster
4878a18ee7 LibWeb: Remove unecessary dependence on Window from Fetch, XHR, FileAPI
These classes only needed Window to get at its realm. Pass a realm
directly to construct Fetch, XMLHttpRequest and FileAPI classes.
2022-10-01 21:05:32 +01:00
Linus Groh
ad04d7ac9b LibWeb: Move ExceptionOr from DOM/ to WebIDL/
This is a concept fully defined in the Web IDL spec and doesn't belong
in the DOM directory/namespace - not even DOMException, despite the name
:^)
2022-09-25 19:13:31 +01:00
Linus Groh
4f73851afc LibWeb: Move CallbackType from Bindings/ to WebIDL/
Let's stop putting generic types and AOs from the Web IDL spec into
the Bindings namespace and directory in LibWeb, and instead follow our
usual naming rules of 'directory = namespace = spec name'. The IDL
namespace is already used by LibIDL, so Web::WebIDL seems like a good
choice.
2022-09-24 19:31:39 +01:00
Linus Groh
1ace80235b LibWeb: Move XMLHttpRequestBodyInit into Fetch
https://fetch.spec.whatwg.org/#typedefdef-xmlhttprequestbodyinit
2022-09-22 21:01:13 +01:00
Linus Groh
4270ede7c4 LibWeb: Remove WRAPPER_HACK() macro
We no longer access Bindings::FooWrapper anywhere for a Foo platform
object, so these can be removed :^)
2022-09-21 21:12:24 +01:00
Andreas Kling
3768743a0a LibWeb: Remove now-unused Bindings::Wrappable class 2022-09-06 00:27:09 +02:00
Andreas Kling
fe9c5395d4 LibWeb: Make URL, URLSearchParams & URLSearchParamsIterator GC-allocated 2022-09-06 00:27:09 +02:00
Andreas Kling
647ac1bdba LibWeb: Make Blob and File GC-allocated 2022-09-06 00:27:09 +02:00
Andreas Kling
8f4ea4e308 LibWeb: Don't use a JS::Handle for XHR response object 2022-09-06 00:27:09 +02:00
Andreas Kling
6f433c8656 LibWeb+LibJS: Make the EventTarget hierarchy (incl. DOM) GC-allocated
This is a monster patch that turns all EventTargets into GC-allocated
PlatformObjects. Their C++ wrapper classes are removed, and the LibJS
garbage collector is now responsible for their lifetimes.

There's a fair amount of hacks and band-aids in this patch, and we'll
have a lot of cleanup to do after this.
2022-09-06 00:27:09 +02:00
Andreas Kling
8cda70c892 LibWeb: Move event listeners, handlers and callbacks to the GC heap
This patch moves the following things to being GC-allocated:
- Bindings::CallbackType
- HTML::EventHandler
- DOM::IDLEventListener
- DOM::DOMEventListener
- DOM::NodeFilter

Note that we only use PlatformObject for things that might be exposed
to web content. Anything that is only used internally inherits directly
from JS::Cell instead, making them a bit more lightweight.
2022-09-06 00:27:09 +02:00
Linus Groh
40a70461a0 LibWeb: Replace GlobalObject with Realm in wrapper functions
Similar to create() in LibJS, wrap() et al. are on a low enough level to
warrant passing a Realm directly instead of relying on the current realm
from the VM, as a wrapper may need to be allocated while no JS is being
executed.
2022-08-23 13:58:30 +01:00
Kenneth Myhra
9a1c27a163 LibWeb: Implement BufferSource support for XHR::send() 2022-07-22 23:08:28 +01:00
Kenneth Myhra
e55bdd434a LibWeb: Add spec link for XMLHttpRequestBodyInit 2022-07-22 23:08:28 +01:00
Linus Groh
042dfc7284 LibWeb: Move extract_mime_type() from XMLHttpRequest to HeaderList
Except some minor tweaks, this is a direct copy of Luke's initial
implementation in XMLHttpRequest, now replacing the former.
2022-07-20 18:03:21 +01:00
Linus Groh
2726fc9c73 LibWeb: Move Fetch infra into the Web::Fetch::Infrastructure namespace
The Fetch spec unfortunately will cause a name clash between the Request
concept and the Request JS object - both cannot live in the Web::Fetch
namespace, and WrapperGenerator generally assumes `Web::<Name>` for
things living in the `<Name>/` subdirectory, so let's instead move infra
code into its own namespace - it already sits in a (sub-)subdirectory
anyway.
2022-07-19 00:27:35 +01:00
Kenneth Myhra
0a511e29d1 LibWeb: Add support for Blob to XHR::send() 2022-07-18 14:57:58 +01:00
Kenneth Myhra
9b3da5a142 LibWeb: Move extract_body() towards spec compliance 2022-07-18 14:57:58 +01:00
Linus Groh
6619483169 LibWeb: Update incorrect Fetch namespaces
Oops, this namespace rename wasn't committed yet.
2022-07-18 08:14:04 +01:00
Linus Groh
c501453425 LibWeb: Use Fetch's HeaderList::get_decode_and_split() in XMLHttpRequest 2022-07-18 08:10:54 +01:00