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    /// All `WebView`s lost focus for keyboard events.
20    WebViewBlurred,
21    /// A history traversal operation completed.
22    HistoryTraversalComplete(WebViewId, TraversalId),
23    /// Notifies the embedder about media session events
24    /// (i.e. when there is metadata for the active media session, playback state changes...).
25    MediaSessionEvent(WebViewId, MediaSessionEvent),
26    /// A pipeline panicked. First string is the reason, second one is the backtrace.
27    Panic(WebViewId, String, Option<String>),
28    /// A `WebView` potentially gained focus for keyboard events.
29    /// If the boolean value is false, the `WebView` could not be focused.
30    WebViewFocused(WebViewId, bool),
31    /// Inform the embedding layer that a particular `InputEvent` was handled by Servo
32    /// and the embedder can continue processing it, if necessary.
33    InputEventsHandled(WebViewId, Vec<InputEventOutcome>),
34    /// A `WebView` was destroyed.
35    WebViewClosed(WebViewId),
36    /// Inform the embedding layer that a JavaScript evaluation has
37    /// finished with the given result.
38    FinishJavaScriptEvaluation(
39        JavaScriptEvaluationId,
40        Result<JSValue, JavaScriptEvaluationError>,
41    ),
42    /// Whether or not to allow script to open a new tab/browser
43    AllowOpeningWebView(WebViewId, GenericSender<Option<NewWebViewDetails>>),
44    /// Whether or not to allow a pipeline to load a url.
45    AllowNavigationRequest(WebViewId, PipelineId, ServoUrl),
46    /// The history state has changed.
47    HistoryChanged(WebViewId, Vec<ServoUrl>, usize),
48}