dymokomi/luce-browser-engine
Source of release 0.6.1
0.6.1 / src / web / html / scripting / agent.lucb
#==============================================================================================
#
# agent - HTML::Agent: the agent of a realm, with its event loop
#
# DESCRIPTION:
# Port of Libraries/LibWeb/HTML/Scripting/Agent.cpp (lines 1-27) and Agent.h (lines
# 1-31). JS::Agent (CanBlock, the agent signifier) is not ported apart from what LibWeb
# reads: the VM owns one HTML::Agent, whose event loop LibWeb reaches through the
# relevant agent of an object.
#
# Copyright (c) 2025, Shannon Booth <shannon@serenityos.org>
# SPDX-License-Identifier: BSD-2-Clause
#
#==============================================================================================
## Ported from Libraries/LibWeb/HTML/Scripting/Agent.cpp:14 Web::HTML::Agent::spin_event_loop_until (virtual).
pub func html_agent_spin_event_loop_until_impl(this: HtmlAgent*, goal_condition: gc.Function0[bool]*?):
platform_event_loop_plugin_spin_until(platform_event_loop_plugin_the(), goal_condition)
## Ported from Libraries/LibWeb/HTML/Scripting/Agent.cpp:20 Web::HTML::relevant_agent.
## https://html.spec.whatwg.org/multipage/webappapis.html#relevant-agent
pub func html_relevant_agent(object: JsObject*) -> HtmlAgent*:
# The relevant agent for a platform object platformObject is platformObject's relevant Realm's agent.
# Spec Note: This pointer is not yet defined in the JavaScript specification; see tc39/ecma262#1357.
return vm_agent(realm_vm(html_relevant_realm(object))) else trap("VERIFY: the VM has an agent")