Rewild Your Web
at main 198 lines 10 kB view raw
1--- original 2+++ modified 3@@ -11,8 +11,9 @@ 4 use devtools_traits::{DevtoolScriptControlMsg, ScriptToDevtoolsControlMsg, WorkerId}; 5 use embedder_traits::user_contents::UserContentManagerId; 6 use embedder_traits::{ 7- AnimationState, FocusSequenceNumber, JSValue, JavaScriptEvaluationError, 8- JavaScriptEvaluationId, MediaSessionEvent, ScriptToEmbedderChan, Theme, ViewportDetails, 9+ AnimationState, EmbedderControlId, EmbedderControlResponse, FocusSequenceNumber, 10+ InputEventAndId, JSValue, JavaScriptEvaluationError, JavaScriptEvaluationId, MediaSessionEvent, 11+ ScriptToEmbedderChan, Theme, ViewportDetails, 12 }; 13 use encoding_rs::Encoding; 14 use euclid::default::Size2D as UntypedSize2D; 15@@ -35,6 +36,7 @@ 16 MessagePortRouterId, PipelineId, ScriptEventLoopId, ServiceWorkerId, 17 ServiceWorkerRegistrationId, WebViewId, 18 }; 19+use servo_config::pref_util::PrefValue; 20 use servo_url::{ImmutableOrigin, OriginSnapshot, ServoUrl}; 21 use storage_traits::StorageThreads; 22 use storage_traits::webstorage_thread::WebStorageType; 23@@ -44,7 +46,8 @@ 24 25 use crate::structured_data::{BroadcastChannelMsg, StructuredSerializedData}; 26 use crate::{ 27- LogEntry, MessagePortMsg, PortMessageTask, PortTransferInfo, TraversalDirection, WindowSizeType, 28+ EmbeddedWebViewEventType, LogEntry, MessagePortMsg, PortMessageTask, PortTransferInfo, 29+ TraversalDirection, WindowSizeType, 30 }; 31 32 pub type ScriptToConstellationSender = 33@@ -407,11 +410,14 @@ 34 pub opener_webview_id: WebViewId, 35 /// The pipeline opener browsing context. 36 pub opener_pipeline_id: PipelineId, 37- /// Sender for the constellation’s response to our request. 38+ /// Sender for the constellation's response to our request. 39 pub response_sender: GenericSender<Option<AuxiliaryWebViewCreationResponse>>, 40+ /// The target URL that window.open() was called with. 41+ /// This is needed because load_data.url is always about:blank for new browsing contexts. 42+ pub target_url: Option<ServoUrl>, 43 } 44 45-/// Constellation’s response to auxiliary browsing context creation requests. 46+/// Constellation's response to auxiliary browsing context creation requests. 47 #[derive(Debug, Deserialize, Serialize)] 48 pub struct AuxiliaryWebViewCreationResponse { 49 /// The new webview ID. 50@@ -422,6 +428,38 @@ 51 pub user_content_manager_id: Option<UserContentManagerId>, 52 } 53 54+/// Request to create an embedded webview in an iframe with the "embed" attribute. 55+#[derive(Debug, Deserialize, Serialize)] 56+pub struct EmbeddedWebViewCreationRequest { 57+ /// Load data containing the url to load 58+ pub load_data: LoadData, 59+ /// The pipeline ID of the parent document containing the iframe. 60+ pub parent_pipeline_id: PipelineId, 61+ /// The webview ID of the parent document. 62+ pub parent_webview_id: WebViewId, 63+ /// The initial viewport size for this embedded webview. 64+ pub viewport_details: ViewportDetails, 65+ /// The [`Theme`] to use within this embedded webview. 66+ pub theme: Theme, 67+ /// Whether this embedded webview should never receive focus (hidefocus attribute). 68+ pub hide_focus: bool, 69+ /// Sender for the constellation's response to our request. 70+ pub response_sender: IpcSender<Option<EmbeddedWebViewCreationResponse>>, 71+} 72+ 73+/// Constellation's response to embedded webview creation requests. 74+#[derive(Debug, Deserialize, Serialize)] 75+pub struct EmbeddedWebViewCreationResponse { 76+ /// The new webview ID for the embedded webview. 77+ pub new_webview_id: WebViewId, 78+ /// The new browsing context ID for the embedded webview. 79+ pub new_browsing_context_id: BrowsingContextId, 80+ /// The new pipeline ID for the embedded webview's initial document. 81+ pub new_pipeline_id: PipelineId, 82+ /// The [`UserContentManagerId`] for this new auxiliary browsing context. 83+ pub user_content_manager_id: Option<UserContentManagerId>, 84+} 85+ 86 /// Specifies the information required to load an iframe. 87 #[derive(Debug, Deserialize, Serialize)] 88 pub struct IFrameLoadInfo { 89@@ -585,6 +623,10 @@ 90 NewBroadcastChannelNameInRouter(BroadcastChannelRouterId, String, ImmutableOrigin), 91 /// A global stopped managing broadcast channels for a given channel-name. 92 RemoveBroadcastChannelNameInRouter(BroadcastChannelRouterId, String, ImmutableOrigin), 93+ /// Register this script thread as having an embedder error listener. 94+ RegisterEmbedderErrorListener(ScriptEventLoopId), 95+ /// Unregister this script thread from embedder error listeners. 96+ UnregisterEmbedderErrorListener(ScriptEventLoopId), 97 /// Broadcast a message to all same-origin broadcast channels, 98 /// excluding the source of the broadcast. 99 ScheduleBroadcast(BroadcastChannelRouterId, BroadcastChannelMsg), 100@@ -597,6 +639,9 @@ 101 Option<String>, 102 Option<String>, 103 ), 104+ /// Broadcast a preference change to all script threads. 105+ /// Used when preferences are changed from JavaScript via `navigator.servo`. 106+ BroadcastPreferenceChange(String, PrefValue), 107 /// Indicates whether this pipeline is currently running animations. 108 ChangeRunningAnimationsState(AnimationState), 109 /// Requests that a new 2D canvas thread be created. (This is done in the constellation because 110@@ -677,6 +722,10 @@ 111 ScriptNewIFrame(IFrameLoadInfoWithData), 112 /// Script has opened a new auxiliary browsing context. 113 CreateAuxiliaryWebView(AuxiliaryWebViewCreationRequest), 114+ /// Script has created an embedded webview in an iframe with the "embed" attribute. 115+ CreateEmbeddedWebView(EmbeddedWebViewCreationRequest), 116+ /// An embedded WebView was removed from a DOM tree. 117+ RemoveEmbeddedWebView(WebViewId), 118 /// Mark a new document as active 119 ActivateDocument, 120 /// Set the document state for a pipeline (used by screenshot / reftests) 121@@ -726,6 +775,77 @@ 122 RespondToScreenshotReadinessRequest(ScreenshotReadinessResponse), 123 /// Request the constellation to force garbage collection in all `ScriptThread`'s. 124 TriggerGarbageCollection, 125+ /// Notification from an embedded webview to be forwarded to its parent iframe element. 126+ /// The Constellation will forward this to the parent pipeline's script thread. 127+ EmbeddedWebViewNotification(EmbeddedWebViewEventType), 128+ /// Load a URL in an embedded webview (only valid for embedded webview pipelines). 129+ EmbeddedWebViewLoad(WebViewId, ServoUrl), 130+ /// Reload an embedded webview (only valid for embedded webview pipelines). 131+ EmbeddedWebViewReload(WebViewId), 132+ /// Traverse history in an embedded webview (only valid for embedded webview pipelines). 133+ /// The TraversalId is used to track completion of the traversal. 134+ EmbeddedWebViewTraverseHistory(WebViewId, TraversalDirection, embedder_traits::TraversalId), 135+ /// Take a screenshot of an embedded webview, encoding it to the specified format. 136+ EmbeddedWebViewTakeScreenshot( 137+ WebViewId, 138+ embedder_traits::EmbeddedWebViewScreenshotRequest, 139+ GenericCallback< 140+ Result< 141+ embedder_traits::EmbeddedWebViewScreenshotResult, 142+ embedder_traits::EmbeddedWebViewScreenshotError, 143+ >, 144+ >, 145+ ), 146+ /// Send a media session action to the active media session in an embedded webview. 147+ EmbeddedWebViewMediaSessionAction(embedder_traits::MediaSessionActionType), 148+ /// Forward an input event to an embedded webview after the parent's DOM hit testing 149+ /// determined that the event target is an embedded iframe element. 150+ ForwardEventToEmbeddedWebView(WebViewId, InputEventAndId), 151+ /// Inject an input event to the webview that currently has an active IME input. 152+ /// Used by the virtual keyboard to send keystrokes to the focused input field. 153+ InjectInputToActiveIme(InputEventAndId), 154+ /// Set the active IME webview for virtual keyboard input routing. 155+ /// Used when the system webview (non-embedded) shows an input method control. 156+ SetActiveImeWebView(WebViewId), 157+ /// Clear the active IME webview when the system webview hides an input method control. 158+ ClearActiveImeWebView(WebViewId), 159+ /// Response from parent iframe to an embedded webview's control request. 160+ /// The parent shell sends this after the user interacts with a custom control UI 161+ /// (e.g., select dropdown, color picker, file dialog). 162+ EmbeddedWebViewControlResponse(EmbedderControlId, EmbedderControlResponse), 163+ /// Set page zoom for an embedded webview. 164+ EmbeddedWebViewSetPageZoom(WebViewId, f32), 165+ /// Request the constellation to start the P2P pairing service. 166+ PairingStart(GenericCallback<Result<(), String>>), 167+ /// Request the constellation to stop the P2P pairing service. 168+ PairingStop(GenericCallback<Result<(), String>>), 169+ /// Request the local endpoint info from the P2P pairing service. 170+ PairingGetLocal(GenericCallback<Result<super::LocalPeerInfo, String>>), 171+ /// Request the list of known peers from the P2P pairing service. 172+ PairingGetPeers(GenericCallback<Result<Vec<super::PeerInfo>, String>>), 173+ /// Update the display name of the local P2P endpoint and restart the service. 174+ PairingSetName(String, GenericCallback<Result<(), String>>), 175+ /// Request pairing with a remote peer. Returns true if accepted, false if rejected. 176+ PairingRequestPairing(String, GenericCallback<Result<bool, String>>), 177+ /// Accept an incoming pairing request from a remote peer. 178+ PairingAcceptPairing(String, GenericCallback<Result<(), String>>), 179+ /// Reject an incoming pairing request from a remote peer. 180+ PairingRejectPairing(String, GenericCallback<Result<(), String>>), 181+ /// Remove a paired peer (unpair and forget). 182+ PairingRemovePeer(String, GenericCallback<Result<(), String>>), 183+ /// Create a peer stream: create a virtual remote port entangled with a local port, 184+ /// and send the offer to a remote peer. 185+ /// Args: peer_id, local_port_id, remote_port_id, target_url, callback. 186+ CreatePeerStream( 187+ String, 188+ MessagePortId, 189+ MessagePortId, 190+ String, 191+ GenericCallback<Result<(), String>>, 192+ ), 193+ /// Response to a DispatchPeerStream — whether the peer stream was accepted or denied. 194+ /// Args: stream_id, from_peer_id, accepted. 195+ PeerStreamResponse(String, String, bool), 196 } 197 198 impl fmt::Debug for ScriptToConstellationMessage {