servo/components/script/lib.rs
webbeef 139774e6b5
Add an about:memory page (#35728)
This patch exposes a servo internal DOM API that is only made available to about:
pages on the navigator object to request memory reports. The about:memory page itself is
loaded like other html resources (eg. bad cert, net error) and makes use of this new API.

On the implementation side, notable changes:
- components/script/routed_promise.rs abstracts the setup used to fulfill a promise when the
  work needs to be routed through the constellation. The goal is to migrate other similar
  promise APIs in followup (eg. dom/webgpu/gpu.rs, bluetooth.rs).
- a new message is added to request a report from the memory reporter, and the memory reporter
  creates a json representation of the set of memory reports.
- the post-processing of memory reports is done in Javascript in the about-memory.html page,
  providing the same results as the current Rust code that outputs to stdout. We can decide
  later if we want to remove the current output.

Signed-off-by: webbeef <me@webbeef.org>
2025-03-07 05:25:08 +00:00

93 lines
2.5 KiB
Rust

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
#![cfg_attr(crown, feature(register_tool))]
#![deny(unsafe_code)]
#![doc = "The script crate contains all matters DOM."]
// Register the linter `crown`, which is the Servo-specific linter for the script
// crate. Issue a warning if `crown` is not being used to compile, but not when
// building rustdoc or running clippy.
#![cfg_attr(crown, register_tool(crown))]
#![cfg_attr(any(doc, clippy), allow(unknown_lints))]
#![deny(crown_is_not_used)]
// These are used a lot so let's keep them for now
#[macro_use]
extern crate js;
#[macro_use]
extern crate jstraceable_derive;
#[macro_use]
extern crate log;
#[macro_use]
extern crate malloc_size_of_derive;
#[macro_use]
extern crate servo_atoms;
mod animation_timeline;
mod animations;
#[macro_use]
mod task;
mod body;
pub(crate) mod clipboard_provider;
pub(crate) mod conversions;
mod devtools;
pub(crate) mod document_loader;
#[macro_use]
mod dom;
mod canvas_context;
mod canvas_state;
pub(crate) mod fetch;
mod init;
mod layout_image;
pub(crate) mod document_collection;
pub(crate) mod iframe_collection;
pub mod layout_dom;
mod mem;
#[allow(unsafe_code)]
pub(crate) mod messaging;
mod microtask;
mod navigation;
mod network_listener;
#[allow(dead_code)]
mod realms;
mod routed_promise;
#[allow(dead_code)]
mod script_module;
pub(crate) mod script_runtime;
#[allow(unsafe_code)]
pub(crate) mod script_thread;
pub(crate) mod security_manager;
pub(crate) mod serviceworker_manager;
mod stylesheet_loader;
mod stylesheet_set;
mod task_manager;
mod task_queue;
mod task_source;
pub mod test;
#[allow(dead_code)]
pub mod textinput;
mod timers;
mod webdriver_handlers;
mod window_named_properties;
mod unminify;
mod drag_data_store;
mod links;
mod xpath;
pub use init::init;
pub use script_runtime::JSEngineSetup;
pub use script_thread::ScriptThread;
pub use serviceworker_manager::ServiceWorkerManager;
pub(crate) use crate::dom::bindings::codegen::DomTypeHolder::DomTypeHolder;
pub(crate) use crate::dom::bindings::codegen::DomTypes::DomTypes;
// These trait exports are public, because they are used in the DOM bindings.
// Since they are used in derive macros,
// it is useful that they are accessible at the root of the crate.
pub(crate) use crate::dom::bindings::inheritance::HasParent;
pub(crate) use crate::dom::bindings::reflector::{DomObject, MutDomObject, Reflector};
pub(crate) use crate::dom::bindings::trace::{CustomTraceable, JSTraceable};