Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions Userland/Libraries/LibWeb/Animations/Animation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ void Animation::cancel(ShouldInvalidate should_invalidate)

// 1. If animation’s play state is not idle, perform the following steps:
if (play_state() != Bindings::AnimationPlayState::Idle) {
HTML::TemporaryExecutionContext execution_context { Bindings::host_defined_environment_settings_object(realm) };
HTML::TemporaryExecutionContext execution_context { realm };

// 1. Run the procedure to reset an animation’s pending tasks on animation.
reset_an_animations_pending_tasks();
Expand Down Expand Up @@ -537,7 +537,7 @@ WebIDL::ExceptionOr<void> Animation::finish()
}

if (should_resolve_ready_promise) {
HTML::TemporaryExecutionContext execution_context { Bindings::host_defined_environment_settings_object(realm()) };
HTML::TemporaryExecutionContext execution_context { realm() };
WebIDL::resolve_promise(realm(), current_ready_promise(), this);
}

Expand Down Expand Up @@ -1111,7 +1111,7 @@ void Animation::update_finished_state(DidSeek did_seek, SynchronouslyNotify sync
return;

// 2. Resolve animation’s current finished promise object with animation.
HTML::TemporaryExecutionContext execution_context { Bindings::host_defined_environment_settings_object(realm) };
HTML::TemporaryExecutionContext execution_context { realm };
WebIDL::resolve_promise(realm, current_finished_promise(), this);
m_is_finished = true;

Expand Down Expand Up @@ -1178,7 +1178,7 @@ void Animation::update_finished_state(DidSeek did_seek, SynchronouslyNotify sync
// 6. If current finished state is false and animation’s current finished promise is already resolved, set
// animation’s current finished promise to a new promise in the relevant Realm of animation.
if (!current_finished_state && m_is_finished) {
HTML::TemporaryExecutionContext execution_context { Bindings::host_defined_environment_settings_object(realm) };
HTML::TemporaryExecutionContext execution_context { realm };
m_current_finished_promise = WebIDL::create_promise(realm);
m_is_finished = false;
}
Expand Down Expand Up @@ -1266,7 +1266,7 @@ void Animation::run_pending_play_task()
}

// 4. Resolve animation’s current ready promise with animation.
HTML::TemporaryExecutionContext execution_context { Bindings::host_defined_environment_settings_object(realm()) };
HTML::TemporaryExecutionContext execution_context { realm() };
WebIDL::resolve_promise(realm(), current_ready_promise(), this);

// 5. Run the procedure to update an animation’s finished state for animation with the did seek flag set to false,
Expand Down Expand Up @@ -1296,7 +1296,7 @@ void Animation::run_pending_pause_task()
m_start_time = {};

// 5. Resolve animation’s current ready promise with animation.
HTML::TemporaryExecutionContext execution_context { Bindings::host_defined_environment_settings_object(realm()) };
HTML::TemporaryExecutionContext execution_context { realm() };
WebIDL::resolve_promise(realm(), current_ready_promise(), this);

// 6. Run the procedure to update an animation’s finished state for animation with the did seek flag set to false,
Expand Down
114 changes: 60 additions & 54 deletions Userland/Libraries/LibWeb/Bindings/MainThreadVM.cpp

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions Userland/Libraries/LibWeb/Bindings/MainThreadVM.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,15 @@ struct WebEngineCustomData final : public JS::VM::CustomData {
};

struct WebEngineCustomJobCallbackData final : public JS::JobCallback::CustomData {
WebEngineCustomJobCallbackData(HTML::EnvironmentSettingsObject& incumbent_settings, OwnPtr<JS::ExecutionContext> active_script_context)
: incumbent_settings(incumbent_settings)
WebEngineCustomJobCallbackData(JS::Realm& incumbent_realm, OwnPtr<JS::ExecutionContext> active_script_context)
: incumbent_realm(incumbent_realm)
, active_script_context(move(active_script_context))
{
}

virtual ~WebEngineCustomJobCallbackData() override = default;

JS::NonnullGCPtr<HTML::EnvironmentSettingsObject> incumbent_settings;
JS::NonnullGCPtr<JS::Realm> incumbent_realm;
OwnPtr<JS::ExecutionContext> active_script_context;
};

Expand Down
2 changes: 1 addition & 1 deletion Userland/Libraries/LibWeb/CSS/CSSStyleSheet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ JS::NonnullGCPtr<WebIDL::Promise> CSSStyleSheet::replace(String text)

// 4. In parallel, do these steps:
Platform::EventLoopPlugin::the().deferred_invoke(JS::create_heap_function(realm.heap(), [&realm, this, text = move(text), promise = JS::Handle(promise)] {
HTML::TemporaryExecutionContext execution_context { HTML::relevant_settings_object(*this), HTML::TemporaryExecutionContext::CallbacksEnabled::Yes };
HTML::TemporaryExecutionContext execution_context { realm, HTML::TemporaryExecutionContext::CallbacksEnabled::Yes };

// 1. Let rules be the result of running parse a stylesheet’s contents from text.
auto context = m_style_sheet_list ? CSS::Parser::ParsingContext { m_style_sheet_list->document() } : CSS::Parser::ParsingContext { realm };
Expand Down
2 changes: 1 addition & 1 deletion Userland/Libraries/LibWeb/CSS/CSSTransition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ CSSTransition::CSSTransition(JS::Realm& realm, DOM::Element& element, PropertyID
element.associate_with_animation(*this);
element.set_transition(m_transition_property, *this);

HTML::TemporaryExecutionContext context(element.document().relevant_settings_object());
HTML::TemporaryExecutionContext context(realm);
play().release_value_but_fixme_should_propagate_errors();
}

Expand Down
8 changes: 4 additions & 4 deletions Userland/Libraries/LibWeb/CSS/FontFace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ JS::NonnullGCPtr<FontFace> FontFace::construct_impl(JS::Realm& realm, String fam

font->m_font_load_promise->when_resolved([font = JS::make_handle(font)](auto const& vector_font) -> ErrorOr<void> {
HTML::queue_global_task(HTML::Task::Source::FontLoading, HTML::relevant_global_object(*font), JS::create_heap_function(font->heap(), [font = JS::NonnullGCPtr(*font), vector_font] {
HTML::TemporaryExecutionContext context(HTML::relevant_settings_object(*font), HTML::TemporaryExecutionContext::CallbacksEnabled::Yes);
HTML::TemporaryExecutionContext context(font->realm(), HTML::TemporaryExecutionContext::CallbacksEnabled::Yes);
// 1. If the load was successful, font face now represents the parsed font;
// fulfill font face’s [[FontStatusPromise]] with font face, and set its status attribute to "loaded".

Expand All @@ -147,7 +147,7 @@ JS::NonnullGCPtr<FontFace> FontFace::construct_impl(JS::Realm& realm, String fam
});
font->m_font_load_promise->when_rejected([font = JS::make_handle(font)](auto const& error) {
HTML::queue_global_task(HTML::Task::Source::FontLoading, HTML::relevant_global_object(*font), JS::create_heap_function(font->heap(), [font = JS::NonnullGCPtr(*font), error = Error::copy(error)] {
HTML::TemporaryExecutionContext context(HTML::relevant_settings_object(*font), HTML::TemporaryExecutionContext::CallbacksEnabled::Yes);
HTML::TemporaryExecutionContext context(font->realm(), HTML::TemporaryExecutionContext::CallbacksEnabled::Yes);
// 2. Otherwise, reject font face’s [[FontStatusPromise]] with a DOMException named "SyntaxError"
// and set font face’s status attribute to "error".
font->m_status = Bindings::FontFaceLoadStatus::Error;
Expand Down Expand Up @@ -356,7 +356,7 @@ void FontFace::load_font_source()
// 5. When the load operation completes, successfully or not, queue a task to run the following steps synchronously:
auto on_error = [font] {
HTML::queue_global_task(HTML::Task::Source::FontLoading, HTML::relevant_global_object(*font), JS::create_heap_function(font->heap(), [font = JS::NonnullGCPtr(*font)] {
HTML::TemporaryExecutionContext context(HTML::relevant_settings_object(*font), HTML::TemporaryExecutionContext::CallbacksEnabled::Yes);
HTML::TemporaryExecutionContext context(font->realm(), HTML::TemporaryExecutionContext::CallbacksEnabled::Yes);

// 1. If the attempt to load fails, reject font face’s [[FontStatusPromise]] with a DOMException whose name
// is "NetworkError" and set font face’s status attribute to "error".
Expand All @@ -370,7 +370,7 @@ void FontFace::load_font_source()
auto on_load = [font](FontLoader const& loader) {
// FIXME: We are assuming that the font loader will live as long as the document! This is an unsafe capture
HTML::queue_global_task(HTML::Task::Source::FontLoading, HTML::relevant_global_object(*font), JS::create_heap_function(font->heap(), [font = JS::NonnullGCPtr(*font), &loader] {
HTML::TemporaryExecutionContext context(HTML::relevant_settings_object(*font), HTML::TemporaryExecutionContext::CallbacksEnabled::Yes);
HTML::TemporaryExecutionContext context(font->realm(), HTML::TemporaryExecutionContext::CallbacksEnabled::Yes);

// 2. Otherwise, font face now represents the loaded font; fulfill font face’s [[FontStatusPromise]] with font face
// and set font face’s status attribute to "loaded".
Expand Down
8 changes: 4 additions & 4 deletions Userland/Libraries/LibWeb/CSS/FontFaceSet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ JS::ThrowCompletionOr<JS::NonnullGCPtr<WebIDL::Promise>> FontFaceSet::load(Strin
// reject promise with a SyntaxError exception and terminate these steps.
auto result = find_matching_font_faces(realm, font_face_set, font, text);
if (result.is_error()) {
HTML::TemporaryExecutionContext execution_context { Bindings::host_defined_environment_settings_object(realm), HTML::TemporaryExecutionContext::CallbacksEnabled::Yes };
HTML::TemporaryExecutionContext execution_context { realm, HTML::TemporaryExecutionContext::CallbacksEnabled::Yes };
WebIDL::reject_promise(realm, promise, Bindings::dom_exception_to_throw_completion(realm.vm(), result.release_error()).release_value().value());
return;
}
Expand All @@ -262,16 +262,16 @@ JS::ThrowCompletionOr<JS::NonnullGCPtr<WebIDL::Promise>> FontFaceSet::load(Strin

// 2. Resolve promise with the result of waiting for all of the [[FontStatusPromise]]s of each font face in
// the font face list, in order.
HTML::TemporaryExecutionContext execution_context { Bindings::host_defined_environment_settings_object(realm), HTML::TemporaryExecutionContext::CallbacksEnabled::Yes };
HTML::TemporaryExecutionContext execution_context { realm, HTML::TemporaryExecutionContext::CallbacksEnabled::Yes };

WebIDL::wait_for_all(
realm, promises,
[&realm, promise](auto const&) {
HTML::TemporaryExecutionContext execution_context { Bindings::host_defined_environment_settings_object(realm), HTML::TemporaryExecutionContext::CallbacksEnabled::Yes };
HTML::TemporaryExecutionContext execution_context { realm, HTML::TemporaryExecutionContext::CallbacksEnabled::Yes };
WebIDL::resolve_promise(realm, promise);
},
[&realm, promise](auto error) {
HTML::TemporaryExecutionContext execution_context { Bindings::host_defined_environment_settings_object(realm), HTML::TemporaryExecutionContext::CallbacksEnabled::Yes };
HTML::TemporaryExecutionContext execution_context { realm, HTML::TemporaryExecutionContext::CallbacksEnabled::Yes };
WebIDL::reject_promise(realm, promise, error);
});
}));
Expand Down
6 changes: 3 additions & 3 deletions Userland/Libraries/LibWeb/CSS/StyleComputer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1140,10 +1140,10 @@ static void apply_animation_properties(DOM::Document& document, StyleProperties&

if (play_state != effect.last_css_animation_play_state()) {
if (play_state == CSS::AnimationPlayState::Running && animation.play_state() == Bindings::AnimationPlayState::Paused) {
HTML::TemporaryExecutionContext context(document.relevant_settings_object());
HTML::TemporaryExecutionContext context(document.realm());
animation.play().release_value_but_fixme_should_propagate_errors();
} else if (play_state == CSS::AnimationPlayState::Paused && animation.play_state() != Bindings::AnimationPlayState::Paused) {
HTML::TemporaryExecutionContext context(document.relevant_settings_object());
HTML::TemporaryExecutionContext context(document.realm());
animation.pause().release_value_but_fixme_should_propagate_errors();
}

Expand Down Expand Up @@ -1561,7 +1561,7 @@ void StyleComputer::compute_cascaded_values(StyleProperties& style, DOM::Element
effect->set_target(&element);
element.set_cached_animation_name_animation(animation, pseudo_element);

HTML::TemporaryExecutionContext context(m_document->relevant_settings_object());
HTML::TemporaryExecutionContext context(realm);
animation->play().release_value_but_fixme_should_propagate_errors();
} else {
// The animation hasn't changed, but some properties of the animation may have
Expand Down
4 changes: 2 additions & 2 deletions Userland/Libraries/LibWeb/Clipboard/Clipboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ JS::NonnullGCPtr<WebIDL::Promise> Clipboard::write_text(String data)
// 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 {
HTML::TemporaryExecutionContext execution_context { Bindings::host_defined_environment_settings_object(realm) };
HTML::TemporaryExecutionContext execution_context { realm };
WebIDL::reject_promise(realm, promise, WebIDL::NotAllowedError::create(realm, "Clipboard writing is only allowed through user activation"_string));
}));

Expand Down Expand Up @@ -188,7 +188,7 @@ JS::NonnullGCPtr<WebIDL::Promise> Clipboard::write_text(String data)
write_blobs_and_option_to_clipboard(realm, item_list, move(option));

// 6. Resolve p.
HTML::TemporaryExecutionContext execution_context { Bindings::host_defined_environment_settings_object(realm) };
HTML::TemporaryExecutionContext execution_context { realm };
WebIDL::resolve_promise(realm, promise, JS::js_undefined());
}));
}));
Expand Down
Loading
Loading