servo/
lib.rs

1/* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4
5//! Servo, the mighty web browser engine from the future.
6//!
7//! This is a very simple library that wires all of Servo's components together as
8//! type `Servo`, along with a Webview implementation, `WebView` to create a working
9//! web browser.
10//!
11//! The `Servo` type is responsible for configuring a `Constellation`, which does the
12//! heavy lifting of coordinating all of Servo's internal subsystems, including the
13//! `ScriptThread` and the `LayoutThread`, as well maintains the navigation context.
14
15mod clipboard_delegate;
16mod javascript_evaluator;
17mod network_manager;
18mod proxies;
19mod responders;
20mod servo;
21mod servo_delegate;
22mod site_data_manager;
23mod user_content_manager;
24mod webview;
25mod webview_delegate;
26
27// These are Servo's public exports. Everything (apart from a couple exceptions below)
28// should be exported at the root. See <https://github.com/servo/servo/issues/18475>.
29pub use accesskit;
30pub use base::generic_channel::GenericSender;
31pub use base::id::WebViewId;
32pub use embedder_traits::user_contents::UserScript;
33pub use embedder_traits::*;
34pub use image::RgbaImage;
35pub use keyboard_types::{
36    Code, CompositionEvent, CompositionState, Key, KeyState, Location, Modifiers, NamedKey,
37};
38pub use media::{
39    GlApi as MediaGlApi, GlContext as MediaGlContext, NativeDisplay as MediaNativeDisplay,
40};
41// This API should probably not be exposed in this way. Instead there should be a fully
42// fleshed out public domains API if we want to expose it.
43pub use net_traits::pub_domains::is_reg_domain;
44pub use paint::WebRenderDebugOption;
45pub use paint_api::rendering_context::{
46    OffscreenRenderingContext, RenderingContext, SoftwareRenderingContext, WindowRenderingContext,
47};
48// This should be replaced with an API on ServoBuilder.
49// See <https://github.com/servo/servo/issues/40950>.
50pub use resources;
51pub use servo_config::opts::{DiagnosticsLogging, Opts, OutputOptions};
52pub use servo_config::prefs::{PrefValue, Preferences, UserAgentPlatform};
53pub use servo_config::{opts, pref, prefs};
54pub use servo_geometry::{
55    DeviceIndependentIntRect, DeviceIndependentPixel, convert_rect_to_css_pixel,
56};
57pub use servo_url::ServoUrl;
58pub use style::Zero;
59pub use style_traits::CSSPixel;
60pub use webrender_api::units::{
61    DeviceIntPoint, DeviceIntRect, DeviceIntSize, DevicePixel, DevicePoint, DeviceVector2D,
62};
63
64pub use crate::network_manager::{CacheEntry, NetworkManager};
65pub use crate::servo::{Servo, ServoBuilder, run_content_process};
66pub use crate::servo_delegate::{ServoDelegate, ServoError};
67pub use crate::site_data_manager::{SiteData, SiteDataManager, StorageType};
68pub use crate::user_content_manager::UserContentManager;
69pub use crate::webview::{WebView, WebViewBuilder};
70pub use crate::webview_delegate::{
71    AlertDialog, AllowOrDenyRequest, AuthenticationRequest, ColorPicker, ConfirmDialog,
72    ContextMenu, CreateNewWebViewRequest, EmbedderControl, FilePicker, InputMethodControl,
73    NavigationRequest, PermissionRequest, PromptDialog, SelectElement, SimpleDialog,
74    WebResourceLoad, WebViewDelegate,
75};
76
77#[cfg(feature = "webxr")]
78pub mod webxr {
79    #[cfg(not(any(target_os = "android", target_env = "ohos")))]
80    pub use webxr::glwindow::{GlWindow, GlWindowDiscovery, GlWindowMode, GlWindowRenderTarget};
81    #[cfg(not(any(target_os = "android", target_env = "ohos")))]
82    pub use webxr::headless::HeadlessMockDiscovery;
83    #[cfg(target_os = "windows")]
84    pub use webxr::openxr::{AppInfo as OpenXrAppInfo, OpenXrDiscovery};
85    pub use webxr::{Discovery, MainThreadRegistry, WebXrRegistry};
86}
87
88// TODO: The protocol handler interface needs to be cleaned and simplified.
89pub mod protocol_handler {
90    pub use net::fetch::methods::{DoneChannel, FetchContext};
91    pub use net::filemanager_thread::FILE_CHUNK_SIZE;
92    pub use net::protocols::{ProtocolHandler, ProtocolRegistry};
93    pub use net_traits::filemanager_thread::RelativePos;
94    pub use net_traits::http_status::HttpStatus;
95    pub use net_traits::request::Request;
96    pub use net_traits::response::{Response, ResponseBody};
97    pub use net_traits::{NetworkError, ResourceFetchTiming};
98
99    pub use crate::webview_delegate::ProtocolHandlerRegistration;
100}