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