aboutsummaryrefslogtreecommitdiffstats
path: root/components/shared/compositing/constellation_msg.rs
diff options
context:
space:
mode:
authorMartin Robinson <mrobinson@igalia.com>2023-10-05 19:47:39 +0200
committerMartin Robinson <mrobinson@igalia.com>2023-11-03 15:38:18 +0000
commitf4d3af296c05260dfbb3deea4f8fa400cb6887d3 (patch)
tree169db2cc68e01a755b30500dd525f1a2ec2da861 /components/shared/compositing/constellation_msg.rs
parent863529d9622c68f0a9535225237eb5e5c5b8c757 (diff)
downloadservo-f4d3af296c05260dfbb3deea4f8fa400cb6887d3.tar.gz
servo-f4d3af296c05260dfbb3deea4f8fa400cb6887d3.zip
Move `*_traits` and other shared types to `shared`
This is the start of the organization of types that are in their own crates in order to break dependency cycles between other crates. The idea here is that putting these packages into their own directory is the first step toward cleaning them up. They have grown organically and it is difficult to explain to new folks where to put new shared types. Many of these crates contain more than traits or don't contain traits at all. Notably, `script_traits` isn't touched because it is vendored from Gecko. Eventually this will move to `third_party`.
Diffstat (limited to 'components/shared/compositing/constellation_msg.rs')
-rw-r--r--components/shared/compositing/constellation_msg.rs120
1 files changed, 120 insertions, 0 deletions
diff --git a/components/shared/compositing/constellation_msg.rs b/components/shared/compositing/constellation_msg.rs
new file mode 100644
index 00000000000..49b7353adfb
--- /dev/null
+++ b/components/shared/compositing/constellation_msg.rs
@@ -0,0 +1,120 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
+
+use std::collections::HashMap;
+use std::fmt;
+use std::time::Duration;
+
+use embedder_traits::Cursor;
+use gfx_traits::Epoch;
+use ipc_channel::ipc::IpcSender;
+use keyboard_types::KeyboardEvent;
+use msg::constellation_msg::{
+ BrowsingContextId, PipelineId, TopLevelBrowsingContextId, TraversalDirection,
+};
+use script_traits::{
+ AnimationTickType, CompositorEvent, LogEntry, MediaSessionActionType, WebDriverCommandMsg,
+ WindowSizeData, WindowSizeType,
+};
+use servo_url::ServoUrl;
+
+/// Messages to the constellation.
+pub enum ConstellationMsg {
+ /// Exit the constellation.
+ Exit,
+ /// Request that the constellation send the BrowsingContextId corresponding to the document
+ /// with the provided pipeline id
+ GetBrowsingContext(PipelineId, IpcSender<Option<BrowsingContextId>>),
+ /// Request that the constellation send the current pipeline id for the provided
+ /// browsing context id, over a provided channel.
+ GetPipeline(BrowsingContextId, IpcSender<Option<PipelineId>>),
+ /// Request that the constellation send the current focused top-level browsing context id,
+ /// over a provided channel.
+ GetFocusTopLevelBrowsingContext(IpcSender<Option<TopLevelBrowsingContextId>>),
+ /// Query the constellation to see if the current compositor output is stable
+ IsReadyToSaveImage(HashMap<PipelineId, Epoch>),
+ /// Inform the constellation of a key event.
+ Keyboard(KeyboardEvent),
+ /// Whether to allow script to navigate.
+ AllowNavigationResponse(PipelineId, bool),
+ /// Request to load a page.
+ LoadUrl(TopLevelBrowsingContextId, ServoUrl),
+ /// Clear the network cache.
+ ClearCache,
+ /// Request to traverse the joint session history of the provided browsing context.
+ TraverseHistory(TopLevelBrowsingContextId, TraversalDirection),
+ /// Inform the constellation of a window being resized.
+ WindowSize(TopLevelBrowsingContextId, WindowSizeData, WindowSizeType),
+ /// Requests that the constellation instruct layout to begin a new tick of the animation.
+ TickAnimation(PipelineId, AnimationTickType),
+ /// Dispatch a webdriver command
+ WebDriverCommand(WebDriverCommandMsg),
+ /// Reload a top-level browsing context.
+ Reload(TopLevelBrowsingContextId),
+ /// A log entry, with the top-level browsing context id and thread name
+ LogEntry(Option<TopLevelBrowsingContextId>, Option<String>, LogEntry),
+ /// Create a new top level browsing context.
+ NewBrowser(ServoUrl, TopLevelBrowsingContextId),
+ /// Close a top level browsing context.
+ CloseBrowser(TopLevelBrowsingContextId),
+ /// Panic a top level browsing context.
+ SendError(Option<TopLevelBrowsingContextId>, String),
+ /// Make browser visible.
+ SelectBrowser(TopLevelBrowsingContextId),
+ /// Forward an event to the script task of the given pipeline.
+ ForwardEvent(PipelineId, CompositorEvent),
+ /// Requesting a change to the onscreen cursor.
+ SetCursor(Cursor),
+ /// Enable the sampling profiler, with a given sampling rate and max total sampling duration.
+ EnableProfiler(Duration, Duration),
+ /// Disable the sampling profiler.
+ DisableProfiler,
+ /// Request to exit from fullscreen mode
+ ExitFullScreen(TopLevelBrowsingContextId),
+ /// Media session action.
+ MediaSessionAction(MediaSessionActionType),
+ /// Toggle browser visibility.
+ ChangeBrowserVisibility(TopLevelBrowsingContextId, bool),
+ /// Virtual keyboard was dismissed
+ IMEDismissed,
+ /// Compositing done, but external code needs to present.
+ ReadyToPresent(TopLevelBrowsingContextId),
+}
+
+impl fmt::Debug for ConstellationMsg {
+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
+ use self::ConstellationMsg::*;
+ let variant = match *self {
+ Exit => "Exit",
+ GetBrowsingContext(..) => "GetBrowsingContext",
+ GetPipeline(..) => "GetPipeline",
+ GetFocusTopLevelBrowsingContext(..) => "GetFocusTopLevelBrowsingContext",
+ IsReadyToSaveImage(..) => "IsReadyToSaveImage",
+ Keyboard(..) => "Keyboard",
+ AllowNavigationResponse(..) => "AllowNavigationResponse",
+ LoadUrl(..) => "LoadUrl",
+ TraverseHistory(..) => "TraverseHistory",
+ WindowSize(..) => "WindowSize",
+ TickAnimation(..) => "TickAnimation",
+ WebDriverCommand(..) => "WebDriverCommand",
+ Reload(..) => "Reload",
+ LogEntry(..) => "LogEntry",
+ NewBrowser(..) => "NewBrowser",
+ CloseBrowser(..) => "CloseBrowser",
+ SendError(..) => "SendError",
+ SelectBrowser(..) => "SelectBrowser",
+ ForwardEvent(..) => "ForwardEvent",
+ SetCursor(..) => "SetCursor",
+ EnableProfiler(..) => "EnableProfiler",
+ DisableProfiler => "DisableProfiler",
+ ExitFullScreen(..) => "ExitFullScreen",
+ MediaSessionAction(..) => "MediaSessionAction",
+ ChangeBrowserVisibility(..) => "ChangeBrowserVisibility",
+ IMEDismissed => "IMEDismissed",
+ ClearCache => "ClearCache",
+ ReadyToPresent(..) => "ReadyToPresent",
+ };
+ write!(formatter, "ConstellationMsg::{}", variant)
+ }
+}