mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-21 16:58:58 +00:00
LibWeb: Make EventLoopPlugin::deferred_invoke take a HeapFunction
This commit is contained in:
parent
7487a782db
commit
29cea5bd24
Notes:
github-actions[bot]
2024-10-30 19:57:08 +00:00
Author: https://github.com/shannonbooth
Commit: 29cea5bd24
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2062
Reviewed-by: https://github.com/kalenikaliaksandr ✅
21 changed files with 75 additions and 73 deletions
|
@ -297,7 +297,7 @@ WebIDL::ExceptionOr<void> HTMLCanvasElement::to_blob(JS::NonnullGCPtr<WebIDL::Ca
|
|||
bitmap_result = TRY_OR_THROW_OOM(vm(), m_bitmap->clone());
|
||||
|
||||
// 4. Run these steps in parallel:
|
||||
Platform::EventLoopPlugin::the().deferred_invoke([this, callback, bitmap_result, type, quality] {
|
||||
Platform::EventLoopPlugin::the().deferred_invoke(JS::create_heap_function(heap(), [this, callback, bitmap_result, type, quality] {
|
||||
// 1. If result is non-null, then set result to a serialization of result as a file with type and quality if given.
|
||||
Optional<SerializeBitmapResult> file_result;
|
||||
if (bitmap_result) {
|
||||
|
@ -320,7 +320,7 @@ WebIDL::ExceptionOr<void> HTMLCanvasElement::to_blob(JS::NonnullGCPtr<WebIDL::Ca
|
|||
if (maybe_error.is_throw_completion())
|
||||
report_exception(maybe_error.throw_completion(), realm());
|
||||
});
|
||||
});
|
||||
}));
|
||||
return {};
|
||||
}
|
||||
|
||||
|
|
|
@ -323,7 +323,7 @@ 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([this, promise, &realm, reject_if_document_not_fully_active, reject_if_current_request_state_broken] {
|
||||
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(), [&] {
|
||||
auto state = this->current_request().state();
|
||||
|
||||
|
@ -357,7 +357,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<WebIDL::Promise>> HTMLImageElement::decode(
|
|||
HTML::TemporaryExecutionContext context(HTML::relevant_settings_object(*this));
|
||||
WebIDL::resolve_promise(realm, promise, JS::js_undefined());
|
||||
}
|
||||
});
|
||||
}));
|
||||
}));
|
||||
|
||||
return promise;
|
||||
|
|
|
@ -1401,7 +1401,7 @@ WebIDL::ExceptionOr<void> Navigable::navigate(NavigateParams params)
|
|||
}
|
||||
|
||||
// 20. In parallel, run these steps:
|
||||
Platform::EventLoopPlugin::the().deferred_invoke([this, source_snapshot_params, target_snapshot_params, csp_navigation_type, document_resource, url, navigation_id, referrer_policy, initiator_origin_snapshot, response, history_handling, initiator_base_url_snapshot] {
|
||||
Platform::EventLoopPlugin::the().deferred_invoke(JS::create_heap_function(heap(), [this, source_snapshot_params, target_snapshot_params, csp_navigation_type, document_resource, url, navigation_id, referrer_policy, initiator_origin_snapshot, response, history_handling, initiator_base_url_snapshot] {
|
||||
// AD-HOC: Not in the spec but subsequent steps will fail if the navigable doesn't have an active window.
|
||||
if (!active_window()) {
|
||||
set_delaying_load_events(false);
|
||||
|
@ -1489,7 +1489,7 @@ WebIDL::ExceptionOr<void> Navigable::navigate(NavigateParams params)
|
|||
finalize_a_cross_document_navigation(*this, to_history_handling_behavior(history_handling), history_entry);
|
||||
}));
|
||||
})).release_value_but_fixme_should_propagate_errors();
|
||||
});
|
||||
}));
|
||||
|
||||
return {};
|
||||
}
|
||||
|
|
|
@ -146,14 +146,14 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<TraversableNavigable>> TraversableNavigable
|
|||
// Skip the initial navigation as well. This matches the behavior of the window open steps.
|
||||
|
||||
if (url_matches_about_blank(initial_navigation_url)) {
|
||||
Platform::EventLoopPlugin::the().deferred_invoke([traversable, initial_navigation_url] {
|
||||
Platform::EventLoopPlugin::the().deferred_invoke(JS::create_heap_function(traversable->heap(), [traversable, initial_navigation_url] {
|
||||
// FIXME: We do this other places too when creating a new about:blank document. Perhaps it's worth a spec issue?
|
||||
HTML::HTMLParser::the_end(*traversable->active_document());
|
||||
|
||||
// FIXME: If we perform the URL and history update steps here, we start hanging tests and the UI process will
|
||||
// try to load() the initial URLs passed on the command line before we finish processing the events here.
|
||||
// However, because we call this before the PageClient is fully initialized... that gets awkward.
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
else {
|
||||
|
@ -642,7 +642,7 @@ TraversableNavigable::HistoryStepResult TraversableNavigable::apply_the_history_
|
|||
// 7. In parallel, attempt to populate the history entry's document for targetEntry, given navigable, potentiallyTargetSpecificSourceSnapshotParams,
|
||||
// targetSnapshotParams, with allowPOST set to allowPOST and completionSteps set to queue a global task on the navigation and traversal task source given
|
||||
// navigable's active window to run afterDocumentPopulated.
|
||||
Platform::EventLoopPlugin::the().deferred_invoke([populated_target_entry, potentially_target_specific_source_snapshot_params, target_snapshot_params, this, allow_POST, navigable, after_document_populated = JS::create_heap_function(this->heap(), move(after_document_populated))] {
|
||||
Platform::EventLoopPlugin::the().deferred_invoke(JS::create_heap_function(this->heap(), [populated_target_entry, potentially_target_specific_source_snapshot_params, target_snapshot_params, this, allow_POST, navigable, after_document_populated = JS::create_heap_function(this->heap(), move(after_document_populated))] {
|
||||
navigable->populate_session_history_entry_document(populated_target_entry, *potentially_target_specific_source_snapshot_params, target_snapshot_params, {}, Empty {}, CSPNavigationType::Other, allow_POST, JS::create_heap_function(this->heap(), [this, after_document_populated, populated_target_entry]() mutable {
|
||||
VERIFY(active_window());
|
||||
queue_global_task(Task::Source::NavigationAndTraversal, *active_window(), JS::create_heap_function(this->heap(), [after_document_populated, populated_target_entry]() mutable {
|
||||
|
@ -650,7 +650,7 @@ TraversableNavigable::HistoryStepResult TraversableNavigable::apply_the_history_
|
|||
}));
|
||||
}))
|
||||
.release_value_but_fixme_should_propagate_errors();
|
||||
});
|
||||
}));
|
||||
}
|
||||
// Otherwise, run afterDocumentPopulated immediately.
|
||||
else {
|
||||
|
|
|
@ -210,7 +210,7 @@ JS::NonnullGCPtr<WebIDL::Promise> WindowOrWorkerGlobalScopeMixin::create_image_b
|
|||
image.visit(
|
||||
[&](JS::Handle<FileAPI::Blob>& blob) {
|
||||
// Run these step in parallel:
|
||||
Platform::EventLoopPlugin::the().deferred_invoke([=]() {
|
||||
Platform::EventLoopPlugin::the().deferred_invoke(JS::create_heap_function(realm.heap(), [=]() {
|
||||
// 1. Let imageData be the result of reading image's data. If an error occurs during reading of the
|
||||
// object, then reject p with an "InvalidStateError" DOMException and abort these steps.
|
||||
// FIXME: I guess this is always fine for us as the data is already read.
|
||||
|
@ -246,7 +246,7 @@ JS::NonnullGCPtr<WebIDL::Promise> WindowOrWorkerGlobalScopeMixin::create_image_b
|
|||
};
|
||||
|
||||
(void)Web::Platform::ImageCodecPlugin::the().decode_image(image_data, move(on_successful_decode), move(on_failed_decode));
|
||||
});
|
||||
}));
|
||||
},
|
||||
[&](auto&) {
|
||||
dbgln("(STUBBED) createImageBitmap() for non-blob types");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue