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