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;
16#[cfg(feature = "gamepad")]
17mod gamepad_delegate;
18#[cfg(feature = "media-gstreamer")]
19mod gstreamer_plugins;
20mod javascript_evaluator;
21mod network_manager;
22mod proxies;
23mod responders;
24mod servo;
25mod servo_delegate;
26mod site_data_manager;
27mod user_content_manager;
28mod webview;
29mod webview_delegate;
30
31// These are Servo's public exports. Everything (apart from a couple exceptions below)
32// should be exported at the root. See <https://github.com/servo/servo/issues/18475>.
33pub use accesskit;
34pub use embedder_traits::user_contents::UserScript;
35pub use embedder_traits::{submit_resource_reader, *};
36pub use image::RgbaImage;
37pub use keyboard_types::{
38    Code, CompositionEvent, CompositionState, Key, KeyState, Location, Modifiers, NamedKey,
39};
40pub use media::{
41    GlApi as MediaGlApi, GlContext as MediaGlContext, NativeDisplay as MediaNativeDisplay,
42};
43// This API should probably not be exposed in this way. Instead there should be a fully
44// fleshed out public domains API if we want to expose it.
45pub use net_traits::pub_domains::is_reg_domain;
46pub use paint::WebRenderDebugOption;
47pub use paint_api::rendering_context::{
48    OffscreenRenderingContext, RenderingContext, SoftwareRenderingContext, WindowRenderingContext,
49};
50// This should be replaced with an API on ServoBuilder.
51// See <https://github.com/servo/servo/issues/40950>.
52pub use resources;
53pub use servo_base::generic_channel::GenericSender;
54pub use servo_base::id::WebViewId;
55pub use servo_config::opts::{DiagnosticsLogging, Opts, OutputOptions};
56pub use servo_config::prefs::{PrefValue, Preferences, UserAgentPlatform};
57pub use servo_config::{opts, pref, prefs};
58pub use servo_geometry::{
59    DeviceIndependentIntRect, DeviceIndependentPixel, convert_rect_to_css_pixel,
60};
61pub use servo_url::ServoUrl;
62pub use style::Zero;
63pub use style_traits::CSSPixel;
64pub use webrender_api::units::{
65    DeviceIntPoint, DeviceIntRect, DeviceIntSize, DevicePixel, DevicePoint, DeviceVector2D,
66};
67
68pub use crate::clipboard_delegate::{ClipboardDelegate, StringRequest};
69#[cfg(feature = "gamepad")]
70pub use crate::gamepad_delegate::{
71    GamepadDelegate, GamepadHapticEffectRequest, GamepadHapticEffectRequestType,
72};
73pub use crate::network_manager::{CacheEntry, NetworkManager};
74pub use crate::servo::{Servo, ServoBuilder, run_content_process};
75pub use crate::servo_delegate::{ServoDelegate, ServoError};
76pub use crate::site_data_manager::{SiteData, SiteDataManager, StorageType};
77pub use crate::user_content_manager::UserContentManager;
78pub use crate::webview::{WebView, WebViewBuilder};
79pub use crate::webview_delegate::{
80    AlertDialog, AllowOrDenyRequest, AuthenticationRequest, BluetoothDeviceSelectionRequest,
81    ColorPicker, ConfirmDialog, ContextMenu, CreateNewWebViewRequest, EmbedderControl, FilePicker,
82    InputMethodControl, NavigationRequest, PermissionRequest, PromptDialog, SelectElement,
83    SimpleDialog, WebResourceLoad, WebViewDelegate,
84};
85
86#[cfg(feature = "webxr")]
87pub mod webxr {
88    #[cfg(not(any(target_os = "android", target_env = "ohos")))]
89    pub use webxr::glwindow::{GlWindow, GlWindowDiscovery, GlWindowMode, GlWindowRenderTarget};
90    #[cfg(not(any(target_os = "android", target_env = "ohos")))]
91    pub use webxr::headless::HeadlessMockDiscovery;
92    #[cfg(target_os = "windows")]
93    pub use webxr::openxr::{AppInfo as OpenXrAppInfo, OpenXrDiscovery};
94    pub use webxr::{Discovery, MainThreadRegistry, WebXrRegistry};
95}
96
97// TODO: The protocol handler interface needs to be cleaned and simplified.
98pub mod protocol_handler {
99    pub use net::fetch::methods::{DoneChannel, FetchContext};
100    pub use net::filemanager_thread::FILE_CHUNK_SIZE;
101    pub use net::protocols::{ProtocolHandler, ProtocolRegistry};
102    pub use net_traits::filemanager_thread::RelativePos;
103    pub use net_traits::http_status::HttpStatus;
104    pub use net_traits::request::Request;
105    pub use net_traits::response::{Response, ResponseBody};
106    pub use net_traits::{NetworkError, ResourceFetchTiming};
107
108    pub use crate::webview_delegate::ProtocolHandlerRegistration;
109}
110
111// We need to reference this crate, in order for the linker not to remove it.
112#[cfg(all(feature = "baked-in-resources", not(target_env = "ohos")))]
113use servo_default_resources as _;