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