mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-01 13:49:16 +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
|
@ -19,9 +19,9 @@
|
|||
|
||||
namespace Web::Clipboard {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(Clipboard);
|
||||
GC_DEFINE_ALLOCATOR(Clipboard);
|
||||
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<Clipboard>> Clipboard::construct_impl(JS::Realm& realm)
|
||||
WebIDL::ExceptionOr<GC::Ref<Clipboard>> Clipboard::construct_impl(JS::Realm& realm)
|
||||
{
|
||||
return realm.create<Clipboard>(realm);
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ static String os_specific_well_known_format(StringView mime_type_string)
|
|||
}
|
||||
|
||||
// https://w3c.github.io/clipboard-apis/#write-blobs-and-option-to-the-clipboard
|
||||
static void write_blobs_and_option_to_clipboard(JS::Realm& realm, ReadonlySpan<JS::NonnullGCPtr<FileAPI::Blob>> items, String presentation_style)
|
||||
static void write_blobs_and_option_to_clipboard(JS::Realm& realm, ReadonlySpan<GC::Ref<FileAPI::Blob>> items, String presentation_style)
|
||||
{
|
||||
auto& window = verify_cast<HTML::Window>(realm.global_object());
|
||||
|
||||
|
@ -141,7 +141,7 @@ static bool check_clipboard_write_permission(JS::Realm& realm)
|
|||
}
|
||||
|
||||
// https://w3c.github.io/clipboard-apis/#dom-clipboard-writetext
|
||||
JS::NonnullGCPtr<WebIDL::Promise> Clipboard::write_text(String data)
|
||||
GC::Ref<WebIDL::Promise> Clipboard::write_text(String data)
|
||||
{
|
||||
// 1. Let realm be this's relevant realm.
|
||||
auto& realm = HTML::relevant_realm(*this);
|
||||
|
@ -150,7 +150,7 @@ JS::NonnullGCPtr<WebIDL::Promise> Clipboard::write_text(String data)
|
|||
auto promise = WebIDL::create_promise(realm);
|
||||
|
||||
// 3. Run the following steps in parallel:
|
||||
Platform::EventLoopPlugin::the().deferred_invoke(JS::create_heap_function(realm.heap(), [&realm, promise, data = move(data)]() mutable {
|
||||
Platform::EventLoopPlugin::the().deferred_invoke(GC::create_function(realm.heap(), [&realm, promise, data = move(data)]() mutable {
|
||||
// 1. Let r be the result of running check clipboard write permission.
|
||||
auto result = check_clipboard_write_permission(realm);
|
||||
|
||||
|
@ -158,7 +158,7 @@ JS::NonnullGCPtr<WebIDL::Promise> Clipboard::write_text(String data)
|
|||
if (!result) {
|
||||
// 1. Queue a global task on the permission task source, given realm’s global object, to reject p with
|
||||
// "NotAllowedError" DOMException in realm.
|
||||
queue_global_task(HTML::Task::Source::Permissions, realm.global_object(), JS::create_heap_function(realm.heap(), [&realm, promise]() mutable {
|
||||
queue_global_task(HTML::Task::Source::Permissions, realm.global_object(), GC::create_function(realm.heap(), [&realm, promise]() mutable {
|
||||
HTML::TemporaryExecutionContext execution_context { realm };
|
||||
WebIDL::reject_promise(realm, promise, WebIDL::NotAllowedError::create(realm, "Clipboard writing is only allowed through user activation"_string));
|
||||
}));
|
||||
|
@ -168,9 +168,9 @@ JS::NonnullGCPtr<WebIDL::Promise> Clipboard::write_text(String data)
|
|||
}
|
||||
|
||||
// 1. Queue a global task on the clipboard task source, given realm’s global object, to perform the below steps:
|
||||
queue_global_task(HTML::Task::Source::Clipboard, realm.global_object(), JS::create_heap_function(realm.heap(), [&realm, promise, data = move(data)]() mutable {
|
||||
queue_global_task(HTML::Task::Source::Clipboard, realm.global_object(), GC::create_function(realm.heap(), [&realm, promise, data = move(data)]() mutable {
|
||||
// 1. Let itemList be an empty sequence<Blob>.
|
||||
Vector<JS::NonnullGCPtr<FileAPI::Blob>> item_list;
|
||||
Vector<GC::Ref<FileAPI::Blob>> item_list;
|
||||
|
||||
// 2. Let textBlob be a new Blob created with: type attribute set to "text/plain;charset=utf-8", and its
|
||||
// underlying byte sequence set to the UTF-8 encoding of data.
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
#pragma once
|
||||
|
||||
#include <AK/String.h>
|
||||
#include <LibGC/Ptr.h>
|
||||
#include <LibJS/Forward.h>
|
||||
#include <LibJS/Heap/GCPtr.h>
|
||||
#include <LibWeb/DOM/EventTarget.h>
|
||||
#include <LibWeb/Forward.h>
|
||||
#include <LibWeb/WebIDL/ExceptionOr.h>
|
||||
|
@ -17,13 +17,13 @@ namespace Web::Clipboard {
|
|||
|
||||
class Clipboard final : public DOM::EventTarget {
|
||||
WEB_PLATFORM_OBJECT(Clipboard, DOM::EventTarget);
|
||||
JS_DECLARE_ALLOCATOR(Clipboard);
|
||||
GC_DECLARE_ALLOCATOR(Clipboard);
|
||||
|
||||
public:
|
||||
static WebIDL::ExceptionOr<JS::NonnullGCPtr<Clipboard>> construct_impl(JS::Realm&);
|
||||
static WebIDL::ExceptionOr<GC::Ref<Clipboard>> construct_impl(JS::Realm&);
|
||||
virtual ~Clipboard() override;
|
||||
|
||||
JS::NonnullGCPtr<WebIDL::Promise> write_text(String);
|
||||
GC::Ref<WebIDL::Promise> write_text(String);
|
||||
|
||||
private:
|
||||
Clipboard(JS::Realm&);
|
||||
|
|
|
@ -11,9 +11,9 @@
|
|||
|
||||
namespace Web::Clipboard {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(ClipboardEvent);
|
||||
GC_DEFINE_ALLOCATOR(ClipboardEvent);
|
||||
|
||||
JS::NonnullGCPtr<ClipboardEvent> ClipboardEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, ClipboardEventInit const& event_init)
|
||||
GC::Ref<ClipboardEvent> ClipboardEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, ClipboardEventInit const& event_init)
|
||||
{
|
||||
return realm.create<ClipboardEvent>(realm, event_name, event_init);
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <LibJS/Heap/GCPtr.h>
|
||||
#include <LibGC/Ptr.h>
|
||||
#include <LibWeb/DOM/Event.h>
|
||||
#include <LibWeb/Forward.h>
|
||||
#include <LibWeb/HTML/DataTransfer.h>
|
||||
|
@ -14,20 +14,20 @@
|
|||
namespace Web::Clipboard {
|
||||
|
||||
struct ClipboardEventInit : public DOM::EventInit {
|
||||
JS::GCPtr<HTML::DataTransfer> clipboard_data;
|
||||
GC::Ptr<HTML::DataTransfer> clipboard_data;
|
||||
};
|
||||
|
||||
// https://w3c.github.io/clipboard-apis/#clipboardevent
|
||||
class ClipboardEvent : public DOM::Event {
|
||||
WEB_PLATFORM_OBJECT(ClipboardEvent, DOM::Event);
|
||||
JS_DECLARE_ALLOCATOR(ClipboardEvent);
|
||||
GC_DECLARE_ALLOCATOR(ClipboardEvent);
|
||||
|
||||
public:
|
||||
static JS::NonnullGCPtr<ClipboardEvent> construct_impl(JS::Realm&, FlyString const& event_name, ClipboardEventInit const& event_init);
|
||||
static GC::Ref<ClipboardEvent> construct_impl(JS::Realm&, FlyString const& event_name, ClipboardEventInit const& event_init);
|
||||
|
||||
virtual ~ClipboardEvent() override;
|
||||
|
||||
JS::GCPtr<HTML::DataTransfer> clipboard_data() { return m_clipboard_data; }
|
||||
GC::Ptr<HTML::DataTransfer> clipboard_data() { return m_clipboard_data; }
|
||||
|
||||
private:
|
||||
ClipboardEvent(JS::Realm&, FlyString const& event_name, ClipboardEventInit const& event_init);
|
||||
|
@ -35,7 +35,7 @@ private:
|
|||
virtual void initialize(JS::Realm&) override;
|
||||
virtual void visit_edges(JS::Cell::Visitor&) override;
|
||||
|
||||
JS::GCPtr<HTML::DataTransfer> m_clipboard_data;
|
||||
GC::Ptr<HTML::DataTransfer> m_clipboard_data;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue