--- original +++ modified @@ -11,8 +11,9 @@ use devtools_traits::{DevtoolScriptControlMsg, ScriptToDevtoolsControlMsg, WorkerId}; use embedder_traits::user_contents::UserContentManagerId; use embedder_traits::{ - AnimationState, FocusSequenceNumber, JSValue, JavaScriptEvaluationError, - JavaScriptEvaluationId, MediaSessionEvent, ScriptToEmbedderChan, Theme, ViewportDetails, + AnimationState, EmbedderControlId, EmbedderControlResponse, FocusSequenceNumber, + InputEventAndId, JSValue, JavaScriptEvaluationError, JavaScriptEvaluationId, MediaSessionEvent, + ScriptToEmbedderChan, Theme, ViewportDetails, }; use encoding_rs::Encoding; use euclid::default::Size2D as UntypedSize2D; @@ -35,6 +36,7 @@ MessagePortRouterId, PipelineId, ScriptEventLoopId, ServiceWorkerId, ServiceWorkerRegistrationId, WebViewId, }; +use servo_config::pref_util::PrefValue; use servo_url::{ImmutableOrigin, OriginSnapshot, ServoUrl}; use storage_traits::StorageThreads; use storage_traits::webstorage_thread::WebStorageType; @@ -44,7 +46,8 @@ use crate::structured_data::{BroadcastChannelMsg, StructuredSerializedData}; use crate::{ - LogEntry, MessagePortMsg, PortMessageTask, PortTransferInfo, TraversalDirection, WindowSizeType, + EmbeddedWebViewEventType, LogEntry, MessagePortMsg, PortMessageTask, PortTransferInfo, + TraversalDirection, WindowSizeType, }; pub type ScriptToConstellationSender = @@ -407,11 +410,14 @@ pub opener_webview_id: WebViewId, /// The pipeline opener browsing context. pub opener_pipeline_id: PipelineId, - /// Sender for the constellation’s response to our request. + /// Sender for the constellation's response to our request. pub response_sender: GenericSender>, + /// The target URL that window.open() was called with. + /// This is needed because load_data.url is always about:blank for new browsing contexts. + pub target_url: Option, } -/// Constellation’s response to auxiliary browsing context creation requests. +/// Constellation's response to auxiliary browsing context creation requests. #[derive(Debug, Deserialize, Serialize)] pub struct AuxiliaryWebViewCreationResponse { /// The new webview ID. @@ -422,6 +428,38 @@ pub user_content_manager_id: Option, } +/// Request to create an embedded webview in an iframe with the "embed" attribute. +#[derive(Debug, Deserialize, Serialize)] +pub struct EmbeddedWebViewCreationRequest { + /// Load data containing the url to load + pub load_data: LoadData, + /// The pipeline ID of the parent document containing the iframe. + pub parent_pipeline_id: PipelineId, + /// The webview ID of the parent document. + pub parent_webview_id: WebViewId, + /// The initial viewport size for this embedded webview. + pub viewport_details: ViewportDetails, + /// The [`Theme`] to use within this embedded webview. + pub theme: Theme, + /// Whether this embedded webview should never receive focus (hidefocus attribute). + pub hide_focus: bool, + /// Sender for the constellation's response to our request. + pub response_sender: IpcSender>, +} + +/// Constellation's response to embedded webview creation requests. +#[derive(Debug, Deserialize, Serialize)] +pub struct EmbeddedWebViewCreationResponse { + /// The new webview ID for the embedded webview. + pub new_webview_id: WebViewId, + /// The new browsing context ID for the embedded webview. + pub new_browsing_context_id: BrowsingContextId, + /// The new pipeline ID for the embedded webview's initial document. + pub new_pipeline_id: PipelineId, + /// The [`UserContentManagerId`] for this new auxiliary browsing context. + pub user_content_manager_id: Option, +} + /// Specifies the information required to load an iframe. #[derive(Debug, Deserialize, Serialize)] pub struct IFrameLoadInfo { @@ -541,6 +579,90 @@ NoLongerActive, } +#[derive(Deserialize, Serialize)] +pub enum AtProtoRequest { + /// User, Password + Login(String, String), + Logout, + Current, + /// Authorize an origin for write operations via at:// protocol. + AuthorizeOrigin(String), + /// Revoke an origin's write authorization. + RevokeOrigin(String), + /// Get the list of authorized origins. + GetAuthorizedOrigins, +} + +/// Data returned by com.atproto.server.createSession xrpc calls. +#[derive(Clone, Debug, Deserialize, Serialize)] +#[serde(rename_all = "camelCase")] +pub struct AtProtoNewSession { + pub access_jwt: String, + pub refresh_jwt: String, + pub handle: String, + pub did: String, + pub email: String, + pub email_confirmed: bool, + #[serde(default)] + pub email_auth_factor: bool, + pub active: bool, + pub status: Option, +} + +/// Error data for atproto calls that return a 400 error. +#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)] +pub enum AtProtoErrorKind { + InvalidRequest, + ExpiredToken, + InvalidToken, + AccountTakedown, + AuthFactorTokenRequired, +} + +#[derive(Clone, Debug, Deserialize, Serialize)] +pub struct AtProtoError { + pub error: AtProtoErrorKind, + pub message: String, +} + +/// Data returned by com.atproto.server.getSession xrpc calls. +#[derive(Clone, Debug, Deserialize, Serialize)] +#[serde(rename_all = "camelCase")] +pub struct AtProtoCurrentSession { + pub handle: String, + pub did: String, + pub email: String, + pub email_confirmed: bool, + pub email_auth_factor: bool, + pub active: bool, + pub status: Option, +} + +/// Data returned by com.atproto.server.refreshSession xrpc calls. +#[derive(Clone, Debug, Deserialize, Serialize)] +#[serde(rename_all = "camelCase")] +pub struct AtProtoRefreshSession { + pub access_jwt: String, + pub refresh_jwt: String, + pub handle: String, + pub did: String, + pub active: bool, + pub status: Option, +} + +#[derive(Debug, Deserialize, Serialize)] +pub enum AtProtoResult { + NewSession(AtProtoNewSession, ServoUrl), // (session, endpoint_url) + CurrentSession(AtProtoCurrentSession), + RefreshRequired, + Logout, + /// List of authorized origins for write operations. + AuthorizedOrigins(Vec), + /// Origin authorization was updated successfully. + OriginUpdated, + Error, +} + /// Messages from the script to the constellation. #[derive(Deserialize, IntoStaticStr, Serialize)] pub enum ScriptToConstellationMessage { @@ -585,6 +707,10 @@ NewBroadcastChannelNameInRouter(BroadcastChannelRouterId, String, ImmutableOrigin), /// A global stopped managing broadcast channels for a given channel-name. RemoveBroadcastChannelNameInRouter(BroadcastChannelRouterId, String, ImmutableOrigin), + /// Register this script thread as having an embedder error listener. + RegisterEmbedderErrorListener(ScriptEventLoopId), + /// Unregister this script thread from embedder error listeners. + UnregisterEmbedderErrorListener(ScriptEventLoopId), /// Broadcast a message to all same-origin broadcast channels, /// excluding the source of the broadcast. ScheduleBroadcast(BroadcastChannelRouterId, BroadcastChannelMsg), @@ -597,6 +723,9 @@ Option, Option, ), + /// Broadcast a preference change to all script threads. + /// Used when preferences are changed from JavaScript via `navigator.servo`. + BroadcastPreferenceChange(String, PrefValue), /// Indicates whether this pipeline is currently running animations. ChangeRunningAnimationsState(AnimationState), /// Requests that a new 2D canvas thread be created. (This is done in the constellation because @@ -677,6 +806,10 @@ ScriptNewIFrame(IFrameLoadInfoWithData), /// Script has opened a new auxiliary browsing context. CreateAuxiliaryWebView(AuxiliaryWebViewCreationRequest), + /// Script has created an embedded webview in an iframe with the "embed" attribute. + CreateEmbeddedWebView(EmbeddedWebViewCreationRequest), + /// An embedded WebView was removed from a DOM tree. + RemoveEmbeddedWebView(WebViewId), /// Mark a new document as active ActivateDocument, /// Set the document state for a pipeline (used by screenshot / reftests) @@ -726,6 +859,79 @@ RespondToScreenshotReadinessRequest(ScreenshotReadinessResponse), /// Request the constellation to force garbage collection in all `ScriptThread`'s. TriggerGarbageCollection, + /// Notification from an embedded webview to be forwarded to its parent iframe element. + /// The Constellation will forward this to the parent pipeline's script thread. + EmbeddedWebViewNotification(EmbeddedWebViewEventType), + /// Load a URL in an embedded webview (only valid for embedded webview pipelines). + EmbeddedWebViewLoad(WebViewId, ServoUrl), + /// Reload an embedded webview (only valid for embedded webview pipelines). + EmbeddedWebViewReload(WebViewId), + /// Traverse history in an embedded webview (only valid for embedded webview pipelines). + /// The TraversalId is used to track completion of the traversal. + EmbeddedWebViewTraverseHistory(WebViewId, TraversalDirection, embedder_traits::TraversalId), + /// Take a screenshot of an embedded webview, encoding it to the specified format. + EmbeddedWebViewTakeScreenshot( + WebViewId, + embedder_traits::EmbeddedWebViewScreenshotRequest, + GenericCallback< + Result< + embedder_traits::EmbeddedWebViewScreenshotResult, + embedder_traits::EmbeddedWebViewScreenshotError, + >, + >, + ), + /// Send a media session action to the active media session in an embedded webview. + EmbeddedWebViewMediaSessionAction(embedder_traits::MediaSessionActionType), + /// Forward an input event to an embedded webview after the parent's DOM hit testing + /// determined that the event target is an embedded iframe element. + ForwardEventToEmbeddedWebView(WebViewId, InputEventAndId), + /// Inject an input event to the webview that currently has an active IME input. + /// Used by the virtual keyboard to send keystrokes to the focused input field. + InjectInputToActiveIme(InputEventAndId), + /// Set the active IME webview for virtual keyboard input routing. + /// Used when the system webview (non-embedded) shows an input method control. + SetActiveImeWebView(WebViewId), + /// Clear the active IME webview when the system webview hides an input method control. + ClearActiveImeWebView(WebViewId), + /// Response from parent iframe to an embedded webview's control request. + /// The parent shell sends this after the user interacts with a custom control UI + /// (e.g., select dropdown, color picker, file dialog). + EmbeddedWebViewControlResponse(EmbedderControlId, EmbedderControlResponse), + /// Set page zoom for an embedded webview. + EmbeddedWebViewSetPageZoom(WebViewId, f32), + /// Request the constellation to start the P2P pairing service. + PairingStart(GenericCallback>), + /// Request the constellation to stop the P2P pairing service. + PairingStop(GenericCallback>), + /// Request the local endpoint info from the P2P pairing service. + PairingGetLocal(GenericCallback>), + /// Request the list of known peers from the P2P pairing service. + PairingGetPeers(GenericCallback, String>>), + /// Update the display name of the local P2P endpoint and restart the service. + PairingSetName(String, GenericCallback>), + /// Request pairing with a remote peer. Returns true if accepted, false if rejected. + PairingRequestPairing(String, GenericCallback>), + /// Accept an incoming pairing request from a remote peer. + PairingAcceptPairing(String, GenericCallback>), + /// Reject an incoming pairing request from a remote peer. + PairingRejectPairing(String, GenericCallback>), + /// Remove a paired peer (unpair and forget). + PairingRemovePeer(String, GenericCallback>), + /// Create a peer stream: create a virtual remote port entangled with a local port, + /// and send the offer to a remote peer. + /// Args: peer_id, local_port_id, remote_port_id, target_url, callback. + CreatePeerStream( + String, + MessagePortId, + MessagePortId, + String, + GenericCallback>, + ), + /// Response to a DispatchPeerStream — whether the peer stream was accepted or denied. + /// Args: stream_id, from_peer_id, accepted. + PeerStreamResponse(String, String, bool), + /// ATProto api message. + AtProto(AtProtoRequest, GenericCallback), } impl fmt::Debug for ScriptToConstellationMessage {