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};
43pub use net_traits::CookieSource;
44// This API should probably not be exposed in this way. Instead there should be a fully
45// fleshed out public domains API if we want to expose it.
46pub use net_traits::pub_domains::is_reg_domain;
47pub use paint::WebRenderDebugOption;
48pub use paint_api::rendering_context::{
49    OffscreenRenderingContext, RenderingContext, SoftwareRenderingContext, WindowRenderingContext,
50};
51// Expose our profile traits for servoshell, so we can instrument code there, but don't
52// add it as an official API.
53#[doc(hidden)]
54pub use profile_traits;
55// This should be replaced with an API on ServoBuilder.
56// See <https://github.com/servo/servo/issues/40950>.
57pub use resources;
58pub use servo_base::generic_channel::GenericSender;
59pub use servo_base::id::WebViewId;
60pub use servo_config::opts::{DiagnosticsLogging, Opts, OutputOptions};
61pub use servo_config::prefs::{PrefValue, Preferences, UserAgentPlatform};
62pub use servo_config::{opts, pref, prefs};
63pub use servo_geometry::{
64    DeviceIndependentIntRect, DeviceIndependentPixel, convert_rect_to_css_pixel,
65};
66#[doc(hidden)]
67pub use servo_tracing;
68pub use servo_url::ServoUrl;
69pub use style::Zero;
70pub use style_traits::CSSPixel;
71pub use webrender_api::units::{
72    DeviceIntPoint, DeviceIntRect, DeviceIntSize, DevicePixel, DevicePoint, DeviceVector2D,
73};
74
75pub use crate::clipboard_delegate::{ClipboardDelegate, StringRequest};
76#[cfg(feature = "gamepad")]
77pub use crate::gamepad_delegate::{
78    GamepadDelegate, GamepadHapticEffectRequest, GamepadHapticEffectRequestType,
79};
80pub use crate::network_manager::{CacheEntry, NetworkManager};
81pub use crate::servo::{Servo, ServoBuilder, run_content_process};
82pub use crate::servo_delegate::{ServoDelegate, ServoError};
83pub use crate::site_data_manager::{SiteData, SiteDataManager, StorageType};
84pub use crate::user_content_manager::UserContentManager;
85pub use crate::webview::{WebView, WebViewBuilder};
86pub use crate::webview_delegate::{
87    AlertDialog, AllowOrDenyRequest, AuthenticationRequest, BluetoothDeviceSelectionRequest,
88    ColorPicker, ConfirmDialog, ContextMenu, CreateNewWebViewRequest, EmbedderControl, FilePicker,
89    InputMethodControl, NavigationRequest, PermissionRequest, PromptDialog, SelectElement,
90    SimpleDialog, WebResourceLoad, WebViewDelegate,
91};
92
93#[cfg(feature = "webxr")]
94pub mod webxr {
95    #[cfg(not(any(target_os = "android", target_env = "ohos")))]
96    pub use webxr::glwindow::{GlWindow, GlWindowDiscovery, GlWindowMode, GlWindowRenderTarget};
97    #[cfg(not(any(target_os = "android", target_env = "ohos")))]
98    pub use webxr::headless::HeadlessMockDiscovery;
99    #[cfg(target_os = "windows")]
100    pub use webxr::openxr::{AppInfo as OpenXrAppInfo, OpenXrDiscovery};
101    pub use webxr::{Discovery, MainThreadRegistry, WebXrRegistry};
102}
103
104// TODO: The protocol handler interface needs to be cleaned and simplified.
105pub mod protocol_handler {
106    pub use net::fetch::methods::{DoneChannel, FetchContext};
107    pub use net::filemanager_thread::FILE_CHUNK_SIZE;
108    pub use net::protocols::{ProtocolHandler, ProtocolRegistry};
109    pub use net_traits::filemanager_thread::RelativePos;
110    pub use net_traits::http_status::HttpStatus;
111    pub use net_traits::request::Request;
112    pub use net_traits::response::{Response, ResponseBody};
113    pub use net_traits::{NetworkError, ResourceFetchTiming};
114
115    pub use crate::webview_delegate::ProtocolHandlerRegistration;
116}
117
118// We need to reference this crate, in order for the linker not to remove it.
119#[cfg(all(feature = "baked-in-resources", not(target_env = "ohos")))]
120use servo_default_resources as _;