mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-12 06:02:51 +00:00
LibGC+Everywhere: Factor out a LibGC from LibJS
Resulting in a massive rename across almost everywhere! Alongside the namespace change, we now have the following names: * JS::NonnullGCPtr -> GC::Ref * JS::GCPtr -> GC::Ptr * JS::HeapFunction -> GC::Function * JS::CellImpl -> GC::Cell * JS::Handle -> GC::Root
This commit is contained in:
parent
ce23efc5f6
commit
f87041bf3a
Notes:
github-actions[bot]
2024-11-15 13:50:17 +00:00
Author: https://github.com/shannonbooth
Commit: f87041bf3a
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2345
1722 changed files with 9939 additions and 9906 deletions
|
@ -31,10 +31,10 @@
|
|||
|
||||
namespace Web::WebSockets {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(WebSocket);
|
||||
GC_DEFINE_ALLOCATOR(WebSocket);
|
||||
|
||||
// https://websockets.spec.whatwg.org/#dom-websocket-websocket
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<WebSocket>> WebSocket::construct_impl(JS::Realm& realm, String const& url, Optional<Variant<String, Vector<String>>> const& protocols)
|
||||
WebIDL::ExceptionOr<GC::Ref<WebSocket>> WebSocket::construct_impl(JS::Realm& realm, String const& url, Optional<Variant<String, Vector<String>>> const& protocols)
|
||||
{
|
||||
auto& vm = realm.vm();
|
||||
|
||||
|
@ -214,7 +214,7 @@ WebIDL::ExceptionOr<void> WebSocket::close(Optional<u16> code, Optional<String>
|
|||
}
|
||||
|
||||
// https://websockets.spec.whatwg.org/#dom-websocket-send
|
||||
WebIDL::ExceptionOr<void> WebSocket::send(Variant<JS::Handle<WebIDL::BufferSource>, JS::Handle<FileAPI::Blob>, String> const& data)
|
||||
WebIDL::ExceptionOr<void> WebSocket::send(Variant<GC::Root<WebIDL::BufferSource>, GC::Root<FileAPI::Blob>, String> const& data)
|
||||
{
|
||||
auto state = ready_state();
|
||||
if (state == Requests::WebSocket::ReadyState::Connecting)
|
||||
|
@ -226,14 +226,14 @@ WebIDL::ExceptionOr<void> WebSocket::send(Variant<JS::Handle<WebIDL::BufferSourc
|
|||
m_websocket->send(string);
|
||||
return {};
|
||||
},
|
||||
[this](JS::Handle<WebIDL::BufferSource> const& buffer_source) -> ErrorOr<void> {
|
||||
[this](GC::Root<WebIDL::BufferSource> const& buffer_source) -> ErrorOr<void> {
|
||||
// FIXME: While the spec doesn't say to do this, it's not observable except from potentially throwing OOM.
|
||||
// Can we avoid this copy?
|
||||
auto data_buffer = TRY(WebIDL::get_buffer_source_copy(*buffer_source->raw_object()));
|
||||
m_websocket->send(data_buffer, false);
|
||||
return {};
|
||||
},
|
||||
[this](JS::Handle<FileAPI::Blob> const& blob) -> ErrorOr<void> {
|
||||
[this](GC::Root<FileAPI::Blob> const& blob) -> ErrorOr<void> {
|
||||
auto byte_buffer = TRY(ByteBuffer::copy(blob->raw_bytes()));
|
||||
m_websocket->send(byte_buffer, false);
|
||||
return {};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue