Rewild Your Web
web
browser
dweb
1--- original
2+++ modified
3@@ -18,8 +18,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 use profile_traits::{mem, time as profile_time};
17 use rustc_hash::FxHashMap;
18 use serde::{Deserialize, Serialize};
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- pub response_sender: IpcSender<Option<AuxiliaryWebViewCreationResponse>>,
39+ /// Sender for the constellation's response to our request.
40+ pub response_sender: GenericSender<Option<AuxiliaryWebViewCreationResponse>>,
41+ /// The target URL that window.open() was called with.
42+ /// This is needed because load_data.url is always about:blank for new browsing contexts.
43+ pub target_url: Option<ServoUrl>,
44 }
45
46-/// Constellation’s response to auxiliary browsing context creation requests.
47+/// Constellation's response to auxiliary browsing context creation requests.
48 #[derive(Debug, Deserialize, Serialize)]
49 pub struct AuxiliaryWebViewCreationResponse {
50 /// The new webview ID.
51@@ -422,6 +428,38 @@
52 pub user_content_manager_id: Option<UserContentManagerId>,
53 }
54
55+/// Request to create an embedded webview in an iframe with the "embed" attribute.
56+#[derive(Debug, Deserialize, Serialize)]
57+pub struct EmbeddedWebViewCreationRequest {
58+ /// Load data containing the url to load
59+ pub load_data: LoadData,
60+ /// The pipeline ID of the parent document containing the iframe.
61+ pub parent_pipeline_id: PipelineId,
62+ /// The webview ID of the parent document.
63+ pub parent_webview_id: WebViewId,
64+ /// The initial viewport size for this embedded webview.
65+ pub viewport_details: ViewportDetails,
66+ /// The [`Theme`] to use within this embedded webview.
67+ pub theme: Theme,
68+ /// Whether this embedded webview should never receive focus (hidefocus attribute).
69+ pub hide_focus: bool,
70+ /// Sender for the constellation's response to our request.
71+ pub response_sender: IpcSender<Option<EmbeddedWebViewCreationResponse>>,
72+}
73+
74+/// Constellation's response to embedded webview creation requests.
75+#[derive(Debug, Deserialize, Serialize)]
76+pub struct EmbeddedWebViewCreationResponse {
77+ /// The new webview ID for the embedded webview.
78+ pub new_webview_id: WebViewId,
79+ /// The new browsing context ID for the embedded webview.
80+ pub new_browsing_context_id: BrowsingContextId,
81+ /// The new pipeline ID for the embedded webview's initial document.
82+ pub new_pipeline_id: PipelineId,
83+ /// The [`UserContentManagerId`] for this new auxiliary browsing context.
84+ pub user_content_manager_id: Option<UserContentManagerId>,
85+}
86+
87 /// Specifies the information required to load an iframe.
88 #[derive(Debug, Deserialize, Serialize)]
89 pub struct IFrameLoadInfo {
90@@ -585,6 +623,10 @@
91 NewBroadcastChannelNameInRouter(BroadcastChannelRouterId, String, ImmutableOrigin),
92 /// A global stopped managing broadcast channels for a given channel-name.
93 RemoveBroadcastChannelNameInRouter(BroadcastChannelRouterId, String, ImmutableOrigin),
94+ /// Register this script thread as having an embedder error listener.
95+ RegisterEmbedderErrorListener(ScriptEventLoopId),
96+ /// Unregister this script thread from embedder error listeners.
97+ UnregisterEmbedderErrorListener(ScriptEventLoopId),
98 /// Broadcast a message to all same-origin broadcast channels,
99 /// excluding the source of the broadcast.
100 ScheduleBroadcast(BroadcastChannelRouterId, BroadcastChannelMsg),
101@@ -597,6 +639,9 @@
102 Option<String>,
103 Option<String>,
104 ),
105+ /// Broadcast a preference change to all script threads.
106+ /// Used when preferences are changed from JavaScript via `navigator.servo`.
107+ BroadcastPreferenceChange(String, PrefValue),
108 /// Indicates whether this pipeline is currently running animations.
109 ChangeRunningAnimationsState(AnimationState),
110 /// Requests that a new 2D canvas thread be created. (This is done in the constellation because
111@@ -677,6 +722,10 @@
112 ScriptNewIFrame(IFrameLoadInfoWithData),
113 /// Script has opened a new auxiliary browsing context.
114 CreateAuxiliaryWebView(AuxiliaryWebViewCreationRequest),
115+ /// Script has created an embedded webview in an iframe with the "embed" attribute.
116+ CreateEmbeddedWebView(EmbeddedWebViewCreationRequest),
117+ /// An embedded WebView was removed from a DOM tree.
118+ RemoveEmbeddedWebView(WebViewId),
119 /// Mark a new document as active
120 ActivateDocument,
121 /// Set the document state for a pipeline (used by screenshot / reftests)
122@@ -724,6 +773,44 @@
123 ForwardKeyboardScroll(PipelineId, KeyboardScroll),
124 /// Notify the Constellation of the screenshot readiness of a given pipeline.
125 RespondToScreenshotReadinessRequest(ScreenshotReadinessResponse),
126+ /// Notification from an embedded webview to be forwarded to its parent iframe element.
127+ /// The Constellation will forward this to the parent pipeline's script thread.
128+ EmbeddedWebViewNotification(EmbeddedWebViewEventType),
129+ /// Load a URL in an embedded webview (only valid for embedded webview pipelines).
130+ EmbeddedWebViewLoad(WebViewId, ServoUrl),
131+ /// Reload an embedded webview (only valid for embedded webview pipelines).
132+ EmbeddedWebViewReload(WebViewId),
133+ /// Traverse history in an embedded webview (only valid for embedded webview pipelines).
134+ /// The TraversalId is used to track completion of the traversal.
135+ EmbeddedWebViewTraverseHistory(WebViewId, TraversalDirection, embedder_traits::TraversalId),
136+ /// Take a screenshot of an embedded webview, encoding it to the specified format.
137+ EmbeddedWebViewTakeScreenshot(
138+ WebViewId,
139+ embedder_traits::EmbeddedWebViewScreenshotRequest,
140+ GenericCallback<
141+ Result<
142+ embedder_traits::EmbeddedWebViewScreenshotResult,
143+ embedder_traits::EmbeddedWebViewScreenshotError,
144+ >,
145+ >,
146+ ),
147+ /// Forward an input event to an embedded webview after the parent's DOM hit testing
148+ /// determined that the event target is an embedded iframe element.
149+ ForwardEventToEmbeddedWebView(WebViewId, InputEventAndId),
150+ /// Inject an input event to the webview that currently has an active IME input.
151+ /// Used by the virtual keyboard to send keystrokes to the focused input field.
152+ InjectInputToActiveIme(InputEventAndId),
153+ /// Set the active IME webview for virtual keyboard input routing.
154+ /// Used when the system webview (non-embedded) shows an input method control.
155+ SetActiveImeWebView(WebViewId),
156+ /// Clear the active IME webview when the system webview hides an input method control.
157+ ClearActiveImeWebView(WebViewId),
158+ /// Response from parent iframe to an embedded webview's control request.
159+ /// The parent shell sends this after the user interacts with a custom control UI
160+ /// (e.g., select dropdown, color picker, file dialog).
161+ EmbeddedWebViewControlResponse(EmbedderControlId, EmbedderControlResponse),
162+ /// Set page zoom for an embedded webview.
163+ EmbeddedWebViewSetPageZoom(WebViewId, f32),
164 }
165
166 impl fmt::Debug for ScriptToConstellationMessage {