mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-28 07:18: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
Libraries/LibWeb/HTML
|
@ -38,7 +38,7 @@
|
|||
|
||||
namespace Web::HTML {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(HTMLImageElement);
|
||||
GC_DEFINE_ALLOCATOR(HTMLImageElement);
|
||||
|
||||
HTMLImageElement::HTMLImageElement(DOM::Document& document, DOM::QualifiedName qualified_name)
|
||||
: HTMLElement(document, move(qualified_name))
|
||||
|
@ -112,7 +112,7 @@ void HTMLImageElement::form_associated_element_attribute_changed(FlyString const
|
|||
}
|
||||
}
|
||||
|
||||
JS::GCPtr<Layout::Node> HTMLImageElement::create_layout_node(CSS::StyleProperties style)
|
||||
GC::Ptr<Layout::Node> HTMLImageElement::create_layout_node(CSS::StyleProperties style)
|
||||
{
|
||||
return heap().allocate<Layout::ImageBox>(document(), *this, move(style), *this);
|
||||
}
|
||||
|
@ -284,7 +284,7 @@ String HTMLImageElement::current_src() const
|
|||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/embedded-content.html#dom-img-decode
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<WebIDL::Promise>> HTMLImageElement::decode() const
|
||||
WebIDL::ExceptionOr<GC::Ref<WebIDL::Promise>> HTMLImageElement::decode() const
|
||||
{
|
||||
auto& realm = this->realm();
|
||||
|
||||
|
@ -292,7 +292,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<WebIDL::Promise>> HTMLImageElement::decode(
|
|||
auto promise = WebIDL::create_promise(realm);
|
||||
|
||||
// 2. Queue a microtask to perform the following steps:
|
||||
queue_a_microtask(&document(), JS::create_heap_function(realm.heap(), [this, promise, &realm]() mutable {
|
||||
queue_a_microtask(&document(), GC::create_function(realm.heap(), [this, promise, &realm]() mutable {
|
||||
auto reject_if_document_not_fully_active = [this, promise, &realm]() -> bool {
|
||||
if (this->document().is_fully_active())
|
||||
return false;
|
||||
|
@ -325,8 +325,8 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<WebIDL::Promise>> HTMLImageElement::decode(
|
|||
return;
|
||||
|
||||
// 2.2 Otherwise, in parallel wait for one of the following cases to occur, and perform the corresponding actions:
|
||||
Platform::EventLoopPlugin::the().deferred_invoke(JS::create_heap_function(heap(), [this, promise, &realm, reject_if_document_not_fully_active, reject_if_current_request_state_broken] {
|
||||
Platform::EventLoopPlugin::the().spin_until(JS::create_heap_function(heap(), [&] {
|
||||
Platform::EventLoopPlugin::the().deferred_invoke(GC::create_function(heap(), [this, promise, &realm, reject_if_document_not_fully_active, reject_if_current_request_state_broken] {
|
||||
Platform::EventLoopPlugin::the().spin_until(GC::create_function(heap(), [&] {
|
||||
auto state = this->current_request().state();
|
||||
|
||||
return !this->document().is_fully_active() || state == ImageRequest::State::Broken || state == ImageRequest::State::CompletelyAvailable;
|
||||
|
@ -393,7 +393,7 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
void enqueue(JS::Handle<JS::HeapFunction<void()>> callback)
|
||||
void enqueue(GC::Root<GC::Function<void()>> callback)
|
||||
{
|
||||
// NOTE: We don't want to flush the queue on every image load, since that would be slow.
|
||||
// However, we don't want to keep growing the batch forever either.
|
||||
|
@ -413,7 +413,7 @@ private:
|
|||
}
|
||||
|
||||
NonnullRefPtr<Core::Timer> m_timer;
|
||||
Vector<JS::Handle<JS::HeapFunction<void()>>> m_queue;
|
||||
Vector<GC::Root<GC::Function<void()>>> m_queue;
|
||||
};
|
||||
|
||||
static BatchingDispatcher& batching_dispatcher()
|
||||
|
@ -519,7 +519,7 @@ ErrorOr<void> HTMLImageElement::update_the_image_data(bool restart_animations, b
|
|||
}
|
||||
after_step_7:
|
||||
// 8. Queue a microtask to perform the rest of this algorithm, allowing the task that invoked this algorithm to continue.
|
||||
queue_a_microtask(&document(), JS::create_heap_function(this->heap(), [this, restart_animations, maybe_omit_events, previous_url]() mutable {
|
||||
queue_a_microtask(&document(), GC::create_function(this->heap(), [this, restart_animations, maybe_omit_events, previous_url]() mutable {
|
||||
// FIXME: 9. If another instance of this algorithm for this img element was started after this instance
|
||||
// (even if it aborted and is no longer running), then return.
|
||||
|
||||
|
@ -674,11 +674,11 @@ after_step_7:
|
|||
return {};
|
||||
}
|
||||
|
||||
void HTMLImageElement::add_callbacks_to_image_request(JS::NonnullGCPtr<ImageRequest> image_request, bool maybe_omit_events, URL::URL const& url_string, URL::URL const& previous_url)
|
||||
void HTMLImageElement::add_callbacks_to_image_request(GC::Ref<ImageRequest> image_request, bool maybe_omit_events, URL::URL const& url_string, URL::URL const& previous_url)
|
||||
{
|
||||
image_request->add_callbacks(
|
||||
[this, image_request, maybe_omit_events, url_string, previous_url]() {
|
||||
batching_dispatcher().enqueue(JS::create_heap_function(realm().heap(), [this, image_request, maybe_omit_events, url_string, previous_url] {
|
||||
batching_dispatcher().enqueue(GC::create_function(realm().heap(), [this, image_request, maybe_omit_events, url_string, previous_url] {
|
||||
VERIFY(image_request->shared_resource_request());
|
||||
auto image_data = image_request->shared_resource_request()->image_data();
|
||||
image_request->set_image_data(image_data);
|
||||
|
@ -748,7 +748,7 @@ void HTMLImageElement::did_set_viewport_rect(CSSPixelRect const& viewport_rect)
|
|||
if (viewport_rect.size() == m_last_seen_viewport_size)
|
||||
return;
|
||||
m_last_seen_viewport_size = viewport_rect.size();
|
||||
batching_dispatcher().enqueue(JS::create_heap_function(realm().heap(), [this] {
|
||||
batching_dispatcher().enqueue(GC::create_function(realm().heap(), [this] {
|
||||
react_to_changes_in_the_environment();
|
||||
}));
|
||||
}
|
||||
|
@ -818,7 +818,7 @@ void HTMLImageElement::react_to_changes_in_the_environment()
|
|||
|
||||
// FIXME: 13. End the synchronous section, continuing the remaining steps in parallel.
|
||||
|
||||
auto step_15 = [this](String const& selected_source, JS::NonnullGCPtr<ImageRequest> image_request, ListOfAvailableImages::Key const& key, JS::NonnullGCPtr<DecodedImageData> image_data) {
|
||||
auto step_15 = [this](String const& selected_source, GC::Ref<ImageRequest> image_request, ListOfAvailableImages::Key const& key, GC::Ref<DecodedImageData> image_data) {
|
||||
// 15. Queue an element task on the DOM manipulation task source given the img element and the following steps:
|
||||
queue_an_element_task(HTML::Task::Source::DOMManipulation, [this, selected_source, image_request, key, image_data] {
|
||||
// 1. FIXME: If the img element has experienced relevant mutations since this algorithm started, then let pending request be null and abort these steps.
|
||||
|
@ -886,7 +886,7 @@ void HTMLImageElement::react_to_changes_in_the_environment()
|
|||
|
||||
// then let pending request be null and abort these steps.
|
||||
|
||||
batching_dispatcher().enqueue(JS::create_heap_function(realm().heap(), [step_15, selected_source = move(selected_source), image_request, key] {
|
||||
batching_dispatcher().enqueue(GC::create_function(realm().heap(), [step_15, selected_source = move(selected_source), image_request, key] {
|
||||
// 7. Otherwise, response's unsafe response is image request's image data. It can be either CORS-same-origin
|
||||
// or CORS-cross-origin; this affects the image's interaction with other APIs (e.g., when used on a canvas).
|
||||
VERIFY(image_request->shared_resource_request());
|
||||
|
@ -979,7 +979,7 @@ static void update_the_source_set(DOM::Element& element)
|
|||
TODO();
|
||||
|
||||
// 2. Let elements be « el ».
|
||||
JS::MarkedVector<DOM::Element*> elements(element.heap());
|
||||
GC::MarkedVector<DOM::Element*> elements(element.heap());
|
||||
elements.append(&element);
|
||||
|
||||
// 3. If el is an img element whose parent node is a picture element,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue