Struct script::dom::globalscope::GlobalScope
source · #[repr(C)]pub struct GlobalScope {Show 40 fields
eventtarget: EventTarget,
crypto: MutNullableDom<Crypto>,
message_port_state: DomRefCell<MessagePortState>,
broadcast_channel_state: DomRefCell<BroadcastChannelState>,
blob_state: DomRefCell<BlobState>,
registration_map: DomRefCell<HashMapTracedValues<ServiceWorkerRegistrationId, Dom<ServiceWorkerRegistration>>>,
worker_map: DomRefCell<HashMapTracedValues<ServiceWorkerId, Dom<ServiceWorker>>>,
pipeline_id: PipelineId,
devtools_wants_updates: Cell<bool>,
console_timers: DomRefCell<HashMap<DOMString, Instant>>,
module_map: DomRefCell<HashMapTracedValues<ServoUrl, Rc<ModuleTree>>>,
inline_module_map: DomRefCell<HashMap<ScriptId, Rc<ModuleTree>>>,
devtools_chan: Option<IpcSender<ScriptToDevtoolsControlMsg>>,
mem_profiler_chan: ProfilerChan,
time_profiler_chan: ProfilerChan,
script_to_constellation_chan: ScriptToConstellationChan,
scheduler_chan: IpcSender<TimerSchedulerMsg>,
in_error_reporting_mode: Cell<bool>,
resource_threads: ResourceThreads,
timers: OneshotTimers,
init_timers: Cell<bool>,
origin: MutableOrigin,
creation_url: Option<ServoUrl>,
permission_state_invocation_results: DomRefCell<HashMap<String, PermissionState>>,
microtask_queue: Rc<MicrotaskQueue>,
list_auto_close_worker: DomRefCell<Vec<AutoCloseWorker>>,
event_source_tracker: DOMTracker<EventSource>,
uncaught_rejections: DomRefCell<Vec<Box<Heap<*mut JSObject>>>>,
consumed_rejections: DomRefCell<Vec<Box<Heap<*mut JSObject>>>>,
is_headless: bool,
user_agent: Cow<'static, str>,
gpu_id_hub: Arc<IdentityHub>,
gpu_devices: DomRefCell<HashMapTracedValues<WebGPUDevice, WeakRef<GPUDevice>>>,
frozen_supported_performance_entry_types: CachedFrozenArray,
https_state: Cell<HttpsState>,
console_group_stack: DomRefCell<Vec<DOMString>>,
console_count_map: DomRefCell<HashMap<DOMString, usize>>,
dynamic_modules: DomRefCell<DynamicModuleList>,
inherited_secure_context: Option<bool>,
unminified_js_dir: Option<String>,
}
Fields§
§eventtarget: EventTarget
§crypto: MutNullableDom<Crypto>
§message_port_state: DomRefCell<MessagePortState>
The message-port router id for this global, if it is managing ports.
broadcast_channel_state: DomRefCell<BroadcastChannelState>
The broadcast channels state this global, if it is managing any.
blob_state: DomRefCell<BlobState>
The blobs managed by this global, if any.
registration_map: DomRefCell<HashMapTracedValues<ServiceWorkerRegistrationId, Dom<ServiceWorkerRegistration>>>
§worker_map: DomRefCell<HashMapTracedValues<ServiceWorkerId, Dom<ServiceWorker>>>
§pipeline_id: PipelineId
Pipeline id associated with this global.
devtools_wants_updates: Cell<bool>
A flag to indicate whether the developer tools has requested live updates from the worker.
console_timers: DomRefCell<HashMap<DOMString, Instant>>
Timers (milliseconds) used by the Console API.
module_map: DomRefCell<HashMapTracedValues<ServoUrl, Rc<ModuleTree>>>
module map is used when importing JavaScript modules https://html.spec.whatwg.org/multipage/#concept-settings-object-module-map
inline_module_map: DomRefCell<HashMap<ScriptId, Rc<ModuleTree>>>
§devtools_chan: Option<IpcSender<ScriptToDevtoolsControlMsg>>
For providing instructions to an optional devtools server.
mem_profiler_chan: ProfilerChan
For sending messages to the memory profiler.
time_profiler_chan: ProfilerChan
For sending messages to the time profiler.
script_to_constellation_chan: ScriptToConstellationChan
A handle for communicating messages to the constellation thread.
scheduler_chan: IpcSender<TimerSchedulerMsg>
§in_error_reporting_mode: Cell<bool>
§resource_threads: ResourceThreads
Associated resource threads for use by DOM objects like XMLHttpRequest, including resource_thread, filemanager_thread and storage_thread
timers: OneshotTimers
The mechanism by which time-outs and intervals are scheduled. https://html.spec.whatwg.org/multipage/#timers
init_timers: Cell<bool>
Have timers been initialized?
origin: MutableOrigin
The origin of the globalscope
creation_url: Option<ServoUrl>
§permission_state_invocation_results: DomRefCell<HashMap<String, PermissionState>>
A map for storing the previous permission state read results.
microtask_queue: Rc<MicrotaskQueue>
The microtask queue associated with this global.
It is refcounted because windows in the same script thread share the same microtask queue.
list_auto_close_worker: DomRefCell<Vec<AutoCloseWorker>>
Vector storing closing references of all workers
event_source_tracker: DOMTracker<EventSource>
Vector storing references of all eventsources.
uncaught_rejections: DomRefCell<Vec<Box<Heap<*mut JSObject>>>>
Storage for watching rejected promises waiting for some client to consume their rejection. Promises in this list have been rejected in the last turn of the event loop without the rejection being handled. Note that this can contain nullptrs in place of promises removed because they’re consumed before it’d be reported.
https://html.spec.whatwg.org/multipage/#about-to-be-notified-rejected-promises-list
consumed_rejections: DomRefCell<Vec<Box<Heap<*mut JSObject>>>>
Promises in this list have previously been reported as rejected (because they were in the above list), but the rejection was handled in the last turn of the event loop.
https://html.spec.whatwg.org/multipage/#outstanding-rejected-promises-weak-set
is_headless: bool
True if headless mode.
user_agent: Cow<'static, str>
An optional string allowing the user agent to be set for testing.
gpu_id_hub: Arc<IdentityHub>
Identity Manager for WebGPU resources
gpu_devices: DomRefCell<HashMapTracedValues<WebGPUDevice, WeakRef<GPUDevice>>>
WebGPU devices
frozen_supported_performance_entry_types: CachedFrozenArray
§https_state: Cell<HttpsState>
currect https state (from previous request)
console_group_stack: DomRefCell<Vec<DOMString>>
The stack of active group labels for the Console APIs.
console_count_map: DomRefCell<HashMap<DOMString, usize>>
The count map for the Console APIs.
dynamic_modules: DomRefCell<DynamicModuleList>
List of ongoing dynamic module imports.
inherited_secure_context: Option<bool>
Is considered in a secure context
unminified_js_dir: Option<String>
Directory to store unminified scripts for this window if unminify-js opt is enabled.
Implementations§
source§impl GlobalScope
impl GlobalScope
pub fn new_inherited( pipeline_id: PipelineId, devtools_chan: Option<IpcSender<ScriptToDevtoolsControlMsg>>, mem_profiler_chan: ProfilerChan, time_profiler_chan: ProfilerChan, script_to_constellation_chan: ScriptToConstellationChan, scheduler_chan: IpcSender<TimerSchedulerMsg>, resource_threads: ResourceThreads, origin: MutableOrigin, creation_url: Option<ServoUrl>, microtask_queue: Rc<MicrotaskQueue>, is_headless: bool, user_agent: Cow<'static, str>, gpu_id_hub: Arc<IdentityHub>, inherited_secure_context: Option<bool>, unminify_js: bool, ) -> Self
sourcefn port_router_id(&self) -> Option<MessagePortRouterId>
fn port_router_id(&self) -> Option<MessagePortRouterId>
The message-port router Id of the global, if any
sourcefn is_managing_port(&self, port_id: &MessagePortId) -> bool
fn is_managing_port(&self, port_id: &MessagePortId) -> bool
Is this global managing a given port?
sourcefn setup_timers(&self)
fn setup_timers(&self)
Setup the IPC-to-event-loop glue for timers to schedule themselves.
sourcepub fn get_serviceworker_registration(
&self,
script_url: &ServoUrl,
scope: &ServoUrl,
registration_id: ServiceWorkerRegistrationId,
installing_worker: Option<ServiceWorkerId>,
_waiting_worker: Option<ServiceWorkerId>,
_active_worker: Option<ServiceWorkerId>,
) -> Root<Dom<ServiceWorkerRegistration>>
pub fn get_serviceworker_registration( &self, script_url: &ServoUrl, scope: &ServoUrl, registration_id: ServiceWorkerRegistrationId, installing_worker: Option<ServiceWorkerId>, _waiting_worker: Option<ServiceWorkerId>, _active_worker: Option<ServiceWorkerId>, ) -> Root<Dom<ServiceWorkerRegistration>>
sourcepub fn get_serviceworker(
&self,
script_url: &ServoUrl,
scope: &ServoUrl,
worker_id: ServiceWorkerId,
) -> Root<Dom<ServiceWorker>>
pub fn get_serviceworker( &self, script_url: &ServoUrl, scope: &ServoUrl, worker_id: ServiceWorkerId, ) -> Root<Dom<ServiceWorker>>
sourcefn complete_port_transfer(
&self,
port_id: MessagePortId,
tasks: VecDeque<PortMessageTask>,
)
fn complete_port_transfer( &self, port_id: MessagePortId, tasks: VecDeque<PortMessageTask>, )
Complete the transfer of a message-port.
sourcepub fn perform_a_dom_garbage_collection_checkpoint(&self)
pub fn perform_a_dom_garbage_collection_checkpoint(&self)
Clean-up DOM related resources
sourcepub fn remove_web_messaging_and_dedicated_workers_infra(&self)
pub fn remove_web_messaging_and_dedicated_workers_infra(&self)
Remove the routers for ports and broadcast-channels. Drain the list of workers.
sourcefn remove_message_ports_router(&self)
fn remove_message_ports_router(&self)
Update our state to un-managed, and tell the constellation to drop the sender to our message-port router.
sourcefn remove_broadcast_channel_router(&self)
fn remove_broadcast_channel_router(&self)
Update our state to un-managed, and tell the constellation to drop the sender to our broadcast router.
sourcepub fn entangle_ports(&self, port1: MessagePortId, port2: MessagePortId)
pub fn entangle_ports(&self, port1: MessagePortId, port2: MessagePortId)
sourcepub fn note_entangled_port_removed(&self, port_id: &MessagePortId)
pub fn note_entangled_port_removed(&self, port_id: &MessagePortId)
Note that the entangled port of port_id
has been removed in another global.
sourcepub fn mark_port_as_transferred(
&self,
port_id: &MessagePortId,
) -> MessagePortImpl
pub fn mark_port_as_transferred( &self, port_id: &MessagePortId, ) -> MessagePortImpl
Handle the transfer of a port in the current task.
sourcepub fn start_message_port(&self, port_id: &MessagePortId)
pub fn start_message_port(&self, port_id: &MessagePortId)
sourcepub fn close_message_port(&self, port_id: &MessagePortId)
pub fn close_message_port(&self, port_id: &MessagePortId)
sourcepub fn post_messageport_msg(
&self,
port_id: MessagePortId,
task: PortMessageTask,
)
pub fn post_messageport_msg( &self, port_id: MessagePortId, task: PortMessageTask, )
sourcefn re_route_port_task(&self, port_id: MessagePortId, task: PortMessageTask)
fn re_route_port_task(&self, port_id: MessagePortId, task: PortMessageTask)
If we don’t know about the port, send the message to the constellation for routing.
sourcepub fn schedule_broadcast(&self, msg: BroadcastMsg, channel_id: &Uuid)
pub fn schedule_broadcast(&self, msg: BroadcastMsg, channel_id: &Uuid)
https://html.spec.whatwg.org/multipage/#dom-broadcastchannel-postmessage Step 7 and following steps.
sourcepub fn broadcast_message_event(
&self,
event: BroadcastMsg,
channel_id: Option<&Uuid>,
)
pub fn broadcast_message_event( &self, event: BroadcastMsg, channel_id: Option<&Uuid>, )
https://html.spec.whatwg.org/multipage/#dom-broadcastchannel-postmessage Step 7 and following steps.
sourcepub fn route_task_to_port(
&self,
port_id: MessagePortId,
task: PortMessageTask,
can_gc: CanGc,
)
pub fn route_task_to_port( &self, port_id: MessagePortId, task: PortMessageTask, can_gc: CanGc, )
Route the task to be handled by the relevant port.
sourcepub fn maybe_add_pending_ports(&self)
pub fn maybe_add_pending_ports(&self)
Check all ports that have been transfer-received in the previous task, and complete their transfer if they haven’t been re-transferred.
sourcepub fn perform_a_broadcast_channel_garbage_collection_checkpoint(&self)
pub fn perform_a_broadcast_channel_garbage_collection_checkpoint(&self)
Remove broadcast-channels that are closed. TODO: Also remove them if they do not have an event-listener. see https://github.com/servo/servo/issues/25772
sourcepub fn track_broadcast_channel(&self, dom_channel: &BroadcastChannel)
pub fn track_broadcast_channel(&self, dom_channel: &BroadcastChannel)
Start tracking a broadcast-channel.
sourcepub fn track_message_port(
&self,
dom_port: &MessagePort,
port_impl: Option<MessagePortImpl>,
)
pub fn track_message_port( &self, dom_port: &MessagePort, port_impl: Option<MessagePortImpl>, )
Start tracking a message-port
sourcepub fn serialize_blob(&self, blob_id: &BlobId) -> BlobImpl
pub fn serialize_blob(&self, blob_id: &BlobId) -> BlobImpl
https://html.spec.whatwg.org/multipage/#serialization-steps defined at https://w3c.github.io/FileAPI/#blob-section. Get the snapshot state and underlying bytes of the blob.
fn track_blob_info(&self, blob_info: BlobInfo, blob_id: BlobId)
sourcepub fn track_blob(&self, dom_blob: &Blob, blob_impl: BlobImpl)
pub fn track_blob(&self, dom_blob: &Blob, blob_impl: BlobImpl)
Start tracking a blob
sourcepub fn track_file(&self, file: &File, blob_impl: BlobImpl)
pub fn track_file(&self, file: &File, blob_impl: BlobImpl)
Start tracking a file
sourcefn perform_a_blob_garbage_collection_checkpoint(&self)
fn perform_a_blob_garbage_collection_checkpoint(&self)
Clean-up any file or blob that is unreachable from script, unless it has an oustanding blob url. https://w3c.github.io/FileAPI/#lifeTime
sourcepub fn clean_up_all_file_resources(&self)
pub fn clean_up_all_file_resources(&self)
Clean-up all file related resources on document unload. https://w3c.github.io/FileAPI/#lifeTime
fn decrement_file_ref(&self, id: Uuid)
sourcepub fn get_blob_bytes(&self, blob_id: &BlobId) -> Result<Vec<u8>, ()>
pub fn get_blob_bytes(&self, blob_id: &BlobId) -> Result<Vec<u8>, ()>
Get a slice to the inner data of a Blob, In the case of a File-backed blob, this might incur synchronous read and caching.
sourcefn get_blob_bytes_non_sliced(&self, blob_id: &BlobId) -> Result<Vec<u8>, ()>
fn get_blob_bytes_non_sliced(&self, blob_id: &BlobId) -> Result<Vec<u8>, ()>
Get bytes from a non-sliced blob
sourcefn get_blob_bytes_or_file_id(&self, blob_id: &BlobId) -> BlobResult
fn get_blob_bytes_or_file_id(&self, blob_id: &BlobId) -> BlobResult
Get a slice to the inner data of a Blob, if it’s a memory blob, or it’s file-id and file-size otherwise.
Note: this is almost a duplicate of get_blob_bytes
,
tweaked for integration with streams.
TODO: merge with get_blob_bytes
by way of broader integration with blob streams.
sourcefn get_blob_bytes_non_sliced_or_file_id(&self, blob_id: &BlobId) -> BlobResult
fn get_blob_bytes_non_sliced_or_file_id(&self, blob_id: &BlobId) -> BlobResult
Get bytes from a non-sliced blob if in memory, or it’s file-id and file-size.
Note: this is almost a duplicate of get_blob_bytes_non_sliced
,
tweaked for integration with streams.
TODO: merge with get_blob_bytes
by way of broader integration with blob streams.
sourcepub fn get_blob_type_string(&self, blob_id: &BlobId) -> String
pub fn get_blob_type_string(&self, blob_id: &BlobId) -> String
Get a copy of the type_string of a blob.
sourcepub fn get_blob_size(&self, blob_id: &BlobId) -> u64
pub fn get_blob_size(&self, blob_id: &BlobId) -> u64
pub fn get_blob_url_id(&self, blob_id: &BlobId) -> Uuid
sourcefn create_sliced_url_id(
&self,
blob_info: &mut BlobInfo,
parent_file_id: &Uuid,
rel_pos: &RelativePos,
parent_len: u64,
) -> Uuid
fn create_sliced_url_id( &self, blob_info: &mut BlobInfo, parent_file_id: &Uuid, rel_pos: &RelativePos, parent_len: u64, ) -> Uuid
Get a FileID representing sliced parent-blob content
sourcepub fn promote(&self, blob_info: &mut BlobInfo, set_valid: bool) -> Uuid
pub fn promote(&self, blob_info: &mut BlobInfo, set_valid: bool) -> Uuid
Promote non-Slice blob:
- Memory-based: The bytes in data slice will be transferred to file manager thread.
- File-based: If set_valid, then activate the FileID so it can serve as URL Depending on set_valid, the returned FileID can be part of valid or invalid Blob URL.
fn send_to_file_manager(&self, msg: FileManagerThreadMsg)
fn read_file(&self, id: Uuid) -> Result<Vec<u8>, ()>
sourcepub fn get_blob_stream(
&self,
blob_id: &BlobId,
can_gc: CanGc,
) -> Root<Dom<ReadableStream>>
pub fn get_blob_stream( &self, blob_id: &BlobId, can_gc: CanGc, ) -> Root<Dom<ReadableStream>>
pub fn read_file_async( &self, id: Uuid, promise: Rc<Promise>, callback: Box<dyn Fn(Rc<Promise>, Result<Vec<u8>, Error>) + Send>, )
fn send_msg(&self, id: Uuid) -> IpcReceiver<FileManagerResult<ReadFileProgress>>
fn read_msg( receiver: IpcReceiver<FileManagerResult<ReadFileProgress>>, ) -> Result<Vec<u8>, ()>
pub fn permission_state_invocation_results( &self, ) -> &DomRefCell<HashMap<String, PermissionState>>
pub fn track_worker( &self, closing: Arc<AtomicBool>, join_handle: JoinHandle<()>, control_sender: Sender<DedicatedWorkerControlMsg>, context: ThreadSafeJSContext, )
pub fn track_event_source(&self, event_source: &EventSource)
pub fn close_event_sources(&self) -> bool
sourcepub fn from_reflector<T: DomObject>(
reflector: &T,
_realm: &AlreadyInRealm,
) -> Root<Dom<Self>>
pub fn from_reflector<T: DomObject>( reflector: &T, _realm: &AlreadyInRealm, ) -> Root<Dom<Self>>
Returns the global scope of the realm that the given DOM object’s reflector was created in.
sourcepub unsafe fn from_object(obj: *mut JSObject) -> Root<Dom<Self>>
pub unsafe fn from_object(obj: *mut JSObject) -> Root<Dom<Self>>
Returns the global scope of the realm that the given JS object was created in.
sourcepub unsafe fn from_context(
cx: *mut JSContext,
_realm: InRealm<'_>,
) -> Root<Dom<Self>>
pub unsafe fn from_context( cx: *mut JSContext, _realm: InRealm<'_>, ) -> Root<Dom<Self>>
Returns the global scope for the given JSContext
sourcepub fn from_safe_context(
cx: SafeJSContext,
realm: InRealm<'_>,
) -> Root<Dom<Self>>
pub fn from_safe_context( cx: SafeJSContext, realm: InRealm<'_>, ) -> Root<Dom<Self>>
Returns the global scope for the given SafeJSContext
sourcepub unsafe fn from_object_maybe_wrapped(
obj: *mut JSObject,
cx: *mut JSContext,
) -> Root<Dom<Self>>
pub unsafe fn from_object_maybe_wrapped( obj: *mut JSObject, cx: *mut JSContext, ) -> Root<Dom<Self>>
Returns the global object of the realm that the given JS object was created in, after unwrapping any wrappers.
pub fn add_uncaught_rejection(&self, rejection: HandleObject)
pub fn remove_uncaught_rejection(&self, rejection: HandleObject)
pub fn get_uncaught_rejections( &self, ) -> &DomRefCell<Vec<Box<Heap<*mut JSObject>>>>
pub fn add_consumed_rejection(&self, rejection: HandleObject)
pub fn remove_consumed_rejection(&self, rejection: HandleObject)
pub fn get_consumed_rejections( &self, ) -> &DomRefCell<Vec<Box<Heap<*mut JSObject>>>>
pub fn set_module_map(&self, url: ServoUrl, module: ModuleTree)
pub fn get_module_map( &self, ) -> &DomRefCell<HashMapTracedValues<ServoUrl, Rc<ModuleTree>>>
pub fn set_inline_module_map(&self, script_id: ScriptId, module: ModuleTree)
pub fn get_inline_module_map( &self, ) -> &DomRefCell<HashMap<ScriptId, Rc<ModuleTree>>>
pub fn get_cx() -> SafeJSContext
pub fn crypto(&self) -> Root<Dom<Crypto>>
pub fn live_devtools_updates(&self) -> bool
pub fn set_devtools_wants_updates(&self, value: bool)
pub fn time(&self, label: DOMString) -> Result<(), ()>
sourcepub fn time_log(&self, label: &str) -> Result<u64, ()>
pub fn time_log(&self, label: &str) -> Result<u64, ()>
Computes the delta time since a label has been created
Returns an error if the label does not exist.
sourcepub fn time_end(&self, label: &str) -> Result<u64, ()>
pub fn time_end(&self, label: &str) -> Result<u64, ()>
Computes the delta time since a label has been created and stops tracking the label.
Returns an error if the label does not exist.
sourcepub fn devtools_chan(&self) -> Option<&IpcSender<ScriptToDevtoolsControlMsg>>
pub fn devtools_chan(&self) -> Option<&IpcSender<ScriptToDevtoolsControlMsg>>
Get an &IpcSender<ScriptToDevtoolsControlMsg>
to send messages
to the devtools thread when available.
pub fn issue_page_warning(&self, warning: &str)
sourcepub fn mem_profiler_chan(&self) -> &ProfilerChan
pub fn mem_profiler_chan(&self) -> &ProfilerChan
Get a sender to the memory profiler thread.
sourcepub fn time_profiler_chan(&self) -> &ProfilerChan
pub fn time_profiler_chan(&self) -> &ProfilerChan
Get a sender to the time profiler thread.
sourcepub fn script_to_constellation_chan(&self) -> &ScriptToConstellationChan
pub fn script_to_constellation_chan(&self) -> &ScriptToConstellationChan
Get a sender to the constellation thread.
pub fn send_to_embedder(&self, msg: EmbedderMsg)
pub fn send_to_constellation(&self, msg: ScriptMsg)
pub fn scheduler_chan(&self) -> &IpcSender<TimerSchedulerMsg>
sourcepub fn pipeline_id(&self) -> PipelineId
pub fn pipeline_id(&self) -> PipelineId
Get the PipelineId
for this global scope.
sourcepub fn origin(&self) -> &MutableOrigin
pub fn origin(&self) -> &MutableOrigin
Get the origin for this global scope
sourcepub fn creation_url(&self) -> &Option<ServoUrl>
pub fn creation_url(&self) -> &Option<ServoUrl>
Get the creation_url for this global scope
pub fn image_cache(&self) -> Arc<dyn ImageCache>
sourcepub fn policy_container(&self) -> PolicyContainer
pub fn policy_container(&self) -> PolicyContainer
sourcepub fn api_base_url(&self) -> ServoUrl
pub fn api_base_url(&self) -> ServoUrl
Get the base url for this global scope.
sourcepub fn get_referrer_policy(&self) -> ReferrerPolicy
pub fn get_referrer_policy(&self) -> ReferrerPolicy
Get the Referrer Policy for this global scope.
sourcepub fn get_referrer(&self) -> Referrer
pub fn get_referrer(&self) -> Referrer
Determine the Referrer for a request whose Referrer is “client”
sourcepub fn as_window(&self) -> &Window
pub fn as_window(&self) -> &Window
Extract a Window
, panic if the global object is not a Window
.
sourcepub fn report_an_error(
&self,
error_info: ErrorInfo,
value: HandleValue<'_>,
can_gc: CanGc,
)
pub fn report_an_error( &self, error_info: ErrorInfo, value: HandleValue<'_>, can_gc: CanGc, )
sourcepub fn resource_threads(&self) -> &ResourceThreads
pub fn resource_threads(&self) -> &ResourceThreads
Get the &ResourceThreads
for this global scope.
sourcepub fn core_resource_thread(&self) -> CoreResourceThread
pub fn core_resource_thread(&self) -> CoreResourceThread
Get the CoreResourceThread
for this global scope.
sourcepub fn script_chan(&self) -> Box<dyn ScriptChan + Send>
pub fn script_chan(&self) -> Box<dyn ScriptChan + Send>
ScriptChan
to send messages to the event loop of this global scope.
sourcepub fn gamepad_task_source(&self) -> GamepadTaskSource
pub fn gamepad_task_source(&self) -> GamepadTaskSource
TaskSource
to send messages to the gamepad task source of
this global scope.
https://w3c.github.io/gamepad/#dfn-gamepad-task-source
sourcepub fn networking_task_source(&self) -> NetworkingTaskSource
pub fn networking_task_source(&self) -> NetworkingTaskSource
TaskSource
to send messages to the networking task source of
this global scope.
sourcepub fn port_message_queue(&self) -> PortMessageQueue
pub fn port_message_queue(&self) -> PortMessageQueue
TaskSource
to send messages to the port message queue of
this global scope.
sourcepub fn timer_task_source(&self) -> TimerTaskSource
pub fn timer_task_source(&self) -> TimerTaskSource
TaskSource
to send messages to the timer queue of
this global scope.
sourcepub fn remote_event_task_source(&self) -> RemoteEventTaskSource
pub fn remote_event_task_source(&self) -> RemoteEventTaskSource
TaskSource
to send messages to the remote-event task source of
this global scope.
sourcepub fn websocket_task_source(&self) -> WebsocketTaskSource
pub fn websocket_task_source(&self) -> WebsocketTaskSource
TaskSource
to send messages to the websocket task source of
this global scope.
sourcepub fn evaluate_js_on_global_with_result(
&self,
code: &str,
rval: MutableHandleValue<'_>,
fetch_options: ScriptFetchOptions,
script_base_url: ServoUrl,
can_gc: CanGc,
) -> bool
pub fn evaluate_js_on_global_with_result( &self, code: &str, rval: MutableHandleValue<'_>, fetch_options: ScriptFetchOptions, script_base_url: ServoUrl, can_gc: CanGc, ) -> bool
Evaluate JS code on this global scope.
sourcepub fn evaluate_script_on_global_with_result(
&self,
code: &SourceCode,
filename: &str,
rval: MutableHandleValue<'_>,
line_number: u32,
fetch_options: ScriptFetchOptions,
script_base_url: ServoUrl,
can_gc: CanGc,
) -> bool
pub fn evaluate_script_on_global_with_result( &self, code: &SourceCode, filename: &str, rval: MutableHandleValue<'_>, line_number: u32, fetch_options: ScriptFetchOptions, script_base_url: ServoUrl, can_gc: CanGc, ) -> bool
Evaluate a JS script on this global scope.
sourcepub fn schedule_callback(
&self,
callback: OneshotTimerCallback,
duration: Duration,
) -> OneshotTimerHandle
pub fn schedule_callback( &self, callback: OneshotTimerCallback, duration: Duration, ) -> OneshotTimerHandle
pub fn unschedule_callback(&self, handle: OneshotTimerHandle)
sourcepub fn set_timeout_or_interval(
&self,
callback: TimerCallback,
arguments: Vec<HandleValue<'_>>,
timeout: Duration,
is_interval: IsInterval,
) -> i32
pub fn set_timeout_or_interval( &self, callback: TimerCallback, arguments: Vec<HandleValue<'_>>, timeout: Duration, is_interval: IsInterval, ) -> i32
pub fn clear_timeout_or_interval(&self, handle: i32)
pub fn queue_function_as_microtask(&self, callback: Rc<VoidFunction>)
pub fn is_js_evaluation_allowed(&self, cx: SafeJSContext) -> bool
pub fn create_image_bitmap( &self, image: ImageBitmapSource, options: &ImageBitmapOptions, can_gc: CanGc, ) -> Rc<Promise>
pub fn fire_timer(&self, handle: TimerEventId, can_gc: CanGc)
pub fn resume(&self)
pub fn suspend(&self)
pub fn slow_down_timers(&self)
pub fn speed_up_timers(&self)
fn timer_source(&self) -> TimerSource
sourcepub fn can_continue_running(&self) -> bool
pub fn can_continue_running(&self) -> bool
Returns a boolean indicating whether the event-loop where this global is running on can continue running JS.
sourcepub fn task_canceller(&self, name: TaskSourceName) -> TaskCanceller
pub fn task_canceller(&self, name: TaskSourceName) -> TaskCanceller
Returns the task canceller of this global to ensure that everything is properly cancelled when the global scope is destroyed.
sourcepub fn perform_a_microtask_checkpoint(&self, can_gc: CanGc)
pub fn perform_a_microtask_checkpoint(&self, can_gc: CanGc)
Perform a microtask checkpoint.
sourcepub fn enqueue_microtask(&self, job: Microtask)
pub fn enqueue_microtask(&self, job: Microtask)
Enqueue a microtask for subsequent execution.
sourcepub fn new_script_pair(
&self,
) -> (Box<dyn ScriptChan + Send>, Box<dyn ScriptPort + Send>)
pub fn new_script_pair( &self, ) -> (Box<dyn ScriptChan + Send>, Box<dyn ScriptPort + Send>)
Create a new sender/receiver pair that can be used to implement an on-demand event loop. Used for implementing web APIs that require blocking semantics without resorting to nested event loops.
sourcepub fn microtask_queue(&self) -> &Rc<MicrotaskQueue>
pub fn microtask_queue(&self) -> &Rc<MicrotaskQueue>
Returns the microtask queue of this global.
sourcepub fn process_event(&self, msg: CommonScriptMsg) -> bool
pub fn process_event(&self, msg: CommonScriptMsg) -> bool
Process a single event as if it were the next event in the queue for the event-loop where this global scope is running on. Returns a boolean indicating whether further events should be processed.
pub fn dom_manipulation_task_source(&self) -> DOMManipulationTaskSource
sourcepub fn file_reading_task_source(&self) -> FileReadingTaskSource
pub fn file_reading_task_source(&self) -> FileReadingTaskSource
Channel to send messages to the file reading task source of this of this global scope.
pub fn runtime_handle(&self) -> ParentRuntime
pub fn performance(&self) -> Root<Dom<Performance>>
sourcepub fn performance_timeline_task_source(&self) -> PerformanceTimelineTaskSource
pub fn performance_timeline_task_source(&self) -> PerformanceTimelineTaskSource
Channel to send messages to the performance timeline task source of this global scope.
sourcepub fn supported_performance_entry_types(
&self,
cx: SafeJSContext,
retval: MutableHandleValue<'_>,
)
pub fn supported_performance_entry_types( &self, cx: SafeJSContext, retval: MutableHandleValue<'_>, )
pub fn is_headless(&self) -> bool
pub fn get_user_agent(&self) -> Cow<'static, str>
pub fn get_https_state(&self) -> HttpsState
pub fn set_https_state(&self, https_state: HttpsState)
pub fn is_secure_context(&self) -> bool
sourcepub fn get_csp_list(&self) -> Option<CspList>
pub fn get_csp_list(&self) -> Option<CspList>
pub fn status_code(&self) -> Option<u16>
pub fn wgpu_id_hub(&self) -> Arc<IdentityHub>
pub fn add_gpu_device(&self, device: &GPUDevice)
pub fn remove_gpu_device(&self, device: WebGPUDevice)
pub fn gpu_device_lost( &self, device: WebGPUDevice, reason: DeviceLostReason, msg: String, )
pub fn handle_uncaptured_gpu_error( &self, device: WebGPUDevice, error: Error, can_gc: CanGc, )
pub fn handle_gamepad_event(&self, gamepad_event: GamepadEvent)
sourcefn handle_gamepad_connect(
&self,
_index: usize,
name: String,
axis_bounds: (f64, f64),
button_bounds: (f64, f64),
supported_haptic_effects: GamepadSupportedHapticEffects,
)
fn handle_gamepad_connect( &self, _index: usize, name: String, axis_bounds: (f64, f64), button_bounds: (f64, f64), supported_haptic_effects: GamepadSupportedHapticEffects, )
sourcepub fn handle_gamepad_disconnect(&self, index: usize)
pub fn handle_gamepad_disconnect(&self, index: usize)
pub(crate) fn current_group_label(&self) -> Option<DOMString>
pub(crate) fn push_console_group(&self, group: DOMString)
pub(crate) fn pop_console_group(&self)
pub(crate) fn increment_console_count(&self, label: &DOMString) -> usize
pub(crate) fn reset_console_count(&self, label: &DOMString) -> Result<(), ()>
pub(crate) fn dynamic_module_list(&self) -> RefMut<'_, DynamicModuleList>
pub(crate) fn structured_clone( &self, cx: SafeJSContext, value: HandleValue<'_>, options: RootedTraceableBox<StructuredSerializeOptions>, retval: MutableHandleValue<'_>, ) -> Result<(), Error>
pub(crate) fn fetch<Listener: FetchResponseListener + PreInvoke + Send + 'static>( &self, request_builder: RequestBuilder, context: Arc<Mutex<Listener>>, task_source: NetworkingTaskSource, cancellation_sender: Option<IpcReceiver<()>>, )
pub(crate) fn fetch_with_network_listener<Listener: FetchResponseListener + PreInvoke + Send + 'static>( &self, request_builder: RequestBuilder, network_listener: NetworkListener<Listener>, cancellation_receiver: Option<IpcReceiver<()>>, )
pub fn unminified_js_dir(&self) -> Option<String>
Trait Implementations§
source§impl Castable for GlobalScope
impl Castable for GlobalScope
source§impl DomObject for GlobalScope
impl DomObject for GlobalScope
source§impl HasParent for GlobalScope
impl HasParent for GlobalScope
source§fn as_parent(&self) -> &EventTarget
fn as_parent(&self) -> &EventTarget
This is used in a type assertion to ensure that the source and webidls agree as to what the parent type is
type Parent = EventTarget
source§impl IDLInterface for GlobalScope
impl IDLInterface for GlobalScope
source§impl MallocSizeOf for GlobalScope
impl MallocSizeOf for GlobalScope
source§fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
source§impl MutDomObject for GlobalScope
impl MutDomObject for GlobalScope
source§impl PartialEq for GlobalScope
impl PartialEq for GlobalScope
source§impl ToJSValConvertible for GlobalScope
impl ToJSValConvertible for GlobalScope
source§impl Traceable for GlobalScope
impl Traceable for GlobalScope
impl DerivedFrom<EventTarget> for GlobalScope
impl DerivedFrom<GlobalScope> for DedicatedWorkerGlobalScope
impl DerivedFrom<GlobalScope> for DissimilarOriginWindow
impl DerivedFrom<GlobalScope> for GlobalScope
impl DerivedFrom<GlobalScope> for PaintWorkletGlobalScope
impl DerivedFrom<GlobalScope> for ServiceWorkerGlobalScope
impl DerivedFrom<GlobalScope> for TestWorkletGlobalScope
impl DerivedFrom<GlobalScope> for Window
impl DerivedFrom<GlobalScope> for WorkerGlobalScope
impl DerivedFrom<GlobalScope> for WorkletGlobalScope
impl Eq for GlobalScope
Auto Trait Implementations§
impl !Freeze for GlobalScope
impl !RefUnwindSafe for GlobalScope
impl !Send for GlobalScope
impl !Sync for GlobalScope
impl Unpin for GlobalScope
impl !UnwindSafe for GlobalScope
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.source§impl<T> Filterable for T
impl<T> Filterable for T
source§fn filterable(
self,
filter_name: &'static str,
) -> RequestFilterDataProvider<T, fn(_: DataRequest<'_>) -> bool>
fn filterable( self, filter_name: &'static str, ) -> RequestFilterDataProvider<T, fn(_: DataRequest<'_>) -> bool>
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more