Skip to main content

servo_constellation/
embedder.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
5use embedder_traits::{
6    InputEventOutcome, JSValue, JavaScriptEvaluationError, JavaScriptEvaluationId,
7    MediaSessionEvent, NewWebViewDetails, TraversalId,
8};
9use servo_base::generic_channel::GenericSender;
10use servo_base::id::{PipelineId, WebViewId};
11use servo_url::ServoUrl;
12
13/// Messages sent from the `Constellation` to the embedder.
14pub enum ConstellationToEmbedderMsg {
15    /// Informs the embedder that the constellation has completed shutdown.
16    /// Required because the constellation can have pending calls to make
17    /// (e.g. SetFrameTree) at the time that we send it an ExitMsg.
18    ShutdownComplete,
19    /// Report a complete sampled profile
20    ReportProfile(Vec<u8>),
21    /// All webviews lost focus for keyboard events.
22    WebViewBlurred,
23    /// A history traversal operation completed.
24    HistoryTraversalComplete(WebViewId, TraversalId),
25    /// Notifies the embedder about media session events
26    /// (i.e. when there is metadata for the active media session, playback state changes...).
27    MediaSessionEvent(WebViewId, MediaSessionEvent),
28    /// A pipeline panicked. First string is the reason, second one is the backtrace.
29    Panic(WebViewId, String, Option<String>),
30    /// A webview potentially gained focus for keyboard events.
31    /// If the boolean value is false, the webiew could not be focused.
32    WebViewFocused(WebViewId, bool),
33    /// Inform the embedding layer that a particular `InputEvent` was handled by Servo
34    /// and the embedder can continue processing it, if necessary.
35    InputEventsHandled(WebViewId, Vec<InputEventOutcome>),
36    /// A webview was destroyed.
37    WebViewClosed(WebViewId),
38    /// Inform the embedding layer that a JavaScript evaluation has
39    /// finished with the given result.
40    FinishJavaScriptEvaluation(
41        JavaScriptEvaluationId,
42        Result<JSValue, JavaScriptEvaluationError>,
43    ),
44    /// Whether or not to allow script to open a new tab/browser
45    AllowOpeningWebView(WebViewId, GenericSender<Option<NewWebViewDetails>>),
46    /// Whether or not to allow a pipeline to load a url.
47    AllowNavigationRequest(WebViewId, PipelineId, ServoUrl),
48    /// The history state has changed.
49    HistoryChanged(WebViewId, Vec<ServoUrl>, usize),
50}