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