Rewild Your Web
web
browser
dweb
1--- original
2+++ modified
3@@ -16,15 +16,16 @@
4 use std::time::Duration;
5
6 use base::cross_process_instant::CrossProcessInstant;
7-use base::generic_channel::GenericCallback;
8+use base::generic_channel::{GenericCallback, GenericSharedMemory};
9 use base::id::{MessagePortId, PipelineId, ScriptEventLoopId, WebViewId};
10 use embedder_traits::user_contents::{
11 UserContentManagerId, UserScript, UserScriptId, UserStyleSheet, UserStyleSheetId,
12 };
13 use embedder_traits::{
14- EmbedderControlId, EmbedderControlResponse, InputEventAndId, JavaScriptEvaluationId,
15- MediaSessionActionType, NewWebViewDetails, PaintHitTestResult, Theme, TraversalId,
16- ViewportDetails, WebDriverCommandMsg,
17+ EmbedderControlId, EmbedderControlRequest, EmbedderControlResponse, InputEventAndId,
18+ JavaScriptEvaluationId, LoadStatus, MediaSessionActionType, NewWebViewDetails, Notification,
19+ PaintHitTestResult, ServoErrorType, SimpleDialogRequest, Theme, TraversalId, ViewportDetails,
20+ WebDriverCommandMsg,
21 };
22 pub use from_script_message::*;
23 use malloc_size_of_derive::MallocSizeOf;
24@@ -37,9 +38,70 @@
25 use servo_url::{ImmutableOrigin, ServoUrl};
26 pub use structured_data::*;
27 use strum::IntoStaticStr;
28-use webrender_api::units::LayoutVector2D;
29+use webrender_api::units::{DeviceIntRect, LayoutVector2D};
30 use webrender_api::{ExternalScrollId, ImageKey};
31
32+/// Event types that are dispatched from embedded webviews to their parent iframe elements.
33+/// These are used to notify the parent document about changes in the embedded webview's state.
34+#[derive(Clone, Debug, Deserialize, Serialize)]
35+pub enum EmbeddedWebViewEventType {
36+ /// The URL of the embedded webview changed.
37+ UrlChanged(ServoUrl),
38+ /// The page title of the embedded webview changed.
39+ TitleChanged(Option<String>),
40+ /// The load status of the embedded webview changed.
41+ LoadStatusChanged(LoadStatus),
42+ /// The favicon of the embedded webview changed.
43+ FaviconChanged {
44+ /// The favicon image bytes.
45+ bytes: GenericSharedMemory,
46+ /// The width of the favicon image.
47+ width: u32,
48+ /// The height of the favicon image.
49+ height: u32,
50+ },
51+ /// The embedded webview was closed.
52+ Closed,
53+ /// The history changed with full history list and current index.
54+ HistoryChanged(Vec<ServoUrl>, usize),
55+ /// A history traversal completed.
56+ HistoryTraversalComplete(TraversalId),
57+ /// The meta=theme-color element changed value.
58+ ThemeColorChanged(String),
59+ /// The embedded webview received input (mouse/touch).
60+ InputReceived,
61+ /// An embedder control (select, color picker, etc.) should be shown.
62+ EmbedderControlShow {
63+ /// Unique ID for response routing.
64+ id: EmbedderControlId,
65+ /// Bounding rect in device pixels.
66+ rect: DeviceIntRect,
67+ /// The control request details.
68+ request: EmbedderControlRequest,
69+ },
70+ /// An embedder control should be hidden.
71+ EmbedderControlHide {
72+ /// The ID of the control to hide.
73+ id: EmbedderControlId,
74+ },
75+ /// A simple dialog (alert, confirm, prompt) should be shown.
76+ /// The request includes an IPC sender for direct response.
77+ SimpleDialogShow(SimpleDialogRequest),
78+ /// A notification should be shown to the user.
79+ NotificationShow(Notification),
80+}
81+
82+/// The type of simple dialog to show.
83+#[derive(Clone, Debug, Deserialize, Serialize)]
84+pub enum SimpleDialogType {
85+ /// An alert dialog that only has an "OK" button.
86+ Alert,
87+ /// A confirm dialog with "OK" and "Cancel" buttons.
88+ Confirm,
89+ /// A prompt dialog with a text input, "OK" and "Cancel" buttons.
90+ Prompt,
91+}
92+
93 /// Messages to the Constellation from the embedding layer, whether from `ServoRenderer` or
94 /// from `libservo` itself.
95 #[derive(IntoStaticStr)]
96@@ -117,6 +179,9 @@
97 UserContentManagerAction(UserContentManagerId, UserContentManagerAction),
98 /// Update pinch zoom details stored in the top level window
99 UpdatePinchZoomInfos(PipelineId, PinchZoomInfos),
100+ /// Notify all script threads about a Servo error, so they can dispatch `servoerror` events
101+ /// to all `navigator.embedder` instances.
102+ NotifyServoError(ServoErrorType, String),
103 }
104
105 pub enum UserContentManagerAction {